-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Grzybol/Ban-command
Ban command
- Loading branch information
Showing
12 changed files
with
609 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/betterbox/mine/game/betterelo/BetterRanksCheaters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package betterbox.mine.game.betterelo; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
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.Set; | ||
|
||
public class BetterRanksCheaters { | ||
private JavaPlugin plugin; | ||
private final PluginLogger pluginLogger; | ||
public List<String> cheatersList; | ||
|
||
public BetterRanksCheaters(JavaPlugin plugin, PluginLogger pluginLogger) { | ||
this.plugin = plugin; | ||
this.pluginLogger = pluginLogger; | ||
this.cheatersList = new ArrayList<>(); | ||
} | ||
|
||
public void CheckCheatersFromBetterRanks() { | ||
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"CheckCheatersFromBetterRanks called"); | ||
File dataFolder = plugin.getServer().getPluginManager().getPlugin("BetterRanks").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ć. | ||
} | ||
|
||
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ć. | ||
} | ||
|
||
|
||
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile); | ||
Set<String> playerNames = config.getKeys(false); | ||
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: Cheaters found: "+ Arrays.toString(cheatersList.toArray())); | ||
} | ||
|
||
public List<String> getCheatersList() { | ||
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"BetterRanksCheaters: getCheatersList called"); | ||
return cheatersList; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/betterbox/mine/game/betterelo/CheaterCheckScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package betterbox.mine.game.betterelo; | ||
|
||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.scheduler.BukkitScheduler; | ||
|
||
public class CheaterCheckScheduler { | ||
private final BetterRanksCheaters betterRanksCheaters; | ||
private final BukkitScheduler scheduler; | ||
private final PluginLogger pluginLogger; | ||
private final Plugin plugin; // Dodaj zmienną plugin | ||
|
||
public CheaterCheckScheduler(Plugin plugin, BetterRanksCheaters betterRanksCheaters, BukkitScheduler scheduler, PluginLogger pluginLogger) { | ||
|
||
this.plugin = plugin; // Zapisz zmienną plugin | ||
this.betterRanksCheaters = betterRanksCheaters; | ||
this.scheduler = scheduler; | ||
this.pluginLogger = pluginLogger; | ||
pluginLogger.log(PluginLogger.LogLevel.DEBUG, "CheaterCheckScheduler called"); | ||
} | ||
|
||
public void startScheduler() { | ||
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL2, "startScheduler called"); | ||
int delay = 0; // Opóźnienie początkowe (0 ticków) | ||
int period = 100; // Okres w tickach (20 ticków to 1 sekunda) | ||
|
||
scheduler.scheduleSyncRepeatingTask(plugin, () -> { | ||
betterRanksCheaters.CheckCheatersFromBetterRanks(); | ||
}, delay, period); | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
src/main/java/betterbox/mine/game/betterelo/CheaterInteractions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package betterbox.mine.game.betterelo; | ||
|
||
public class CheaterInteractions { | ||
private String rankingType; | ||
private String playerName; | ||
private String victimName; | ||
private double totalPoints; | ||
|
||
public CheaterInteractions(String rankingType, String playerName, String victimName, double totalPoints) { | ||
this.rankingType = rankingType; | ||
this.playerName = playerName; | ||
this.victimName = victimName; | ||
this.totalPoints = totalPoints; | ||
} | ||
|
||
public String getRankingType() { | ||
return rankingType; | ||
} | ||
|
||
public String getPlayerName() { | ||
return playerName; | ||
} | ||
|
||
public String getVictimName() { | ||
return victimName; | ||
} | ||
|
||
public double getTotalPoints() { | ||
return totalPoints; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.