Skip to content

Commit

Permalink
- Not BetterElo is not dependent on BetterRanks, but some functionali…
Browse files Browse the repository at this point in the history
…ty might not bee available without 2nd plugin.
  • Loading branch information
Grzybol committed Jan 23, 2024
1 parent 4b1e568 commit 7f0481c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>3.1.18-SNAPSHOT</version>
<version>3.1.19-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;

public class BetterRanksCheaters {
private JavaPlugin plugin;
private final PluginLogger pluginLogger;
public List<String> cheatersList;
private List<String> cheatersList;

public BetterRanksCheaters(JavaPlugin plugin, PluginLogger pluginLogger) {
this.plugin = plugin;
Expand All @@ -21,36 +22,44 @@ public BetterRanksCheaters(JavaPlugin plugin, PluginLogger pluginLogger) {
}

public void CheckCheatersFromBetterRanks() {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"CheckCheatersFromBetterRanks called");
File dataFolder = plugin.getServer().getPluginManager().getPlugin("BetterRanks").getDataFolder();
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "CheckCheatersFromBetterRanks called");
Plugin betterRanksPlugin = plugin.getServer().getPluginManager().getPlugin("BetterRanks");
if (betterRanksPlugin == null || !betterRanksPlugin.isEnabled()) {
pluginLogger.log(PluginLogger.LogLevel.WARNING, "BetterRanks plugin is not found or is disabled.");
cheatersList.clear(); // Clear the list to ensure it's empty.
return;
}

File dataFolder = betterRanksPlugin.getDataFolder();
if (!dataFolder.exists()) {
pluginLogger.log(PluginLogger.LogLevel.WARNING, "BetterRanks plugin folder doesn't exist!");
return; // Jeśli folder danych nie istnieje, to nie ma co sprawdzać.
cheatersList.clear(); // Clear the list to ensure it's empty.
return;
}

File configFile = new File(dataFolder, "database.yml");
if (!configFile.exists()) {
pluginLogger.log(PluginLogger.LogLevel.WARNING, "BetterRanks database.yml doesn't exist!");
return; // Jeśli plik database.yml nie istnieje, to nie ma co sprawdzać.
cheatersList.clear(); // Clear the list to ensure it's empty.
return;
}


FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
Set<String> playerNames = config.getKeys(false);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"BetterRanksCheaters: CheckCheatersFromBetterRanks checking..");
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks checking..");
cheatersList.clear();
for (String playerName : playerNames) {
String rank = config.getString(playerName + ".rank");
if (rank != null && rank.equalsIgnoreCase("CHEATER")) {
cheatersList.add(playerName);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"BetterRanksCheaters: CheckCheatersFromBetterRanks: adding cheater "+playerName);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks: adding cheater " + playerName);
}
}
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"BetterRanksCheaters: CheckCheatersFromBetterRanks: Cheaters found: "+ Arrays.toString(cheatersList.toArray()));
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: CheckCheatersFromBetterRanks: Cheaters found: " + cheatersList);
}

public List<String> getCheatersList() {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"BetterRanksCheaters: getCheatersList called");
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3, "BetterRanksCheaters: getCheatersList called");
return cheatersList;
}
}

0 comments on commit 7f0481c

Please sign in to comment.