ids = new ArrayList<>();
- while (rs.next()){
- ids.add(rs.getInt("ID"));
- }
- return ids;
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static String getNameByReportID(int ReportID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM reports WHERE ID='" + ReportID + "'");
- if(rs.next()){
- return getNameByUUID(rs.getString("UUID"));
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static String getReasonByReportID(int ReportID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM reports WHERE ID='" + ReportID + "'");
- if(rs.next()){
- return rs.getString("REASON");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static void setReportDone(int ID){
- Main.mysql.update("UPDATE reports SET STATUS = 1 WHERE ID = "+ID);
- }
-
- public static void setReportTeamUUID(int ID, String UUID){
- Main.mysql.update("UPDATE reports SET TEAM = '"+UUID+"' WHERE ID = "+ID);
- }
-
- public static boolean isChatlogAvailable(int ID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM reports WHERE ID='" + ID + "'");
- if(rs.next()){
- if(rs.getString("LOG") != "null"){
- return true;
- } else {
- return false;
- }
- }
- } catch (SQLException exc){
-
- }
- return false;
- }
-
- public static String getChatlogbyReportID(int ReportID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM reports WHERE ID='" + ReportID + "'");
- if(rs.next()){
- return rs.getString("LOG");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static void updateLastLogin(String UUID){
- Main.mysql.update("UPDATE bans SET LASTLOGIN = '" + System.currentTimeMillis() + "' WHERE UUID = '"+UUID+"'");
- }
-
- public static String getLastLogin(String UUID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM bans WHERE UUID='" + UUID + "'");
- if(rs.next()){
- return rs.getString("LASTLOGIN");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static String getFirstLogin(String UUID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM bans WHERE UUID='" + UUID + "'");
- if(rs.next()){
- return rs.getString("FIRSTLOGIN");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static String formatTimestamp(long timestamp){
- Date date = new Date(timestamp);
- SimpleDateFormat jdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
- return jdf.format(date);
- }
-
-}
diff --git a/src/de/tutorialwork/utils/IPManager.java b/src/de/tutorialwork/utils/IPManager.java
deleted file mode 100644
index 60e5c7c..0000000
--- a/src/de/tutorialwork/utils/IPManager.java
+++ /dev/null
@@ -1,250 +0,0 @@
-package de.tutorialwork.utils;
-
-import de.tutorialwork.main.Main;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class IPManager {
-
- //ips(IP varchar(64) UNIQUE, USED_BY varchar(64), USED_AT varchar(64), BANNED int(11), REASON varchar(64), END long, TEAMUUID varchar(64), BANS int(11));
-
- public static boolean IPExists(String IP){
- try {
-
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return rs.getString("IP") != null;
- }
-
- } catch (SQLException exc){
-
- }
-
- return false;
-
- }
-
- public static void insertIP(String IP, String UUID){
- if(!IPExists(IP)){
- Main.mysql.update("INSERT INTO ips(IP, USED_BY, USED_AT, BANNED, REASON, END, TEAMUUID, BANS) " +
- "VALUES ('" + IP + "', '" + UUID + "', '" + System.currentTimeMillis() + "', '0', 'null', 'null', 'null', '0')");
- } else {
- updateIPInfos(IP, UUID);
- }
- }
-
- public static void updateIPInfos(String IP, String newUUID){
- if(IPExists(IP)){
- Main.mysql.update("UPDATE ips SET USED_BY = '"+newUUID+"', USED_AT='" + System.currentTimeMillis() + "' WHERE IP='" + IP + "'");
- }
- }
-
- public static void ban(String IP, int GrundID, String TeamUUID){
- long current = System.currentTimeMillis();
- long end = current + BanManager.getReasonTime(GrundID) * 60000L;
- if(BanManager.getReasonTime(GrundID) == -1){
- //Perma Ban
- Main.mysql.update("UPDATE ips SET BANNED='1', REASON='" + BanManager.getReasonByID(GrundID) + "', END='-1', TEAMUUID='" + TeamUUID + "' WHERE IP='" + IP + "'");
- } else {
- //Temp Ban
- Main.mysql.update("UPDATE ips SET BANNED='1', REASON='" + BanManager.getReasonByID(GrundID) + "', END='" + end + "', TEAMUUID='" + TeamUUID + "' WHERE IP='" + IP + "'");
- }
- }
-
-
- public static boolean isBanned(String IP){
- if(IPExists(IP)){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- if(rs.getInt("BANNED") == 1){
- return true;
- } else {
- return false;
- }
- }
- } catch (SQLException exc){
-
- }
- }
- return false;
- }
-
- public static String getReasonString(String IP){
- if(IPExists(IP)){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return rs.getString("REASON");
- }
- } catch (SQLException exc){
-
- }
- }
- return null;
- }
-
- public static Long getRAWEnd(String IP){
- if(IPExists(IP)){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return rs.getLong("END");
- }
- } catch (SQLException exc){
-
- }
- }
- return null;
- }
-
- public static String getEnd(String UUID) {
- long uhrzeit = System.currentTimeMillis();
- long end = getRAWEnd(UUID);
-
- long millis = end - uhrzeit;
-
- long sekunden = 0L;
- long minuten = 0L;
- long stunden = 0L;
- long tage = 0L;
- while (millis > 1000L)
- {
- millis -= 1000L;
- sekunden += 1L;
- }
- while (sekunden > 60L)
- {
- sekunden -= 60L;
- minuten += 1L;
- }
- while (minuten > 60L)
- {
- minuten -= 60L;
- stunden += 1L;
- }
- while (stunden > 24L)
- {
- stunden -= 24L;
- tage += 1L;
- }
- if(tage != 0){
- return "§a" + tage + " §7Tag(e) §a" + stunden + " §7Stunde(n) §a" + minuten + " §7Minute(n)";
- } else if(tage == 0 && stunden != 0){
- return "§a" + stunden + " §7Stunde(n) §a" + minuten + " §7Minute(n) §a" + sekunden + " §7Sekunde(n)";
- } else if(tage == 0 && stunden == 0 && minuten != 0){
- return "§a" + minuten + " §7Minute(n) §a" + sekunden + " §7Sekunde(n)";
- } else if(tage == 0 && stunden == 0 && minuten == 0 && sekunden != 0) {
- return "§a" + sekunden + " §7Sekunde(n)";
- } else {
- return "§4Fehler in der Berechnung!";
- }
- //Alter Code
- //return "§a" + tage + " §7Tag(e) §a" + stunden + " §7Stunde(n) §a" + minuten + " §7Minute(n) §a" + sekunden + " §7Sekunde(n)";
- }
-
- public static void unban(String IP){
- if(IPExists(IP)){
- Main.mysql.update("UPDATE ips SET BANNED='0' WHERE IP='" + IP + "'");
- }
- }
-
- public static boolean isVPN(String IP){
- if(!IP.equals("127.0.0.1")){
- if(Main.APIKey != null){
- String json = Main.callURL("http://proxycheck.io/v2/"+IP+"?key="+Main.APIKey);
- json = json.replace("{\n" +
- " \"status\": \"ok\",\n" +
- " \""+IP+"\": {\n" +
- " \"proxy\": \"", "");
- json = json.replace("\"\n" +
- " }\n" +
- "}", "");
- if(json.equals("yes")){
- return true;
- } else {
- return false;
- }
- } else {
- String json = Main.callURL("http://proxycheck.io/v2/"+IP+"?key=318n07-0o7054-y9y82a-75o3hr");
- json = json.replace("{\n" +
- " \"status\": \"ok\",\n" +
- " \""+IP+"\": {\n" +
- " \"proxy\": \"", "");
- json = json.replace("\"\n" +
- " }\n" +
- "}", "");
- if(json.equals("yes")){
- return true;
- } else {
- return false;
- }
- }
- } else {
- return false;
- }
- }
-
- public static String getIPFromPlayer(String UUID){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE USED_BY='" + UUID + "'");
- if(rs.next()){
- return rs.getString("IP");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static String getPlayerFromIP(String IP){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return rs.getString("USED_BY");
- }
- } catch (SQLException exc){
-
- }
- return null;
- }
-
- public static Integer getBans(String IP){
- if(IPExists(IP)){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return rs.getInt("BANS");
- }
- } catch (SQLException exc){
-
- }
- }
- return null;
- }
-
- public static void setBans(String IP, int Bans){
- if(IPExists(IP)){
- Main.mysql.update("UPDATE ips SET BANS='" + Bans + "' WHERE IP='" + IP + "'");
- }
- }
-
- public static void addBan(String IP){
- setBans(IP, getBans(IP) + 1);
- }
-
- public static long getLastUseLong(String IP){
- if(IPExists(IP)){
- try {
- ResultSet rs = Main.mysql.query("SELECT * FROM ips WHERE IP='" + IP + "'");
- if(rs.next()){
- return Long.valueOf(rs.getString("USED_AT"));
- }
- } catch (SQLException exc){
-
- }
- }
- return 0;
- }
-
-}
diff --git a/src/de/tutorialwork/utils/Metrics.java b/src/de/tutorialwork/utils/Metrics.java
deleted file mode 100644
index c5dceec..0000000
--- a/src/de/tutorialwork/utils/Metrics.java
+++ /dev/null
@@ -1,754 +0,0 @@
-package de.tutorialwork.utils;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
-import net.md_5.bungee.api.plugin.Plugin;
-import net.md_5.bungee.config.Configuration;
-import net.md_5.bungee.config.ConfigurationProvider;
-import net.md_5.bungee.config.YamlConfiguration;
-
-import javax.net.ssl.HttpsURLConnection;
-import java.io.*;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * bStats collects some data for plugin authors.
- *
- * Check out https://bStats.org/ to learn more about bStats!
- */
-@SuppressWarnings({"WeakerAccess", "unused"})
-public class Metrics {
-
- static {
- // You can use the property to disable the check in your test environment
- if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
- // Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
- final String defaultPackage = new String(
- new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'n', 'g', 'e', 'e', 'c', 'o', 'r', 'd'});
- final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
- // We want to make sure nobody just copy & pastes the example and use the wrong package names
- if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
- throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
- }
- }
- }
-
- // The version of this bStats class
- public static final int B_STATS_VERSION = 1;
-
- // The url to which the data is sent
- private static final String URL = "https://bStats.org/submitData/bungeecord";
-
- // The plugin
- private final Plugin plugin;
-
- // Is bStats enabled on this server?
- private boolean enabled;
-
- // The uuid of the server
- private String serverUUID;
-
- // Should failed requests be logged?
- private boolean logFailedRequests = false;
-
- // Should the sent data be logged?
- private static boolean logSentData;
-
- // Should the response text be logged?
- private static boolean logResponseStatusText;
-
- // A list with all known metrics class objects including this one
- private static final List knownMetricsInstances = new ArrayList<>();
-
- // A list with all custom charts
- private final List charts = new ArrayList<>();
-
- public Metrics(Plugin plugin) {
- this.plugin = plugin;
-
- try {
- loadConfig();
- } catch (IOException e) {
- // Failed to load configuration
- plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
- return;
- }
-
- // We are not allowed to send data about this server :(
- if (!enabled) {
- return;
- }
-
- Class> usedMetricsClass = getFirstBStatsClass();
- if (usedMetricsClass == null) {
- // Failed to get first metrics class
- return;
- }
- if (usedMetricsClass == getClass()) {
- // We are the first! :)
- linkMetrics(this);
- startSubmitting();
- } else {
- // We aren't the first so we link to the first metrics class
- try {
- usedMetricsClass.getMethod("linkMetrics", Object.class).invoke(null, this);
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
- if (logFailedRequests) {
- plugin.getLogger().log(Level.WARNING, "Failed to link to first metrics class " + usedMetricsClass.getName() + "!", e);
- }
- }
- }
- }
-
- /**
- * Checks if bStats is enabled.
- *
- * @return Whether bStats is enabled or not.
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * Adds a custom chart.
- *
- * @param chart The chart to add.
- */
- public void addCustomChart(CustomChart chart) {
- if (chart == null) {
- plugin.getLogger().log(Level.WARNING, "Chart cannot be null");
- }
- charts.add(chart);
- }
-
- /**
- * Links an other metrics class with this class.
- * This method is called using Reflection.
- *
- * @param metrics An object of the metrics class to link.
- */
- public static void linkMetrics(Object metrics) {
- knownMetricsInstances.add(metrics);
- }
-
- /**
- * Gets the plugin specific data.
- * This method is called using Reflection.
- *
- * @return The plugin specific data.
- */
- public JsonObject getPluginData() {
- JsonObject data = new JsonObject();
-
- String pluginName = plugin.getDescription().getName();
- String pluginVersion = plugin.getDescription().getVersion();
-
- data.addProperty("pluginName", pluginName);
- data.addProperty("pluginVersion", pluginVersion);
-
- JsonArray customCharts = new JsonArray();
- for (CustomChart customChart : charts) {
- // Add the data of the custom charts
- JsonObject chart = customChart.getRequestJsonObject(plugin.getLogger(), logFailedRequests);
- if (chart == null) { // If the chart is null, we skip it
- continue;
- }
- customCharts.add(chart);
- }
- data.add("customCharts", customCharts);
-
- return data;
- }
-
- private void startSubmitting() {
- // The data collection is async, as well as sending the data
- // Bungeecord does not have a main thread, everything is async
- plugin.getProxy().getScheduler().schedule(plugin, this::submitData, 2, 30, TimeUnit.MINUTES);
- // Submit the data every 30 minutes, first time after 2 minutes to give other plugins enough time to start
- // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
- // WARNING: Just don't do it!
- }
-
- /**
- * Gets the server specific data.
- *
- * @return The server specific data.
- */
- private JsonObject getServerData() {
- // Minecraft specific data
- int playerAmount = plugin.getProxy().getOnlineCount();
- playerAmount = playerAmount > 500 ? 500 : playerAmount;
- int onlineMode = plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0;
- String bungeecordVersion = plugin.getProxy().getVersion();
- int managedServers = plugin.getProxy().getServers().size();
-
- // OS/Java specific data
- String javaVersion = System.getProperty("java.version");
- String osName = System.getProperty("os.name");
- String osArch = System.getProperty("os.arch");
- String osVersion = System.getProperty("os.version");
- int coreCount = Runtime.getRuntime().availableProcessors();
-
- JsonObject data = new JsonObject();
-
- data.addProperty("serverUUID", serverUUID);
-
- data.addProperty("playerAmount", playerAmount);
- data.addProperty("managedServers", managedServers);
- data.addProperty("onlineMode", onlineMode);
- data.addProperty("bungeecordVersion", bungeecordVersion);
-
- data.addProperty("javaVersion", javaVersion);
- data.addProperty("osName", osName);
- data.addProperty("osArch", osArch);
- data.addProperty("osVersion", osVersion);
- data.addProperty("coreCount", coreCount);
-
- return data;
- }
-
- /**
- * Collects the data and sends it afterwards.
- */
- private void submitData() {
- final JsonObject data = getServerData();
-
- final JsonArray pluginData = new JsonArray();
- // Search for all other bStats Metrics classes to get their plugin data
- for (Object metrics : knownMetricsInstances) {
- try {
- Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
- if (plugin instanceof JsonObject) {
- pluginData.add((JsonObject) plugin);
- }
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
- }
-
- data.add("plugins", pluginData);
-
- try {
- // Send the data
- sendData(plugin, data);
- } catch (Exception e) {
- // Something went wrong! :(
- if (logFailedRequests) {
- plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats!", e);
- }
- }
- }
-
- /**
- * Loads the bStats configuration.
- *
- * @throws IOException If something did not work :(
- */
- private void loadConfig() throws IOException {
- Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
- configPath.toFile().mkdirs();
- File configFile = new File(configPath.toFile(), "config.yml");
- if (!configFile.exists()) {
- writeFile(configFile,
- "#bStats collects some data for plugin authors like how many servers are using their plugins.",
- "#To honor their work, you should not disable it.",
- "#This has nearly no effect on the server performance!",
- "#Check out https://bStats.org/ to learn more :)",
- "enabled: true",
- "serverUuid: \"" + UUID.randomUUID().toString() + "\"",
- "logFailedRequests: false",
- "logSentData: false",
- "logResponseStatusText: false");
- }
-
- Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
-
- // Load configuration
- enabled = configuration.getBoolean("enabled", true);
- serverUUID = configuration.getString("serverUuid");
- logFailedRequests = configuration.getBoolean("logFailedRequests", false);
- logSentData = configuration.getBoolean("logSentData", false);
- logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
- }
-
- /**
- * Gets the first bStat Metrics class.
- *
- * @return The first bStats metrics class.
- */
- private Class> getFirstBStatsClass() {
- Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
- configPath.toFile().mkdirs();
- File tempFile = new File(configPath.toFile(), "temp.txt");
-
- try {
- String className = readFile(tempFile);
- if (className != null) {
- try {
- // Let's check if a class with the given name exists.
- return Class.forName(className);
- } catch (ClassNotFoundException ignored) { }
- }
- writeFile(tempFile, getClass().getName());
- return getClass();
- } catch (IOException e) {
- if (logFailedRequests) {
- plugin.getLogger().log(Level.WARNING, "Failed to get first bStats class!", e);
- }
- return null;
- }
- }
-
- /**
- * Reads the first line of the file.
- *
- * @param file The file to read. Cannot be null.
- * @return The first line of the file or null
if the file does not exist or is empty.
- * @throws IOException If something did not work :(
- */
- private String readFile(File file) throws IOException {
- if (!file.exists()) {
- return null;
- }
- try (
- FileReader fileReader = new FileReader(file);
- BufferedReader bufferedReader = new BufferedReader(fileReader);
- ) {
- return bufferedReader.readLine();
- }
- }
-
- /**
- * Writes a String to a file. It also adds a note for the user,
- *
- * @param file The file to write to. Cannot be null.
- * @param lines The lines to write.
- * @throws IOException If something did not work :(
- */
- private void writeFile(File file, String... lines) throws IOException {
- if (!file.exists()) {
- file.createNewFile();
- }
- try (
- FileWriter fileWriter = new FileWriter(file);
- BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)
- ) {
- for (String line : lines) {
- bufferedWriter.write(line);
- bufferedWriter.newLine();
- }
- }
- }
-
- /**
- * Sends the data to the bStats server.
- *
- * @param plugin Any plugin. It's just used to get a logger instance.
- * @param data The data to send.
- * @throws Exception If the request failed.
- */
- private static void sendData(Plugin plugin, JsonObject data) throws Exception {
- if (data == null) {
- throw new IllegalArgumentException("Data cannot be null");
- }
- if (logSentData) {
- plugin.getLogger().info("Sending data to bStats: " + data.toString());
- }
-
- HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
-
- // Compress the data to save bandwidth
- byte[] compressedData = compress(data.toString());
-
- // Add headers
- connection.setRequestMethod("POST");
- connection.addRequestProperty("Accept", "application/json");
- connection.addRequestProperty("Connection", "close");
- connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
- connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
- connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
- connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
-
- // Send data
- connection.setDoOutput(true);
- DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
- outputStream.write(compressedData);
- outputStream.flush();
- outputStream.close();
-
- InputStream inputStream = connection.getInputStream();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
-
- StringBuilder builder = new StringBuilder();
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- builder.append(line);
- }
- bufferedReader.close();
- if (logResponseStatusText) {
- plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
- }
- }
-
- /**
- * Gzips the given String.
- *
- * @param str The string to gzip.
- * @return The gzipped String.
- * @throws IOException If the compression failed.
- */
- private static byte[] compress(final String str) throws IOException {
- if (str == null) {
- return null;
- }
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
- gzip.write(str.getBytes(StandardCharsets.UTF_8));
- gzip.close();
- return outputStream.toByteArray();
- }
-
-
- /**
- * Represents a custom chart.
- */
- public static abstract class CustomChart {
-
- // The id of the chart
- private final String chartId;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- CustomChart(String chartId) {
- if (chartId == null || chartId.isEmpty()) {
- throw new IllegalArgumentException("ChartId cannot be null or empty!");
- }
- this.chartId = chartId;
- }
-
- private JsonObject getRequestJsonObject(Logger logger, boolean logFailedRequests) {
- JsonObject chart = new JsonObject();
- chart.addProperty("chartId", chartId);
- try {
- JsonObject data = getChartData();
- if (data == null) {
- // If the data is null we don't send the chart.
- return null;
- }
- chart.add("data", data);
- } catch (Throwable t) {
- if (logFailedRequests) {
- logger.log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
- }
- return null;
- }
- return chart;
- }
-
- protected abstract JsonObject getChartData() throws Exception;
-
- }
-
- /**
- * Represents a custom simple pie.
- */
- public static class SimplePie extends CustomChart {
-
- private final Callable callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public SimplePie(String chartId, Callable callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- String value = callable.call();
- if (value == null || value.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- data.addProperty("value", value);
- return data;
- }
- }
-
- /**
- * Represents a custom advanced pie.
- */
- public static class AdvancedPie extends CustomChart {
-
- private final Callable> callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public AdvancedPie(String chartId, Callable> callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- JsonObject values = new JsonObject();
- Map map = callable.call();
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue() == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- values.addProperty(entry.getKey(), entry.getValue());
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.add("values", values);
- return data;
- }
- }
-
- /**
- * Represents a custom drilldown pie.
- */
- public static class DrilldownPie extends CustomChart {
-
- private final Callable>> callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public DrilldownPie(String chartId, Callable>> callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- public JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- JsonObject values = new JsonObject();
- Map> map = callable.call();
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean reallyAllSkipped = true;
- for (Map.Entry> entryValues : map.entrySet()) {
- JsonObject value = new JsonObject();
- boolean allSkipped = true;
- for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) {
- value.addProperty(valueEntry.getKey(), valueEntry.getValue());
- allSkipped = false;
- }
- if (!allSkipped) {
- reallyAllSkipped = false;
- values.add(entryValues.getKey(), value);
- }
- }
- if (reallyAllSkipped) {
- // Null = skip the chart
- return null;
- }
- data.add("values", values);
- return data;
- }
- }
-
- /**
- * Represents a custom single line chart.
- */
- public static class SingleLineChart extends CustomChart {
-
- private final Callable callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public SingleLineChart(String chartId, Callable callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- int value = callable.call();
- if (value == 0) {
- // Null = skip the chart
- return null;
- }
- data.addProperty("value", value);
- return data;
- }
-
- }
-
- /**
- * Represents a custom multi line chart.
- */
- public static class MultiLineChart extends CustomChart {
-
- private final Callable> callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public MultiLineChart(String chartId, Callable> callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- JsonObject values = new JsonObject();
- Map map = callable.call();
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue() == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- values.addProperty(entry.getKey(), entry.getValue());
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.add("values", values);
- return data;
- }
-
- }
-
- /**
- * Represents a custom simple bar chart.
- */
- public static class SimpleBarChart extends CustomChart {
-
- private final Callable> callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public SimpleBarChart(String chartId, Callable> callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- JsonObject values = new JsonObject();
- Map map = callable.call();
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- for (Map.Entry entry : map.entrySet()) {
- JsonArray categoryValues = new JsonArray();
- categoryValues.add(new JsonPrimitive(entry.getValue()));
- values.add(entry.getKey(), categoryValues);
- }
- data.add("values", values);
- return data;
- }
-
- }
-
- /**
- * Represents a custom advanced bar chart.
- */
- public static class AdvancedBarChart extends CustomChart {
-
- private final Callable> callable;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- * @param callable The callable which is used to request the chart data.
- */
- public AdvancedBarChart(String chartId, Callable> callable) {
- super(chartId);
- this.callable = callable;
- }
-
- @Override
- protected JsonObject getChartData() throws Exception {
- JsonObject data = new JsonObject();
- JsonObject values = new JsonObject();
- Map map = callable.call();
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue().length == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- JsonArray categoryValues = new JsonArray();
- for (int categoryValue : entry.getValue()) {
- categoryValues.add(new JsonPrimitive(categoryValue));
- }
- values.add(entry.getKey(), categoryValues);
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.add("values", values);
- return data;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/src/de/tutorialwork/utils/MySQLConnect.java b/src/de/tutorialwork/utils/MySQLConnect.java
deleted file mode 100644
index 93fa340..0000000
--- a/src/de/tutorialwork/utils/MySQLConnect.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package de.tutorialwork.utils;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import de.tutorialwork.main.Main;
-import net.md_5.bungee.BungeeCord;
-
-public class MySQLConnect {
-
- public static String HOST;
- public static String DATABASE;
- public static String USER;
- public static String PASSWORD;
-
- private Connection con;
-
- public MySQLConnect(String host, String database, String user, String password) {
- this.HOST = host;
- this.DATABASE = database;
- this.USER = user;
- this.PASSWORD = password;
-
- connect();
- }
-
- public void connect() {
- try {
- con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":3306/" + DATABASE + "?autoReconnect=true", USER, PASSWORD);
- BungeeCord.getInstance().getConsole().sendMessage(Main.Prefix+"§aDie Verbindung mit der MySQL Datenbank wurde erfolgreich hergestellt");
- } catch (SQLException e) {
- BungeeCord.getInstance().getConsole().sendMessage(Main.Prefix+"§cDie Verbindung mit der MySQL Datenbank ist fehlgeschlagen: §4" + e.getMessage());
- }
- }
-
- public void close() {
- try {
- if(con != null) {
- con.close();
- }
- } catch (SQLException e) {
- }
- }
-
- public void update(String qry) {
- try {
- Statement st = con.createStatement();
- st.executeUpdate(qry);
- st.close();
- } catch (SQLException e) {
- connect();
- System.err.println(e);
- }
- }
-
- public ResultSet query(String qry) {
- ResultSet rs = null;
-
- try {
- Statement st = con.createStatement();
- rs = st.executeQuery(qry);
- } catch (SQLException e) {
- connect();
- System.err.println(e);
- }
- return rs;
- }
-}
\ No newline at end of file
diff --git a/src/de/tutorialwork/utils/RandomString.java b/src/de/tutorialwork/utils/RandomString.java
deleted file mode 100644
index c045a80..0000000
--- a/src/de/tutorialwork/utils/RandomString.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package de.tutorialwork.utils;
-
-import java.security.SecureRandom;
-
-public class RandomString {
- private static final String ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
- private static final SecureRandom RANDOM = new SecureRandom();
-
- /**
- * Generates random string of given length from Base65 alphabet (numbers, lowercase letters, uppercase letters).
- *
- * @param count length
- * @return random string of given length
- */
- public static String generate(int count) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < count; ++i) {
- sb.append(ALPHABET.charAt(RANDOM.nextInt(ALPHABET.length())));
- }
- return sb.toString();
- }
-}
\ No newline at end of file
diff --git a/src/de/tutorialwork/utils/UUIDFetcher.java b/src/de/tutorialwork/utils/UUIDFetcher.java
deleted file mode 100644
index 5440784..0000000
--- a/src/de/tutorialwork/utils/UUIDFetcher.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package de.tutorialwork.utils;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.HashMap;
-
-public class UUIDFetcher
-{
- private static HashMap uuidCache = new HashMap();
-
- public static String getUUID(String username)
- {
- if (uuidCache.containsKey(username)) {
- return (String)uuidCache.get(username);
- }
- try
- {
- URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + username);
- InputStream stream = url.openStream();
- InputStreamReader inr = new InputStreamReader(stream);
- BufferedReader reader = new BufferedReader(inr);
- String s = null;
- StringBuilder sb = new StringBuilder();
- while ((s = reader.readLine()) != null) {
- sb.append(s);
- }
- String result = sb.toString();
- JsonElement element = new JsonParser().parse(result);
- JsonObject obj = element.getAsJsonObject();
- String api = obj.get("id").toString();
- api = api.substring(1);
- api = api.substring(0, api.length() - 1);
- StringBuffer sbu = new StringBuffer(api);
- sbu.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-");
- String uuid = sbu.toString();
- uuidCache.put(username, uuid);
- return uuid;
- }
- catch (IOException|IllegalStateException localIOException) {}
- return null;
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/Global.kt b/src/main/kotlin/de/tutorialwork/Global.kt
new file mode 100644
index 0000000..c7dfe54
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/Global.kt
@@ -0,0 +1,7 @@
+package de.tutorialwork
+
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+
+val console: CommandSender get() = ProxyServer.getInstance().console
+
diff --git a/src/main/kotlin/de/tutorialwork/commands/Ban.kt b/src/main/kotlin/de/tutorialwork/commands/Ban.kt
new file mode 100644
index 0000000..6d2424f
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Ban.kt
@@ -0,0 +1,179 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import java.io.File
+import java.io.IOException
+
+class Ban(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.ban")) {
+ if (args.size == 1) {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ val id = args[1].toIntOrNull() ?: return //add fail message
+ if (BanManager.playerExists(uuid)) {
+ if (BanManager.isWebaccountAdmin(uuid)) {
+ sender.sendMessage(Main.prefix + "§cDiesen Spieler kannst du nicht bannen/muten")
+ return
+ }
+ BanManager.setReasonBans(id, BanManager.getReasonBans(id) ?: 0 + 1)
+ if (BanManager.isBanReason(id)) {
+ if (BanManager.hasExtraPerms(id)) {
+ if (!sender.hasPermission(BanManager.getExtraPerms(id))) {
+ sender.sendMessage(Main.prefix + "§cDu hast keine Berechtigung diesen Bangrund zu nutzen")
+ return
+ }
+ }
+ BanManager.ban(uuid, id, sender.uniqueId.toString(), Main.increaseValue, Main.increaseBans)
+ LogManager.createEntry("", sender.uniqueId.toString(), "BAN", id.toString())
+ BanManager.setBans(uuid, BanManager.getBans(uuid) + 1)
+ BanManager.sendNotify("BAN", BanManager.getNameByUUID(uuid).toString(), sender.name, BanManager.getReasonByID(id))
+ val banned = Main.instance.proxy.getPlayer(args[0])
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (BanManager.getRAWEnd(banned.uniqueId) == -1L) {
+ banned.disconnect(ChatColor.translateAlternateColorCodes('&',
+ configcfg.getString("LAYOUT.BAN").replace("%grund%", BanManager.getReasonByID(id).toString())))
+ } else {
+ var msg = configcfg.getString("LAYOUT.TEMPBAN")
+ msg = msg.replace("%grund%", BanManager.getReasonString(uuid))
+ msg = msg.replace("%dauer%", BanManager.getEnd(uuid))
+ banned.disconnect(ChatColor.translateAlternateColorCodes('&', msg))
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ } else {
+ if (BanManager.hasExtraPerms(id)) {
+ if (!sender.hasPermission(BanManager.getExtraPerms(id))) {
+ sender.sendMessage(Main.prefix + "§cDu hast keine Berechtigung diesen Mutegrund zu nutzen")
+ return
+ }
+ }
+ BanManager.mute(uuid, id, sender.uniqueId.toString())
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "MUTE", id.toString())
+ BanManager.setMutes(uuid, BanManager.getMutes(uuid) ?: 0 + 1)
+ BanManager.sendNotify("MUTE", BanManager.getNameByUUID(uuid).toString(), sender.name, BanManager.getReasonByID(id).toString())
+ val banned = ProxyServer.getInstance().getPlayer(args[0])
+ if (banned != null) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (BanManager.getRAWEnd(banned.uniqueId) == -1L) {
+ banned.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ configcfg.getString("LAYOUT.MUTE").replace("%grund%", BanManager.getReasonByID(id).toString())))
+ } else {
+ var MSG = configcfg.getString("LAYOUT.TEMPMUTE")
+ MSG = MSG.replace("%grund%", BanManager.getReasonString(uuid))
+ MSG = MSG.replace("%dauer%", BanManager.getEnd(uuid))
+ banned.sendMessage(ChatColor.translateAlternateColorCodes('&', MSG))
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ } else {
+ BanManager.getBanReasonsList(sender)
+ sender.sendMessage(Main.prefix + "/ban ")
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ if (args.isEmpty() || args.size == 1) {
+ for (zaehler in 1 until (BanManager.countReasons() ?: 0) + 1) {
+ if (BanManager.isBanReason(zaehler)) {
+ console.sendMessage("§7" + zaehler + " §8| §e" + BanManager.getReasonByID(zaehler))
+ } else {
+ console.sendMessage("§7" + zaehler + " §8| §e" + BanManager.getReasonByID(zaehler) + " §8(§cMUTE§8)")
+ }
+ }
+ console.sendMessage(Main.prefix + "/ban ")
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ val id = Integer.valueOf(args[1])
+ if (BanManager.playerExists(uuid)) {
+ if (BanManager.isWebaccountAdmin(uuid)) {
+ console.sendMessage(Main.prefix + "§cDiesen Spieler kannst du nicht bannen/muten")
+ return
+ }
+ BanManager.setReasonBans(id, BanManager.getReasonBans(id) ?: 0 + 1)
+ if (BanManager.isBanReason(id)) {
+ BanManager.ban(uuid, id, "KONSOLE", Main.increaseValue, Main.increaseBans)
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "BAN", id.toString())
+ BanManager.setBans(uuid, BanManager.getBans(uuid) ?: 0 + 1)
+ BanManager.sendNotify("BAN", BanManager.getNameByUUID(uuid).toString(), "KONSOLE", BanManager.getReasonByID(id).toString())
+ val banned = ProxyServer.getInstance().getPlayer(args[0])
+ if (banned != null) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (BanManager.getRAWEnd(banned.uniqueId) == -1L) {
+ banned.disconnect(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.BAN")
+ .replace("%grund%", BanManager.getReasonByID(id).toString())))
+ } else {
+ var MSG = configcfg.getString("LAYOUT.TEMPBAN")
+ MSG = MSG.replace("%grund%", BanManager.getReasonString(uuid).toString())
+ MSG = MSG.replace("%dauer%", BanManager.getEnd(uuid))
+ banned.disconnect(ChatColor.translateAlternateColorCodes('&', MSG))
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+ } else {
+ BanManager.mute(uuid, id, "KONSOLE")
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "MUTE", id.toString())
+ BanManager.setMutes(uuid, BanManager.getMutes(uuid) ?: 0 + 1)
+ BanManager.sendNotify("MUTE", BanManager.getNameByUUID(uuid).toString(), "KONSOLE", BanManager.getReasonByID(id).toString())
+ val banned = ProxyServer.getInstance().getPlayer(args[0])
+ if (banned != null) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (BanManager.getRAWEnd(banned.uniqueId) == -1L) {
+ banned.sendMessage(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.MUTE")
+ .replace("%grund%", BanManager.getReasonByID(id).toString())))
+ } else {
+ var msg = configcfg.getString("LAYOUT.TEMPMUTE")
+ msg = msg.replace("%grund%", BanManager.getReasonString(uuid).toString())
+ msg = msg.replace("%dauer%", BanManager.getEnd(uuid))
+ banned.sendMessage(ChatColor.translateAlternateColorCodes('&', msg))
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+ }
+ } else {
+ console.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Blacklist.kt b/src/main/kotlin/de/tutorialwork/commands/Blacklist.kt
new file mode 100644
index 0000000..7a17515
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Blacklist.kt
@@ -0,0 +1,125 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.LogManager
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import java.io.File
+import java.io.IOException
+import java.util.*
+
+class Blacklist(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.blacklist") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty() || args.size == 1) {
+ sender.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ sender.sendMessage(Main.prefix + "/blacklist ")
+ } else if (args.size == 2) {
+ val blacklist = File(Main.instance.dataFolder, "blacklist.yml")
+ try {
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(blacklist)
+
+ val tempblacklist = ArrayList()
+
+ if (args[0].equals("add", ignoreCase = true)) {
+ val word = args[1]
+ for (congigstr in cfg.getStringList("BLACKLIST")) {
+ tempblacklist.add(congigstr)
+ }
+ tempblacklist.add(word)
+ Main.blacklist.add(word)
+ cfg.set("BLACKLIST", tempblacklist)
+ sender.sendMessage(Main.prefix + "§e§l" + word + " §7wurde zur Blacklist hinzugefügt")
+ LogManager.createEntry("", sender.uniqueId.toString(), "ADD_WORD_BLACKLIST", word)
+ } else if (args[0].equals("del", ignoreCase = true)) {
+ val Wort = args[1]
+ if (Main.blacklist.contains(Wort)) {
+ for (congigstr in cfg.getStringList("BLACKLIST")) {
+ tempblacklist.add(congigstr)
+ }
+ tempblacklist.remove(Wort)
+ Main.blacklist.remove(Wort)
+ cfg.set("BLACKLIST", tempblacklist)
+ sender.sendMessage(Main.prefix + "§e§l" + Wort + " §7wurde von der Blacklist entfernt")
+ LogManager.createEntry("", sender.uniqueId.toString(), "DEL_WORD_BLACKLIST", Wort)
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieses Wort steht nicht auf der Blacklist")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ sender.sendMessage(Main.prefix + "/blacklist ")
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(cfg, blacklist)
+ tempblacklist.clear()
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ } else {
+ sender.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ sender.sendMessage(Main.prefix + "/blacklist ")
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ //KONSOLE
+ if (args.isEmpty() || args.size == 1) {
+ console.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ console.sendMessage(Main.prefix + "/blacklist ")
+ } else if (args.size == 2) {
+ val blacklist = File(Main.instance.dataFolder, "blacklist.yml")
+ try {
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(blacklist)
+
+ val tempblacklist = ArrayList()
+
+ if (args[0].equals("add", ignoreCase = true)) {
+ val Wort = args[1]
+ for (congigstr in cfg.getStringList("BLACKLIST")) {
+ tempblacklist.add(congigstr)
+ }
+ tempblacklist.add(Wort)
+ Main.blacklist.add(Wort)
+ cfg.set("BLACKLIST", tempblacklist)
+ console.sendMessage(Main.prefix + "§e§l" + Wort + " §7wurde zur Blacklist hinzugefügt")
+ LogManager.createEntry("", "KONSOLE", "ADD_WORD_BLACKLIST", Wort)
+ } else if (args[0].equals("del", ignoreCase = true)) {
+ val Wort = args[1]
+ if (Main.blacklist.contains(Wort)) {
+ for (congigstr in cfg.getStringList("BLACKLIST")) {
+ tempblacklist.add(congigstr)
+ }
+ tempblacklist.remove(Wort)
+ Main.blacklist.remove(Wort)
+ cfg.set("BLACKLIST", tempblacklist)
+ console.sendMessage(Main.prefix + "§e§l" + Wort + " §7wurde von der Blacklist entfernt")
+ LogManager.createEntry("", "KONSOLE", "DEL_WORD_BLACKLIST", Wort)
+ } else {
+ console.sendMessage(Main.prefix + "§cDieses Wort steht nicht auf der Blacklist")
+ }
+ } else {
+ console.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ console.sendMessage(Main.prefix + "/blacklist ")
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(cfg, blacklist)
+ tempblacklist.clear()
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ } else {
+ console.sendMessage(Main.prefix + "Derzeit sind §e§l" + Main.blacklist.size + " Wörter §7auf der Blacklist")
+ console.sendMessage(Main.prefix + "/blacklist ")
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Chatlog.kt b/src/main/kotlin/de/tutorialwork/commands/Chatlog.kt
new file mode 100644
index 0000000..590ee8c
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Chatlog.kt
@@ -0,0 +1,43 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.listener.Chat
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.exists
+import de.tutorialwork.utils.getUUID
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import java.io.File
+
+class Chatlog(name: String) : Command(name) {
+
+ private val chatLogUrl by lazy {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ cfg.getString("CHATLOG.URL")
+ }
+
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender !is ProxiedPlayer) return
+ if (args.size != 1) {
+
+ val target = args[0].getUUID(sender) ?: return
+ target.exists(sender) ?: return
+
+ if (sender.uniqueId != target) {
+ if (Chat.hasMessages(target)) {
+ val id = Chat.createChatlog(target, sender.uniqueId.toString()) ?: return
+ sender.sendMessage(Main.prefix + "Der Chatlog von §e§l" + BanManager.getNameByUUID(target) + " §7wurde erfolgreich erstellt")
+ sender.sendMessage(Main.prefix + "Link: §e§l$chatLogUrl$id")
+ LogManager.createEntry(target.toString(), sender.uniqueId.toString(), "CREATE_CHATLOG", id)
+ } else sender.sendMessage(Main.prefix + "§cDieser Spieler hat in der letzten Zeit keine Nachrichten verfasst")
+ } else sender.sendMessage(Main.prefix + "§cDu kannst kein Chatlog von dir selbst erstellen")
+ } else sender.sendMessage(Main.prefix + "/chatlog ")
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Check.kt b/src/main/kotlin/de/tutorialwork/commands/Check.kt
new file mode 100644
index 0000000..3e978f7
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Check.kt
@@ -0,0 +1,135 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.IPManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+
+class Check(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.check") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty()) {
+ sender.sendMessage(Main.prefix + "/check ")
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ if (IPBan.validate(args[0])) {
+ val ip = args[0]
+ if (IPManager.ipExists(ip)) {
+ sender.sendMessage("§8[]===================================[]")
+ if (IPManager.getPlayerFromIP(ip) != null) {
+ sender.sendMessage("§7Spieler: §e§l" + BanManager.getNameByUUID(IPManager.getPlayerFromIP(ip)
+ ?: return))
+ } else {
+ sender.sendMessage("§7Spieler: §c§lKeiner")
+ }
+ if (IPManager.isBanned(ip)) {
+ sender.sendMessage("§7IP-Ban: §c§lJa §8/ " + IPManager.getReasonString(IPManager.getIPFromPlayer(uuid)))
+ } else {
+ sender.sendMessage("§7IP-Ban: §a§lNein")
+ }
+ sender.sendMessage("§7Bans: §e§l" + IPManager.getBans(ip))
+ sender.sendMessage("§7Zuletzt genutzt: §e§l" + BanManager.formatTimestamp(IPManager.getLastUseLong(ip)))
+ sender.sendMessage("§8[]===================================[]")
+ } else {
+ sender.sendMessage(Main.prefix + "§cZu dieser IP-Adresse sind keine Informationen verfügbar")
+ }
+ } else {
+ if (BanManager.playerExists(uuid)) {
+ sender.sendMessage("§8[]===================================[]")
+ sender.sendMessage("§7Spieler: §e§l" + BanManager.getNameByUUID(uuid))
+ if (BanManager.isBanned(uuid)) {
+ sender.sendMessage("§7Gebannt: §c§lJa §8/ " + BanManager.getReasonString(uuid))
+ } else {
+ sender.sendMessage("§7Gebannt: §a§lNein")
+ }
+ if (BanManager.isMuted(uuid)) {
+ sender.sendMessage("§7Gemutet: §c§lJa §8/ " + BanManager.getReasonString(uuid))
+ } else {
+ sender.sendMessage("§7Gemutet: §a§lNein")
+ }
+ if (IPManager.isBanned(IPManager.getIPFromPlayer(uuid).toString())) {
+ sender.sendMessage("§7IP-Ban: §c§lJa §8/ " + IPManager.getReasonString(IPManager.getIPFromPlayer(uuid).toString()))
+ } else {
+ sender.sendMessage("§7IP-Ban: §a§lNein")
+ }
+ sender.sendMessage("§7Bans: §e§l" + BanManager.getBans(uuid))
+ sender.sendMessage("§7Mutes: §e§l" + BanManager.getMutes(uuid))
+ sender.sendMessage("§7Letzter Login: §e§l" + BanManager.formatTimestamp(java.lang.Long.valueOf(BanManager.getLastLogin(uuid))))
+ sender.sendMessage("§7Erster Login: §e§l" + BanManager.formatTimestamp(java.lang.Long.valueOf(BanManager.getFirstLogin(uuid))))
+ sender.sendMessage("§8[]===================================[]")
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ if (args.isEmpty()) {
+ console.sendMessage(Main.prefix + "/check ")
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ if (IPBan.validate(args[0])) {
+ val ip = args[0]
+ if (IPManager.ipExists(ip)) {
+ console.sendMessage("§8[]===================================[]")
+ if (IPManager.getPlayerFromIP(ip) != null) {
+ console.sendMessage("§7Spieler: §e§l" + BanManager.getNameByUUID(IPManager.getPlayerFromIP(ip)
+ ?: return))
+ } else {
+ console.sendMessage("§7Spieler: §c§lKeiner")
+ }
+ if (IPManager.isBanned(ip)) {
+ console.sendMessage("§7IP-Ban: §c§lJa §8/ " + IPManager.getReasonString(IPManager.getIPFromPlayer(uuid).toString()))
+ } else {
+ console.sendMessage("§7IP-Ban: §a§lNein")
+ }
+ console.sendMessage("§7Bans: §e§l" + IPManager.getBans(ip))
+ console.sendMessage("§7Zuletzt genutzt: §e§l" + BanManager.formatTimestamp(IPManager.getLastUseLong(ip)))
+ console.sendMessage("§8[]===================================[]")
+ } else {
+ console.sendMessage(Main.prefix + "§cZu dieser IP-Adresse sind keine Informationen verfügbar")
+ }
+ } else {
+ if (BanManager.playerExists(uuid)) {
+ console.sendMessage("§8[]===================================[]")
+ console.sendMessage("§7Spieler: §e§l" + BanManager.getNameByUUID(uuid))
+ if (BanManager.isBanned(uuid)) {
+ console.sendMessage("§7Gebannt: §c§lJa §8/ " + BanManager.getReasonString(uuid))
+ } else {
+ console.sendMessage("§7Gebannt: §a§lNein")
+ }
+ if (BanManager.isMuted(uuid)) {
+ console.sendMessage("§7Gemutet: §c§lJa §8/ " + BanManager.getReasonString(uuid))
+ } else {
+ console.sendMessage("§7Gemutet: §a§lNein")
+ }
+ if (IPManager.isBanned(IPManager.getIPFromPlayer(uuid).toString())) {
+ console.sendMessage("§7IP-Ban: §c§lJa §8/ " + IPManager.getReasonString(IPManager.getIPFromPlayer(uuid).toString()))
+ } else {
+ console.sendMessage("§7IP-Ban: §a§lNein")
+ }
+ console.sendMessage("§7Bans: §e§l" + BanManager.getBans(uuid))
+ console.sendMessage("§7Mutes: §e§l" + BanManager.getMutes(uuid))
+ if (BanManager.getLastLogin(uuid) != null) {
+ console.sendMessage("§7Letzter Login: §e§l" + BanManager.formatTimestamp(java.lang.Long.valueOf(BanManager.getLastLogin(uuid))))
+ }
+ if (BanManager.getFirstLogin(uuid) != null) {
+ console.sendMessage("§7Erster Login: §e§l" + BanManager.formatTimestamp(java.lang.Long.valueOf(BanManager.getFirstLogin(uuid))))
+ }
+ console.sendMessage("§8[]===================================[]")
+ } else {
+ console.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/IPBan.kt b/src/main/kotlin/de/tutorialwork/commands/IPBan.kt
new file mode 100644
index 0000000..6254a76
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/IPBan.kt
@@ -0,0 +1,101 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.IPManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+
+import java.io.File
+import java.io.IOException
+import java.util.regex.Pattern
+
+class IPBan(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.ipban") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty() || args.size == 1) {
+ for (zaehler in 1 until BanManager.countReasons()!! + 1) {
+ if (BanManager.isBanReason(zaehler)) {
+ sender.sendMessage("§7" + zaehler + " §8| §e" + BanManager.getReasonByID(zaehler))
+ }
+ }
+ sender.sendMessage(Main.prefix + "/ipban ")
+ } else {
+ val ip = args[0]
+ val id = Integer.valueOf(args[1])
+ if (validate(ip)) {
+ if (IPManager.ipExists(ip)) {
+ IPManager.ban(ip, id, sender.uniqueId.toString())
+ IPManager.addBan(ip)
+ BanManager.sendNotify("IPBAN", ip, sender.name, BanManager.getReasonByID(id).toString())
+ } else {
+ IPManager.insertIP(ip, sender.uniqueId)
+ IPManager.ban(ip, id, sender.uniqueId.toString())
+ IPManager.addBan(ip)
+ BanManager.sendNotify("IPBAN", ip, sender.name, BanManager.getReasonByID(id).toString())
+ }
+ disconnectIPBannedPlayers(ip)
+ LogManager.createEntry("", sender.uniqueId.toString(), "IPBAN_IP", ip)
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ val dbip = IPManager.getIPFromPlayer(uuid)
+ IPManager.ban(dbip, id, sender.uniqueId.toString())
+ IPManager.addBan(dbip)
+ BanManager.sendNotify("IPBAN", dbip, sender.name, BanManager.getReasonByID(id).toString())
+ disconnectIPBannedPlayers(dbip)
+ LogManager.createEntry("", sender.uniqueId.toString(), "IPBAN_PLAYER", id.toString())
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ }
+ }
+
+ companion object {
+
+ fun disconnectIPBannedPlayers(IP: String) {
+ for (all in Main.instance.proxy.players) {
+ if (all.address.hostString == IP) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+
+ if (IPManager.getRAWEnd(IP) == -1L) {
+ all.disconnect(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.IPBAN").replace("%grund%", IPManager.getReasonString(IP)!!)))
+ } else {
+ if (System.currentTimeMillis() < IPManager.getRAWEnd(IP) ?: 0) {
+ var MSG = configcfg.getString("LAYOUT.TEMPIPBAN")
+ MSG = MSG.replace("%grund%", IPManager.getReasonString(IP)!!)
+ MSG = MSG.replace("%dauer%", IPManager.getEnd(IP))
+ all.disconnect(ChatColor.translateAlternateColorCodes('&', MSG))
+ } else {
+ IPManager.unban(IP)
+ }
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e2: IOException) {
+ e2.printStackTrace()
+ }
+
+ }
+ }
+ }
+
+ private val PATTERN = Pattern.compile(
+ "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$")
+
+ fun validate(ip: String): Boolean {
+ return PATTERN.matcher(ip).matches()
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Kick.kt b/src/main/kotlin/de/tutorialwork/commands/Kick.kt
new file mode 100644
index 0000000..f7ebba0
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Kick.kt
@@ -0,0 +1,79 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+
+import java.io.File
+import java.io.IOException
+
+class Kick(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.kick") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty() || args.size == 1) {
+ sender.sendMessage(Main.prefix + "/kick ")
+ } else {
+ val tokick = ProxyServer.getInstance().getPlayer(args[0])
+ if (tokick != null) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ var grund = ""
+ for (i in 1 until args.size) {
+ grund = grund + " " + args[i]
+ }
+ BanManager.sendNotify("KICK", tokick.name, sender.name, grund)
+ LogManager.createEntry(tokick.uniqueId.toString(), sender.uniqueId.toString(), "KICK", grund)
+ tokick.disconnect(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.KICK")
+ .replace("%grund%", grund)))
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler ist nicht online")
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ if (args.isEmpty() || args.size == 1) {
+ console.sendMessage(Main.prefix + "/kick ")
+ } else {
+ val tokick = ProxyServer.getInstance().getPlayer(args[0])
+ if (tokick != null) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ var grund = ""
+ for (i in 1 until args.size) {
+ grund = grund + " " + args[i]
+ }
+ BanManager.sendNotify("KICK", tokick.name, "KONSOLE", grund)
+ LogManager.createEntry(tokick.uniqueId.toString(), "KONSOLE", "KICK", grund)
+ tokick.disconnect(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.KICK")
+ .replace("%grund%", grund)))
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ } else {
+ console.sendMessage(Main.prefix + "§cDieser Spieler ist nicht online")
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Report.kt b/src/main/kotlin/de/tutorialwork/commands/Report.kt
new file mode 100644
index 0000000..9982c61
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Report.kt
@@ -0,0 +1,76 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+
+import java.io.File
+import java.io.IOException
+
+class Report(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (args.isEmpty() || args.size == 1) {
+ var reasons = ""
+ var komma = Main.reportreasons.size
+ for (reason in Main.reportreasons) {
+ komma--
+ reasons = if (komma != 0) {
+ "$reasons$reason, "
+ } else {
+ reasons + reason
+ }
+ }
+ sender.sendMessage(Main.prefix + "Verfügbare Reportgründe: §e§l" + reasons)
+ sender.sendMessage(Main.prefix + "/report ")
+ } else {
+ if (args[0].toUpperCase() == sender.name.toUpperCase()) {
+ sender.sendMessage(Main.prefix + "§cDu kannst dich nicht selbst melden")
+ return
+ }
+ if (Main.reportreasons.contains(args[1].toUpperCase())) {
+ val target = ProxyServer.getInstance().getPlayer(args[0])
+ if (target != null) {
+ BanManager.createReport(target.uniqueId, sender.uniqueId.toString(), args[1].toUpperCase(), null)
+ sender.sendMessage(Main.prefix + "Der Spieler §e§l" + target.name + " §7wurde erfolgreich wegen §e§l" + args[1].toUpperCase() + " §7gemeldet")
+ BanManager.sendNotify("REPORT", target.name, sender.name, args[1].toUpperCase())
+ LogManager.createEntry(target.uniqueId.toString(), sender.uniqueId.toString(), "REPORT", args[1].toUpperCase())
+ } else {
+ try {
+ val file = File(Main.instance.dataFolder, "config.yml")
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(file)
+ if (cfg.getBoolean("REPORTS.OFFLINEREPORTS")) {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ if (BanManager.playerExists(uuid)) {
+ BanManager.createReport(uuid, sender.uniqueId.toString(), args[1].toUpperCase(), null)
+ sender.sendMessage(Main.prefix + "Der Spieler §e§l" + args[0] + " §7(§4Offline§7) wurde erfolgreich wegen §e§l" + args[1].toUpperCase() + " §7gemeldet")
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "REPORT_OFFLINE", args[1].toUpperCase())
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler wurde nicht gefunden")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler ist offline")
+ }
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDer eingegebene Reportgrund wurde nicht gefunden")
+ }
+ }
+ } else {
+ console.sendMessage(Main.prefix + "§e§lReports §7sind nur als Spieler verfügbar")
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Reports.kt b/src/main/kotlin/de/tutorialwork/commands/Reports.kt
new file mode 100644
index 0000000..94f4efe
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Reports.kt
@@ -0,0 +1,67 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.chat.ClickEvent
+import net.md_5.bungee.api.chat.ComponentBuilder
+import net.md_5.bungee.api.chat.HoverEvent
+import net.md_5.bungee.api.chat.TextComponent
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+
+class Reports(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.reports") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty()) {
+ if (BanManager.countOpenReports() != 0) {
+ sender.sendMessage("§8[]===================================[]")
+ sender.sendMessage("§e§loffene Reports §7(§8" + BanManager.countOpenReports() + "§7)")
+ var offline = 0
+ for (element in BanManager.iDsFromOpenReports) {
+ val target = ProxyServer.getInstance().getPlayer(BanManager.getNameByReportID(element))
+ if (target != null) {
+ val tc = TextComponent()
+ tc.text = "§e§l" + target.name + " §7gemeldet wegen §c§l " +
+ BanManager.getReasonByReportID(element) + " §8| §7Online auf §e§l" + target.server.info.name
+ tc.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reports jump " + target.name + " " + element)
+ tc.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT,
+ ComponentBuilder("§7Klicken um §e§l" + target.name + " §7nachzuspringen").create())
+ sender.sendMessage(tc)
+ } else {
+ offline++
+ }
+ }
+ if (offline != 0) {
+ sender.sendMessage("§4§o$offline Reports §7§ovon Spieler die offline sind ausgeblendet")
+ }
+ sender.sendMessage("§8[]===================================[]")
+ } else {
+ sender.sendMessage(Main.prefix + "§cEs sind derzeit keine Reports offen")
+ }
+ } else if (args[0].equals("jump", ignoreCase = true)) {
+ val target = ProxyServer.getInstance().getPlayer(args[1])
+ if (target != null) {
+ sender.connect(target.server.info)
+ val id = Integer.parseInt(args[2])
+ BanManager.setReportDone(id)
+ BanManager.setReportTeamUUID(id, sender.uniqueId.toString())
+ sender.sendMessage(Main.prefix + "Du hast den Report von §e§l" + BanManager.getNameByReportID(id) + " §7wegen §c§l" + BanManager.getReasonByReportID(id) + " §aangenommen")
+ LogManager.createEntry(sender.uniqueId.toString(), null, "REPORT_ACCEPT", id.toString())
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler ist nicht mehr online")
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ console.sendMessage(Main.prefix + "§e§lReports §7sind nur als Spieler verfügbar")
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/SupportChat.kt b/src/main/kotlin/de/tutorialwork/commands/SupportChat.kt
new file mode 100644
index 0000000..8580e13
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/SupportChat.kt
@@ -0,0 +1,135 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.chat.ClickEvent
+import net.md_5.bungee.api.chat.ComponentBuilder
+import net.md_5.bungee.api.chat.HoverEvent
+import net.md_5.bungee.api.chat.TextComponent
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import java.util.*
+
+class SupportChat(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (args.isNotEmpty()) {
+ if (args[0].equals("end", ignoreCase = true)) {
+ if (activechats.containsValue(sender) || activechats.containsKey(sender)) {
+ for (key in activechats.keys) {
+ //Key has started the support chat
+ if (key === sender) {
+ activechats[sender]?.sendMessage(Main.prefix + "§e§l" + sender.name + " §7hat den Support Chat §cbeeendet")
+ activechats.remove(key)
+ } else {
+ key.sendMessage(Main.prefix + "§e§l" + sender.name + " §7hat den Support Chat §cbeeendet")
+ activechats.remove(key)
+ }
+ }
+ sender.sendMessage(Main.prefix + "§cDu hast den Support Chat beendet")
+ return
+ } else {
+ sender.sendMessage(Main.prefix + "§cDu hast derzeit keinen offenen Support Chat")
+ return
+ }
+ }
+ }
+ if (sender.hasPermission("professionalbans.supportchat") || sender.hasPermission("professionalbans.*")) {
+ //Team Member
+ if (args.isNotEmpty()) {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.getName() == args[0]) {
+ if (openchats.containsKey(all)) {
+ activechats[all] = sender
+ openchats.remove(all)
+ all.sendMessage(Main.prefix + "§e§l" + sender.name + " §7ist jetzt mit dir im Support Chat")
+ all.sendMessage(Main.prefix + "§8§oDu kannst in den Support Chat schreiben in dem du einfach eine normale Nachricht schreibst")
+ all.sendMessage(Main.prefix + "§8§oDu kannst den Support Chat mit §7§o/support end §8§obeenden")
+ sender.sendMessage(Main.prefix + "§e§l" + all.getName() + " §7ist jetzt im Support Chat mit dir")
+ sender.sendMessage(Main.prefix + "§8§oDu kannst den Support Chat mit §7§o/support end §8§obeenden")
+ } else {
+ sender.sendMessage(Main.prefix + "§cDiese Anfrage ist ausgelaufen")
+ }
+ }
+ }
+ } else {
+ if (openchats.size != 0) {
+ sender.sendMessage("§8[]===================================[]")
+ var i = 0
+ for (key in SupportChat.openchats.keys) {
+ sender.sendMessage("§e§l" + key + " §8• §9" + SupportChat.openchats[key])
+ val tc = TextComponent()
+ tc.text = "§aSupport Chat starten"
+ tc.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/support $key")
+ tc.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentBuilder("§7Klicken um den Chat mit §e§l$key §7zu starten").create())
+ sender.sendMessage(tc)
+ i++
+ }
+ sender.sendMessage("§8[]===================================[]")
+ sender.sendMessage(Main.prefix + "Es sind derzeit §e§l" + i + " Support Chats §7Anfragen §aoffen")
+ } else {
+ sender.sendMessage(Main.prefix + "§cDerzeit sind keine Support Chats Anfragen offen")
+ }
+ }
+ } else {
+ //Normal Member
+ if (args.isEmpty()) {
+ sender.sendMessage(Main.prefix + "Wenn du den §e§lSupport Chat §7starten möchtest gebe ein §8§oBetreff §7ein")
+ sender.sendMessage(Main.prefix + "Möchtest du eine Anfrage abbrechen? §8§o/support cancel")
+ } else {
+ var supporter = 0
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.supportchat") || all.hasPermission("professionalbans.*")) {
+ supporter++
+ }
+ }
+ if (!args[0].equals("cancel", ignoreCase = true)) {
+ var subject = ""
+ for (i in args.indices) {
+ subject = subject + " " + args[i]
+ }
+ if (!openchats.containsKey(sender)) {
+ if (supporter > 0) {
+ openchats[sender] = subject
+ sender.sendMessage(Main.prefix + "Du hast eine Anfrage mit dem Betreff §e§l" + subject + " §7gestartet")
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.supportchat") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§e§l" + sender.name + " §7benötigt Support §8(§e§o" + subject + "§8)")
+ val tc = TextComponent()
+ tc.text = "§aSupport Chat starten"
+ tc.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/support " + sender.name)
+ tc.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, ComponentBuilder("§7Klicken um den Chat mit §e§l" + sender.name + " §7zu starten").create())
+ all.sendMessage(tc)
+ }
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDerzeit ist kein Supporter online")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "Du hast bereits eine §e§lSupport Chat §7Anfrage gestellt")
+ sender.sendMessage(Main.prefix + "Möchtest du diese Anfrage §cabbrechen §7benutze §c§l/support cancel")
+ }
+ } else {
+ if (!openchats.containsKey(sender)) {
+ openchats.remove(sender)
+ sender.sendMessage(Main.prefix + "Deine Anfrage wurde erfolgreich §cgelöscht")
+ } else {
+ sender.sendMessage(Main.prefix + "§cDu hast derzeit keine offene Anfrage")
+ }
+ }
+ }
+ }
+ } else {
+ console.sendMessage(Main.prefix + "Der §e§lSupport Chat §7ist nur als Spieler verfügbar")
+ }
+ }
+
+ companion object {
+
+ var openchats = HashMap()
+ var activechats = HashMap()
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/Unban.kt b/src/main/kotlin/de/tutorialwork/commands/Unban.kt
new file mode 100644
index 0000000..34a3894
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/Unban.kt
@@ -0,0 +1,94 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.IPManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+
+class Unban(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.unban") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty()) {
+ sender.sendMessage(Main.prefix + "/unban ")
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ if (IPBan.validate(args[0])) {
+ IPManager.unban(args[0])
+ BanManager.sendNotify("UNBANIP", args[0], sender.name, null)
+ sender.sendMessage(Main.prefix + "§7Die IP-Adresse §e§l" + args[0] + " §7wurde §aerfolgreich §7entbannt")
+ LogManager.createEntry("", sender.uniqueId.toString(), "UNBAN_IP", args[0])
+ } else {
+ if (BanManager.playerExists(uuid)) {
+ if (IPManager.isBanned(IPManager.getIPFromPlayer(uuid).toString())) {
+ IPManager.unban(IPManager.getIPFromPlayer(uuid).toString())
+ sender.sendMessage(Main.prefix + "Die IP §e§l" + IPManager.getIPFromPlayer(uuid) + " §7war gebannt und wurde ebenfalls §aentbannt")
+ }
+ when {
+ BanManager.isBanned(uuid) -> {
+ BanManager.unban(uuid)
+ BanManager.sendNotify("UNBAN", BanManager.getNameByUUID(uuid).toString(), sender.name, "null")
+ sender.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerfolgreich §7entbannt")
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "UNBAN_BAN", null)
+ }
+ BanManager.isMuted(uuid) -> {
+ BanManager.unmute(uuid)
+ BanManager.sendNotify("UNMUTE", BanManager.getNameByUUID(uuid).toString(), sender.name, "null")
+ sender.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerfolgreich §7entmutet")
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "UNBAN_MUTE", null)
+ }
+ else -> sender.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7ist weder gebannt oder gemutet")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ } else {
+ if (args.isEmpty()) {
+ console.sendMessage(Main.prefix + "/unban ")
+ } else {
+ val uuid = UUIDFetcher.getUUID(args[0]) ?: return
+ if (IPBan.validate(args[0])) {
+ IPManager.unban(args[0])
+ BanManager.sendNotify("UNBANIP", args[0], "KONSOLE", null)
+ console.sendMessage(Main.prefix + "§7Die IP-Adresse §e§l" + args[0] + " §7wurde §aerfolgreich §7entbannt")
+ LogManager.createEntry("", "KONSOLE", "UNBAN_IP", args[0])
+ } else {
+ if (BanManager.playerExists(uuid)) {
+ if (IPManager.isBanned(IPManager.getIPFromPlayer(uuid).toString())) {
+ IPManager.unban(IPManager.getIPFromPlayer(uuid).toString())
+ console.sendMessage(Main.prefix + "Die IP §e§l" + IPManager.getIPFromPlayer(uuid) + " §7war gebannt und wurde ebenfalls §aentbannt")
+ }
+ when {
+ BanManager.isBanned(uuid) -> {
+ BanManager.unban(uuid)
+ BanManager.sendNotify("UNBAN", BanManager.getNameByUUID(uuid).toString(), "KONSOLE", "null")
+ console.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerfolgreich §7entbannt")
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "UNBAN_BAN", null)
+ }
+ BanManager.isMuted(uuid) -> {
+ BanManager.unmute(uuid)
+ BanManager.sendNotify("UNMUTE", BanManager.getNameByUUID(uuid).toString(), "KONSOLE", "null")
+ console.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerfolgreich §7entmutet")
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "UNBAN_MUTE", null)
+ }
+ else -> console.sendMessage(Main.prefix + "§e§l" + BanManager.getNameByUUID(uuid) + " §7ist weder gebannt oder gemutet")
+ }
+ } else {
+ console.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt b/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt
new file mode 100644
index 0000000..6a0565b
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt
@@ -0,0 +1,94 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BCrypt
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+import java.util.*
+
+class WebAccount(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (sender.hasPermission("professionalbans.webaccount") || sender.hasPermission("professionalbans.*")) {
+ if (args.isEmpty() || args.size == 1) {
+ sender.sendMessage(Main.prefix + "/webaccount [Rang]")
+ } else {
+ if (args[0].equals("erstellen", ignoreCase = true)) {
+ if (args.size == 2) {
+ sender.sendMessage(Main.prefix + "Du musst noch ein Rang des Accounts angeben §4Admin§7, §cMod§7, §9Sup")
+ return
+ }
+ val uuid = UUIDFetcher.getUUID(args[1]) ?: return
+ if (BanManager.playerExists(uuid)) {
+ if (!BanManager.webaccountExists(uuid)) {
+ val target = ProxyServer.getInstance().getPlayer(args[1])
+ if (target != null) {
+ val rowPW = randomString(7)
+ val hash = BCrypt.hashpw(rowPW, BCrypt.gensalt())
+ when {
+ args[2].equals("Admin", ignoreCase = true) -> {
+ BanManager.createWebAccount(uuid, BanManager.getNameByUUID(uuid).toString(), 3, hash)
+ sender.sendMessage(Main.prefix + "Ein §4§lAdmin §7Account für §e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerstellt")
+ }
+ args[2].equals("Mod", ignoreCase = true) -> {
+ BanManager.createWebAccount(uuid, BanManager.getNameByUUID(uuid).toString(), 2, hash)
+ sender.sendMessage(Main.prefix + "Ein §c§lMod §7Account für §e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerstellt")
+ }
+ args[2].equals("Sup", ignoreCase = true) -> {
+ BanManager.createWebAccount(uuid, BanManager.getNameByUUID(uuid).toString(), 1, hash)
+ sender.sendMessage(Main.prefix + "Ein §9§lSup §7Account für §e§l" + BanManager.getNameByUUID(uuid) + " §7wurde §aerstellt")
+ }
+ }
+ target.sendMessage(Main.prefix + "§e§l" + sender.name + " §7hat einen Webaccount für dich erstellt")
+ target.sendMessage(Main.prefix + "Passwort: §c§l" + rowPW)
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "ADD_WEBACCOUNT", args[2])
+ } else {
+ sender.sendMessage(Main.prefix + "§e§l" + args[1] + " §7ist derzeit nicht online")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat bereits einen Zugang zum Webinterface")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ } else if (args[0].equals("löschen", ignoreCase = true)) {
+ val uuid = UUIDFetcher.getUUID(args[1]) ?: return
+ if (BanManager.playerExists(uuid)) {
+ if (BanManager.webaccountExists(uuid)) {
+ BanManager.deleteWebAccount(uuid)
+ sender.sendMessage(Main.prefix + "Der Zugang von dem Spieler §e§l" + BanManager.getNameByUUID(uuid) + " §7wurde erfolgreich §agelöscht")
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), "DEL_WEBACCOUNT", null)
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat keinen Zugang zum Webinterface")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler hat den Server noch nie betreten")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDiese Aktion ist nicht gültig")
+ }
+ }
+ } else {
+ sender.sendMessage(Main.noPerms)
+ }
+ }
+ }
+
+ companion object {
+ private val AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"
+ private var rnd = Random()
+
+ private fun randomString(length: Int): String {
+ val sb = StringBuilder(length)
+ for (i in 0 until length)
+ sb.append(AB[rnd.nextInt(AB.length)])
+ return sb.toString()
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/commands/WebVerify.kt b/src/main/kotlin/de/tutorialwork/commands/WebVerify.kt
new file mode 100644
index 0000000..d356e34
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/commands/WebVerify.kt
@@ -0,0 +1,41 @@
+package de.tutorialwork.commands
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.plugin.Command
+
+class WebVerify(name: String) : Command(name) {
+
+ override fun execute(sender: CommandSender, args: Array) {
+ if (sender is ProxiedPlayer) {
+ if (args.isEmpty()) {
+ sender.sendMessage(Main.prefix + "/webverify ")
+ } else {
+ val uuid = sender.uniqueId
+ if (BanManager.webaccountExists(uuid)) {
+ if (BanManager.hasAuthToken(uuid)) {
+ if (args[0].length == 25) {
+ if (BanManager.getAuthCode(uuid) == args[0]) {
+ BanManager.updateAuthStatus(uuid)
+ sender.sendMessage(Main.prefix + "§a§lErfolgreich! §7Du kannst jetzt dein Passwort festlegen.")
+ } else {
+ sender.sendMessage(Main.prefix + "§cDer eingegebene Token ist ungültig")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDer eingegebene Token ist ungültig")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cEs wurde keine Verifizierungsanfrage von dir gefunden")
+ }
+ } else {
+ sender.sendMessage(Main.prefix + "§cDu hast keinen Account im Webinterface")
+ }
+ }
+ } else {
+ console.sendMessage(Main.prefix + "§cDieser Befehl ist nur als Spieler nutzbar")
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/listener/Chat.kt b/src/main/kotlin/de/tutorialwork/listener/Chat.kt
new file mode 100644
index 0000000..9490860
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/listener/Chat.kt
@@ -0,0 +1,206 @@
+package de.tutorialwork.listener
+
+import de.tutorialwork.commands.SupportChat
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.LogManager
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import net.md_5.bungee.api.event.ChatEvent
+import net.md_5.bungee.api.plugin.Listener
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import net.md_5.bungee.event.EventHandler
+import java.io.File
+import java.io.IOException
+import java.security.SecureRandom
+import java.sql.SQLException
+import java.util.*
+
+class Chat : Listener {
+
+ @EventHandler
+ fun onChat(e: ChatEvent) {
+ val p = e.sender as ProxiedPlayer
+ if (!e.message.startsWith("/")) {
+ if (SupportChat.activechats.containsKey(p)) {
+ e.isCancelled = true
+ val target = SupportChat.activechats[p] ?: return
+ target.sendMessage("§9§lSUPPORT §8• §c" + p.name + " §8» " + e.message)
+ p.sendMessage("§9§lSUPPORT §8• §aDu §8» " + e.message)
+ }
+ if (SupportChat.activechats.containsValue(p)) {
+ e.isCancelled = true
+ for (key in SupportChat.activechats.keys) {
+ //Key has started the support chat
+ key.sendMessage("§9§lSUPPORT §8• §c" + p.name + " §8» " + e.message)
+ }
+ p.sendMessage("§9§lSUPPORT §8• §aDu §8» " + e.message)
+ }
+ val uuid = p.uniqueId
+ if (BanManager.isMuted(uuid)) {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ e.isCancelled = true
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.MUTE").replace("%grund%", BanManager.getReasonString(uuid))))
+ } else {
+ if (System.currentTimeMillis() < BanManager.getRAWEnd(uuid) ?: 0) {
+ e.isCancelled = true
+ var MSG = configcfg.getString("LAYOUT.TEMPMUTE")
+ MSG = MSG.replace("%grund%", BanManager.getReasonString(uuid))
+ MSG = MSG.replace("%dauer%", BanManager.getEnd(uuid))
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', MSG))
+ } else {
+ BanManager.unmute(uuid)
+ }
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e2: IOException) {
+ e2.printStackTrace()
+ }
+
+ } else {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+
+ if (!p.hasPermission("professionalbans.blacklist.bypass") || !p.hasPermission("professionalbans.*")) {
+ if (configcfg.getBoolean("AUTOMUTE.ENABLED")) {
+ insertMessage(uuid, e.message, p.server.info.name)
+ for (blacklist in Main.blacklist) {
+ if (e.message.toUpperCase().contains(blacklist.toUpperCase())) {
+ e.isCancelled = true
+ BanManager.mute(uuid, configcfg.getInt("AUTOMUTE.MUTEID"), "KONSOLE")
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "AUTOMUTE_BLACKLIST", e.message)
+ BanManager.setMutes(uuid, BanManager.getMutes(uuid) + 1)
+ BanManager.sendNotify("MUTE", BanManager.getNameByUUID(uuid).toString()
+ , "KONSOLE", BanManager.getReasonByID(configcfg.getInt("AUTOMUTE.MUTEID")))
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.MUTE")
+ .replace("%grund%", BanManager.getReasonByID(configcfg.getInt("AUTOMUTE.MUTEID")).toString())))
+ } else {
+ var MSG = configcfg.getString("LAYOUT.TEMPMUTE")
+ MSG = MSG.replace("%grund%", BanManager.getReasonString(uuid))
+ MSG = MSG.replace("%dauer%", BanManager.getEnd(uuid))
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', MSG))
+ }
+ return
+ }
+ }
+ for (adblacklist in Main.adblacklist) {
+ if (e.message.toUpperCase().contains(adblacklist.toUpperCase())) {
+ if (!Main.adwhitelist.contains(e.message.toUpperCase())) {
+ e.isCancelled = true
+ BanManager.mute(uuid, configcfg.getInt("AUTOMUTE.ADMUTEID"), "KONSOLE")
+ LogManager.createEntry(uuid.toString(), "KONSOLE", "AUTOMUTE_ADBLACKLIST", e.message)
+ BanManager.setMutes(uuid, BanManager.getMutes(uuid) + 1)
+ BanManager.sendNotify("MUTE", BanManager.getNameByUUID(uuid).toString(), "KONSOLE", BanManager.getReasonByID(configcfg.getInt("AUTOMUTE.ADMUTEID")))
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.MUTE")
+ .replace("%grund%", BanManager.getReasonByID(configcfg.getInt("AUTOMUTE.MUTEID")))))
+ } else {
+ var msg = configcfg.getString("LAYOUT.TEMPMUTE")
+ msg = msg.replace("%grund%", BanManager.getReasonString(uuid))
+ msg = msg.replace("%dauer%", BanManager.getEnd(uuid))
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', msg))
+ }
+ return
+ }
+ }
+ }
+ } else {
+ insertMessage(uuid, e.message, p.server.info.name)
+ if (configcfg.getBoolean("AUTOMUTE.AUTOREPORT")) {
+ for (blacklist in Main.blacklist) {
+ if (e.message.toUpperCase().contains(blacklist.toUpperCase())) {
+ e.isCancelled = true
+ p.sendMessage(Main.prefix + "§cAchte auf deine Wortwahl")
+ val LogID = Chat.createChatlog(uuid, "KONSOLE")
+ BanManager.createReport(uuid, "KONSOLE", "VERHALTEN", LogID)
+ BanManager.sendNotify("REPORT", p.name, "KONSOLE", "VERHALTEN")
+ return
+ }
+ }
+ for (adblacklist in Main.adblacklist) {
+ if (e.message.toUpperCase().contains(adblacklist.toUpperCase())) {
+ if (!Main.adwhitelist.contains(e.message.toUpperCase())) {
+ e.isCancelled = true
+ p.sendMessage(Main.prefix + "§cDu darfst keine Werbung machen")
+ val LogID = Chat.createChatlog(uuid, "KONSOLE")
+ BanManager.createReport(uuid, "KONSOLE", "WERBUNG", LogID)
+ BanManager.sendNotify("REPORT", p.name, "KONSOLE", "WERBUNG")
+ return
+ }
+ }
+ }
+ }
+ }
+ } else {
+ insertMessage(uuid, e.message, p.server.info.name)
+ }
+
+ } catch (e2: IOException) {
+ e2.printStackTrace()
+ }
+
+ }
+ }
+ }
+
+ companion object {
+
+ fun insertMessage(uuid: UUID, Message: String, Server: String) {
+ Main.mysql.update("INSERT INTO chat(UUID, SERVER, MESSAGE, SENDDATE) " +
+ "VALUES ('" + uuid + "', '" + Server + "', '" + Message + "', '" + System.currentTimeMillis() + "')")
+ }
+
+ fun createChatlog(uuid: UUID, createdUUID: String): String {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM chat WHERE uuid='$uuid'") ?: return "Null"
+ val id = randomString(20)
+ val now = System.currentTimeMillis()
+ while (rs.next()) {
+ val tenMinutes = 10 * 60 * 1000
+ val tenAgo = System.currentTimeMillis() - tenMinutes
+ if (java.lang.Long.valueOf(rs.getString("SENDDATE")) > tenAgo) {
+ Main.mysql.update("INSERT INTO chatlog(LOGID, uuid, CREATOR_UUID, SERVER, MESSAGE, SENDDATE, CREATED_AT) " +
+ "VALUES ('" + id + "' ,'" + uuid + "', '" + createdUUID + "', '" + rs.getString("SERVER") + "', '" + rs.getString("MESSAGE") + "', '" + rs.getString("SENDDATE") + "', '" + now + "')")
+ }
+ }
+ return id
+ } catch (exc: SQLException) {
+
+ }
+
+ return "Null"
+ }
+
+ fun hasMessages(uuid: UUID): Boolean {
+ return try {
+ val rs = Main.mysql.query("SELECT * FROM chat WHERE uuid='$uuid'") ?: return false
+ var i = 0
+ while (rs.next()) {
+ i++
+ }
+ i != 0
+ } catch (exc: SQLException) {
+ false
+ }
+ }
+
+ private const val alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ private var rnd = SecureRandom()
+
+ private fun randomString(len: Int): String {
+ val sb = StringBuilder(len)
+ for (i in 0 until len)
+ sb.append(alphabet[rnd.nextInt(alphabet.length)])
+ return sb.toString()
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/listener/Login.kt b/src/main/kotlin/de/tutorialwork/listener/Login.kt
new file mode 100644
index 0000000..1a3301a
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/listener/Login.kt
@@ -0,0 +1,136 @@
+package de.tutorialwork.listener
+
+import de.tutorialwork.commands.SupportChat
+import de.tutorialwork.main.Main
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.IPManager
+import de.tutorialwork.utils.UUIDFetcher
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.event.PostLoginEvent
+import net.md_5.bungee.api.event.PreLoginEvent
+import net.md_5.bungee.api.plugin.Listener
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import net.md_5.bungee.event.EventHandler
+
+import java.io.File
+import java.io.IOException
+
+class Login : Listener {
+
+ @EventHandler
+ fun onPreLoginEvent(event: PreLoginEvent) {
+ val uuid = UUIDFetcher.getUUID(event.connection.name) ?: return
+ val ip = event.connection.virtualHost.hostName
+ /*val ip = event.connection.address.hostString*/
+ BanManager.createPlayer(uuid, event.connection.name)
+ IPManager.insertIP(ip, uuid)
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (cfg.getBoolean("VPN.BLOCKED")) {
+ if (!Main.ipwhitelist.contains(ip)) {
+ if (IPManager.isVPN(ip)) {
+ if (cfg.getBoolean("VPN.KICK")) {
+ event.isCancelled = true
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', cfg.getString("VPN.KICKMSG"))
+ }
+ if (cfg.getBoolean("VPN.BAN")) {
+ val id = cfg.getInt("VPN.BANID")
+ BanManager.ban(uuid, id, "KONSOLE", Main.increaseValue, Main.increaseBans)
+ BanManager.sendNotify("IPBAN", event.connection.address.hostString, "KONSOLE", BanManager.getReasonByID(id))
+ event.isCancelled = true
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', cfg.getString("LAYOUT.IPBAN").replace("%grund%", BanManager.getReasonByID(id)!!))
+ } else {
+ var MSG = cfg.getString("LAYOUT.TEMPIPBAN")
+ MSG = MSG.replace("%grund%", BanManager.getReasonString(uuid)!!)
+ MSG = MSG.replace("%dauer%", BanManager.getEnd(uuid))
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', MSG)
+ }
+ }
+ }
+ }
+ }
+ } catch (er: IOException) {
+ er.printStackTrace()
+ }
+
+ if (IPManager.isBanned(ip)) {
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+
+ if (IPManager.getRAWEnd(ip) == -1L) {
+ event.isCancelled = true
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.IPBAN").replace("%grund%", IPManager.getReasonString(ip)!!))
+ } else {
+ if (System.currentTimeMillis() < IPManager.getRAWEnd(ip) ?: 0) {
+ event.isCancelled = true
+ var msg = configcfg.getString("LAYOUT.TEMPIPBAN")
+ msg = msg.replace("%grund%", IPManager.getReasonString(ip)!!)
+ msg = msg.replace("%dauer%", IPManager.getEnd(ip))
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', msg)
+ } else {
+ IPManager.unban(ip)
+ }
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e2: IOException) {
+ e2.printStackTrace()
+ }
+
+ }
+ if (BanManager.isBanned(uuid)) {
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ event.isCancelled = true
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.BAN").replace("%grund%", BanManager.getReasonString(uuid)!!))
+ } else {
+ if (System.currentTimeMillis() < BanManager.getRAWEnd(uuid) ?: 0) {
+ event.isCancelled = true
+ var msg = configcfg.getString("LAYOUT.TEMPBAN")
+ msg = msg.replace("%grund%", BanManager.getReasonString(uuid)!!)
+ msg = msg.replace("%dauer%", BanManager.getEnd(uuid))
+ event.cancelReason = ChatColor.translateAlternateColorCodes('&', msg)
+ } else {
+ BanManager.unban(uuid)
+ }
+ }
+
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e2: IOException) {
+ e2.printStackTrace()
+ }
+
+ }
+ }
+
+ @EventHandler
+ fun onFinalLogin(e: PostLoginEvent) {
+ val p = e.player
+ if (p.hasPermission("professionalbans.reports") || p.hasPermission("professionalbans.*")) {
+ if (BanManager.countOpenReports() != 0) {
+ p.sendMessage(Main.prefix + "Derzeit sind noch §e§l" + BanManager.countOpenReports() + " Reports §7offen")
+ }
+ }
+ if (p.hasPermission("professionalbans.supportchat") || p.hasPermission("professionalbans.*")) {
+ if (SupportChat.openchats.size != 0) {
+ p.sendMessage(Main.prefix + "Derzeit sind noch §e§l" + SupportChat.openchats.size + " §7Support Chat Anfragen §aoffen")
+ }
+ }
+ //Update Check
+ if (p.hasPermission("professionalbans.*")) {
+ if (Main.callURL("https://api.spigotmc.org/legacy/update.php?resource=63657") != Main.Version) {
+ p.sendMessage("§8[]===================================[]")
+ p.sendMessage("§e§lProfessionalBans §7Reloaded §8| §7Version §c" + Main.Version)
+ p.sendMessage("§cDu benutzt eine §c§lVERALTETE §cVersion des Plugins!")
+ p.sendMessage("§7Update: §4§lhttps://spigotmc.org/resources/63657")
+ p.sendMessage("§8[]===================================[]")
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/listener/Quit.kt b/src/main/kotlin/de/tutorialwork/listener/Quit.kt
new file mode 100644
index 0000000..97b03e3
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/listener/Quit.kt
@@ -0,0 +1,28 @@
+package de.tutorialwork.listener
+
+import de.tutorialwork.commands.SupportChat
+import de.tutorialwork.main.Main
+import net.md_5.bungee.api.event.PlayerDisconnectEvent
+import net.md_5.bungee.api.plugin.Listener
+import net.md_5.bungee.event.EventHandler
+
+class Quit : Listener {
+
+ @EventHandler
+ fun onPlayerDisconnectEvent(event: PlayerDisconnectEvent) {
+ val player = event.player
+ if (SupportChat.activechats.containsKey(player) || SupportChat.activechats.containsValue(player)) {
+ for (key in SupportChat.activechats.keys) {
+ //Key has started the support chat
+ if (key === player) {
+ SupportChat.activechats[player]?.sendMessage(Main.prefix + "§event§l" + player.name + " §7hat den Support hat §cbeeendet")
+ SupportChat.activechats.remove(player)
+ } else {
+ key.sendMessage(Main.prefix + "§event§l" + player.name + " §7hat den Support Chat §cbeeendet")
+ SupportChat.activechats.remove(key)
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/main/Main.kt b/src/main/kotlin/de/tutorialwork/main/Main.kt
new file mode 100644
index 0000000..adc88e2
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/main/Main.kt
@@ -0,0 +1,261 @@
+package de.tutorialwork.main
+
+import de.tutorialwork.commands.*
+import de.tutorialwork.console
+import de.tutorialwork.listener.Chat
+import de.tutorialwork.listener.Login
+import de.tutorialwork.listener.Quit
+import de.tutorialwork.utils.BanManager
+import de.tutorialwork.utils.MySQLConnect
+import net.md_5.bungee.api.ChatColor
+import net.md_5.bungee.api.plugin.Command
+import net.md_5.bungee.api.plugin.Plugin
+import net.md_5.bungee.config.ConfigurationProvider
+import net.md_5.bungee.config.YamlConfiguration
+import java.io.File
+import java.io.IOException
+import java.net.URL
+import java.net.URLConnection
+import java.util.*
+import java.util.concurrent.TimeUnit
+
+
+class Main : Plugin() {
+
+ init {
+ instance = this
+ }
+
+
+ override fun onEnable() {
+ config()
+ mySQL()
+ registerCommands()
+ registerListeners()
+ //Konsolen Nachricht über das Plugin
+ proxy.console.apply {
+ sendMessage("§8[]===================================[]")
+ sendMessage("§e§lProfessionalBans §7§oReloaded §8| §7Version: §c$Version")
+ sendMessage("§7Developer: §e§lTutorialwork, LeBaasti")
+ sendMessage("§5YT §7Kanal: §cyoutube.com/Tutorialwork")
+ sendMessage("§8[]===================================[]")
+ }
+
+
+ //Überprüft auf Bans aus dem Webinterface
+ proxy.scheduler.schedule(this, {
+ val config = File(Main.instance.dataFolder, "config.yml")
+ try {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ for (all in proxy.players) {
+ val uuid = all.uniqueId
+ if (BanManager.isBanned(uuid)) {
+ if (BanManager.getRAWEnd(uuid) == -1L) {
+ all.disconnect(ChatColor.translateAlternateColorCodes('&', configcfg.getString("LAYOUT.BAN")
+ .replace("%grund%", BanManager.getReasonString(uuid))))
+ } else {
+ var msg = configcfg.getString("LAYOUT.TEMPBAN")
+ msg = msg.replace("%grund%", BanManager.getReasonString(uuid))
+ msg = msg.replace("%dauer%", BanManager.getEnd(uuid))
+ all.disconnect(ChatColor.translateAlternateColorCodes('&', msg))
+ }
+ }
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+ }, 5, 5, TimeUnit.SECONDS)
+ }
+
+ private fun config() {
+ if (!dataFolder.exists()) dataFolder.mkdir()
+ val file = File(dataFolder.path, "mysql.yml")
+ val config = File(dataFolder.path, "config.yml")
+ val blacklistfile = File(dataFolder.path, "blacklist.yml")
+ try {
+ if (!file.exists()) {
+ file.createNewFile()
+ val mysql = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(file)
+ mysql.set("HOST", "localhost")
+ mysql.set("DATENBANK", "Bans")
+ mysql.set("USER", "root")
+ mysql.set("PASSWORT", "deinpasswort")
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(mysql, file)
+ }
+ if (!config.exists()) {
+ config.createNewFile()
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ configcfg.set("PREFIX", "&e&lBANS &8• &7")
+ configcfg.set("LAYOUT.BAN", "&8[]===================================[] \n\n &4&lDu wurdest GEBANNT \n\n &eGrund: §c§l%grund% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.KICK", "&8[]===================================[] \n\n &e&lDu wurdest GEKICKT \n\n &eGrund: §c§l%grund% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.TEMPBAN", "&8[]===================================[] \n\n &4&lDu wurdest temporär GEBANNT \n\n &eGrund: §c§l%grund% \n &eRestzeit: &c&l%dauer% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.MUTE", "&8[]===================================[] \n\n &4&lDu wurdest GEMUTET \n\n &eGrund: §c§l%grund% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.TEMPMUTE", "&8[]===================================[] \n\n &4&lDu wurdest temporär GEMUTET \n\n &eGrund: §c§l%grund% \n &eRestzeit: &c&l%dauer% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.IPBAN", "&8[]===================================[] \n\n &4&lDeine IP-Adresse wurde GEBANNT \n\n &eGrund: §c§l%grund% \n\n&8[]===================================[]")
+ configcfg.set("LAYOUT.TEMPIPBAN", "&8[]===================================[] \n\n &4&lDeine IP-Adresse wurde temporär GEBANNT \n\n &eGrund: §c§l%grund% \n &eRestzeit: &c&l%dauer% \n\n&8[]===================================[]")
+ configcfg.set("VPN.BLOCKED", true)
+ configcfg.set("VPN.KICK", true)
+ configcfg.set("VPN.KICKMSG", "&7Das benutzen einer &4VPN &7ist auf unserem Netzwerk &cUNTERSAGT")
+ configcfg.set("VPN.BAN", false)
+ configcfg.set("VPN.BANID", 0)
+ ipwhitelist.add("8.8.8.8")
+ configcfg.set("VPN.WHITELIST", ipwhitelist)
+ configcfg.set("VPN.APIKEY", "Go to https://proxycheck.io/dashboard and register with your email and enter here your API Key")
+ configcfg.set("REPORTS.ENABLED", true)
+ reportreasons.add("Hacking")
+ reportreasons.add("Verhalten")
+ reportreasons.add("Teaming")
+ reportreasons.add("TPA-Falle")
+ reportreasons.add("Werbung")
+ configcfg.set("REPORTS.REASONS", reportreasons)
+ configcfg.set("REPORTS.OFFLINEREPORTS", false)
+ configcfg.set("CHATLOG.ENABLED", true)
+ configcfg.set("CHATLOG.URL", "DeinServer.net/BanWebinterface/public/chatlog.php?id=")
+ configcfg.set("AUTOMUTE.ENABLED", false)
+ configcfg.set("AUTOMUTE.AUTOREPORT", true)
+ //configcfg.set("AUTOMUTE.AUTOREPORT.REASON", "Automatischer Report");
+ configcfg.set("AUTOMUTE.MUTEID", 0)
+ configcfg.set("AUTOMUTE.ADMUTEID", 0)
+ configcfg.set("BANTIME-INCREASE.ENABLED", true)
+ configcfg.set("BANTIME-INCREASE.PERCENTRATE", 50)
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ } else {
+ val configcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(config)
+ if (configcfg.getBoolean("VPN.KICK") && configcfg.getBoolean("VPN.BAN")) {
+ console.sendMessage("§8[]===================================[]")
+ console.sendMessage("§c§lSINNLOSE EINSTELLUNG ENTDECKT")
+ console.sendMessage("§7Wenn ein Spieler mit einer VPN das Netzwerk betritt kann er nicht gekickt UND gebannt werden.")
+ console.sendMessage("§4§lÜberprüfe die VPN Einstellung in der CONFIG.YML")
+ console.sendMessage("§8[]===================================[]")
+ //Setze VPN Einstellung zurück!
+ configcfg.set("VPN.BLOCKED", true)
+ configcfg.set("VPN.KICK", true)
+ configcfg.set("VPN.KICKMSG", "&7Das benutzen einer &4VPN &7ist auf unserem Netzwerk &cUNTERSAGT")
+ configcfg.set("VPN.BAN", false)
+ configcfg.set("VPN.BANID", 0)
+ }
+ for (reasons in configcfg.getStringList("REPORTS.REASONS")) {
+ reportreasons.add(reasons.toUpperCase())
+ }
+ for (ips in configcfg.getStringList("VPN.WHITELIST")) {
+ ipwhitelist.add(ips)
+ }
+ prefix = configcfg.getString("PREFIX").replace("&", "§")
+ increaseBans = configcfg.getBoolean("BANTIME-INCREASE.ENABLED")
+ increaseValue = configcfg.getInt("BANTIME-INCREASE.PERCENTRATE")
+ if (configcfg.getString("VPN.APIKEY").length == 27) {
+ APIKey = configcfg.getString("VPN.APIKEY")
+ }
+ ConfigurationProvider.getProvider(YamlConfiguration::class.java).save(configcfg, config)
+ }
+ if (!blacklistfile.exists()) blacklistfile.createNewFile()
+ val blacklistcfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(blacklistfile)
+ for (congigstr in blacklistcfg.getStringList("BLACKLIST")) blacklist.add(congigstr)
+ for (congigstr in blacklistcfg.getStringList("ADBLACKLIST")) adblacklist.add(congigstr)
+ for (congigstr in blacklistcfg.getStringList("ADWHITELIST")) adwhitelist.add(congigstr.toUpperCase())
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+
+ private fun mySQL() {
+ try {
+ val file = File(dataFolder.path, "mysql.yml")
+ val mysql = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(file)
+ MySQLConnect.HOST = mysql.getString("HOST")
+ MySQLConnect.DATABASE = mysql.getString("DATENBANK")
+ MySQLConnect.USER = mysql.getString("USER")
+ MySQLConnect.PASSWORD = mysql.getString("PASSWORT")
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ mysql = MySQLConnect(MySQLConnect.HOST, MySQLConnect.DATABASE, MySQLConnect.USER, MySQLConnect.PASSWORD)
+ mysql.update("CREATE TABLE IF NOT EXISTS accounts(UUID varchar(64) UNIQUE, USERNAME varchar(255), PASSWORD varchar(255), RANK int(11), GOOGLE_AUTH varchar(255), AUTHCODE varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS reasons(ID int(11) UNIQUE, REASON varchar(255), TIME int(255), TYPE int(11), ADDED_AT varchar(11), BANS int(11), PERMS varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS bans(UUID varchar(64) UNIQUE, NAME varchar(64), BANNED int(11), MUTED int(11), REASON varchar(64), END long, TEAMUUID varchar(64), BANS int(11), MUTES int(11), FIRSTLOGIN varchar(255), LASTLOGIN varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS ips(IP varchar(64) UNIQUE, USED_BY varchar(64), USED_AT varchar(64), BANNED int(11), REASON varchar(64), END long, TEAMUUID varchar(64), BANS int(11));")
+ mysql.update("CREATE TABLE IF NOT EXISTS reports(ID int(11) AUTO_INCREMENT UNIQUE, UUID varchar(64), REPORTER varchar(64), TEAM varchar(64), REASON varchar(64), LOG varchar(64), STATUS int(11), CREATED_AT long);")
+ mysql.update("CREATE TABLE IF NOT EXISTS chat(ID int(11) AUTO_INCREMENT UNIQUE, UUID varchar(64), SERVER varchar(64), MESSAGE varchar(2500), SENDDATE varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS chatlog(ID int(11) AUTO_INCREMENT UNIQUE, LOGID varchar(255), UUID varchar(64), CREATOR_UUID varchar(64), SERVER varchar(64), MESSAGE varchar(2500), SENDDATE varchar(255), CREATED_AT varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS log(ID int(11) AUTO_INCREMENT UNIQUE, UUID varchar(255), BYUUID varchar(255), ACTION varchar(255), NOTE varchar(255), DATE varchar(255));")
+ mysql.update("CREATE TABLE IF NOT EXISTS unbans(ID int(11) AUTO_INCREMENT UNIQUE, UUID varchar(255), FAIR int(11), MESSAGE varchar(10000), DATE varchar(255), STATUS int(11));")
+ mysql.update("CREATE TABLE IF NOT EXISTS apptokens(UUID varchar(36) UNIQUE, TOKEN varchar(555));")
+ //SQL Update 2.0
+ mysql.update("ALTER TABLE accounts ADD IF NOT EXISTS AUTHSTATUS int(11);")
+ //SQL Update 2.2
+ mysql.update("ALTER TABLE bans ADD IF NOT EXISTS FIRSTLOGIN varchar(255);")
+ mysql.update("ALTER TABLE bans ADD IF NOT EXISTS LASTLOGIN varchar(255);")
+ //SQL Update 2.4
+ mysql.update("ALTER TABLE reasons ADD COLUMN SORTINDEX int(11)")
+ }
+
+ private fun registerCommands() {
+ try {
+ val file = File(dataFolder.path, "config.yml")
+ val cfg = ConfigurationProvider.getProvider(YamlConfiguration::class.java).load(file)
+ arrayOf(Ban("ban"),
+ Unban("unban"),
+ Kick("kick"),
+ WebAccount("webaccount"),
+ Check("check"),
+ IPBan("ipban"),
+ Blacklist("blacklist"),
+ WebVerify("webverify"),
+ SupportChat("support")
+ ).forEach { it.register() }
+
+
+ if (cfg.getBoolean("REPORTS.ENABLED")) {
+ Report("report").register()
+ Reports("reports").register()
+ }
+ if (cfg.getBoolean("CHATLOG.ENABLED")) Chatlog("chatlog").register()
+ } catch (e: IOException) {
+ e.printStackTrace()
+ }
+
+ }
+
+ private fun registerListeners() {
+ proxy.pluginManager.registerListener(this, Login())
+ proxy.pluginManager.registerListener(this, Chat())
+ proxy.pluginManager.registerListener(this, Quit())
+ }
+
+ companion object {
+
+ lateinit var instance: Main
+ lateinit var mysql: MySQLConnect
+ var prefix = "§e§lBANS §8• §7"
+ var noPerms = "$prefix§cDu hast keine Berechtigung diesen Befehl zu nutzen"
+
+ var reportreasons = mutableListOf()
+ var blacklist = ArrayList()
+ var adblacklist = ArrayList()
+ var adwhitelist = ArrayList()
+ var ipwhitelist = ArrayList()
+
+ var increaseBans = true
+ var increaseValue: Int = 50
+
+ var APIKey: String? = null
+
+ //==============================================
+ //Plugin Informationen
+ var Version = "2.4"
+
+ fun callURL(myURL: String): String {
+ val url = URL(myURL)
+ val urlConn: URLConnection? = url.openConnection()
+ if (urlConn != null) urlConn.readTimeout = 60 * 1000
+ val inputStream = urlConn?.getInputStream() ?: return ""
+ return inputStream.reader().readText()
+ }
+ }
+
+ private fun Command.register() = proxy.pluginManager.registerCommand(this@Main, this)
+
+}
\ No newline at end of file
diff --git a/src/de/tutorialwork/utils/BCrypt.java b/src/main/kotlin/de/tutorialwork/utils/BCrypt.java
similarity index 87%
rename from src/de/tutorialwork/utils/BCrypt.java
rename to src/main/kotlin/de/tutorialwork/utils/BCrypt.java
index 500e75e..a805495 100644
--- a/src/de/tutorialwork/utils/BCrypt.java
+++ b/src/main/kotlin/de/tutorialwork/utils/BCrypt.java
@@ -1,21 +1,6 @@
-// Copyright (c) 2006 Damien Miller
-//
-// Permission to use, copy, modify, and distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
package de.tutorialwork.utils;
import java.io.UnsupportedEncodingException;
-
import java.security.SecureRandom;
/**
@@ -378,10 +363,10 @@ public class BCrypt {
* encoding scheme. Note that this is *not* compatible with
* the standard MIME-base64 encoding.
*
- * @param d the byte array to encode
- * @param len the number of bytes to encode
- * @return base64-encoded string
- * @exception IllegalArgumentException if the length is invalid
+ * @param d the byte array to encode
+ * @param len the number of bytes to encode
+ * @return base64-encoded string
+ * @throws IllegalArgumentException if the length is invalid
*/
private static String encode_base64(byte d[], int len)
throws IllegalArgumentException {
@@ -390,7 +375,7 @@ private static String encode_base64(byte d[], int len)
int c1, c2;
if (len <= 0 || len > d.length)
- throw new IllegalArgumentException ("Invalid len");
+ throw new IllegalArgumentException("Invalid len");
while (off < len) {
c1 = d[off++] & 0xff;
@@ -419,22 +404,24 @@ private static String encode_base64(byte d[], int len)
/**
* Look up the 3 bits base64-encoded by the specified character,
* range-checking againt conversion table
- * @param x the base64-encoded value
- * @return the decoded value of x
+ *
+ * @param x the base64-encoded value
+ * @return the decoded value of x
*/
private static byte char64(char x) {
- if ((int)x < 0 || (int)x > index_64.length)
+ if ((int) x < 0 || (int) x > index_64.length)
return -1;
- return index_64[(int)x];
+ return index_64[(int) x];
}
/**
* Decode a string encoded using bcrypt's base64 scheme to a
* byte array. Note that this is *not* compatible with
* the standard MIME-base64 encoding.
- * @param s the string to decode
- * @param maxolen the maximum number of bytes to decode
- * @return an array containing the decoded bytes
+ *
+ * @param s the string to decode
+ * @param maxolen the maximum number of bytes to decode
+ * @return an array containing the decoded bytes
* @throws IllegalArgumentException if maxolen is invalid
*/
private static byte[] decode_base64(String s, int maxolen)
@@ -445,50 +432,51 @@ private static byte[] decode_base64(String s, int maxolen)
byte c1, c2, c3, c4, o;
if (maxolen <= 0)
- throw new IllegalArgumentException ("Invalid maxolen");
+ throw new IllegalArgumentException("Invalid maxolen");
while (off < slen - 1 && olen < maxolen) {
c1 = char64(s.charAt(off++));
c2 = char64(s.charAt(off++));
if (c1 == -1 || c2 == -1)
break;
- o = (byte)(c1 << 2);
+ o = (byte) (c1 << 2);
o |= (c2 & 0x30) >> 4;
- rs.append((char)o);
+ rs.append((char) o);
if (++olen >= maxolen || off >= slen)
break;
c3 = char64(s.charAt(off++));
if (c3 == -1)
break;
- o = (byte)((c2 & 0x0f) << 4);
+ o = (byte) ((c2 & 0x0f) << 4);
o |= (c3 & 0x3c) >> 2;
- rs.append((char)o);
+ rs.append((char) o);
if (++olen >= maxolen || off >= slen)
break;
c4 = char64(s.charAt(off++));
- o = (byte)((c3 & 0x03) << 6);
+ o = (byte) ((c3 & 0x03) << 6);
o |= c4;
- rs.append((char)o);
+ rs.append((char) o);
++olen;
}
ret = new byte[olen];
for (off = 0; off < olen; off++)
- ret[off] = (byte)rs.charAt(off);
+ ret[off] = (byte) rs.charAt(off);
return ret;
}
/**
* Blowfish encipher a single 64-bit block encoded as
* two 32-bit halves
- * @param lr an array containing the two 32-bit half blocks
- * @param off the position in the array of the blocks
+ *
+ * @param lr an array containing the two 32-bit half blocks
+ * @param off the position in the array of the blocks
*/
private final void encipher(int lr[], int off) {
int i, n, l = lr[off], r = lr[off + 1];
l ^= P[0];
- for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) {
+ for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2; ) {
// Feistel substitution on left word
n = S[(l >> 24) & 0xff];
n += S[0x100 | ((l >> 16) & 0xff)];
@@ -509,10 +497,11 @@ private final void encipher(int lr[], int off) {
/**
* Cycically extract a word of key material
- * @param data the string to extract the data from
- * @param offp a "pointer" (as a one-entry array) to the
- * current offset into data
- * @return the next word of material from data
+ *
+ * @param data the string to extract the data from
+ * @param offp a "pointer" (as a one-entry array) to the
+ * current offset into data
+ * @return the next word of material from data
*/
private static int streamtoword(byte data[], int offp[]) {
int i;
@@ -532,18 +521,19 @@ private static int streamtoword(byte data[], int offp[]) {
* Initialise the Blowfish key schedule
*/
private void init_key() {
- P = (int[])P_orig.clone();
- S = (int[])S_orig.clone();
+ P = (int[]) P_orig.clone();
+ S = (int[]) S_orig.clone();
}
/**
* Key the Blowfish cipher
- * @param key an array containing the key
+ *
+ * @param key an array containing the key
*/
private void key(byte key[]) {
int i;
- int koffp[] = { 0 };
- int lr[] = { 0, 0 };
+ int koffp[] = {0};
+ int lr[] = {0, 0};
int plen = P.length, slen = S.length;
for (i = 0; i < plen; i++)
@@ -566,13 +556,14 @@ private void key(byte key[]) {
* Perform the "enhanced key schedule" step described by
* Provos and Mazieres in "A Future-Adaptable Password Scheme"
* http://www.openbsd.org/papers/bcrypt-paper.ps
- * @param data salt information
- * @param key password information
+ *
+ * @param data salt information
+ * @param key password information
*/
private void ekskey(byte data[], byte key[]) {
int i;
- int koffp[] = { 0 }, doffp[] = { 0 };
- int lr[] = { 0, 0 };
+ int koffp[] = {0}, doffp[] = {0};
+ int lr[] = {0, 0};
int plen = P.length, slen = S.length;
for (i = 0; i < plen; i++)
@@ -598,23 +589,24 @@ private void ekskey(byte data[], byte key[]) {
/**
* Perform the central password hashing step in the
* bcrypt scheme
- * @param password the password to hash
- * @param salt the binary salt to hash with the password
- * @param log_rounds the binary logarithm of the number
- * of rounds of hashing to apply
- * @return an array containing the binary hashed password
+ *
+ * @param password the password to hash
+ * @param salt the binary salt to hash with the password
+ * @param log_rounds the binary logarithm of the number
+ * of rounds of hashing to apply
+ * @return an array containing the binary hashed password
*/
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
int rounds, i, j;
- int cdata[] = (int[])bf_crypt_ciphertext.clone();
+ int cdata[] = (int[]) bf_crypt_ciphertext.clone();
int clen = cdata.length;
byte ret[];
if (log_rounds < 4 || log_rounds > 31)
- throw new IllegalArgumentException ("Bad number of rounds");
+ throw new IllegalArgumentException("Bad number of rounds");
rounds = 1 << log_rounds;
if (salt.length != BCRYPT_SALT_LEN)
- throw new IllegalArgumentException ("Bad salt length");
+ throw new IllegalArgumentException("Bad salt length");
init_key();
ekskey(salt, password);
@@ -630,43 +622,44 @@ private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
ret = new byte[clen * 4];
for (i = 0, j = 0; i < clen; i++) {
- ret[j++] = (byte)((cdata[i] >> 24) & 0xff);
- ret[j++] = (byte)((cdata[i] >> 16) & 0xff);
- ret[j++] = (byte)((cdata[i] >> 8) & 0xff);
- ret[j++] = (byte)(cdata[i] & 0xff);
+ ret[j++] = (byte) ((cdata[i] >> 24) & 0xff);
+ ret[j++] = (byte) ((cdata[i] >> 16) & 0xff);
+ ret[j++] = (byte) ((cdata[i] >> 8) & 0xff);
+ ret[j++] = (byte) (cdata[i] & 0xff);
}
return ret;
}
/**
* Hash a password using the OpenBSD bcrypt scheme
- * @param password the password to hash
- * @param salt the salt to hash with (perhaps generated
- * using BCrypt.gensalt)
- * @return the hashed password
+ *
+ * @param password the password to hash
+ * @param salt the salt to hash with (perhaps generated
+ * using BCrypt.gensalt)
+ * @return the hashed password
*/
public static String hashpw(String password, String salt) {
BCrypt B;
String real_salt;
byte passwordb[], saltb[], hashed[];
- char minor = (char)0;
+ char minor = (char) 0;
int rounds, off = 0;
StringBuffer rs = new StringBuffer();
if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
- throw new IllegalArgumentException ("Invalid salt version");
+ throw new IllegalArgumentException("Invalid salt version");
if (salt.charAt(2) == '$')
off = 3;
else {
minor = salt.charAt(2);
if (minor != 'a' || salt.charAt(3) != '$')
- throw new IllegalArgumentException ("Invalid salt revision");
+ throw new IllegalArgumentException("Invalid salt revision");
off = 4;
}
// Extract number of rounds
if (salt.charAt(off + 2) > '$')
- throw new IllegalArgumentException ("Missing salt rounds");
+ throw new IllegalArgumentException("Missing salt rounds");
rounds = Integer.parseInt(salt.substring(off, off + 2));
real_salt = salt.substring(off + 3, off + 25);
@@ -697,11 +690,12 @@ public static String hashpw(String password, String salt) {
/**
* Generate a salt for use with the BCrypt.hashpw() method
- * @param log_rounds the log2 of the number of rounds of
- * hashing to apply - the work factor therefore increases as
- * 2**log_rounds.
- * @param random an instance of SecureRandom to use
- * @return an encoded salt value
+ *
+ * @param log_rounds the log2 of the number of rounds of
+ * hashing to apply - the work factor therefore increases as
+ * 2**log_rounds.
+ * @param random an instance of SecureRandom to use
+ * @return an encoded salt value
*/
public static String gensalt(int log_rounds, SecureRandom random) {
StringBuffer rs = new StringBuffer();
@@ -720,10 +714,11 @@ public static String gensalt(int log_rounds, SecureRandom random) {
/**
* Generate a salt for use with the BCrypt.hashpw() method
- * @param log_rounds the log2 of the number of rounds of
- * hashing to apply - the work factor therefore increases as
- * 2**log_rounds.
- * @return an encoded salt value
+ *
+ * @param log_rounds the log2 of the number of rounds of
+ * hashing to apply - the work factor therefore increases as
+ * 2**log_rounds.
+ * @return an encoded salt value
*/
public static String gensalt(int log_rounds) {
return gensalt(log_rounds, new SecureRandom());
@@ -733,7 +728,8 @@ public static String gensalt(int log_rounds) {
* Generate a salt for use with the BCrypt.hashpw() method,
* selecting a reasonable default for the number of hashing
* rounds to apply
- * @return an encoded salt value
+ *
+ * @return an encoded salt value
*/
public static String gensalt() {
return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS);
@@ -742,11 +738,12 @@ public static String gensalt() {
/**
* Check that a plaintext password matches a previously hashed
* one
- * @param plaintext the plaintext password to verify
- * @param hashed the previously-hashed password
- * @return true if the passwords match, false otherwise
+ *
+ * @param plaintext the plaintext password to verify
+ * @param hashed the previously-hashed password
+ * @return true if the passwords match, false otherwise
*/
public static boolean checkpw(String plaintext, String hashed) {
return (hashed.compareTo(hashpw(plaintext, hashed)) == 0);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/de/tutorialwork/utils/BanManager.kt b/src/main/kotlin/de/tutorialwork/utils/BanManager.kt
new file mode 100644
index 0000000..2870708
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/BanManager.kt
@@ -0,0 +1,628 @@
+package de.tutorialwork.utils
+
+import de.tutorialwork.main.Main
+import net.md_5.bungee.api.ProxyServer
+import net.md_5.bungee.api.connection.ProxiedPlayer
+import java.sql.SQLException
+import java.text.SimpleDateFormat
+import java.util.*
+
+object BanManager {
+
+ val iDsFromOpenReports: List
+ get() {
+ return try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE STATUS = 0")
+ val ids = ArrayList()
+ while (rs!!.next()) {
+ ids.add(rs.getInt("ID"))
+ }
+ ids
+ } catch (exc: SQLException) {
+ emptyList()
+ }
+ }
+
+ //DATENBANK Struktur
+ //UUID varchar(64) UNIQUE, NAME varchar(64), BANNED int(11), MUTED int(11), REASON varchar(64), END long(255), TEAMUUID varchar(64), BANS int(11), MUTES int(11)
+
+ fun playerExists(uuid: UUID): Boolean {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'") ?: return false
+ return if (rs.next()) rs.getString("uuid") != null
+ else false
+ }
+
+ fun createPlayer(uuid: UUID, name: String) {
+ if (!playerExists(uuid)) {
+ Main.mysql.update("INSERT INTO bans(uuid, NAME, BANNED, MUTED, REASON, END, TEAMUUID, BANS, MUTES, FIRSTLOGIN, LASTLOGIN) " +
+ "VALUES ('" + uuid + "', '" + name + "', '0', '0', 'null', 'null', 'null', '0', '0', '" + System.currentTimeMillis() + "', '" + System.currentTimeMillis() + "')")
+ } else {
+ updateName(uuid, name)
+ updateLastLogin(uuid)
+ }
+ }
+
+ fun getBanReasonsList(p: ProxiedPlayer) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons ORDER BY SORTINDEX ASC")
+ while (rs!!.next()) {
+ val id = rs.getInt("ID")
+ if (isBanReason(id)) {
+ p.sendMessage("§7" + id + " §8| §e" + getReasonByID(id))
+ } else {
+ p.sendMessage("§7" + id + " §8| §e" + getReasonByID(id) + " §8(§cMUTE§8)")
+ }
+ }
+ } catch (exc: SQLException) {
+ }
+
+ }
+
+ fun getNameByUUID(uuid: UUID): String? {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getString("NAME")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return null
+ }
+
+ fun getUUIDByName(name: String): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE NAME='$name'")
+ if (rs!!.next()) {
+ return rs.getString("UUID")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ private fun updateName(uuid: UUID, newName: String) {
+ if (playerExists(uuid)) Main.mysql.update("UPDATE bans SET NAME='$newName' WHERE uuid='$uuid'")
+ }
+
+ fun ban(uuid: UUID, GrundID: Int, TeamUUID: String, Prozentsatz: Int, increaseBans: Boolean) {
+ if (getReasonTime(GrundID) == -1) {
+ //Perma Ban
+ Main.mysql.update("UPDATE bans SET BANNED='1', REASON='" + getReasonByID(GrundID) + "', END='-1', TEAMUUID='" + TeamUUID + "' WHERE uuid='" + uuid + "'")
+ } else {
+ //Temp Ban
+ //Formel: 1.50 * Anzahl an Tagen = Ergebniss (50%)
+ val bans = getBans(uuid)
+ val defaultmins = getReasonTime(GrundID)!!
+ val current = System.currentTimeMillis()
+ val end = current + getReasonTime(GrundID)!! * 60000L
+ val increaseEnd = current + (Prozentsatz / 100).toLong() + 1 * defaultmins.toLong() * bans.toLong() * 60000L //Formel!!!!!
+ if (increaseBans) {
+ if (bans > 0) {
+ Main.mysql.update("UPDATE bans SET BANNED='1', REASON='" + getReasonByID(GrundID) + "', END='" + end + "', TEAMUUID='" + TeamUUID + "' WHERE uuid='" + uuid + "'")
+ } else {
+ Main.mysql.update("UPDATE bans SET BANNED='1', REASON='" + getReasonByID(GrundID) + "', END='" + increaseEnd + "', TEAMUUID='" + TeamUUID + "' WHERE uuid='" + uuid + "'")
+ }
+ } else {
+ Main.mysql.update("UPDATE bans SET BANNED='1', REASON='" + getReasonByID(GrundID) + "', END='" + end + "', TEAMUUID='" + TeamUUID + "' WHERE uuid='" + uuid + "'")
+ }
+ }
+ }
+
+ fun mute(uuid: UUID, GrundID: Int, TeamUUID: String) {
+ val current = System.currentTimeMillis()
+ val end = current + getReasonTime(GrundID)!! * 60000L
+ if (getReasonTime(GrundID) == -1) {
+ //Perma Mute
+ Main.mysql.update("UPDATE bans SET MUTED='1', REASON='" + getReasonByID(GrundID) + "', END='-1', TEAMUUID='" + TeamUUID + "' WHERE UUID='" + uuid + "'")
+ } else {
+ //Temp Mute
+ Main.mysql.update("UPDATE bans SET MUTED='1', REASON='" + getReasonByID(GrundID) + "', END='" + end + "', TEAMUUID='" + TeamUUID + "' WHERE UUID='" + uuid + "'")
+ }
+ }
+
+ fun getRAWEnd(uuid: UUID): Long? {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getLong("END")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return null
+ }
+
+ fun getEnd(uuid: UUID): String {
+ val uhrzeit = System.currentTimeMillis()
+ val end = getRAWEnd(uuid)!!
+
+ var millis = end - uhrzeit
+
+ var sekunden = 0L
+ var minuten = 0L
+ var stunden = 0L
+ var tage = 0L
+ while (millis > 1000L) {
+ millis -= 1000L
+ sekunden += 1L
+ }
+ while (sekunden > 60L) {
+ sekunden -= 60L
+ minuten += 1L
+ }
+ while (minuten > 60L) {
+ minuten -= 60L
+ stunden += 1L
+ }
+ while (stunden > 24L) {
+ stunden -= 24L
+ tage += 1L
+ }
+ return if (tage != 0L) {
+ "§a$tage §7Tag(e) §a$stunden §7Stunde(n) §a$minuten §7Minute(n)"
+ } else if (tage == 0L && stunden != 0L) {
+ "§a$stunden §7Stunde(n) §a$minuten §7Minute(n) §a$sekunden §7Sekunde(n)"
+ } else if (tage == 0L && stunden == 0L && minuten != 0L) {
+ "§a$minuten §7Minute(n) §a$sekunden §7Sekunde(n)"
+ } else if (tage == 0L && stunden == 0L && minuten == 0L && sekunden != 0L) {
+ "§a$sekunden §7Sekunde(n)"
+ } else {
+ "§4Fehler in der Berechnung!"
+ }
+ //Alter Code
+ //return "§a" + tage + " §7Tag(e) §a" + stunden + " §7Stunde(n) §a" + minuten + " §7Minute(n) §a" + sekunden + " §7Sekunde(n)";
+ }
+
+ fun isBanned(uuid: UUID): Boolean {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE UUID='$uuid'")
+ if (rs!!.next()) {
+ return rs.getInt("BANNED") == 1
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return false
+ }
+
+ fun isMuted(uuid: UUID): Boolean {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getInt("MUTED") == 1
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return false
+ }
+
+ fun unban(uuid: UUID) {
+ if (playerExists(uuid)) Main.mysql.update("UPDATE bans SET BANNED='0' WHERE uuid='$uuid'")
+ }
+
+ fun unmute(uuid: UUID) {
+ if (playerExists(uuid)) {
+ Main.mysql.update("UPDATE bans SET MUTED='0' WHERE uuid='$uuid'")
+ }
+ }
+
+ fun getReasonString(uuid: UUID): String {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getString("REASON")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return "Nothing"
+ }
+
+ fun sendNotify(Type: String, BannedName: String, TeamName: String, Grund: String?) {
+ if (Type.toUpperCase() == "BAN") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify")) {
+ all.sendMessage(Main.prefix + "§e§l" + BannedName + " §7wurde von §c§l" + TeamName + " §cgebannt §7wegen §a" + Grund)
+ }
+ }
+ }
+ if (Type.toUpperCase() == "IPBAN") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify")) {
+ all.sendMessage(Main.prefix + "§7Die IP §e§l" + BannedName + " §7wurde von §c§l" + TeamName + " §cgebannt §7wegen §a" + Grund)
+ }
+ }
+ }
+ if (Type.toUpperCase() == "MUTE") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§e§l" + BannedName + " §7wurde von §c§l" + TeamName + " §cgemutet §7wegen §a" + Grund)
+ }
+ }
+ }
+ if (Type.toUpperCase() == "KICK") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§e§l" + BannedName + " §7wurde von §c§l" + TeamName + " §cgekickt §7wegen §a" + Grund)
+ }
+ }
+ }
+ if (Type.toUpperCase() == "UNBAN") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§c§l" + TeamName + " §7hat §e§l" + BannedName + " §aentbannt")
+ }
+ }
+ }
+ if (Type.toUpperCase() == "UNBANIP") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§c§l" + TeamName + " §7hat die IP-Adresse §e§l" + BannedName + " §aentbannt")
+ }
+ }
+ }
+ if (Type.toUpperCase() == "UNMUTE") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§c§l" + TeamName + " §7hat §e§l" + BannedName + " §aentmutet")
+ }
+ }
+ }
+ if (Type.toUpperCase() == "REPORT") {
+ for (all in ProxyServer.getInstance().getPlayers()) {
+ if (all.hasPermission("professionalbans.notify") || all.hasPermission("professionalbans.*")) {
+ all.sendMessage(Main.prefix + "§c§l" + TeamName + " §7hat §e§l" + BannedName + " §7wegen §a" + Grund + " §7gemeldet")
+ }
+ }
+ }
+ }
+
+ fun getBans(uuid: UUID): Int {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getInt("BANS")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return 0
+ }
+
+ fun setBans(uuid: UUID, Bans: Int) {
+ if (playerExists(uuid)) {
+ Main.mysql.update("UPDATE bans SET BANS='$Bans' WHERE uuid='$uuid'")
+ }
+ }
+
+ fun getMutes(uuid: UUID): Int {
+ if (playerExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE uuid='$uuid'")
+ if (rs!!.next()) {
+ return rs.getInt("MUTES")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return 0
+ }
+
+ fun setMutes(uuid: UUID, Mutes: Int) {
+ if (playerExists(uuid)) {
+ Main.mysql.update("UPDATE bans SET MUTES='$Mutes' WHERE uuid='$uuid'")
+ }
+ }
+
+ fun countReasons(): Int? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons")
+ var i = 0
+ while (rs!!.next()) {
+ i++
+ }
+ return i
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun getReasonByID(Reason: Int): String {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$Reason'") ?: return "Nothing"
+ if (rs.next()) {
+ return rs.getString("REASON")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return "Nothing"
+ }
+
+ fun getReasonTime(ID: Int): Int? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$ID'")
+ if (rs!!.next()) {
+ return rs.getInt("TIME")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun isBanReason(ID: Int): Boolean {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$ID'")
+ if (rs!!.next()) {
+ return rs.getInt("TYPE") == 0
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return false
+ }
+
+ fun getReasonBans(ReasonID: Int): Int? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$ReasonID'")
+ if (rs!!.next()) {
+ return rs.getInt("BANS")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun setReasonBans(ReasonID: Int, Bans: Int) {
+ Main.mysql.update("UPDATE reasons SET BANS='$Bans' WHERE ID='$ReasonID'")
+ }
+
+ fun hasExtraPerms(ReasonID: Int): Boolean {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$ReasonID'")
+ if (rs!!.next()) {
+ return rs.getString("PERMS") != "null"
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return false
+ }
+
+ fun getExtraPerms(ReasonID: Int): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reasons WHERE ID='$ReasonID'")
+ if (rs!!.next()) {
+ return rs.getString("PERMS")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+
+ fun webaccountExists(uuid: UUID): Boolean {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM accounts WHERE UUID='$uuid'") ?: return false
+ if (rs.next()) {
+ return rs.getString("UUID") != null
+ }
+
+ } catch (exc: SQLException) {
+
+ }
+
+ return false
+
+ }
+
+ fun createWebAccount(uuid: UUID, Name: String, Rank: Int, PasswordHash: String) {
+ Main.mysql.update("INSERT INTO accounts(UUID, USERNAME, PASSWORD, RANK, GOOGLE_AUTH, AUTHCODE) " +
+ "VALUES ('" + uuid + "', '" + Name + "', '" + PasswordHash + "', '" + Rank + "', 'null', 'initialpassword')")
+ }
+
+ fun deleteWebAccount(uuid: UUID) {
+ Main.mysql.update("DELETE FROM accounts WHERE UUID='$uuid'")
+ }
+
+ fun isWebaccountAdmin(uuid: UUID): Boolean {
+ if (webaccountExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM accounts WHERE UUID='$uuid'")
+ if (rs!!.next()) {
+ return rs.getInt("RANK") == 3
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ } else {
+ return false
+ }
+ return false
+ }
+
+ fun hasAuthToken(uuid: UUID): Boolean {
+ if (webaccountExists(uuid)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM accounts WHERE UUID='$uuid'")
+ if (rs!!.next()) {
+ return rs.getString("AUTHCODE") !== "null"
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ } else {
+ return false
+ }
+ return false
+ }
+
+ fun getAuthCode(uuid: UUID): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM accounts WHERE UUID='$uuid'")
+ if (rs!!.next()) {
+ return rs.getString("AUTHCODE")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun updateAuthStatus(uuid: UUID) {
+ Main.mysql.update("UPDATE accounts SET AUTHSTATUS = 1 WHERE UUID = '$uuid'")
+ }
+
+ fun createReport(uuid: UUID, ReporterUUID: String, Reason: String, LogID: String?) {
+ Main.mysql.update("INSERT INTO reports(uuid, REPORTER, TEAM, REASON, LOG, STATUS, CREATED_AT) " +
+ "VALUES ('" + uuid + "', '" + ReporterUUID + "', 'null', '" + Reason + "', '" + LogID + "', '0', '" + System.currentTimeMillis() + "')")
+ }
+
+ fun countOpenReports(): Int {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE STATUS = 0")
+ var i = 0
+ while (rs!!.next()) {
+ i++
+ }
+ return i
+ } catch (exc: SQLException) {
+
+ }
+
+ return 0
+ }
+
+ fun getNameByReportID(ReportID: Int): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE ID='$ReportID'")
+ if (rs!!.next()) {
+ return getNameByUUID(UUID.fromString(rs.getString("UUID")))
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun getReasonByReportID(ReportID: Int): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE ID='$ReportID'")
+ if (rs!!.next()) {
+ return rs.getString("REASON")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun setReportDone(ID: Int) {
+ Main.mysql.update("UPDATE reports SET STATUS = 1 WHERE ID = $ID")
+ }
+
+ fun setReportTeamUUID(ID: Int, UUID: String) {
+ Main.mysql.update("UPDATE reports SET TEAM = '$UUID' WHERE ID = $ID")
+ }
+
+ fun isChatlogAvailable(ID: Int): Boolean {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE ID='$ID'")
+ if (rs!!.next()) {
+ return rs.getString("LOG") !== "null"
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return false
+ }
+
+ fun getChatlogbyReportID(ReportID: Int): String? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM reports WHERE ID='$ReportID'")
+ if (rs!!.next()) {
+ return rs.getString("LOG")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ private fun updateLastLogin(uuid: UUID) = Main.mysql.update("UPDATE bans SET LASTLOGIN = '" + System.currentTimeMillis() + "' WHERE uuid = '" + uuid + "'")
+
+ fun getLastLogin(uuid: UUID): String {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE UUID='$uuid'")
+ if (rs!!.next()) {
+ return rs.getString("LASTLOGIN")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return "None"
+ }
+
+ fun getFirstLogin(uuid: UUID): String {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM bans WHERE UUID='$uuid'") ?: return "none"
+ if (rs.next()) {
+ return rs.getString("FIRSTLOGIN")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return "none"
+ }
+
+ fun formatTimestamp(timestamp: Long): String {
+ val date = Date(timestamp)
+ val jdf = SimpleDateFormat("dd.MM.yyyy HH:mm")
+ return jdf.format(date)
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/utils/Functions.kt b/src/main/kotlin/de/tutorialwork/utils/Functions.kt
new file mode 100644
index 0000000..8e9bd02
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/Functions.kt
@@ -0,0 +1,20 @@
+package de.tutorialwork.utils
+
+import de.tutorialwork.main.Main
+import net.md_5.bungee.api.CommandSender
+import java.util.*
+
+
+fun UUID.exists(sender: CommandSender): Unit? {
+ val exists = BanManager.playerExists(this)
+ return if (exists) sender.sendMessage(Main.prefix + "§cDieser Spieler wurde nicht gefunden")
+ else null
+}
+
+fun String.getUUID(sender: CommandSender): UUID? {
+ val uuid = UUIDFetcher.getUUID(this)
+ return if (uuid != null) uuid else {
+ sender.sendMessage(Main.prefix + "§cDieser Spieler wurde nicht gefunden")
+ null
+ }
+}
diff --git a/src/main/kotlin/de/tutorialwork/utils/IPManager.kt b/src/main/kotlin/de/tutorialwork/utils/IPManager.kt
new file mode 100644
index 0000000..40ea83a
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/IPManager.kt
@@ -0,0 +1,240 @@
+package de.tutorialwork.utils
+
+import de.tutorialwork.main.Main
+import java.sql.SQLException
+import java.util.*
+
+object IPManager {
+
+ //ips(IP varchar(64) UNIQUE, USED_BY varchar(64), USED_AT varchar(64), BANNED int(11), REASON varchar(64), END long, TEAMUUID varchar(64), BANS int(11));
+
+ fun ipExists(IP: String): Boolean {
+ try {
+
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return rs.getString("IP") != null
+ }
+
+ } catch (exc: SQLException) {
+
+ }
+
+ return false
+
+ }
+
+ fun insertIP(IP: String, uuid: UUID) {
+ if (!ipExists(IP)) {
+ Main.mysql.update("INSERT INTO ips(IP, USED_BY, USED_AT, BANNED, REASON, END, TEAMUUID, BANS) " +
+ "VALUES ('" + IP + "', '" + uuid + "', '" + System.currentTimeMillis() + "', '0', 'null', 'null', 'null', '0')")
+ } else {
+ updateIPInfos(IP, uuid)
+ }
+ }
+
+ private fun updateIPInfos(IP: String, newUUID: UUID) {
+ if (ipExists(IP)) {
+ Main.mysql.update("UPDATE ips SET USED_BY = '" + newUUID + "', USED_AT='" + System.currentTimeMillis() + "' WHERE IP='" + IP + "'")
+ }
+ }
+
+ fun ban(IP: String, GrundID: Int, TeamUUID: String) {
+ val current = System.currentTimeMillis()
+ val end = current + BanManager.getReasonTime(GrundID)!! * 60000L
+ if (BanManager.getReasonTime(GrundID) == -1) {
+ //Perma Ban
+ Main.mysql.update("UPDATE ips SET BANNED='1', REASON='" + BanManager.getReasonByID(GrundID) + "', END='-1', TEAMUUID='" + TeamUUID + "' WHERE IP='" + IP + "'")
+ } else {
+ //Temp Ban
+ Main.mysql.update("UPDATE ips SET BANNED='1', REASON='" + BanManager.getReasonByID(GrundID) + "', END='" + end + "', TEAMUUID='" + TeamUUID + "' WHERE IP='" + IP + "'")
+ }
+ }
+
+
+ fun isBanned(IP: String): Boolean {
+ if (ipExists(IP)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return rs.getInt("BANNED") == 1
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return false
+ }
+
+ fun getReasonString(IP: String): String? {
+ if (ipExists(IP)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return rs.getString("REASON")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return null
+ }
+
+ fun getRAWEnd(IP: String): Long? {
+ if (ipExists(IP)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return rs.getLong("END")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return null
+ }
+
+ fun getEnd(UUID: String): String {
+ val uhrzeit = System.currentTimeMillis()
+ val end = getRAWEnd(UUID)!!
+
+ var millis = end - uhrzeit
+
+ var sekunden = 0L
+ var minuten = 0L
+ var stunden = 0L
+ var tage = 0L
+ while (millis > 1000L) {
+ millis -= 1000L
+ sekunden += 1L
+ }
+ while (sekunden > 60L) {
+ sekunden -= 60L
+ minuten += 1L
+ }
+ while (minuten > 60L) {
+ minuten -= 60L
+ stunden += 1L
+ }
+ while (stunden > 24L) {
+ stunden -= 24L
+ tage += 1L
+ }
+ return if (tage != 0L) {
+ "§a$tage §7Tag(e) §a$stunden §7Stunde(n) §a$minuten §7Minute(n)"
+ } else if (tage == 0L && stunden != 0L) {
+ "§a$stunden §7Stunde(n) §a$minuten §7Minute(n) §a$sekunden §7Sekunde(n)"
+ } else if (tage == 0L && stunden == 0L && minuten != 0L) {
+ "§a$minuten §7Minute(n) §a$sekunden §7Sekunde(n)"
+ } else if (tage == 0L && stunden == 0L && minuten == 0L && sekunden != 0L) {
+ "§a$sekunden §7Sekunde(n)"
+ } else {
+ "§4Fehler in der Berechnung!"
+ }
+ //Alter Code
+ //return "§a" + tage + " §7Tag(e) §a" + stunden + " §7Stunde(n) §a" + minuten + " §7Minute(n) §a" + sekunden + " §7Sekunde(n)";
+ }
+
+ fun unban(IP: String) {
+ if (ipExists(IP)) {
+ Main.mysql.update("UPDATE ips SET BANNED='0' WHERE IP='$IP'")
+ }
+ }
+
+ fun isVPN(IP: String): Boolean {
+ if (IP != "127.0.0.1") {
+ if (Main.APIKey != null) {
+ var json = Main.callURL("http://proxycheck.io/v2/" + IP + "?key=" + Main.APIKey)
+ json = json.replace("{\n" +
+ " \"status\": \"ok\",\n" +
+ " \"" + IP + "\": {\n" +
+ " \"proxy\": \"", "")
+ json = json.replace("\"\n" +
+ " }\n" +
+ "}", "")
+ return json == "yes"
+ } else {
+ var json = Main.callURL("http://proxycheck.io/v2/$IP?key=318n07-0o7054-y9y82a-75o3hr")
+ json = json.replace("{\n" +
+ " \"status\": \"ok\",\n" +
+ " \"" + IP + "\": {\n" +
+ " \"proxy\": \"", "")
+ json = json.replace("\"\n" +
+ " }\n" +
+ "}", "")
+ return json == "yes"
+ }
+ } else {
+ return false
+ }
+ }
+
+ fun getIPFromPlayer(uuid: UUID): String {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE USED_BY='$uuid'") ?: return ""
+ if (rs.next()) {
+ return rs.getString("IP")
+ }
+ } catch (exc: SQLException) {
+
+ }
+ return ""
+ }
+
+ fun getPlayerFromIP(IP: String): UUID? {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return UUID.fromString(rs.getString("USED_BY"))
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ return null
+ }
+
+ fun getBans(IP: String): Int? {
+ if (ipExists(IP)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return rs.getInt("BANS")
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return null
+ }
+
+ private fun setBans(IP: String, Bans: Int) {
+ if (ipExists(IP)) {
+ Main.mysql.update("UPDATE ips SET BANS='$Bans' WHERE IP='$IP'")
+ }
+ }
+
+ fun addBan(IP: String) {
+ setBans(IP, getBans(IP)!! + 1)
+ }
+
+ fun getLastUseLong(IP: String): Long {
+ if (ipExists(IP)) {
+ try {
+ val rs = Main.mysql.query("SELECT * FROM ips WHERE IP='$IP'")
+ if (rs!!.next()) {
+ return java.lang.Long.valueOf(rs.getString("USED_AT"))
+ }
+ } catch (exc: SQLException) {
+
+ }
+
+ }
+ return 0
+ }
+
+}
\ No newline at end of file
diff --git a/src/de/tutorialwork/utils/LogManager.java b/src/main/kotlin/de/tutorialwork/utils/LogManager.kt
similarity index 67%
rename from src/de/tutorialwork/utils/LogManager.java
rename to src/main/kotlin/de/tutorialwork/utils/LogManager.kt
index fa5ef85..02c2851 100644
--- a/src/de/tutorialwork/utils/LogManager.java
+++ b/src/main/kotlin/de/tutorialwork/utils/LogManager.kt
@@ -1,8 +1,8 @@
-package de.tutorialwork.utils;
+package de.tutorialwork.utils
-import de.tutorialwork.main.Main;
+import de.tutorialwork.main.Main
-public class LogManager {
+object LogManager {
//DATABASE STRUCTURE
//ID int(11) AUTO_INCREMENT UNIQUE, UUID varchar(255), BYUUID varchar(255), ACTION varchar(255), NOTE varchar(255), DATE varchar(255)
@@ -13,9 +13,9 @@ public class LogManager {
//
//UUID/BY_UUID = UUID des Spielers, null = keine Spieler verfügbar, "KONSOLE" = Befehl über Konsole ausgeführt
- public static void createEntry(String UUID, String ByUUID, String Action, String Note){
- Main.mysql.update("INSERT INTO log(UUID, BYUUID, ACTION, NOTE, DATE) " +
- "VALUES ('" + UUID + "', '" + ByUUID + "', '" + Action + "', '" + Note + "', '" + System.currentTimeMillis() + "')");
+ fun createEntry(uuid: String, ByUUID: String?, Action: String, Note: String?) {
+ Main.mysql.update("INSERT INTO log(uuid, BYUUID, ACTION, NOTE, DATE) " +
+ "VALUES ('" + uuid + "', '" + ByUUID + "', '" + Action + "', '" + Note + "', '" + System.currentTimeMillis() + "')")
}
-}
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/utils/MySQLConnect.kt b/src/main/kotlin/de/tutorialwork/utils/MySQLConnect.kt
new file mode 100644
index 0000000..1af42fe
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/MySQLConnect.kt
@@ -0,0 +1,76 @@
+package de.tutorialwork.utils
+
+import de.tutorialwork.console
+import de.tutorialwork.main.Main
+import java.sql.Connection
+import java.sql.DriverManager
+import java.sql.ResultSet
+import java.sql.SQLException
+
+class MySQLConnect(host: String, database: String, user: String, password: String) {
+
+ private var con: Connection? = null
+
+ init {
+ HOST = host
+ DATABASE = database
+ USER = user
+ PASSWORD = password
+
+ connect()
+ }
+
+ private fun connect() {
+ try {
+ con = DriverManager.getConnection("jdbc:mysql://$HOST:3306/$DATABASE?autoReconnect=true", USER, PASSWORD)
+ console.sendMessage(Main.prefix + "§aDie Verbindung mit der MySQL Datenbank wurde erfolgreich hergestellt")
+ } catch (e: SQLException) {
+ console.sendMessage(Main.prefix + "§cDie Verbindung mit der MySQL Datenbank ist fehlgeschlagen: §4" + e.message)
+ }
+
+ }
+
+ fun close() {
+ try {
+ if (con != null) {
+ con!!.close()
+ }
+ } catch (e: SQLException) {
+ }
+
+ }
+
+ fun update(qry: String) {
+ try {
+ val st = con!!.createStatement()
+ st.executeUpdate(qry)
+ st.close()
+ } catch (e: SQLException) {
+ connect()
+ System.err.println(e)
+ }
+
+ }
+
+ fun query(qry: String): ResultSet? {
+ var rs: ResultSet? = null
+
+ try {
+ val st = con!!.createStatement()
+ rs = st.executeQuery(qry)
+ } catch (e: SQLException) {
+ connect()
+ System.err.println(e)
+ }
+
+ return rs
+ }
+
+ companion object {
+
+ lateinit var HOST: String
+ lateinit var DATABASE: String
+ lateinit var USER: String
+ lateinit var PASSWORD: String
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/utils/UUIDFetcher.kt b/src/main/kotlin/de/tutorialwork/utils/UUIDFetcher.kt
new file mode 100644
index 0000000..b483925
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/UUIDFetcher.kt
@@ -0,0 +1,36 @@
+package de.tutorialwork.utils
+
+import com.google.gson.JsonParser
+import java.io.IOException
+import java.net.URL
+import java.util.*
+
+object UUIDFetcher {
+ private val uuidCache = mutableMapOf()
+
+ fun getUUID(username: String): UUID? {
+ if (uuidCache.containsKey(username)) return uuidCache[username]
+ try {
+ val url = URL("https://api.mojang.com/users/profiles/minecraft/$username")
+ val stream = url.openStream()
+
+ val result = stream.reader().readText()
+
+
+ val element = JsonParser().parse(result)
+ val obj = element.asJsonObject
+ var api = obj.get("id").toString()
+ .substring(1)
+ api = api.substring(0, api.length - 1)
+ val sbu = StringBuffer(api)
+ sbu.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
+ val uuid = UUID.fromString(sbu.toString())
+ uuidCache[username] = uuid
+ return uuid
+ } catch (localIOException: IOException) {
+ } catch (localIOException: IllegalStateException) {
+ }
+
+ return null
+ }
+}
\ No newline at end of file
diff --git a/src/plugin.yml b/src/main/resources/plugin.yml
similarity index 100%
rename from src/plugin.yml
rename to src/main/resources/plugin.yml