Fixed a lot of things. Plugin should work a lot better on 1.12 now.

This commit is contained in:
marcomoesman committed 2018-08-13 14:36:05 +02:00
1 parent f609758d28
commit 06c1eab2e6
52 files changed
+416 -343

No files matched your search

@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.config;
import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.files.Config;
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
import com.rammelkast.anticheatreloaded.config.holders.mysql.*;
@@ -48,7 +48,7 @@ public class Configuration {
private ArrayList<ConfigurationFile> flatfiles;
private ArrayList<ConfigurationTable> dbfiles;
public Configuration(AntiCheat plugin, AntiCheatManager manager) {
public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
removeOldFiles();
this.manager = manager;
config = new Config(plugin, this);
@@ -146,20 +146,20 @@ public class Configuration {
private void removeOldFiles() {
ArrayList<String> removed = new ArrayList<String>();
File configFile = new File(AntiCheat.getPlugin().getDataFolder(), "config.yml");
File configFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.yml");
if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
configFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "config.old"));
configFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.old"));
removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
}
File eventsFile = new File(AntiCheat.getPlugin().getDataFolder(), "events.yml");
File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
if (eventsFile.exists()) {
eventsFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "events.old"));
eventsFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.old"));
removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
}
if (removed.size() > 0) {
AntiCheat.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
AntiCheatReloaded.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
for (String s : removed) {
AntiCheat.getPlugin().getLogger().info(s);
AntiCheatReloaded.getPlugin().getLogger().info(s);
}
}
}
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
import java.io.File;
@@ -37,21 +37,21 @@ public class ConfigurationFile {
private FileConfiguration defaultConfigFile;
private Configuration config;
private AntiCheat plugin;
private AntiCheatReloaded plugin;
private boolean saveDefault;
protected boolean needsReload;
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName) {
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
this(plugin, config, fileName, true);
}
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault) {
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault) {
this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
}
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
// Can't change with user editing
this.plugin = plugin;
this.config = config;
@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.config;
import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
import java.sql.Connection;
@@ -59,7 +59,7 @@ public class ConfigurationTable {
public void reload() {
// For after sql inserts have been made
Bukkit.getScheduler().runTask(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
load();
@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.config.files;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -51,7 +51,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<List<String>> disabledChecks;
public Config(AntiCheat plugin, Configuration config) {
public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -18,7 +18,7 @@
package com.rammelkast.anticheatreloaded.config.files;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
@@ -43,7 +43,7 @@ public class Enterprise extends ConfigurationFile {
public Database database;
public Enterprise(AntiCheat plugin, Configuration config) {
public Enterprise(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
@@ -52,7 +52,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
@Override
public void open() {
InputStreamReader reader = new InputStreamReader(AntiCheat.getPlugin().getResource("lang.yml"));
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("lang.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
@@ -150,7 +150,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
return value;
}
}
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
return "Language error. See console for details.";
}
@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
import org.bukkit.Bukkit;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
@@ -81,11 +81,11 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override
public void saveLevelFromUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
if (!user.isWaitingOnLevelSync()) {
AntiCheat.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
try {
PreparedStatement statement = getConnection().prepareStatement(sqlSave);
statement.setString(1, user.getUUID().toString());
@@ -101,14 +101,14 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
e.printStackTrace();
}
}
AntiCheat.getManager().getUserManager().remove(user);
AntiCheatReloaded.getManager().getUserManager().remove(user);
}
});
}
@Override
public void loadLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -120,7 +120,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
boolean has = false;
while (set.next()) {
has = true;
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
user.setLevel(set.getInt("level"));
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
}
@@ -162,7 +162,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
@Override
public void updateLevelToUser(final User user) {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
@Override
public void run() {
try {
@@ -174,7 +174,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
ResultSet set = statement.executeQuery();
while (set.next()) {
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
user.setLevel(set.getInt("level"));
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
}
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
@@ -49,7 +49,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
@Override
public void open() {
InputStreamReader reader = new InputStreamReader(AntiCheat.getPlugin().getResource("magic.yml"));
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("magic.yml"));
defaults = YamlConfiguration.loadConfiguration(reader);
try {
reader.close();
@@ -102,7 +102,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
} else if (set.getObject("value_double") != null) {
doubles.put(key, set.getDouble("value_double"));
} else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
for (int i=1;i<=methods.length;i++) {
String name = methods[i-1].getName();
if (name.equalsIgnoreCase(key)) {
@@ -149,7 +149,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
return value;
}
}
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return 0;
}
}
@@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
@@ -65,7 +65,7 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
if (rule != null) {
this.rules.add(rule);
} else {
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
}
}
} catch (SQLException e) {
@@ -20,7 +20,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.*;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Groups;
@@ -34,7 +34,7 @@ public class YamlGroupsHolder extends ConfigurationFile implements Groups {
private int highestLevel;
public YamlGroupsHolder(AntiCheat plugin, Configuration config) {
public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -22,7 +22,7 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -30,7 +30,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
public static final String FILENAME = "lang.yml";
public YamlLangHolder(AntiCheat plugin, Configuration config) {
public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -76,7 +76,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
return value.getValue();
}
}
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
return "Language error. See console for details.";
}
}
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.List;
import java.util.UUID;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Levels;
@@ -31,7 +31,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
public static final String FILENAME = "data/levels.yml";
public YamlLevelsHolder(AntiCheat plugin, Configuration config) {
public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME, false);
}
@@ -47,7 +47,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
private void saveLevelFromUser(User user, boolean remove) {
saveLevel(user.getUUID(), user.getLevel());
if (remove) AntiCheat.getManager().getUserManager().remove(user);
if (remove) AntiCheatReloaded.getManager().getUserManager().remove(user);
}
@Override
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
@@ -29,7 +29,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
public static final String FILENAME = "magic.yml";
public YamlMagicHolder(AntiCheat plugin, Configuration config) {
public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -41,7 +41,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
} else if (method.getReturnType().getSimpleName().equals("double")) {
return new ConfigValue<Double>(key).getValue();
} else {
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
return -1;
}
}
@@ -21,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
import java.util.ArrayList;
import java.util.List;
import com.rammelkast.anticheatreloaded.AntiCheat;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
import com.rammelkast.anticheatreloaded.config.providers.Rules;
@@ -33,7 +33,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
private List<Rule> rules;
public YamlRulesHolder(AntiCheat plugin, Configuration config) {
public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
}
@@ -61,7 +61,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
if (rule != null) {
this.rules.add(rule);
} else {
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
}
}
}