Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tr-TR.yml #47

Open
wants to merge 29 commits into
base: java8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5e6308e
Create tr-TR.yml
WinTone01 Oct 2, 2023
cfbe860
Merge branch 'Emibergo02:main' into main
WinTone01 Jan 19, 2024
7e9f1e5
Update tr-TR.yml
WinTone01 Jan 19, 2024
8b7a009
4.3.9
Emibergo02 Mar 16, 2024
c8eb73c
Removed stress command
Emibergo02 Mar 16, 2024
9f0709f
Reduced verbose
Emibergo02 Mar 17, 2024
cbe46bd
max balance and save transactions
Emibergo02 Mar 28, 2024
7130be9
4.3.11
Emibergo02 Apr 3, 2024
ef828f7
Merge branch 'Emibergo02:main' into main
WinTone01 Apr 9, 2024
3ac6bb9
4.3.12
Emibergo02 May 5, 2024
86dc411
4.3.13
Emibergo02 May 7, 2024
f7ae0e0
4.3.14
Emibergo02 May 9, 2024
3338e61
Bump version
Emibergo02 May 18, 2024
583d39b
Update README.md
Emibergo02 Jun 7, 2024
c692ee0
Better timeout handling in updateAccountCloudCache
Emibergo02 Sep 1, 2024
392daf8
Better timeout handling in updateAccountCloudCache
Emibergo02 Sep 1, 2024
b24c8b2
Better timeout handling in updateAccountCloudCache
Emibergo02 Sep 16, 2024
b08fff5
Added per-player max balance
Emibergo02 Sep 21, 2024
fe378c5
changed duplicated channel name
Emibergo02 Sep 30, 2024
080a2ec
Fixed error and shading
Emibergo02 Oct 2, 2024
6ff875a
Fix Permissions
Koora7334 Oct 1, 2024
0d3dac9
Fixed setting wrong max balance
Emibergo02 Oct 2, 2024
0a6215d
Fixed error when receiving max bal
Emibergo02 Oct 2, 2024
cbc5643
Removed unused Settings parameter
Emibergo02 Oct 2, 2024
8f2cf09
4.3.19
Emibergo02 Oct 14, 2024
f32416a
Merge branch 'Emibergo02:main' into main
WinTone01 Nov 11, 2024
7176cda
4.3.20
Emibergo02 Dec 19, 2024
02b3c72
4.3.21
Emibergo02 Dec 31, 2024
3e0a2cd
Merge branch 'Emibergo02:main' into main
WinTone01 Jan 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
}
```
## API usage

YOU PROBABLY DON'T NEED TO USE REDISECONOMY API: USE VAULT API https://github.com/MilkBowl/VaultAPI
```java
// Access Point
RedisEconomyAPI api = RedisEconomyAPI.getAPI();
Expand All @@ -53,7 +53,7 @@ api.getCurrencyBySymbol("€");//Gets the currency by symbol
//Currency is a Vault Economy https://github.com/MilkBowl/VaultAPI/blob/master/src/main/java/net/milkbowl/vault/economy/Economy.java,
//same methods and everything
currency.getBalance(offlinePlayer);
currency.withdrawPlayer(offlinePlayer, 100);
currency.withdrawPlayer(offlinePlayer, 100, "Reason of withdrawal");

//Modify a player balance (default currency)
api.getDefaultCurrency().setPlayerBalance(player.getUniqueId(), 1000);
Expand Down
6 changes: 3 additions & 3 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jdk:
- openjdk16
- openjdk17
before_install:
- sdk install java 16.0.1-open
- sdk use java 16.0.1-open
- sdk install java 17.0.1-open
- sdk use java 17.0.1-open
35 changes: 20 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

<groupId>dev.unnm3d</groupId>
<artifactId>RedisEconomy</artifactId>
<version>4.3.8-SNAPSHOT</version>
<version>4.3.21</version>
<packaging>jar</packaging>

<name>RedisEconomy</name>

<properties>
<java.version>16</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -23,8 +23,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -44,6 +44,10 @@
<pattern>net.kyori</pattern>
<shadedPattern>dev.unnm3d.shaded.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>de.exlll.configlib</pattern>
<shadedPattern>dev.unnm3d.shaded.configlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.Anon8281.universalScheduler</pattern>
<shadedPattern>dev.unnm3d.shaded.universalScheduler</shadedPattern>
Expand Down Expand Up @@ -114,16 +118,17 @@
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>devmart-other</id>
<url>https://nexuslite.gcnt.net/repos/other/</url>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -135,35 +140,35 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<version>1.18.34</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.0</version>
<version>4.3.3</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.3</version>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.2.4.RELEASE</version>
<version>6.4.0.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Emibergo02</groupId>
<artifactId>ConfigLib</artifactId>
<version>master-SNAPSHOT</version>
<groupId>de.exlll</groupId>
<artifactId>configlib-yaml</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>com.github.Anon8281</groupId>
Expand Down
61 changes: 30 additions & 31 deletions src/main/java/dev/unnm3d/rediseconomy/RedisEconomyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@
import org.bukkit.plugin.java.JavaPlugin;

import java.time.Duration;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

public final class RedisEconomyPlugin extends JavaPlugin {

@Getter
private static RedisEconomyPlugin instance;
//private EzRedisMessenger ezRedisMessenger;
@Getter
private ConfigManager configManager;
@Getter
private CurrenciesManager currenciesManager;
private RedisManager redisManager;
@Getter
private TaskScheduler scheduler;
@Getter
private Plugin vaultPlugin;
@Getter
private static UUID instanceUUID;


public Settings settings() {
Expand All @@ -53,41 +58,44 @@ public Langs langs() {
return configManager.getLangs();
}

public static RedisEconomyPlugin getInstance() {
return instance;
}

@Override
public void onLoad() {
instance = this;
//Generate a unique instance id to not send redis updates to itself
instanceUUID = UUID.randomUUID();

this.configManager = new ConfigManager(this);

if (!setupRedis()) {
this.getLogger().severe("Disabling: redis server unreachable!");
this.getLogger().severe("Please setup a redis server before running this plugin!");
this.getServer().getPluginManager().disablePlugin(this);
return;
} else {
this.getLogger().info("Redis server connected!");
}

if (!setupVault()) { //creates currenciesManager and exchange
this.getLogger().severe("Disabled due to no Vault dependency found!");
this.getServer().getPluginManager().disablePlugin(this);
} else {
this.getLogger().info("Hooked into Vault!");
}
}

@Override
public void onEnable() {
if (redisManager == null) return;

this.scheduler = UniversalScheduler.getScheduler(this);
this.configManager.postStartupLoad();
this.configManager.loadLangs();
this.vaultPlugin = getServer().getPluginManager().getPlugin("Vault");
if (this.vaultPlugin == null) { //creates currenciesManager and exchange
this.getLogger().severe("Disabled due to no Vault dependency found!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}

this.currenciesManager = new CurrenciesManager(redisManager, this, configManager);
this.getLogger().info("Hooked into Vault!");

if (settings().migrationEnabled) {
scheduler.runTaskLater(() ->
currenciesManager.getCompleteMigration().complete(null),
100L);//load: STARTUP doesn't consider dependencies on load so i have to wait a bit (bukkit bug?)
currenciesManager.migrateFromOfflinePlayers(getServer().getOfflinePlayers()), 100L);
} else {
currenciesManager.loadDefaultCurrency(this.vaultPlugin);
}

getServer().getPluginManager().registerEvents(currenciesManager, this);
Expand Down Expand Up @@ -124,11 +132,10 @@ public void onEnable() {

@Override
public void onDisable() {
redisManager.close();
if (redisManager != null)
redisManager.close();
if (currenciesManager != null)
this.getServer().getServicesManager().unregister(Economy.class, currenciesManager.getDefaultCurrency());
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
this.getServer().getMessenger().unregisterIncomingPluginChannel(this);
getLogger().info("RedisEconomy disabled successfully!");
}

Expand All @@ -143,16 +150,16 @@ private boolean setupRedis() {
if (configManager.getSettings().redis.user().equals("changecredentials"))
getLogger().warning("You are using default redis credentials. Please change them in the config.yml file!");
//Authentication params
redisURIBuilder = configManager.getSettings().redis.password().equals("") ?
redisURIBuilder = configManager.getSettings().redis.password().isEmpty() ?
redisURIBuilder :
configManager.getSettings().redis.user().equals("") ?
configManager.getSettings().redis.user().isEmpty() ?
redisURIBuilder.withPassword(configManager.getSettings().redis.password().toCharArray()) :
redisURIBuilder.withAuthentication(configManager.getSettings().redis.user(), configManager.getSettings().redis.password());

getLogger().info("Connecting to redis server " + redisURIBuilder.build().toString() + "...");
this.redisManager = new RedisManager(RedisClient.create(redisURIBuilder.build()));
this.redisManager = new RedisManager(RedisClient.create(redisURIBuilder.build()), configManager.getSettings().redis.getPoolSize());
redisManager.isConnected().get(1, java.util.concurrent.TimeUnit.SECONDS);
if (!configManager.getSettings().clusterId.equals(""))
if (!configManager.getSettings().clusterId.isEmpty())
RedisKeys.setClusterId(configManager.getSettings().clusterId);
return true;
} catch (Exception e) {
Expand All @@ -164,14 +171,6 @@ private boolean setupRedis() {
}
}

private boolean setupVault() {
Plugin vault = getServer().getPluginManager().getPlugin("Vault");
if (vault == null)
return false;
this.currenciesManager = new CurrenciesManager(redisManager, this, configManager);
currenciesManager.loadDefaultCurrency(vault);
return true;
}

private void loadCommand(String cmdName, CommandExecutor executor, TabCompleter tabCompleter) {
PluginCommand cmd = getServer().getPluginCommand(cmdName);
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/dev/unnm3d/rediseconomy/command/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
} else if (args.length == 1) {
if (!args[0].equalsIgnoreCase("reload")) return true;
if (!sender.hasPermission("rediseconomy.admin")) return true;
String serverId = plugin.getConfigManager().getSettings().serverId; //Keep serverId
plugin.getConfigManager().loadSettingsConfig();//Reload configs
plugin.getConfigManager().loadLangs();
plugin.getConfigManager().getSettings().serverId = serverId; //Restore serverId
plugin.getConfigManager().loadLangs(); //Reload langs
plugin.getConfigManager().saveConfigs(); //Save configs
this.adventureWebuiEditorAPI = new AdventureWebuiEditorAPI(plugin.getConfigManager().getSettings().webEditorUrl);
sender.sendMessage("§aReloaded successfully " + plugin.getConfigManager().getSettings().serverId + "!");
sender.sendMessage("§aReloaded successfully!");
return true;
}
String langField = args[1];

if (args[0].equalsIgnoreCase("expandpool")) {
if (!sender.hasPermission("rediseconomy.admin.expandpool")) {
plugin.getConfigManager().getLangs().send(sender, plugin.getConfigManager().getLangs().noPermission);
return true;
}
try {
plugin.getCurrenciesManager().getRedisManager().expandPool(Integer.parseInt(args[1]));
plugin.getConfigManager().getLangs().send(sender, "§aPool expanded successfully!");
} catch (Exception e) {
plugin.getConfigManager().getLangs().send(sender, "§cError expanding pool: " + e.getMessage());
}
return true;
}

if (!sender.hasPermission("rediseconomy.admin.editmessage")) {
plugin.getConfigManager().getLangs().send(sender, plugin.getConfigManager().getLangs().noPermission);
return true;
Expand Down Expand Up @@ -83,9 +95,15 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
@Override
public @NotNull List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
if (args.length == 1) {
return List.of("reload", "editmessage");
} else if (args.length == 2 && sender.hasPermission("rediseconomy.admin.editmessage")) {
return Arrays.stream(plugin.getConfigManager().getLangs().getClass().getFields()).filter(field -> field.getType().equals(String.class)).map(Field::getName).toList();
return List.of("reload", "editmessage", "expandpool");
} else if (args.length == 2 && args[0].equalsIgnoreCase("expandpool")) {
return List.of("1", "2", "3", "4", "5");
} else if (args.length == 2 && sender.hasPermission("rediseconomy.admin.editmessage") && args[0].equalsIgnoreCase("editmessage")) {
return Arrays.stream(plugin.getConfigManager().getLangs().getClass().getFields())
.filter(field -> field.getType().equals(String.class))
.map(Field::getName)
.filter(name -> name.startsWith(args[1]))
.toList();
}
return List.of();
}
Expand Down
Loading