mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Implement new levels system.
This commit is contained in:
1 parent
14ca51bac9
commit
52a90b9bc8
11 files changed
+307
-131
No files matched your search
@@ -97,7 +97,7 @@ public class Anticheat extends JavaPlugin {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void save(InputStream in, File file) {
|
||||
private boolean save(InputStream in, File file) {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
@@ -115,7 +115,9 @@ public class Anticheat extends JavaPlugin {
|
||||
if (verbose) {
|
||||
getLogger().log(Level.INFO, file.getName() + " created.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setupXray() {
|
||||
@@ -210,6 +212,7 @@ public class Anticheat extends JavaPlugin {
|
||||
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
config.load();
|
||||
checkConfigs();
|
||||
verbose = config.verboseStartup();
|
||||
if (verbose) {
|
||||
@@ -231,6 +234,9 @@ public class Anticheat extends JavaPlugin {
|
||||
save(getResource("config.yml"), new File(getDataFolder() + "/config.yml"));
|
||||
save(getResource("lang.yml"), new File(getDataFolder() + "/lang.yml"));
|
||||
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
||||
if(!save(getResource("events.yml"), new File(getDataFolder() + "/events.yml"))) {
|
||||
config.updateEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin() {
|
||||
|
||||
@@ -359,12 +359,11 @@ public class CommandHandler implements CommandExecutor {
|
||||
public void sendPlayerReport(CommandSender cs, List<CheckType> types, User user, int page) {
|
||||
String name = user.getName();
|
||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||
int level = user.getLevel();
|
||||
String levelString = GREEN + "Low";
|
||||
if (level >= CONFIG.highThreshold()) {
|
||||
levelString = RED + "High";
|
||||
} else if (level >= CONFIG.medThreshold()) {
|
||||
levelString = YELLOW + "Medium";
|
||||
String levelString = ChatColor.GREEN+"Low";
|
||||
for(Level level : CONFIG.getLevels()) {
|
||||
if(level.getValue() == user.getLevel()) {
|
||||
levelString = level.getColor()+level.getName();
|
||||
}
|
||||
}
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
||||
@@ -410,11 +409,13 @@ public class CommandHandler implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args) {
|
||||
if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("report")) {
|
||||
if (args[1].equalsIgnoreCase("low") || args[1].equalsIgnoreCase("medium") || args[1].equalsIgnoreCase("high")) {
|
||||
handleReport(cs, args);
|
||||
} else {
|
||||
handlePlayerReport(cs, args);
|
||||
for(Level level : CONFIG.getLevels()) {
|
||||
if(args[1].equalsIgnoreCase(level.getName())) {
|
||||
handleReport(cs, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
handlePlayerReport(cs, args);
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("log")) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Level;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -33,11 +34,11 @@ import java.util.List;
|
||||
public class User {
|
||||
private final String name;
|
||||
private int level = 0;
|
||||
private int high;
|
||||
private int med;
|
||||
private Location goodLocation;
|
||||
private boolean silentMode;
|
||||
private List<ItemStack> inventorySnapshot = null;
|
||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||
private List<Level> levels = new ArrayList<Level>();
|
||||
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
@@ -51,10 +52,9 @@ public class User {
|
||||
}
|
||||
|
||||
private void getConfigInfo() {
|
||||
Configuration config = Anticheat.getManager().getConfiguration();
|
||||
config = Anticheat.getManager().getConfiguration();
|
||||
silentMode = config.silentMode();
|
||||
med = config.medThreshold();
|
||||
high = config.highThreshold();
|
||||
levels = config.getLevels();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -76,12 +76,13 @@ public class User {
|
||||
return false;
|
||||
} else {
|
||||
level++;
|
||||
if (level == med) {
|
||||
Anticheat.getManager().getUserManager().alertMed(this, type);
|
||||
} else if (level == high) {
|
||||
Anticheat.getManager().getUserManager().alertHigh(this, type);
|
||||
// Prevent the player from going over the high limit
|
||||
level = high - 10;
|
||||
for(Level l : levels) {
|
||||
if(l.getValue() == level) {
|
||||
Anticheat.getManager().getUserManager().alert(this, l, type);
|
||||
if(l.getValue() == config.getHighestLevel()) {
|
||||
level = l.getValue() - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -95,7 +96,7 @@ public class User {
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
if (level > 0 && level <= high) {
|
||||
if (level > 0 && level <= config.getHighestLevel()) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Language;
|
||||
import net.h31ix.anticheat.util.Level;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -103,57 +104,46 @@ public class UserManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void alertMed(User user, CheckType type) {
|
||||
List<String> messageArray = lang.getMediumAlert();
|
||||
public void alert(User user, Level level, CheckType type) {
|
||||
List<String> messageArray = lang.getAlert();
|
||||
for (int i = 0; i < messageArray.size(); i++) {
|
||||
String message = messageArray.get(i);
|
||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||
message = message.replaceAll("medium", YELLOW + "medium" + GRAY);
|
||||
message = message.replaceAll("&level", level.getColor() + level.getName() + GRAY);
|
||||
messageArray.set(i, message);
|
||||
}
|
||||
Utilities.alert(messageArray);
|
||||
execute(user, config.mediumEvent());
|
||||
execute(user, level.getActions(), type);
|
||||
}
|
||||
|
||||
public void alertHigh(User user, CheckType type) {
|
||||
List<String> messageArray = lang.getHighAlert();
|
||||
for (int i = 0; i < messageArray.size(); i++) {
|
||||
String message = messageArray.get(i);
|
||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||
message = message.replaceAll("high", RED + "high" + GRAY);
|
||||
messageArray.set(i, message);
|
||||
}
|
||||
Utilities.alert(messageArray);
|
||||
execute(user, config.highEvent());
|
||||
}
|
||||
|
||||
public void execute(User user, String event) {
|
||||
public void execute(User user, List<String> actions, CheckType type) {
|
||||
final String name = user.getName();
|
||||
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName());
|
||||
for(String event : actions) {
|
||||
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
|
||||
|
||||
if (event.startsWith("COMMAND[")) {
|
||||
for(String cmd : Utilities.getCommands(event)) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("KICK")) {
|
||||
user.getPlayer().kickPlayer(RED + lang.getKickReason());
|
||||
String msg = RED + lang.getKickBroadcast().replaceAll("&player", name);
|
||||
if (!msg.equals("")) {
|
||||
Bukkit.broadcastMessage(msg);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("WARN")) {
|
||||
List<String> message = lang.getWarning();
|
||||
for (String string : message) {
|
||||
user.getPlayer().sendMessage(RED + string);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("BAN")) {
|
||||
user.getPlayer().setBanned(true);
|
||||
user.getPlayer().kickPlayer(RED + lang.getBanReason());
|
||||
String msg = RED + lang.getBanBroadcast().replaceAll("&player", name);
|
||||
if (!msg.equals("")) {
|
||||
Bukkit.broadcastMessage(msg);
|
||||
if (event.startsWith("COMMAND[")) {
|
||||
for(String cmd : Utilities.getCommands(event)) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("KICK")) {
|
||||
user.getPlayer().kickPlayer(RED + lang.getKickReason());
|
||||
String msg = RED + lang.getKickBroadcast().replaceAll("&player", name);
|
||||
if (!msg.equals("")) {
|
||||
Bukkit.broadcastMessage(msg);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("WARN")) {
|
||||
List<String> message = lang.getWarning();
|
||||
for (String string : message) {
|
||||
user.getPlayer().sendMessage(RED + string);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("BAN")) {
|
||||
user.getPlayer().setBanned(true);
|
||||
user.getPlayer().kickPlayer(RED + lang.getBanReason());
|
||||
String msg = RED + lang.getBanBroadcast().replaceAll("&player", name);
|
||||
if (!msg.equals("")) {
|
||||
Bukkit.broadcastMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.util.yaml.CommentedConfiguration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -37,9 +39,11 @@ public class Configuration {
|
||||
private File levelFile = null;
|
||||
private File langFile = null;
|
||||
private File magicFile = null;
|
||||
private File eventsFile = null;
|
||||
private CommentedConfiguration config;
|
||||
private FileConfiguration level;
|
||||
private FileConfiguration magic;
|
||||
private FileConfiguration events;
|
||||
private boolean logConsole;
|
||||
private boolean logXRay;
|
||||
private boolean alertXRay;
|
||||
@@ -52,16 +56,14 @@ public class Configuration {
|
||||
private boolean trackCreativeXRay;
|
||||
private boolean eventChains;
|
||||
private int fileLogLevel = 0;
|
||||
private int medThreshold = 0;
|
||||
private int highThreshold = 0;
|
||||
private String updateFolder;
|
||||
private String eventMed;
|
||||
private String eventHigh;
|
||||
private String chatActionKick;
|
||||
private String chatActionBan;
|
||||
private static Language language;
|
||||
private List<String> exemptWorlds = new ArrayList<String>();
|
||||
private List<Level> levels = new ArrayList<Level>();
|
||||
private Magic magicInstance;
|
||||
private int highestLevel;
|
||||
|
||||
public Configuration(AnticheatManager instance) {
|
||||
micromanage = instance;
|
||||
@@ -69,14 +71,19 @@ public class Configuration {
|
||||
levelFile = new File(micromanage.getPlugin().getDataFolder() + "/data/level.yml");
|
||||
langFile = new File(micromanage.getPlugin().getDataFolder() + "/lang.yml");
|
||||
magicFile = new File(micromanage.getPlugin().getDataFolder() + "/magic.yml");
|
||||
load();
|
||||
eventsFile = new File(micromanage.getPlugin().getDataFolder() + "/events.yml");
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
events.save(eventsFile);
|
||||
level.save(levelFile);
|
||||
magic.save(magicFile);
|
||||
System.out.println("Saved");
|
||||
System.out.println(config.get("Events.Level Medium"));
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Configuration.class.getName()).severe(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,22 +135,6 @@ public class Configuration {
|
||||
return eventChains;
|
||||
}
|
||||
|
||||
public int medThreshold() {
|
||||
return medThreshold;
|
||||
}
|
||||
|
||||
public int highThreshold() {
|
||||
return highThreshold;
|
||||
}
|
||||
|
||||
public String mediumEvent() {
|
||||
return eventMed;
|
||||
}
|
||||
|
||||
public String highEvent() {
|
||||
return eventHigh;
|
||||
}
|
||||
|
||||
public String chatActionKick() {
|
||||
return chatActionKick;
|
||||
}
|
||||
@@ -159,12 +150,86 @@ public class Configuration {
|
||||
public Language getLang() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public List<Level> getLevels() {
|
||||
return levels;
|
||||
}
|
||||
|
||||
public int getHighestLevel() {
|
||||
return highestLevel = -99;
|
||||
}
|
||||
|
||||
public void updateEvents() {
|
||||
// Update the old event system to events.yml
|
||||
CommentedConfiguration config = CommentedConfiguration.loadConfig(configFile);
|
||||
events = YamlConfiguration.loadConfiguration(Anticheat.getPlugin().getResource("events.yml"));
|
||||
String medium = config.getString("Events.Level Medium");
|
||||
String high = config.getString("Events.Level High");
|
||||
int medValue = config.getString("Events.Medium threshold") != null ? config.getInt("Events.Medium threshold") : -1;
|
||||
int highValue = config.getString("Events.High threshold") != null ? config.getInt("Events.High threshold") : -1;
|
||||
|
||||
System.out.println("Set event null");
|
||||
config.set("Events", null);
|
||||
System.out.println(config.get("Events.Level Medium"));
|
||||
Level mediumLevel = new Level("Medium", medValue != -1 ? medValue : 20, ChatColor.YELLOW);
|
||||
Level highLevel = new Level("High", highValue != -1 ? highValue : 50, ChatColor.RED);
|
||||
Level customLevel = new Level("Custom", -1, ChatColor.GREEN);
|
||||
mediumLevel.addAction(medium != null ? medium : "WARN");
|
||||
highLevel.addAction(high != null ? high : "KICK");
|
||||
customLevel.addAction("COMMAND[ban &player;say hello world]");
|
||||
|
||||
levels.add(mediumLevel);
|
||||
levels.add(highLevel);
|
||||
levels.add(customLevel);
|
||||
|
||||
writeEvents();
|
||||
}
|
||||
|
||||
private void writeEvents() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list2 = new ArrayList<String>();
|
||||
for(Level level : levels) {
|
||||
list.add(level.toString());
|
||||
for(String string : level.getActions()) {
|
||||
list2.add(level.getName()+": "+string);
|
||||
}
|
||||
}
|
||||
events.set("levels", list);
|
||||
events.set("actions", list2);
|
||||
save();
|
||||
}
|
||||
|
||||
private void readEvents() {
|
||||
levels = new ArrayList<Level>();
|
||||
for(String string : events.getStringList("levels")) {
|
||||
Level level = Level.load(string);
|
||||
levels.add(level);
|
||||
highestLevel = level.getValue() > highestLevel ? level.getValue() : highestLevel;
|
||||
}
|
||||
for(String string : events.getStringList("actions")) {
|
||||
String name;
|
||||
String action;
|
||||
try {
|
||||
name = string.split(": ")[0];
|
||||
action = string.split(": ")[1];
|
||||
} catch (Exception ex) {
|
||||
Anticheat.getPlugin().getLogger().warning("Couldn't load action '"+string+"' from config. Improper formatting used.");
|
||||
break;
|
||||
}
|
||||
for(Level level : levels) {
|
||||
if(level.getName().equalsIgnoreCase(name)) {
|
||||
level.addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void load() {
|
||||
micromanage.getPlugin().checkConfigs();
|
||||
boolean secondLoad = config != null;
|
||||
config = CommentedConfiguration.loadConfig(configFile);
|
||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||
magic = YamlConfiguration.loadConfiguration(magicFile);
|
||||
events = YamlConfiguration.loadConfiguration(eventsFile);
|
||||
language = new Language(YamlConfiguration.loadConfiguration(langFile), langFile);
|
||||
updateFolder = Bukkit.getUpdateFolder();
|
||||
|
||||
@@ -176,13 +241,9 @@ public class Configuration {
|
||||
alertXRay = getBoolean("XRay.Alert when xray is found", false);
|
||||
fileLogLevel = getInt("System.File log level", 1);
|
||||
silentMode = getBoolean("System.Silent mode", false);
|
||||
medThreshold = getInt("Events.Medium threshold", 20);
|
||||
highThreshold = getInt("Events.High threshold", 50);
|
||||
opExempt = getBoolean("System.Exempt op", false);
|
||||
trackCreativeXRay = getBoolean("XRay.Track creative", true);
|
||||
eventChains = getBoolean("System.Event Chains", true);
|
||||
eventMed = getString("Events.Level Medium", "WARN");
|
||||
eventHigh = getString("Events.Level High", "KICK");
|
||||
chatActionKick = getString("Chat.Kick Action", "KICK");
|
||||
chatActionBan = getString("Chat.Ban Action", "BAN");
|
||||
chatSpam = getBoolean("Chat.Block chat spam", true);
|
||||
@@ -218,6 +279,10 @@ public class Configuration {
|
||||
}
|
||||
|
||||
exemptWorlds = config.getStringList("Disable in");
|
||||
|
||||
if(secondLoad) {
|
||||
readEvents();
|
||||
}
|
||||
// End pulling values from config
|
||||
save();
|
||||
magicInstance = new Magic(getMagic(), this, CommentedConfiguration.loadConfiguration(micromanage.getPlugin().getResource("magic.yml")));
|
||||
@@ -259,7 +324,7 @@ public class Configuration {
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Configuration.class.getName()).severe(ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +352,7 @@ public class Configuration {
|
||||
try {
|
||||
level.save(levelFile);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Configuration.class.getName()).severe(ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +360,7 @@ public class Configuration {
|
||||
try {
|
||||
newMagic.save(magicFile);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Configuration.class.getName()).severe(ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class Language {
|
||||
private static String[] medAlert = null;
|
||||
private static String[] highAlert = null;
|
||||
private static String[] warning = null;
|
||||
private static List<String> alert = null;
|
||||
private static List<String> warning = null;
|
||||
private static String banReason = null;
|
||||
private static String banBroadcast = null;
|
||||
private static String kickReason = null;
|
||||
@@ -45,25 +44,31 @@ public class Language {
|
||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||
private FileConfiguration file;
|
||||
private File f;
|
||||
|
||||
public Language(FileConfiguration file, File f) {
|
||||
this.file = file;
|
||||
String[] temp = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
||||
medAlert = new String[temp.length + 2];
|
||||
medAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
medAlert[i + 1] = GRAY + temp[i];
|
||||
this.f = f;
|
||||
|
||||
// Begin medium_alert / high_alert -> alert swap
|
||||
List<String> list = file.getStringList("alert.medium_alert");
|
||||
if(list != null && list.size() > 0) {
|
||||
list.set(1, "&player has just entered the &level hack level.");
|
||||
file.set("alert", null);
|
||||
file.set("alert", list);
|
||||
save();
|
||||
}
|
||||
medAlert[medAlert.length - 1] = GOLD + "-----------------------------------------------------";
|
||||
temp = file.getList("alert.high_alert").toArray(new String[file.getList("alert.high_alert").size()]);
|
||||
highAlert = new String[temp.length + 2];
|
||||
highAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
highAlert[i + 1] = GRAY + temp[i];
|
||||
// End swap
|
||||
|
||||
List<String> temp = file.getStringList("alert");
|
||||
alert = new ArrayList<String>();
|
||||
alert.add(GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------");
|
||||
for (int i = 0; i < temp.size(); i++) {
|
||||
alert.add(GRAY + temp.get(i));
|
||||
}
|
||||
highAlert[highAlert.length - 1] = GOLD + "-----------------------------------------------------";
|
||||
alert.add(GOLD + "-----------------------------------------------------");
|
||||
|
||||
warning = file.getList("warning.player_warning").toArray(new String[file.getList("warning.player_warning").size()]);
|
||||
warning = file.getStringList("warning.player_warning");
|
||||
banReason = getString("ban.ban_reason", "Banned by AntiCheat");
|
||||
banBroadcast = getString("ban.ban_broadcast", "[AntiCheat] &player was banned for hacking.");
|
||||
kickReason = getString("kick.kick_reason", "Kicked by AntiCheat");
|
||||
@@ -73,6 +78,10 @@ public class Language {
|
||||
chatBanReason = getString("chat.ban_reason", "Banned for spamming");
|
||||
chatKickBroadcast = getString("chat.kick_broadcast", "[AntiCheat] &player was kicked for spamming");
|
||||
chatBanBroadcast = getString("chat.ban_broadcast", "[AntiCheat] &player was banned for spamming");
|
||||
save();
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
file.save(f);
|
||||
} catch (IOException ex) {
|
||||
@@ -80,16 +89,12 @@ public class Language {
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getMediumAlert() {
|
||||
return new ArrayList<String>(Arrays.asList(medAlert));
|
||||
}
|
||||
|
||||
public List<String> getHighAlert() {
|
||||
return new ArrayList<String>(Arrays.asList(highAlert));
|
||||
public List<String> getAlert() {
|
||||
return alert;
|
||||
}
|
||||
|
||||
public List<String> getWarning() {
|
||||
return new ArrayList<String>(Arrays.asList(warning));
|
||||
return warning;
|
||||
}
|
||||
|
||||
public String getBanReason() {
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2013 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.util;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
private String name;
|
||||
private int value;
|
||||
private ChatColor color = ChatColor.RED;
|
||||
private boolean customColor = false;
|
||||
private List<String> actions = new ArrayList<String>();
|
||||
|
||||
public Level(String name, int value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Level(String name, int value, ChatColor color) {
|
||||
this(name, value);
|
||||
this.color = color;
|
||||
customColor = true;
|
||||
}
|
||||
|
||||
public Level(String name, int value, String color) {
|
||||
this(name, value);
|
||||
ChatColor c = ChatColor.valueOf(color);
|
||||
if(c == null) {
|
||||
Anticheat.getPlugin().getLogger().warning("Event '"+name+"' was initialized with the color '"+color+"' which is invalid.");
|
||||
Anticheat.getPlugin().getLogger().warning("This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
|
||||
} else {
|
||||
this.color = c;
|
||||
customColor = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAction(String string) {
|
||||
actions.add(string);
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public List<String> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static Level load(String string) {
|
||||
try {
|
||||
string = string.trim();
|
||||
String name = string.split(":")[0];
|
||||
int level = Integer.parseInt(string.split(":")[1]);
|
||||
if(string.split(":").length == 3) {
|
||||
String color = string.split(":")[2];
|
||||
return new Level(name, level, color);
|
||||
} else {
|
||||
return new Level(name, level);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Anticheat.getPlugin().getLogger().warning("An event was intialized with an invalid string: '"+string+"'");
|
||||
Anticheat.getPlugin().getLogger().warning("The proper format is: 'name: threshold, color' such as 'high: 50, RED'");
|
||||
Anticheat.getPlugin().getLogger().warning("This event will NOT run. ("+ex.getMessage()+")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " : " + value + (customColor ? " : "+color.name() : "");
|
||||
}
|
||||
}
|
||||
@@ -50,12 +50,6 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||
comments.put("Chat:", " # Should AntiCheat block players spamming messages in chat?");
|
||||
comments.put("Block chat spam:", " # Should AntiCheat block players spamming commands in chat?");
|
||||
comments.put("Block command spam:", " # Valid actions = NONE,KICK,BAN,COMMAND[command]");
|
||||
comments.put("Ban Action:", "# Events occur when a player's hack level changes. You may configure reactions to these events here.");
|
||||
comments.put("# Events occur when a player's hack level changes. You may configure reactions to these events here.", "# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]");
|
||||
comments.put("# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]", "# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]");
|
||||
comments.put("# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]", "# &player will be replaced with player's name, and &world will be replaced with the player's world");
|
||||
comments.put("Level High:", " # How many warnings should the player get before entering medium?");
|
||||
comments.put("Medium threshold:", " # How many warnings should the player get before entering high?");
|
||||
comments.put("System:", " # Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.");
|
||||
comments.put("# Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.", " # Should AntiCheat log ALL failed checks to console?");
|
||||
comments.put("Log to console:", " # Should AntiCheat log to files?");
|
||||
|
||||
Reference in new issue
Block a user