From d49de14fc093c75bd21684359e92c6d9fa6229ac Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:42:46 +0100 Subject: [PATCH 01/11] change(all): IntelliJ reformatting --- .github/workflows/codeql.yml | 54 ++--- .../dependency-reduced-pom.xml | 117 ++++----- BanSystem-SpigotChatAdapter/pom.xml | 4 +- .../spigotchatadapter/SpigotChatAdapter.java | 5 +- BanSystem-StatisticServer/pom.xml | 4 +- LICENSE.md | 140 +++++------ README.md | 93 +++++--- pom.xml | 4 +- .../bansystem/bungee/BanSystemBungee.java | 28 +-- .../bungee/listener/BungeeChatListener.java | 6 +- .../bungee/listener/BungeeLoginListener.java | 4 +- .../listener/BungeePluginMessageListener.java | 4 +- .../bansystem/bungee/util/BungeeUser.java | 2 +- .../coalcube/bansystem/core/BanSystem.java | 27 +++ .../bansystem/core/ban/BanManager.java | 37 ++- .../bansystem/core/ban/BanManagerMySQL.java | 40 ++-- .../bansystem/core/ban/BanManagerSQLite.java | 47 ++-- .../bansystem/core/command/CMDban.java | 36 +-- .../bansystem/core/command/CMDbansystem.java | 225 +++++++++--------- .../bansystem/core/command/CMDcheck.java | 2 +- .../core/command/CMDdeletehistory.java | 9 +- .../bansystem/core/command/CMDhistory.java | 8 +- .../bansystem/core/command/CMDkick.java | 12 +- .../bansystem/core/command/CMDunban.java | 2 +- .../bansystem/core/command/Command.java | 1 + .../bansystem/core/listener/ChatListener.java | 68 +++--- .../bansystem/core/listener/Event.java | 13 +- .../core/listener/LoginListener.java | 2 +- .../coalcube/bansystem/core/sql/Database.java | 8 +- .../coalcube/bansystem/core/sql/MySQL.java | 56 ++--- .../coalcube/bansystem/core/sql/SQLite.java | 14 +- .../core/textcomponent/TextComponent.java | 1 + .../textcomponent/TextComponentKyori.java | 18 +- .../core/textcomponent/TextComponentmd5.java | 2 +- .../bansystem/core/util/BlacklistUtil.java | 22 +- .../core/util/ConfigurationUtil.java | 14 +- .../coalcube/bansystem/core/util/History.java | 4 +- .../bansystem/core/util/IDManager.java | 28 +-- .../bansystem/core/util/ServerSocket.java | 4 +- .../bansystem/core/util/TimeFormatUtil.java | 16 +- .../coalcube/bansystem/core/util/URLUtil.java | 10 +- .../bansystem/core/util/UpdateChecker.java | 4 +- .../coalcube/bansystem/core/util/WebHook.java | 65 +++-- .../core/uuidfetcher/UUIDFetcher.java | 17 +- .../bansystem/spigot/BanSystemSpigot.java | 45 ++-- .../PlayerCommandPreprocessListener.java | 16 +- .../SpigotAsyncPlayerChatListener.java | 2 +- .../SpigotPlayerConnectionListener.java | 6 +- .../bansystem/spigot/util/SpigotUser.java | 4 +- .../bansystem/velocity/BanSystemVelocity.java | 53 +++-- .../bansystem/velocity/CommandWrapper.java | 1 + .../velocity/listener/VelocityChatEvent.java | 2 +- .../velocity/listener/VelocityLoginEvent.java | 5 +- .../velocity/util/VelocityConfig.java | 49 ++-- .../bansystem/velocity/util/VelocityUser.java | 8 +- src/main/resources/bungee.yml | 2 +- src/main/resources/plugin.yml | 2 +- 57 files changed, 785 insertions(+), 687 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c2b073d..a1d37c3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -47,38 +47,38 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml index 333c10c..d61b657 100644 --- a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml +++ b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml @@ -1,60 +1,61 @@ - - 4.0.0 - net.coalcube.bansystem - BanSystem-SpigotChatAdapter - BanSystem-SpigotChatAdapter - 1.0-SNAPSHOT - - - - true - src/main/resources - - - - - maven-compiler-plugin - 3.8.1 - - ${java.version} - ${java.version} - - - - maven-shade-plugin - 3.2.4 - - - package - - shade - - - - - - - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - sonatype - https://oss.sonatype.org/content/groups/public/ - - - - - org.spigotmc - spigot-api - 1.19-R0.1-SNAPSHOT - provided - - - - 1.8 - UTF-8 - + + 4.0.0 + net.coalcube.bansystem + BanSystem-SpigotChatAdapter + BanSystem-SpigotChatAdapter + 1.0-SNAPSHOT + + + + true + src/main/resources + + + + + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + + org.spigotmc + spigot-api + 1.19-R0.1-SNAPSHOT + provided + + + + 1.8 + UTF-8 + diff --git a/BanSystem-SpigotChatAdapter/pom.xml b/BanSystem-SpigotChatAdapter/pom.xml index 6a5acce..129457b 100644 --- a/BanSystem-SpigotChatAdapter/pom.xml +++ b/BanSystem-SpigotChatAdapter/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/BanSystem-SpigotChatAdapter/src/main/java/net/coalcube/bansystem/spigotchatadapter/SpigotChatAdapter.java b/BanSystem-SpigotChatAdapter/src/main/java/net/coalcube/bansystem/spigotchatadapter/SpigotChatAdapter.java index 4a9972b..720a425 100644 --- a/BanSystem-SpigotChatAdapter/src/main/java/net/coalcube/bansystem/spigotchatadapter/SpigotChatAdapter.java +++ b/BanSystem-SpigotChatAdapter/src/main/java/net/coalcube/bansystem/spigotchatadapter/SpigotChatAdapter.java @@ -8,6 +8,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; + import org.apache.commons.io.*; public final class SpigotChatAdapter extends JavaPlugin implements PluginMessageListener { @@ -15,7 +16,7 @@ public final class SpigotChatAdapter extends JavaPlugin implements PluginMessage private final String CHANNEL_NAME = "bansys:chatsign"; @Override - public void onEnable(){ + public void onEnable() { Bukkit.getMessenger().registerIncomingPluginChannel(this, CHANNEL_NAME, this); Bukkit.getConsoleSender().sendMessage("§8§l┃ §cBanSystem-ChatAdapter §8» §7Plugin wurde gestartet."); } @@ -26,7 +27,7 @@ public void onDisable() { } public void onPluginMessageReceived(String s, Player player, byte[] bytes) { - if(s.equalsIgnoreCase("bansys:chatsign")){ + if (s.equalsIgnoreCase("bansys:chatsign")) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); byteArrayInputStream.skip(2); try { diff --git a/BanSystem-StatisticServer/pom.xml b/BanSystem-StatisticServer/pom.xml index 158ab34..f6d0547 100644 --- a/BanSystem-StatisticServer/pom.xml +++ b/BanSystem-StatisticServer/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/LICENSE.md b/LICENSE.md index cba6f6a..74c892a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -204,23 +204,23 @@ produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: -- a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. -- b) The work must carry prominent notices stating that it is - released under this License and any conditions added under - section 7. This requirement modifies the requirement in section 4 - to "keep intact all notices". -- c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. -- d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. +- a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. +- b) The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in section 4 + to "keep intact all notices". +- c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. +- d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, @@ -239,42 +239,42 @@ sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: -- a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. -- b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the Corresponding - Source from a network server at no charge. -- c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. -- d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. -- e) Convey the object code using peer-to-peer transmission, - provided you inform other peers where the object code and - Corresponding Source of the work are being offered to the general - public at no charge under subsection 6d. +- a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. +- b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. +- c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. +- d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. +- e) Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the general + public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be @@ -350,23 +350,23 @@ Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: -- a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or -- b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or -- c) Prohibiting misrepresentation of the origin of that material, - or requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or -- d) Limiting the use for publicity purposes of names of licensors - or authors of the material; or -- e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or -- f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions - of it) with contractual assumptions of liability to the recipient, - for any liability that these contractual assumptions directly - impose on those licensors and authors. +- a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or +- b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or +- c) Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or +- d) Limiting the use for publicity purposes of names of licensors + or authors of the material; or +- e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or +- f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you diff --git a/README.md b/README.md index 5a4e44c..539c4b5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ # BanSystem + Ein umfangreiches Bestrafungssystem für Minecraft Server. Umfasst viele Funktionen und ist einfach zu bedienen. ## Anforderungen + - **mindestens Java 8** - **BungeeCord, Spigot oder Velocity Server** - MySQL Datenbank (optional) ## Funktionen + - **Ban, Mute & Kick** - **Chatfilter** - **Chatverzögerung** @@ -20,69 +23,87 @@ Ein umfangreiches Bestrafungssystem für Minecraft Server. Umfasst viele Funktio - **Geyser Support** ## Installation + 1. Lade dir das Plugin herunter. -2. Ziehe das Plugin in den Plugins-Ordner (bei Verwendung eines Proxys nur in den jeweiligen Plugins-Ordner ziehen **nicht in die Unterserver**). +2. Ziehe das Plugin in den Plugins-Ordner (bei Verwendung eines Proxys nur in den jeweiligen Plugins-Ordner ziehen * + *nicht in die Unterserver**). 3. Server starten. ### Ab der Version 1.19.1 + Wegen der **Chat-Signatur** ab dieser Version müssen zusätzliche Schritte gemacht werden. **BungeeCord** + 1. Die Option `signdChatBypass` in der `config.yml` auf `true` stellen. 2. Die beigelegte Datei `BanSystem-SpigotChatAdapter-X.X-SNAPSHOT.jar` auf den Unterservern installieren. **Velocity** -1. `SigndVelocity` für Velocity und den entsprechenden Backend-Server herunterladen (https://modrinth.com/plugin/signedvelocity). + +1. `SigndVelocity` für Velocity und den entsprechenden Backend-Server + herunterladen (https://modrinth.com/plugin/signedvelocity). 2. `SigndVelocity` installieren. ## Support + Discord Server: https://discord.gg/PfQTqhfjgA ## IP Handling -Wenn ein Spieler gebannt wird, dann wird die IP in der Datenbank gespeichert. Falls ein Spieler mit derselben IP den Server betritt, werden alle berechtigten Teammitglieder benachrichtigt, dass ein Spieler die gleiche IP wie ein gebannter Spieler hat. -Ob der Spieler gebannt werden soll oder nicht, wird selbst entschieden. Man kann allerdings auch einstellen, dass diese automatisch gebannt werden. + +Wenn ein Spieler gebannt wird, dann wird die IP in der Datenbank gespeichert. Falls ein Spieler mit derselben IP den +Server betritt, werden alle berechtigten Teammitglieder benachrichtigt, dass ein Spieler die gleiche IP wie ein +gebannter Spieler hat. +Ob der Spieler gebannt werden soll oder nicht, wird selbst entschieden. Man kann allerdings auch einstellen, dass diese +automatisch gebannt werden. ## ID System -Das ID System ist komplett variabel, d.h. man kann IDs abändern, entfernen und hinzufügen. Es lassen sich alle IDs mithilfe von `/ban` auflisten. Die Zeit ist in Sekunden gerechnet, z.B. ein Tag sind `86400 Sekunden` oder für ein Jahr `31536000 Sekunden`. -Für jede ID gibt es auch Level, d.h. wenn ein Spieler **zweimal** für den **gleichen Grund gebannt wird**, wird dieser **länger gebannt**, insofern ein zweites Level bei der ID angegeben wurde. + +Das ID System ist komplett variabel, d.h. man kann IDs abändern, entfernen und hinzufügen. Es lassen sich alle IDs +mithilfe von `/ban` auflisten. Die Zeit ist in Sekunden gerechnet, z.B. ein Tag sind `86400 Sekunden` oder für ein Jahr +`31536000 Sekunden`. +Für jede ID gibt es auch Level, d.h. wenn ein Spieler **zweimal** für den **gleichen Grund gebannt wird**, wird dieser * +*länger gebannt**, insofern ein zweites Level bei der ID angegeben wurde. Falls ein Spieler schon mal für alle Level gebannt wurde, wird dieser für das letzte Level nochmal gebannt. ## VPN-Check API-Key -Bei dem API-Key musst du nicht zwingend etwas eintragen, jedoch kann man sich bei [https://vpnapi.io/](https://vpnapi.io/) einen Account erstellen und erhält somit einen API-Key. Diesen wird benötigt, wenn auf dem Server mehr als 100 Leute am Tag beitreten. + +Bei dem API-Key musst du nicht zwingend etwas eintragen, jedoch kann man sich +bei [https://vpnapi.io/](https://vpnapi.io/) einen Account erstellen und erhält somit einen API-Key. Diesen wird +benötigt, wenn auf dem Server mehr als 100 Leute am Tag beitreten. ## Befehle und Rechte ### Befehlberechtigungen -| Befehl | Berechtigung | -|--------|--------------| -| `/bansystem` | `bansys.bansys` | -| `/bansystem reload` | `bansys.reload` | -| `/bansystem ids create ` | `bansys.ids.create` | -| `/bansystem ids delete ` | `bansys.ids.delete` | -| `/bansystem ids edit add lvl ` | `bansys.ids.addlvl` | -| `/bansystem ids edit remove lvl ` | `bansys.ids.removelvl` | -| `/bansystem ids edit set lvlduration ` | `bansys.ids.setduration` | -| `/bansystem ids edit set lvltype ` | `bansys.ids.settype` | -| `/bansystem ids edit set onlyadmins ` | `bansys.ids.setonlyadmins` | -| `/bansystem ids edit set reason ` | `bansys.ids.setreason` | -| `/bansystem ids show ` | `bansys.ids.show` | -| `/bansys logs show [site]` | `bansys.logs.show` | -| `/bansys logs clear` | `bansys.logs.clear` | -| `/ban ` | `bansys.ban(./.all/.admin)` | -| `/unban ` | `bansys.unban` | -| `/unmute ` | `bansys.unmute` | -| `/check ` | `bansys.check` | -| `/deletehistory ` | `bansys.history.delete` | -| `/history ` | `bansys.history.show` | -| `/kick [Grund]` | `bansys.kick(.admin)` | +| Befehl | Berechtigung | +|----------------------------------------------------------------------|---------------------------------| +| `/bansystem` | `bansys.bansys` | +| `/bansystem reload` | `bansys.reload` | +| `/bansystem ids create ` | `bansys.ids.create` | +| `/bansystem ids delete ` | `bansys.ids.delete` | +| `/bansystem ids edit add lvl ` | `bansys.ids.addlvl` | +| `/bansystem ids edit remove lvl ` | `bansys.ids.removelvl` | +| `/bansystem ids edit set lvlduration ` | `bansys.ids.setduration` | +| `/bansystem ids edit set lvltype ` | `bansys.ids.settype` | +| `/bansystem ids edit set onlyadmins ` | `bansys.ids.setonlyadmins` | +| `/bansystem ids edit set reason ` | `bansys.ids.setreason` | +| `/bansystem ids show ` | `bansys.ids.show` | +| `/bansys logs show [site]` | `bansys.logs.show` | +| `/bansys logs clear` | `bansys.logs.clear` | +| `/ban ` | `bansys.ban(./.all/.admin)` | +| `/unban ` | `bansys.unban` | +| `/unmute ` | `bansys.unmute` | +| `/check ` | `bansys.check` | +| `/deletehistory ` | `bansys.history.delete` | +| `/history ` | `bansys.history.show` | +| `/kick [Grund]` | `bansys.kick(.admin)` | ### Sonstige Berechtigungen -| Aktion | Berechtigung | -|--------|--------------| -| Team Benachrichtigungen | `bansys.notify` | -| Kick bypass | `bansys.kick.bypass` | -| Ban bypass | `bansys.ban.bypass` | -| Chatfilter bypass | `bansys.bypasschatfilter` | -| Chatdelay bypass | `bansys.bypasschatdelay` | +| Aktion | Berechtigung | +|-------------------------|---------------------------| +| Team Benachrichtigungen | `bansys.notify` | +| Kick bypass | `bansys.kick.bypass` | +| Ban bypass | `bansys.ban.bypass` | +| Chatfilter bypass | `bansys.bypasschatfilter` | +| Chatdelay bypass | `bansys.bypasschatdelay` | diff --git a/pom.xml b/pom.xml index 2b31b20..3417519 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/src/main/java/net/coalcube/bansystem/bungee/BanSystemBungee.java b/src/main/java/net/coalcube/bansystem/bungee/BanSystemBungee.java index 2ba38dc..760c983 100644 --- a/src/main/java/net/coalcube/bansystem/bungee/BanSystemBungee.java +++ b/src/main/java/net/coalcube/bansystem/bungee/BanSystemBungee.java @@ -35,7 +35,10 @@ public class BanSystemBungee extends Plugin implements BanSystem { + public static String prefix = "§8§l┃ §cBanSystem §8» §7"; private static Plugin instance; + private static List cachedBannedPlayerNames; + private static List cachedMutedPlayerNames; private BanManager banManager; private IDManager idManager; private URLUtil urlUtil; @@ -48,17 +51,17 @@ public class BanSystemBungee extends Plugin implements BanSystem { private net.coalcube.bansystem.core.textcomponent.TextComponent textComponent; private CommandSender console; private MetricsAdapter metricsAdapter; - - private static List cachedBannedPlayerNames; - private static List cachedMutedPlayerNames; private String hostname, database, user, pw; private int port; - public static String prefix = "§8§l┃ §cBanSystem §8» §7"; private String banScreen; private List blockedCommands, ads, blockedWords, whitelist; private File sqliteDatabase; private boolean isUpdateAvailable; + public static Plugin getInstance() { + return instance; + } + @Override public void onEnable() { super.onEnable(); @@ -122,9 +125,9 @@ public void onEnable() { console.sendMessage(new TextComponent(prefix + "§cDebug Message: §e" + e.getMessage())); } try { - if(mysql.isConnected()) { + if (mysql.isConnected()) { mysql.createTables(config); - if(mysql.isOldDatabase()) { + if (mysql.isOldDatabase()) { console.sendMessage(new TextComponent(prefix + "§7Die MySQL Daten vom dem alten BanSystem wurden §2importiert§7.")); } console.sendMessage(new TextComponent(prefix + "§7Die MySQL Tabellen wurden §2erstellt§7.")); @@ -134,7 +137,7 @@ public void onEnable() { e.printStackTrace(); } try { - if(mysql.isConnected()) { + if (mysql.isConnected()) { mysql.syncIDs(config); console.sendMessage(new TextComponent(prefix + "§7Die Ban IDs wurden §2synchronisiert§7.")); } @@ -194,8 +197,7 @@ public void onEnable() { init(pluginmanager); - - if(sql.isConnected()) { + if (sql.isConnected()) { try { sql.updateTables(); } catch (SQLException | ExecutionException | InterruptedException e) { @@ -442,9 +444,9 @@ public boolean isUpdateAvailable() { private void initCachedBannedPlayerNames() throws SQLException, ExecutionException, InterruptedException { new Thread(() -> { try { - for(Ban ban : banManager.getAllBans()) { + for (Ban ban : banManager.getAllBans()) { String name = UUIDFetcher.getName(ban.getPlayer()); - if(ban.getType() == Type.NETWORK) { + if (ban.getType() == Type.NETWORK) { cachedBannedPlayerNames.add(name); } else { cachedMutedPlayerNames.add(name); @@ -474,8 +476,4 @@ public User getConsole() { public String getVersion() { return this.getDescription().getVersion(); } - - public static Plugin getInstance() { - return instance; - } } diff --git a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeChatListener.java b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeChatListener.java index e7ea9ba..28a2e70 100644 --- a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeChatListener.java +++ b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeChatListener.java @@ -43,13 +43,13 @@ public void onChat(ChatEvent event) throws SQLException, IOException, ExecutionE Event chatEvent = chatListener.onChat(user, message); - if(chatEvent.isCancelled()) + if (chatEvent.isCancelled()) chatEvent.setCancelled(true); // send message to Spigot server to bypass the problem with chat signing. - if(!signedChatBypass) return; - if(event.isCommand() || event.isCancelled() || event.isProxyCommand()) return; + if (!signedChatBypass) return; + if (event.isCommand() || event.isCancelled() || event.isProxyCommand()) return; // experimental checking client version // if(player.getPendingConnection().getVersion() < 767) return; diff --git a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeLoginListener.java b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeLoginListener.java index a416555..03592e8 100644 --- a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeLoginListener.java +++ b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeeLoginListener.java @@ -47,7 +47,7 @@ public void onLogin(LoginEvent event) { event.registerIntent(BanSystemBungee.getInstance()); new Thread(() -> { Event loginEvent = loginListener.onJoin(uuid, username, ip); - if(loginEvent.isCancelled()) { + if (loginEvent.isCancelled()) { event.setCancelled(loginEvent.isCancelled()); event.setReason(new TextComponent(loginEvent.getCancelReason())); } @@ -62,7 +62,7 @@ public void onPostLogin(PostLoginEvent e) { try { Event postEvent = loginListener.onPostJoin(user, user.getAddress()); - if(postEvent.isCancelled()) { + if (postEvent.isCancelled()) { user.disconnect(postEvent.getCancelReason()); } } catch (SQLException | ExecutionException | InterruptedException ex) { diff --git a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeePluginMessageListener.java b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeePluginMessageListener.java index f78ea06..236fde8 100644 --- a/src/main/java/net/coalcube/bansystem/bungee/listener/BungeePluginMessageListener.java +++ b/src/main/java/net/coalcube/bansystem/bungee/listener/BungeePluginMessageListener.java @@ -8,8 +8,8 @@ public class BungeePluginMessageListener implements Listener { @EventHandler - public void onChat(PluginMessageEvent event){ - if(event.getSender() instanceof ProxiedPlayer && event.getTag().equalsIgnoreCase("bansys:chatsign")) + public void onChat(PluginMessageEvent event) { + if (event.getSender() instanceof ProxiedPlayer && event.getTag().equalsIgnoreCase("bansys:chatsign")) event.setCancelled(true); } diff --git a/src/main/java/net/coalcube/bansystem/bungee/util/BungeeUser.java b/src/main/java/net/coalcube/bansystem/bungee/util/BungeeUser.java index 730e51d..0950c95 100644 --- a/src/main/java/net/coalcube/bansystem/bungee/util/BungeeUser.java +++ b/src/main/java/net/coalcube/bansystem/bungee/util/BungeeUser.java @@ -29,7 +29,7 @@ public void sendMessage(TextComponent msg) { @Override public void disconnect(String message) { - if(sender instanceof ProxiedPlayer) + if (sender instanceof ProxiedPlayer) ((ProxiedPlayer) sender).disconnect(message); } diff --git a/src/main/java/net/coalcube/bansystem/core/BanSystem.java b/src/main/java/net/coalcube/bansystem/core/BanSystem.java index bd92d59..9714304 100644 --- a/src/main/java/net/coalcube/bansystem/core/BanSystem.java +++ b/src/main/java/net/coalcube/bansystem/core/BanSystem.java @@ -14,35 +14,62 @@ public interface BanSystem { BanSystem[] BANSYSTEM = new BanSystem[1]; + static BanSystem getInstance() { return BANSYSTEM[0]; } + static void setInstance(BanSystem bs) { BANSYSTEM[0] = bs; } + List getAllPlayers(); + User getConsole(); + String getVersion(); + void onEnable(); + void onDisable(); + String getEnvironment(); + User getUser(String name); + User getUser(UUID uniqueId); + void disconnect(User u, String msg); + void loadConfig(); + Database getSQL(); + TimeFormatUtil getTimeFormatUtil(); + String getBanScreen(); + ConfigurationUtil getConfigurationUtil(); + BanManager getBanManager(); + void sendConsoleMessage(String msg); + InputStream getResourceAsInputStream(String path); + List getCachedBannedPlayerNames(); + List getCachedMutedPlayerNames(); + void addCachedBannedPlayerNames(String name); + void addCachedMutedPlayerNames(String name); + void removeCachedBannedPlayerNames(String name); + void removeCachedMutedPlayerNames(String name); + MetricsAdapter getMetricsAdapter(); + boolean isUpdateAvailable(); } \ No newline at end of file diff --git a/src/main/java/net/coalcube/bansystem/core/ban/BanManager.java b/src/main/java/net/coalcube/bansystem/core/ban/BanManager.java index 672ca63..b695f23 100644 --- a/src/main/java/net/coalcube/bansystem/core/ban/BanManager.java +++ b/src/main/java/net/coalcube/bansystem/core/ban/BanManager.java @@ -15,50 +15,85 @@ public interface BanManager { Ban getBan(UUID player, Type type) throws SQLException, ExecutionException, InterruptedException; + Ban getBan(String id) throws SQLException, ExecutionException, InterruptedException; + List getAllBans() throws SQLException, ExecutionException, InterruptedException; + List getAllBans(Type type) throws SQLException, ExecutionException, InterruptedException; + void log(String action, String creator, String target, String note) throws SQLException; + Log getLog(int id) throws SQLException, ExecutionException, InterruptedException, ParseException; + List getAllLogs() throws SQLException, ExecutionException, InterruptedException, ParseException; + void clearLogs() throws SQLException; + void kick(UUID player, String creator) throws SQLException; + void kick(UUID player, UUID creator) throws SQLException; + void kick(UUID player, String creator, String reason) throws SQLException; + void kick(UUID player, UUID creator, String reason) throws SQLException; + Ban ban(UUID player, long time, UUID creator, Type type, String reason, InetAddress v4adress) throws IOException, SQLException, ExecutionException, InterruptedException; + Ban ban(UUID player, long time, UUID creator, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException; + Ban ban(UUID player, long time, String creator, Type type, String reason, InetAddress v4adress) throws IOException, SQLException, ExecutionException, InterruptedException; + Ban ban(UUID player, long time, String creator, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException; + void unBan(Ban ban, String unBanner, String reason) throws SQLException, ExecutionException, InterruptedException; + void unBan(Ban ban, UUID unBanner, String reason) throws SQLException, ExecutionException, InterruptedException; + void unBan(Ban ban, String unBanner) throws SQLException, ExecutionException, InterruptedException; + void unBan(Ban ban, UUID unBanner) throws SQLException, ExecutionException, InterruptedException; -// void unBan(UUID player, UUID unBanner, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException; + + // void unBan(UUID player, UUID unBanner, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException; // void unBan(UUID player, String unBanner, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException; // void unBan(UUID player, UUID unBanner, Type type) throws IOException, SQLException, ExecutionException, InterruptedException; // void unBan(UUID player, String unBanner, Type type) throws IOException, SQLException, ExecutionException, InterruptedException; void deleteHistory(UUID player) throws SQLException; + void setIP(UUID player, InetAddress address) throws SQLException; + void saveBedrockUser(UUID uuid, String username) throws SQLException; + //String getBanReason(UUID player, Type type) throws SQLException, ExecutionException, InterruptedException; //Long getEnd(UUID player, Type type) throws SQLException, ParseException, ExecutionException, InterruptedException; //String getBanner(UUID player, Type type) throws SQLException, ExecutionException, InterruptedException; //Long getRemainingTime(UUID player, Type type) throws SQLException, ParseException, ExecutionException, InterruptedException; //String getReason(UUID player, Type type) throws SQLException, ExecutionException, InterruptedException; int getLevel(UUID player, String reason) throws UnknownHostException, SQLException, ExecutionException, InterruptedException; + //Long getCreationDate(UUID player, Type type) throws SQLException, ParseException, ExecutionException, InterruptedException; List getHistory(UUID player) throws UnknownHostException, SQLException, ParseException, ExecutionException, InterruptedException; + List getBannedPlayersWithSameIP(InetAddress address) throws SQLException, ExecutionException, InterruptedException; + String getSavedBedrockUsername(UUID player) throws SQLException, ExecutionException, InterruptedException; + UUID getSavedBedrockUUID(String username) throws SQLException, ExecutionException, InterruptedException; + boolean hasHistory(UUID player) throws UnknownHostException, SQLException, ExecutionException, InterruptedException, ParseException; + boolean hasHistory(UUID player, String reason) throws UnknownHostException, SQLException, ExecutionException, InterruptedException; + boolean isSavedBedrockPlayer(UUID player) throws SQLException, ExecutionException, InterruptedException; + boolean isSavedBedrockPlayer(String username) throws SQLException, ExecutionException, InterruptedException; + //boolean isBanned(UUID player, Type type) throws SQLException, ExecutionException, InterruptedException; boolean isSetIP(UUID player) throws SQLException, ExecutionException, InterruptedException; + boolean isMaxBanLvl(String id, int lvl); + int getMaxLvl(String id); + String generateNewID() throws SQLException, ExecutionException, InterruptedException; } \ No newline at end of file diff --git a/src/main/java/net/coalcube/bansystem/core/ban/BanManagerMySQL.java b/src/main/java/net/coalcube/bansystem/core/ban/BanManagerMySQL.java index a601c16..52420cd 100644 --- a/src/main/java/net/coalcube/bansystem/core/ban/BanManagerMySQL.java +++ b/src/main/java/net/coalcube/bansystem/core/ban/BanManagerMySQL.java @@ -44,7 +44,7 @@ public Ban getBan(UUID player, Type type) throws SQLException, ExecutionExceptio id = ""; Date creationDate = null; - while(rs.next()) { + while (rs.next()) { id = rs.getString("id"); duration = rs.getLong("duration"); reason = rs.getString("reason"); @@ -68,7 +68,7 @@ public Ban getBan(String id) throws SQLException, ExecutionException, Interrupte UUID player = null; Type type = null; - while(rs.next()) { + while (rs.next()) { id = rs.getString("id"); duration = rs.getLong("duration"); reason = rs.getString("reason"); @@ -97,7 +97,7 @@ public List getAllBans() throws SQLException, ExecutionException, Interrupt UUID player = null; Type type = null; - while(rs.next()) { + while (rs.next()) { id = rs.getString("id"); duration = rs.getLong("duration"); reason = rs.getString("reason"); @@ -116,8 +116,8 @@ public List getAllBans() throws SQLException, ExecutionException, Interrupt @Override public List getAllBans(Type type) throws SQLException, ExecutionException, InterruptedException { List bans = new ArrayList<>(); - for(Ban ban : getAllBans()) { - if(ban.getType() == type) { + for (Ban ban : getAllBans()) { + if (ban.getType() == type) { bans.add(ban); } } @@ -133,7 +133,7 @@ public void log(String action, String creator, String target, String note) throw public Log getLog(int id) throws SQLException, ExecutionException, InterruptedException { ResultSet rs = mysql.getResult("SELECT * FROM `logs` WHERE id=" + id + ";"); Log log = null; - while(rs.next()) { + while (rs.next()) { String target, creator, action, note; Date date; @@ -154,7 +154,7 @@ public Log getLog(int id) throws SQLException, ExecutionException, InterruptedEx public List getAllLogs() throws SQLException, ExecutionException, InterruptedException { ResultSet rs = mysql.getResult("SELECT * FROM `logs` ORDER BY creationdate DESC;"); List logs = new ArrayList<>(); - while(rs.next()) { + while (rs.next()) { int id; String target, creator, action, note; Date date; @@ -211,7 +211,7 @@ public Ban ban(UUID player, long time, UUID creator, Type type, String reason) t public Ban ban(UUID player, long time, String creator, Type type, String reason, InetAddress v4adress) throws IOException, SQLException, ExecutionException, InterruptedException { String id = generateNewID(); - if(type == Type.NETWORK) + if (type == Type.NETWORK) BanSystem.getInstance().addCachedBannedPlayerNames(UUIDFetcher.getName(player)); else BanSystem.getInstance().addCachedMutedPlayerNames(UUIDFetcher.getName(player)); @@ -221,7 +221,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason, mysql.update("INSERT INTO `banhistories` (`id`, `player`, `duration`, `creator`, `reason`, `ip`, `type`, `creationdate`) " + "VALUES ('" + id + "', '" + player + "', '" + time + "', '" + creator + "', '" + reason + "', " + "'" + v4adress.getHostName() + "', '" + type + "', NOW());"); - if(type == Type.CHAT) { + if (type == Type.CHAT) { metricsAdapter.addCustomChart(new SimplePie("punishments", () -> { return "Mute"; })); @@ -235,7 +235,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason, public Ban ban(UUID player, long time, String creator, Type type, String reason) throws IOException, SQLException, ExecutionException, InterruptedException { String id = generateNewID(); - if(type == Type.NETWORK) + if (type == Type.NETWORK) BanSystem.getInstance().addCachedBannedPlayerNames(UUIDFetcher.getName(player)); else BanSystem.getInstance().addCachedMutedPlayerNames(UUIDFetcher.getName(player)); @@ -246,7 +246,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason) mysql.update("INSERT INTO `banhistories` (`id`, `player`, `duration`, `creator`, `reason`, `type`, `ip`,`creationdate`) " + "VALUES ('" + id + "', '" + player + "', '" + time + "', '" + creator + "', '" + reason + "', '" + type + "', '', NOW());"); - if(type == Type.CHAT) { + if (type == Type.CHAT) { BanSystem.getInstance().addCachedMutedPlayerNames(UUIDFetcher.getName(player)); metricsAdapter.addCustomChart(new SimplePie("punishments", () -> { return "Mute"; @@ -262,7 +262,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason) @Override public void unBan(Ban ban, String unBanner, String reason) throws SQLException, ExecutionException, InterruptedException { - if(ban.getType() == Type.NETWORK) + if (ban.getType() == Type.NETWORK) BanSystem.getInstance().removeCachedBannedPlayerNames(UUIDFetcher.getName(ban.getPlayer())); else BanSystem.getInstance().removeCachedMutedPlayerNames(UUIDFetcher.getName(ban.getPlayer())); @@ -393,7 +393,7 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc List list = new ArrayList<>(); while (resultSet.next()) { InetAddress ip; - if(resultSet.getString("ip") == null || resultSet.getString("ip").isEmpty()) { + if (resultSet.getString("ip") == null || resultSet.getString("ip").isEmpty()) { ip = null; } else { ip = InetAddress.getByName(resultSet.getString("ip")); @@ -412,7 +412,7 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc resultSet = mysql.getResult("SELECT * FROM `kicks` WHERE player = '" + player + "';"); while (resultSet.next()) { HistoryType historyType = HistoryType.KICK; - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.KICKWITHREASON; list.add(new History(historyType, UUID.fromString(resultSet.getString("player")), @@ -428,11 +428,11 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc while (resultSet.next()) { Type type = Type.valueOf(resultSet.getString("type")); HistoryType historyType = HistoryType.UNBAN; - if(type == Type.NETWORK) { - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (type == Type.NETWORK) { + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.UNBANWITHREASON; } else { - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.UNMUTEWITHREASON; else historyType = HistoryType.UNMUTE; @@ -558,15 +558,15 @@ public String generateNewID() throws SQLException, ExecutionException, Interrupt String uuid = UUID.randomUUID().toString(); String id = ""; int i = 0; - for(String character : uuid.split("")) { - if(i >= 5) { + for (String character : uuid.split("")) { + if (i >= 5) { break; } id = id + character; i++; } ResultSet rs = mysql.getResult("SELECT id FROM `banhistories` WHERE id='" + id + "'"); - while(rs.next()) { + while (rs.next()) { return generateNewID(); } diff --git a/src/main/java/net/coalcube/bansystem/core/ban/BanManagerSQLite.java b/src/main/java/net/coalcube/bansystem/core/ban/BanManagerSQLite.java index a00fe19..59ef7a5 100644 --- a/src/main/java/net/coalcube/bansystem/core/ban/BanManagerSQLite.java +++ b/src/main/java/net/coalcube/bansystem/core/ban/BanManagerSQLite.java @@ -27,9 +27,9 @@ public class BanManagerSQLite implements BanManager { private final SQLite sqlite; - SimpleDateFormat simpleDateFormat; private final YamlDocument config; private final MetricsAdapter metricsAdapter; + SimpleDateFormat simpleDateFormat; public BanManagerSQLite(SQLite sqlite, YamlDocument config) { this.sqlite = sqlite; @@ -49,7 +49,7 @@ public Ban getBan(UUID player, Type type) throws SQLException, ExecutionExceptio id = ""; Date creationDate = null; - while(rs.next()) { + while (rs.next()) { duration = rs.getLong("duration"); reason = rs.getString("reason"); creator = rs.getString("creator"); @@ -74,7 +74,7 @@ public Ban getBan(String id) throws SQLException, ExecutionException, Interrupte UUID player = null; Type type = null; - while(rs.next()) { + while (rs.next()) { id = rs.getString("id"); duration = rs.getLong("duration"); reason = rs.getString("reason"); @@ -103,7 +103,7 @@ public List getAllBans() throws SQLException, ExecutionException, Interrupt UUID player = null; Type type = null; - while(rs.next()) { + while (rs.next()) { id = rs.getString("id"); duration = rs.getLong("duration"); reason = rs.getString("reason"); @@ -122,8 +122,8 @@ public List getAllBans() throws SQLException, ExecutionException, Interrupt @Override public List getAllBans(Type type) throws SQLException, ExecutionException, InterruptedException { List bans = new ArrayList<>(); - for(Ban ban : getAllBans()) { - if(ban.getType() == type) { + for (Ban ban : getAllBans()) { + if (ban.getType() == type) { bans.add(ban); } } @@ -139,7 +139,7 @@ public void log(String action, String creator, String target, String note) throw public Log getLog(int id) throws SQLException, ExecutionException, InterruptedException, ParseException { ResultSet rs = sqlite.getResult("SELECT * FROM `logs` WHERE id=" + id + ";"); Log log = null; - while(rs.next()) { + while (rs.next()) { String target, creator, action, note; Date date; @@ -160,7 +160,7 @@ public Log getLog(int id) throws SQLException, ExecutionException, InterruptedEx public List getAllLogs() throws SQLException, ExecutionException, InterruptedException, ParseException { ResultSet rs = sqlite.getResult("SELECT * FROM `logs` ORDER BY creationdate DESC;"); List logs = new ArrayList<>(); - while(rs.next()) { + while (rs.next()) { int id; String target, creator, action, note; Date date; @@ -184,6 +184,7 @@ public List getAllLogs() throws SQLException, ExecutionException, Interrupt public void clearLogs() throws SQLException { sqlite.update("DELETE FROM logs;"); } + public void kick(UUID player, String creator) throws SQLException { kick(player, creator, ""); } @@ -221,7 +222,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason, sqlite.update("INSERT INTO `banhistories` (`id`, `player`, `duration`, `creator`, `reason`, `ip`, `type`, `creationdate`) " + "VALUES ('" + id + "', '" + player + "', '" + time + "', '" + creator + "', '" + reason + "', " + "'" + v4adress.getHostName() + "', '" + type + "', datetime('now', 'localtime'));"); - if(type == Type.CHAT) { + if (type == Type.CHAT) { BanSystem.getInstance().addCachedMutedPlayerNames(UUIDFetcher.getName(player)); metricsAdapter.addCustomChart(new SimplePie("punishments", () -> { return "Mute"; @@ -244,7 +245,7 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason) sqlite.update("INSERT INTO `banhistories` (`id`, `player`, `duration`, `creator`, `reason`, `type`, `ip`,`creationdate`) " + "VALUES ('" + id + "', '" + player + "', '" + time + "', '" + creator + "', '" + reason + "', '" + type + "', '', datetime('now', 'localtime'));"); - if(type == Type.CHAT) { + if (type == Type.CHAT) { BanSystem.getInstance().addCachedMutedPlayerNames(UUIDFetcher.getName(player)); metricsAdapter.addCustomChart(new SimplePie("punishments", () -> { return "Mute"; @@ -262,8 +263,8 @@ public Ban ban(UUID player, long time, String creator, Type type, String reason) public void unBan(Ban ban, String unBanner, String reason) throws SQLException, ExecutionException, InterruptedException { sqlite.update("DELETE FROM `bans` WHERE id = '" + ban.getId() + "';"); sqlite.update("INSERT INTO `unbans` (`id`, `player`, `unbanner`, `creationdate`, `reason`, `type`) " + - "VALUES ('" + ban.getId() + "', '" + ban.getPlayer() + "', '" + unBanner + "', datetime('now', 'localtime'), '" + reason + "','" + ban.getType() +"');"); - if(ban.getType() == Type.NETWORK) + "VALUES ('" + ban.getId() + "', '" + ban.getPlayer() + "', '" + unBanner + "', datetime('now', 'localtime'), '" + reason + "','" + ban.getType() + "');"); + if (ban.getType() == Type.NETWORK) BanSystem.getInstance().removeCachedBannedPlayerNames(UUIDFetcher.getName(ban.getPlayer())); else BanSystem.getInstance().removeCachedMutedPlayerNames(UUIDFetcher.getName(ban.getPlayer())); @@ -315,7 +316,7 @@ public Long getEnd(UUID player, Type type) throws SQLException, ParseException { while (resultSet.next()) { Long duration = resultSet.getLong("duration"); - return (duration == -1) ? duration : getCreationDate(player, type) + duration ; + return (duration == -1) ? duration : getCreationDate(player, type) + duration; } return null; } @@ -342,10 +343,10 @@ public String getReason(UUID player, Type type) throws SQLException { public int getLevel(UUID player, String reason) throws UnknownHostException, SQLException { int lvl = 0; - if(hasHistory(player, reason)) { + if (hasHistory(player, reason)) { ResultSet resultSet = sqlite.getResult("SELECT * FROM `banhistories` WHERE player = '" + player + "' AND reason = '" + reason + "';"); while (resultSet.next()) { - lvl ++; + lvl++; } } return lvl; @@ -365,7 +366,7 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc List list = new ArrayList<>(); while (resultSet.next()) { InetAddress ip; - if(resultSet.getString("ip") == null || resultSet.getString("ip").isEmpty()) { + if (resultSet.getString("ip") == null || resultSet.getString("ip").isEmpty()) { ip = null; } else { ip = InetAddress.getByName(resultSet.getString("ip")); @@ -385,7 +386,7 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc resultSet = sqlite.getResult("SELECT * FROM `kicks` WHERE player = '" + player + "';"); while (resultSet.next()) { HistoryType historyType = HistoryType.KICK; - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.KICKWITHREASON; list.add(new History(historyType, UUID.fromString(resultSet.getString("player")), @@ -401,11 +402,11 @@ public List getHistory(UUID player) throws UnknownHostException, SQLExc while (resultSet.next()) { Type type = Type.valueOf(resultSet.getString("type")); HistoryType historyType = HistoryType.UNBAN; - if(type == Type.NETWORK) { - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (type == Type.NETWORK) { + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.UNBANWITHREASON; } else { - if(resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) + if (resultSet.getString("reason") != null && !resultSet.getString("reason").isEmpty()) historyType = HistoryType.UNMUTEWITHREASON; else historyType = HistoryType.UNMUTE; @@ -531,15 +532,15 @@ public String generateNewID() throws SQLException, ExecutionException, Interrupt String uuid = UUID.randomUUID().toString(); String id = ""; int i = 0; - for(String character : uuid.split("")) { - if(i >= 5) { + for (String character : uuid.split("")) { + if (i >= 5) { break; } id = id + character; i++; } ResultSet rs = sqlite.getResult("SELECT id FROM `banhistories` WHERE id='" + id + "'"); - while(rs.next()) { + while (rs.next()) { return generateNewID(); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDban.java b/src/main/java/net/coalcube/bansystem/core/command/CMDban.java index 8a9c09b..69ad4bc 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDban.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDban.java @@ -101,14 +101,14 @@ public void execute(User user, String[] args) { if (args.length == 2) { // Set name and uuid - if(BanSystem.getInstance().getUser(args[0]).getUniqueId() != null) { + if (BanSystem.getInstance().getUser(args[0]).getUniqueId() != null) { uuid = BanSystem.getInstance().getUser(args[0]).getUniqueId(); name = BanSystem.getInstance().getUser(args[0]).getName(); } else { try { uuid = UUID.fromString(args[0]); - if(UUIDFetcher.getName(uuid) == null) { - if(banmanager.isSavedBedrockPlayer(uuid)) { + if (UUIDFetcher.getName(uuid) == null) { + if (banmanager.isSavedBedrockPlayer(uuid)) { name = banmanager.getSavedBedrockUsername(uuid); uuid = banmanager.getSavedBedrockUUID(name); } @@ -116,9 +116,9 @@ public void execute(User user, String[] args) { name = UUIDFetcher.getName(uuid); } } catch (IllegalArgumentException exception) { - if(UUIDFetcher.getUUID(args[0].replaceAll("&", "§")) == null) { + if (UUIDFetcher.getUUID(args[0].replaceAll("&", "§")) == null) { try { - if(banmanager.isSavedBedrockPlayer(args[0].replaceAll("&", "§"))) { + if (banmanager.isSavedBedrockPlayer(args[0].replaceAll("&", "§"))) { uuid = banmanager.getSavedBedrockUUID(args[0].replaceAll("&", "§")); name = banmanager.getSavedBedrockUsername(uuid); } else @@ -147,7 +147,7 @@ public void execute(User user, String[] args) { } // cannot ban yourself - if(user.getUniqueId() != null && user.getUniqueId().equals(uuid)) { + if (user.getUniqueId() != null && user.getUniqueId().equals(uuid)) { user.sendMessage(configurationUtil.getMessage("Ban.cannotban.yourself")); return; } @@ -173,7 +173,7 @@ public void execute(User user, String[] args) { if (user.hasPermission("bansys.ban." + args[1]) || user.hasPermission("bansys.ban.all") || user.hasPermission("bansys.ban.admin")) { String formattedEndDate; - if(endDate != null) { + if (endDate != null) { formattedEndDate = simpleDateFormat.format(endDate); } else formattedEndDate = "§4§lPERMANENT"; @@ -209,8 +209,8 @@ public void execute(User user, String[] args) { else ban = banmanager.ban(uuid, duration, creator, type, reason); - banmanager.log("Banned Player", creator, uuid.toString(), "banID: " + ban.getId() - + "; reason: "+reason+"; lvl: "+lvl); + banmanager.log("Banned Player", creator, uuid.toString(), "banID: " + ban.getId() + + "; reason: " + reason + "; lvl: " + lvl); } catch (ExecutionException | InterruptedException | IOException | SQLException e) { user.sendMessage(configurationUtil.getMessage("Ban.failed")); throw new RuntimeException(e); @@ -220,13 +220,13 @@ public void execute(User user, String[] args) { if (BanSystem.getInstance().getUser(name).getUniqueId() != null) { User target = BanSystem.getInstance().getUser(name.replaceAll("&", "§")); - if((target.hasPermission("bansys.ban") || target.hasPermission("bansys.ban.all") || hasPermissionForAnyID(target)) + if ((target.hasPermission("bansys.ban") || target.hasPermission("bansys.ban.all") || hasPermissionForAnyID(target)) && !user.hasPermission("bansys.ban.admin")) { user.sendMessage(configurationUtil.getMessage("Ban.cannotban.teammembers")); return; } - if(target.hasPermission("bansys.ban.admin") && user.getUniqueId() != null) { + if (target.hasPermission("bansys.ban.admin") && user.getUniqueId() != null) { user.sendMessage(configurationUtil.getMessage("Ban.cannotban.teammembers")); return; } @@ -275,12 +275,12 @@ public void execute(User user, String[] args) { .replaceAll("%enddate%", formattedEndDate) .replaceAll("%id%", ban.getId()); - if(user.getUniqueId() != null) + if (user.getUniqueId() != null) user.sendMessage(banSuccess); else BanSystem.getInstance().sendConsoleMessage(banSuccess); - if(user.getUniqueId() != null) { + if (user.getUniqueId() != null) { BanSystem.getInstance().sendConsoleMessage(configurationUtil.getMessage("Ban.notify") .replaceAll("%player%", Objects.requireNonNull(name)) .replaceAll("%reason%", reason) @@ -329,12 +329,12 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); - if(args.length == 0 || args.length == 1) { - for(User player : players) { + if (args.length == 0 || args.length == 1) { + for (User player : players) { suggests.add(player.getName()); } - } else if(args.length == 2) { + } else if (args.length == 2) { for (Object key : config.getSection("IDs").getKeys()) { suggests.add(key.toString()); } @@ -371,7 +371,7 @@ private void setParameters(User user, String[] args) throws UnknownHostException // set lvl try { if (!banmanager.isMaxBanLvl(args[1], banmanager.getLevel(uuid, reason))) { - lvl = banmanager.getLevel(uuid, reason)+1; + lvl = banmanager.getLevel(uuid, reason) + 1; } else { lvl = banmanager.getMaxLvl(args[1]); } @@ -395,7 +395,7 @@ private void setParameters(User user, String[] args) throws UnknownHostException } - if(duration != -1) { + if (duration != -1) { endDate = new Date(System.currentTimeMillis() + duration); } else { endDate = null; diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java b/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java index 3f3af96..50df792 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java @@ -107,7 +107,7 @@ public void execute(User user, String[] args) { } else user.sendMessage(configurationUtil.getMessage("bansystem.usage.syncids")); } else if (args[0].equalsIgnoreCase("ids")) { - if(args.length < 2) { + if (args.length < 2) { sendHelp(user); return; } @@ -141,7 +141,7 @@ public void execute(User user, String[] args) { return; } - for(int i=6; i= 2) { + if (args.length >= 2) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM.yy HH:mm"); List allLogs; int maxPage, page; @@ -647,12 +648,12 @@ public void execute(User user, String[] args) { maxPage = (int) Math.ceil((double) allLogs.size() / 10); - if(allLogs.isEmpty()) { + if (allLogs.isEmpty()) { user.sendMessage(configurationUtil.getMessage("bansystem.logs.show.empty")); return; } - if(args.length == 2) { + if (args.length == 2) { page = 1; } else { try { @@ -662,7 +663,7 @@ public void execute(User user, String[] args) { .replaceAll("%maxpage%", String.valueOf(maxPage))); return; } - if(page > maxPage) { + if (page > maxPage) { user.sendMessage(configurationUtil.getMessage("bansystem.logs.show.pageNotFound") .replaceAll("%maxpage%", String.valueOf(maxPage))); return; @@ -672,9 +673,9 @@ public void execute(User user, String[] args) { user.sendMessage(configurationUtil.getMessage("bansystem.logs.show.header")); int row; - for(int i=0; i<10; i++) { - row = page*10-10+i; - if(allLogs.size() > row) { + for (int i = 0; i < 10; i++) { + row = page * 10 - 10 + i; + if (allLogs.size() > row) { Log log = allLogs.get(row); String creator = log.getCreator(); @@ -688,7 +689,7 @@ public void execute(User user, String[] args) { } try { UUID targetID = UUID.fromString(target); - if(UUIDFetcher.getName(targetID) != null) + if (UUIDFetcher.getName(targetID) != null) target = UUIDFetcher.getName(targetID); } catch (IllegalArgumentException ignored) { } @@ -707,8 +708,8 @@ public void execute(User user, String[] args) { textComponent.sendLogsFooter(user, page, maxPage); } - } else if(args[1].equalsIgnoreCase("clear")) { - if(!user.hasPermission("bansys.logs.clear")) { + } else if (args[1].equalsIgnoreCase("clear")) { + if (!user.hasPermission("bansys.logs.clear")) { user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); return; } @@ -748,48 +749,48 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); - if(args.length == 0 || args.length == 1) { - if(user.hasPermission("bansys.reload")) { + if (args.length == 0 || args.length == 1) { + if (user.hasPermission("bansys.reload")) { suggests.add("reload"); } - if(user.hasPermission("bansys.ids.create") || - user.hasPermission("bansys.ids.delete") || - user.hasPermission("bansys.ids.addlvl") || - user.hasPermission("bansys.ids.removelvl") || - user.hasPermission("bansys.ids.setduration") || - user.hasPermission("bansys.ids.settype") || - user.hasPermission("bansys.ids.setonlyadmins") || - user.hasPermission("bansys.ids.setreason") || - user.hasPermission("bansys.ids.show")) { + if (user.hasPermission("bansys.ids.create") || + user.hasPermission("bansys.ids.delete") || + user.hasPermission("bansys.ids.addlvl") || + user.hasPermission("bansys.ids.removelvl") || + user.hasPermission("bansys.ids.setduration") || + user.hasPermission("bansys.ids.settype") || + user.hasPermission("bansys.ids.setonlyadmins") || + user.hasPermission("bansys.ids.setreason") || + user.hasPermission("bansys.ids.show")) { suggests.add("ids"); } - if(user.hasPermission("bansys.logs.show") - || user.hasPermission("bansys.logs.clear")) { + if (user.hasPermission("bansys.logs.show") + || user.hasPermission("bansys.logs.clear")) { suggests.add("logs"); } - if(user.hasPermission("bansys.syncids")) { + if (user.hasPermission("bansys.syncids")) { suggests.add("syncids"); } suggests.add("help"); suggests.add("version"); suggests.add("ver"); - } else if(args.length == 2) { - if(args[0].equalsIgnoreCase("logs")) { - if(user.hasPermission("bansys.logs.show")) { + } else if (args.length == 2) { + if (args[0].equalsIgnoreCase("logs")) { + if (user.hasPermission("bansys.logs.show")) { suggests.add("show"); } - if(user.hasPermission("bansys.logs.clear")) { + if (user.hasPermission("bansys.logs.clear")) { suggests.add("clear"); } } - if(args[0].equalsIgnoreCase("ids")) { - if(user.hasPermission("bansys.ids.create")) { + if (args[0].equalsIgnoreCase("ids")) { + if (user.hasPermission("bansys.ids.create")) { suggests.add("create"); } - if(user.hasPermission("bansys.ids.delete")) { + if (user.hasPermission("bansys.ids.delete")) { suggests.add("delete"); } - if(user.hasPermission("bansys.ids.addlvl") || + if (user.hasPermission("bansys.ids.addlvl") || user.hasPermission("bansys.ids.removelvl") || user.hasPermission("bansys.ids.setduration") || user.hasPermission("bansys.ids.settype") || @@ -797,15 +798,15 @@ public List suggest(User user, String[] args) { user.hasPermission("bansys.ids.setreason")) { suggests.add("edit"); } - if(user.hasPermission("bansys.ids.show")) { + if (user.hasPermission("bansys.ids.show")) { suggests.add("show"); } } - } else if(args.length == 3) { - if(args[1].equalsIgnoreCase("edit") || + } else if (args.length == 3) { + if (args[1].equalsIgnoreCase("edit") || args[1].equalsIgnoreCase("delete") || args[1].equalsIgnoreCase("show")) { - if(user.hasPermission("bansys.ids.create") || + if (user.hasPermission("bansys.ids.create") || user.hasPermission("bansys.ids.delete") || user.hasPermission("bansys.ids.addlvl") || user.hasPermission("bansys.ids.removelvl") || @@ -818,9 +819,9 @@ public List suggest(User user, String[] args) { } } } - if(args[0].equalsIgnoreCase("logs")) { - if(args[1].equalsIgnoreCase("show")) { - if(user.hasPermission("bansys.logs.show")) { + if (args[0].equalsIgnoreCase("logs")) { + if (args[1].equalsIgnoreCase("show")) { + if (user.hasPermission("bansys.logs.show")) { try { List allLogs = banManager.getAllLogs(); int maxPage = (int) Math.ceil((double) allLogs.size() / 10); @@ -834,21 +835,21 @@ public List suggest(User user, String[] args) { } } - } else if(args.length == 4) { - if(args[0].equalsIgnoreCase("ids")) { - if(args[1].equalsIgnoreCase("create")) { + } else if (args.length == 4) { + if (args[0].equalsIgnoreCase("ids")) { + if (args[1].equalsIgnoreCase("create")) { if (user.hasPermission("bansys.ids.create")) { suggests.add("NETWORK"); suggests.add("CHAT"); } - } else if(args[1].equalsIgnoreCase("edit")) { - if(user.hasPermission("bansys.ids.addlvl")) { + } else if (args[1].equalsIgnoreCase("edit")) { + if (user.hasPermission("bansys.ids.addlvl")) { suggests.add("add"); } - if(user.hasPermission("bansys.ids.removelvl")) { + if (user.hasPermission("bansys.ids.removelvl")) { suggests.add("remove"); } - if(user.hasPermission("bansys.ids.setduration") || + if (user.hasPermission("bansys.ids.setduration") || user.hasPermission("bansys.ids.settype") || user.hasPermission("bansys.ids.setonlyadmins") || user.hasPermission("bansys.ids.setreason")) { @@ -856,65 +857,65 @@ public List suggest(User user, String[] args) { } } } - } else if(args.length == 5) { - if(args[0].equalsIgnoreCase("ids")) { + } else if (args.length == 5) { + if (args[0].equalsIgnoreCase("ids")) { if (args[1].equalsIgnoreCase("create")) { - if(user.hasPermission("bansys.ids.create")) { + if (user.hasPermission("bansys.ids.create")) { suggests.add("true"); suggests.add("false"); } } if (args[1].equalsIgnoreCase("edit")) { - if(args[3].equalsIgnoreCase("add")) { - if(user.hasPermission("bansys.ids.addlvl")) { + if (args[3].equalsIgnoreCase("add")) { + if (user.hasPermission("bansys.ids.addlvl")) { suggests.add("lvl"); } } - if(args[3].equalsIgnoreCase("remove")) { - if(user.hasPermission("bansys.ids.removelvl")) { + if (args[3].equalsIgnoreCase("remove")) { + if (user.hasPermission("bansys.ids.removelvl")) { suggests.add("lvl"); } } - if(args[3].equalsIgnoreCase("set")) { - if(user.hasPermission("bansys.ids.setduration")) { + if (args[3].equalsIgnoreCase("set")) { + if (user.hasPermission("bansys.ids.setduration")) { suggests.add("lvlduration"); } - if(user.hasPermission("bansys.ids.settype")) { + if (user.hasPermission("bansys.ids.settype")) { suggests.add("lvltype"); } - if(user.hasPermission("bansys.ids.setonlyadmins")) { + if (user.hasPermission("bansys.ids.setonlyadmins")) { suggests.add("onlyadmins"); } - if(user.hasPermission("bansys.ids.setreason")) { + if (user.hasPermission("bansys.ids.setreason")) { suggests.add("reason"); } } } } - } else if(args.length == 6) { - if(args[0].equalsIgnoreCase("ids")) { - if(args[1].equalsIgnoreCase("edit")) { - if(args[3].equalsIgnoreCase("remove")) { - if(user.hasPermission("bansys.ids.removelvl")) { + } else if (args.length == 6) { + if (args[0].equalsIgnoreCase("ids")) { + if (args[1].equalsIgnoreCase("edit")) { + if (args[3].equalsIgnoreCase("remove")) { + if (user.hasPermission("bansys.ids.removelvl")) { for (Object key : config.getSection("IDs." + args[2] + ".lvl").getKeys()) { suggests.add(key.toString()); } } - } else if(args[3].equalsIgnoreCase("set")) { - if(args[4].equalsIgnoreCase("lvlduration")) { - if(user.hasPermission("bansys.ids.setduration")) { + } else if (args[3].equalsIgnoreCase("set")) { + if (args[4].equalsIgnoreCase("lvlduration")) { + if (user.hasPermission("bansys.ids.setduration")) { for (Object key : config.getSection("IDs." + args[2] + ".lvl").getKeys()) { suggests.add(key.toString()); } } - } else if(args[4].equalsIgnoreCase("lvltype")) { - if(user.hasPermission("bansys.ids.settype")) { + } else if (args[4].equalsIgnoreCase("lvltype")) { + if (user.hasPermission("bansys.ids.settype")) { for (Object key : config.getSection("IDs." + args[2] + ".lvl").getKeys()) { suggests.add(key.toString()); } } - } else if(args[4].equalsIgnoreCase("onlyadmins")) { - if(user.hasPermission("bansys.ids.setonlyadmins")) { + } else if (args[4].equalsIgnoreCase("onlyadmins")) { + if (user.hasPermission("bansys.ids.setonlyadmins")) { suggests.add("true"); suggests.add("false"); } @@ -922,19 +923,19 @@ public List suggest(User user, String[] args) { } } } - } else if(args.length == 7) { - if(args[0].equalsIgnoreCase("ids")) { - if(args[1].equalsIgnoreCase("edit")) { - if(args[3].equalsIgnoreCase("add")) { - if(args[4].equalsIgnoreCase("lvl")) { - if(user.hasPermission("bansys.ids.addlvl")) { + } else if (args.length == 7) { + if (args[0].equalsIgnoreCase("ids")) { + if (args[1].equalsIgnoreCase("edit")) { + if (args[3].equalsIgnoreCase("add")) { + if (args[4].equalsIgnoreCase("lvl")) { + if (user.hasPermission("bansys.ids.addlvl")) { suggests.add("NETWORK"); suggests.add("CHAT"); } } - } else if(args[3].equalsIgnoreCase("set")) { - if(args[4].equalsIgnoreCase("lvltype")) { - if(user.hasPermission("bansys.ids.settype")) { + } else if (args[3].equalsIgnoreCase("set")) { + if (args[4].equalsIgnoreCase("lvltype")) { + if (user.hasPermission("bansys.ids.settype")) { suggests.add("NETWORK"); suggests.add("CHAT"); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java b/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java index 7adb0bd..064a6b4 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java @@ -235,7 +235,7 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); - if(args.length == 0 || args.length == 1) { + if (args.length == 0 || args.length == 1) { for (User player : players) { suggests.add(player.getName()); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDdeletehistory.java b/src/main/java/net/coalcube/bansystem/core/command/CMDdeletehistory.java index ea1689a..4a58386 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDdeletehistory.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDdeletehistory.java @@ -113,7 +113,8 @@ public void execute(User user, String[] args) { } else { user.sendMessage(configurationUtil.getMessage("History.historynotfound")); } - } catch (UnknownHostException | SQLException | InterruptedException | ExecutionException | ParseException e) { + } catch (UnknownHostException | SQLException | InterruptedException | ExecutionException | + ParseException e) { user.sendMessage(configurationUtil.getMessage("Deletehistory.failed")); e.printStackTrace(); } @@ -121,8 +122,8 @@ public void execute(User user, String[] args) { user.sendMessage(configurationUtil.getMessage("Deletehistory.usage")); } } else { - user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); - } + user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); + } } /* @@ -139,7 +140,7 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); - if(args.length == 0 || args.length == 1) { + if (args.length == 0 || args.length == 1) { for (User player : players) { suggests.add(player.getName()); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java b/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java index dfcd433..fdda1ba 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java @@ -118,7 +118,7 @@ public int compare(Date o1, Date o2) { String id = "Not Found"; String duration = timeFormatUtil.getFormattedRemainingTime(history.getDuration()); String endDate; - if(history.getEndDate() != null) { + if (history.getEndDate() != null) { endDate = simpleDateFormat.format(history.getEndDate()); } else { endDate = "§cNot available"; @@ -199,8 +199,8 @@ public int compare(Date o1, Date o2) { user.sendMessage(configurationUtil.getMessage("History.usage")); } } else { - user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); - } + user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); + } } /* @@ -216,7 +216,7 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); - if(args.length == 0 || args.length == 1) { + if (args.length == 0 || args.length == 1) { for (User player : players) { suggests.add(player.getName()); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDkick.java b/src/main/java/net/coalcube/bansystem/core/command/CMDkick.java index 54d3c41..defa84d 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDkick.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDkick.java @@ -68,10 +68,10 @@ public void kick(User p, User target, String[] args) throws SQLException { if (p.getUniqueId() == null) { banManager.kick(target.getUniqueId(), p.getName(), msg.toString()); - banManager.log("Kicked Player", p.getName(), target.getUniqueId().toString(), "reason: "+ msg); + banManager.log("Kicked Player", p.getName(), target.getUniqueId().toString(), "reason: " + msg); } else { banManager.kick(target.getUniqueId(), p.getUniqueId(), msg.toString()); - banManager.log("Kicked Player", p.getUniqueId().toString(), target.getUniqueId().toString(), "reason: "+ msg); + banManager.log("Kicked Player", p.getUniqueId().toString(), target.getUniqueId().toString(), "reason: " + msg); } for (User all : BanSystem.getInstance().getAllPlayers()) { if (all.hasPermission("bansys.notify") && all.getUniqueId() != p.getUniqueId()) { @@ -87,11 +87,11 @@ public void kick(User p, User target, String[] args) throws SQLException { public void execute(User p, String[] args) { if (p.hasPermission("bansys.kick") || p.hasPermission("bansys.kick.admin")) { if (args.length >= 1) { - if(BanSystem.getInstance().getUser(args[0].replaceAll("&", "§")).getUniqueId() != null) { + if (BanSystem.getInstance().getUser(args[0].replaceAll("&", "§")).getUniqueId() != null) { target = BanSystem.getInstance().getUser(args[0].replaceAll("&", "§")); } else { try { - if(BanSystem.getInstance().getUser(UUID.fromString(args[0])) != null) { + if (BanSystem.getInstance().getUser(UUID.fromString(args[0])) != null) { target = BanSystem.getInstance().getUser(UUID.fromString(args[0])); } else { p.sendMessage(configurationUtil.getMessage("PlayerNotFound")); @@ -107,7 +107,7 @@ public void execute(User p, String[] args) { name = target.getDisplayName(); if (!target.getUniqueId().equals(p.getUniqueId())) { - if(((target.hasPermission("bansys.kick") && !p.hasPermission("bansys.kick.admin")) + if (((target.hasPermission("bansys.kick") && !p.hasPermission("bansys.kick.admin")) || target.hasPermission("bansys.kick.admin")) && p.getUniqueId() != null) { p.sendMessage(configurationUtil.getMessage("Kick.cannotkick.teammembers")); return; @@ -154,7 +154,7 @@ public List suggest(User user, String[] args) { List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); - if(args.length == 0 || args.length == 1) { + if (args.length == 0 || args.length == 1) { for (User player : players) { suggests.add(player.getName()); } diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDunban.java b/src/main/java/net/coalcube/bansystem/core/command/CMDunban.java index 531cf36..1185bbd 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDunban.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDunban.java @@ -191,7 +191,7 @@ public void execute(User user, String[] args) { } } } else { - user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); + user.sendMessage(configurationUtil.getMessage("NoPermissionMessage")); } } diff --git a/src/main/java/net/coalcube/bansystem/core/command/Command.java b/src/main/java/net/coalcube/bansystem/core/command/Command.java index c677e82..7c14372 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/Command.java +++ b/src/main/java/net/coalcube/bansystem/core/command/Command.java @@ -7,5 +7,6 @@ public interface Command { void execute(User user, String[] args); + List suggest(User user, String[] args); } \ No newline at end of file diff --git a/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java b/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java index 61971f8..5475e4f 100644 --- a/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java +++ b/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java @@ -77,38 +77,38 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio if (startsWithBlockedCommnad || !message.startsWith("/")) { - Ban ban = banManager.getBan(uuid, Type.CHAT); - if (ban != null) { - if (ban.getEnd() > System.currentTimeMillis() - || ban.getEnd() == -1) { - event.setCancelled(true); - sender.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") - .replaceAll("%reason%", ban.getReason()) - .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(ban.getRemainingTime())) - .replaceAll("%id%", ban.getId())); - bansystem.getConsole().sendMessage("§8[§c§lMUTED§r§8] §f" + sender.getDisplayName() + "§f: " + message ); + Ban ban = banManager.getBan(uuid, Type.CHAT); + if (ban != null) { + if (ban.getEnd() > System.currentTimeMillis() + || ban.getEnd() == -1) { + event.setCancelled(true); + sender.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") + .replaceAll("%reason%", ban.getReason()) + .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() + .getFormattedRemainingTime(ban.getRemainingTime())) + .replaceAll("%id%", ban.getId())); + bansystem.getConsole().sendMessage("§8[§c§lMUTED§r§8] §f" + sender.getDisplayName() + "§f: " + message); + } else { + if (config.getBoolean("needReason.Unmute")) { + banManager.unBan(ban, bansystem.getConsole().getName(), "Strafe abgelaufen"); } else { - if (config.getBoolean("needReason.Unmute")) { - banManager.unBan(ban, bansystem.getConsole().getName(), "Strafe abgelaufen"); - } else { - banManager.unBan(ban, bansystem.getConsole().getName()); - } + banManager.unBan(ban, bansystem.getConsole().getName()); + } - banManager.log("Unmuted Player", bansystem.getConsole().getName(), uuid.toString(), "Autounmute; banID: " + ban.getId()); + banManager.log("Unmuted Player", bansystem.getConsole().getName(), uuid.toString(), "Autounmute; banID: " + ban.getId()); - bansystem.getConsole().sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") - .replaceAll("%player%", sender.getDisplayName())); - for (User all : bansystem.getAllPlayers()) { - if (all.hasPermission("system.ban")) { - all.sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") - .replaceAll("%player%", sender.getDisplayName())); - } + bansystem.getConsole().sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") + .replaceAll("%player%", sender.getDisplayName())); + for (User all : bansystem.getAllPlayers()) { + if (all.hasPermission("system.ban")) { + all.sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") + .replaceAll("%player%", sender.getDisplayName())); } } } + } } - if(!sender.hasPermission("bansys.bypasschatfilter") && !event.isCancelled()) { + if (!sender.hasPermission("bansys.bypasschatfilter") && !event.isCancelled()) { if (config.getBoolean("blacklist.words.enable")) { if ((message.startsWith("/") && config.getBoolean("blacklist.words.checkcommands.enable") && blacklistUtil.hasBlockedWordsContains(message)) || (!message.startsWith("/") && @@ -125,7 +125,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio else lvl = idManager.getLastLvl(id); Long duration = config.getLong("IDs." + id + ".lvl." + lvl + ".duration"); - if(duration != -1) duration = duration * 1000; + if (duration != -1) duration = duration * 1000; Type type = Type.valueOf(config.getString("IDs." + id + ".lvl." + lvl + ".type")); String enddate = simpleDateFormat.format(new Date(System.currentTimeMillis() + duration)); @@ -133,10 +133,10 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio banManager.log("Banned Player", bansystem.getConsole().getName(), uuid.toString(), "Autoban; banID: " + ban.getId() + "; " + - "reason: " + ban.getReason() + "; " + - "Type: " + type + "; " + - "duration: " + ban.getDuration() + "; " + - "Chatmessage: " + message); + "reason: " + ban.getReason() + "; " + + "Type: " + type + "; " + + "duration: " + ban.getDuration() + "; " + + "Chatmessage: " + message); metricsAdapter.addCustomChart(new SimplePie("automations", () -> { return "Blacklist mute word"; @@ -207,7 +207,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio else lvl = idManager.getLastLvl(id); Long duration = config.getLong("IDs." + id + ".lvl." + lvl + ".duration"); - if(duration != -1) duration = duration * 1000; + if (duration != -1) duration = duration * 1000; Type type = Type.valueOf(config.getString("IDs." + id + ".lvl." + lvl + ".type")); String enddate = simpleDateFormat.format(new Date(System.currentTimeMillis() + duration)); @@ -280,13 +280,13 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio } // Chat cooldown - if(!event.isCancelled() && chatDelayEnabled + if (!event.isCancelled() && chatDelayEnabled && !sender.hasPermission("bansys.bypasschatdelay") && !message.startsWith("/")) { - if(chatDelayedPlayer.containsKey(uuid)) { + if (chatDelayedPlayer.containsKey(uuid)) { long tmpReamingTime = chatDelayedPlayer.get(uuid); tmpReamingTime = tmpReamingTime - System.currentTimeMillis(); - if(tmpReamingTime <= 0) { + if (tmpReamingTime <= 0) { chatDelayedPlayer.remove(uuid); } else { diff --git a/src/main/java/net/coalcube/bansystem/core/listener/Event.java b/src/main/java/net/coalcube/bansystem/core/listener/Event.java index dc6abf0..1204a37 100644 --- a/src/main/java/net/coalcube/bansystem/core/listener/Event.java +++ b/src/main/java/net/coalcube/bansystem/core/listener/Event.java @@ -5,21 +5,22 @@ public class Event { private boolean cancelled; private String cancelReason; - public Event() {} - - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; + public Event() { } public boolean isCancelled() { return cancelled; } - public void setCancelReason(String reason) { - this.cancelReason = reason; + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; } public String getCancelReason() { return cancelReason; } + + public void setCancelReason(String reason) { + this.cancelReason = reason; + } } diff --git a/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java b/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java index bdf3d00..fc2e3aa 100644 --- a/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java +++ b/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java @@ -124,7 +124,7 @@ public Event onJoin(UUID uuid, String name, InetAddress inetAddress) { public Event onPostJoin(User user, InetAddress inetAddress) throws SQLException, ExecutionException, InterruptedException { Event event = new Event(); String ip = inetAddress.getHostAddress(); - if(!sql.isConnected()) { + if (!sql.isConnected()) { return event; } if (user == null) { diff --git a/src/main/java/net/coalcube/bansystem/core/sql/Database.java b/src/main/java/net/coalcube/bansystem/core/sql/Database.java index 0b97819..83dd30d 100644 --- a/src/main/java/net/coalcube/bansystem/core/sql/Database.java +++ b/src/main/java/net/coalcube/bansystem/core/sql/Database.java @@ -9,10 +9,16 @@ public interface Database { void connect() throws SQLException; + void disconnect() throws SQLException; + void update(String qry) throws SQLException; + ResultSet getResult(String qry) throws SQLException, ExecutionException, InterruptedException; + void createTables(YamlDocument config) throws SQLException, ExecutionException, InterruptedException; + boolean isConnected(); - void updateTables() throws SQLException, ExecutionException, InterruptedException; + + void updateTables() throws SQLException, ExecutionException, InterruptedException; } diff --git a/src/main/java/net/coalcube/bansystem/core/sql/MySQL.java b/src/main/java/net/coalcube/bansystem/core/sql/MySQL.java index 022ff1c..67c6ac9 100644 --- a/src/main/java/net/coalcube/bansystem/core/sql/MySQL.java +++ b/src/main/java/net/coalcube/bansystem/core/sql/MySQL.java @@ -49,7 +49,7 @@ public void connect() throws SQLException { @Override public ResultSet getResult(String s) throws SQLException, ExecutionException, InterruptedException { - if(!isConnected()) { + if (!isConnected()) { connect(); } final FutureTask task = new FutureTask<>(() -> { @@ -64,7 +64,7 @@ public ResultSet getResult(String s) throws SQLException, ExecutionException, In @Override public void update(String qry) throws SQLException { - if(!isConnected()) { + if (!isConnected()) { connect(); } new FutureTask<>(() -> { @@ -104,12 +104,12 @@ public void importFromOldBanDatabase() throws SQLException, ParseException, Exec SimpleDateFormat parser = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); - for(int i = 0; i whitelist = blacklist.getStringList("Whitelist"); @@ -35,8 +37,8 @@ public boolean hasBlockedWordsContains(String message) { message.equalsIgnoreCase(word) || message.toUpperCase().equals(word) || message.toLowerCase().equals(word)) { - for(String whitelistRow : whitelist) { - if(message.contains(whitelistRow) || message.equalsIgnoreCase(whitelistRow)) { + for (String whitelistRow : whitelist) { + if (message.contains(whitelistRow) || message.equalsIgnoreCase(whitelistRow)) { return false; } else return true; @@ -45,8 +47,8 @@ public boolean hasBlockedWordsContains(String message) { } - for(String pice : trimmed) { - if(pice.equalsIgnoreCase(word) && !whitelist.contains(word)) + for (String pice : trimmed) { + if (pice.equalsIgnoreCase(word) && !whitelist.contains(word)) return true; } } @@ -75,8 +77,8 @@ public boolean hasAdContains(String message) { String[] trimmed = message.split(" "); - for(String ad : blacklist.getStringList("Ads")) { - if(message.contains(ad) + for (String ad : blacklist.getStringList("Ads")) { + if (message.contains(ad) || message.equalsIgnoreCase(ad) || message.toUpperCase().equals(ad) || message.toLowerCase().equals(ad) @@ -84,15 +86,15 @@ public boolean hasAdContains(String message) { || rawMessage.equalsIgnoreCase(ad) || rawMessage.toUpperCase().equals(ad) || rawMessage.toLowerCase().equals(ad)) - for(String whitelistRow : whitelist) { - if(message.contains(whitelistRow) || message.equalsIgnoreCase(whitelistRow)) { + for (String whitelistRow : whitelist) { + if (message.contains(whitelistRow) || message.equalsIgnoreCase(whitelistRow)) { return false; } else return true; } - for(String word : trimmed) { - if(word.equalsIgnoreCase(ad) && !whitelist.contains(word)) + for (String word : trimmed) { + if (word.equalsIgnoreCase(ad) && !whitelist.contains(word)) return true; } diff --git a/src/main/java/net/coalcube/bansystem/core/util/ConfigurationUtil.java b/src/main/java/net/coalcube/bansystem/core/util/ConfigurationUtil.java index f385342..a515104 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/ConfigurationUtil.java +++ b/src/main/java/net/coalcube/bansystem/core/util/ConfigurationUtil.java @@ -11,7 +11,6 @@ import java.io.File; import java.io.IOException; -import java.util.List; import java.util.Map; public class ConfigurationUtil { @@ -100,7 +99,7 @@ public String getMessage(String path) { if (msg.contains("%P%")) { msg = msg.replace("%P%", messages.getString("prefix")); } - + if (msg.contains("&")) { msg = msg.replace("&", "§"); } @@ -109,7 +108,7 @@ public String getMessage(String path) { public void update() throws IOException { // Messages - if(messages.get("History.body") != null) + if (messages.get("History.body") != null) messages.set("History.body", null); updateConfigValue(messages, "messages.yml", "file-version"); updateConfigValue(messages, "messages.yml", "History.ban"); @@ -152,9 +151,9 @@ public void update() throws IOException { private Object getParameterValue(Map yamlData, String path) { String[] keys = path.split("\\."); Object value = null; - int i=1; - for(String key : keys) { - if(i == 1) { + int i = 1; + for (String key : keys) { + if (i == 1) { value = yamlData.get(keys[0]); } else { if (value instanceof Map) { @@ -175,7 +174,7 @@ private Object getParameterValue(Map yamlData, String path) { private void updateConfigValue(YamlDocument config, String resource, String path) { Yaml resourceYAML = new Yaml(); Map resourceData = resourceYAML.load(banSystem.getResourceAsInputStream(resource)); - if(config.get(path) == null) { + if (config.get(path) == null) { config.set(path, getParameterValue(resourceData, path)); } } @@ -187,6 +186,7 @@ public YamlDocument getConfig() { public YamlDocument getMessagesConfig() { return messages; } + public YamlDocument getBlacklist() { return blacklist; } diff --git a/src/main/java/net/coalcube/bansystem/core/util/History.java b/src/main/java/net/coalcube/bansystem/core/util/History.java index f28bb3d..4aedd20 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/History.java +++ b/src/main/java/net/coalcube/bansystem/core/util/History.java @@ -70,14 +70,14 @@ public Type getType() { } public Date getEndDate() { - if(getDuration() == -1) { + if (getDuration() == -1) { return null; } return new Date(getCreateDate().getTime() + getDuration()); } public String getId() { - if(id == null) { + if (id == null) { return "Not available"; } return id; diff --git a/src/main/java/net/coalcube/bansystem/core/util/IDManager.java b/src/main/java/net/coalcube/bansystem/core/util/IDManager.java index 6b6fa50..49c121d 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/IDManager.java +++ b/src/main/java/net/coalcube/bansystem/core/util/IDManager.java @@ -31,15 +31,15 @@ public void createID(String id, String reason, boolean onlyAdmin, long duration, config.set("IDs." + id + ".lvl.1.type", type.toString()); config.set("IDs." + id + ".lvl.1.duration", duration); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("INSERT INTO `ids` (`id`, `reason`, `lvl`, `duration`, `onlyadmin`, `type`, `creationdate`, `creator`) " + - "VALUES ('" + id + "', '" + reason + "', '1', '" + duration + "', " + onlyAdmin + ", '" + type.toString() + "', NOW(), '" + creator + "');"); + "VALUES ('" + id + "', '" + reason + "', '1', '" + duration + "', " + onlyAdmin + ", '" + type.toString() + "', NOW(), '" + creator + "');"); } public void deleteID(String id) throws SQLException, IOException { config.remove("IDs." + id); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("DELETE FROM `ids` WHERE id='" + id + "';"); } @@ -49,7 +49,7 @@ public void addLvl(String id, long duration, Type type, String creator) throws I config.set("IDs." + id + ".lvl." + lvl + ".type", type.toString()); config.set("IDs." + id + ".lvl." + lvl + ".duration", duration); config.save(configFile); - if(isMySQLused()) { + if (isMySQLused()) { database.update("INSERT INTO `ids` (`id`, `reason`, `lvl`, `duration`, `onlyadmin`, `type`, `creationdate`, `creator`) " + "VALUES ('" + id + "', '" + getReason(id) + "', '" + lvl + "', '" + duration + "', " + getOnlyAdmins(id) + ", '" + type.toString() + "', NOW(), '" + creator + "')"); @@ -59,7 +59,7 @@ public void addLvl(String id, long duration, Type type, String creator) throws I public void removeLvl(String id, String lvl) throws IOException, SQLException, ExecutionException, InterruptedException { config.remove("IDs." + id + ".lvl." + lvl); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("DELETE FROM `ids` WHERE id='" + id + "' AND lvl='" + lvl + "';"); reassignLvls(id); @@ -68,28 +68,28 @@ public void removeLvl(String id, String lvl) throws IOException, SQLException, E public void setLvlDuration(String id, String lvl, long duration) throws IOException, SQLException { config.set("IDs." + id + ".lvl." + lvl + ".duration", duration); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("UPDATE `ids` SET duration='" + duration + "' WHERE id='" + id + "' AND lvl='" + lvl + "'"); } public void setLvlType(String id, String lvl, Type type) throws IOException, SQLException { config.set("IDs." + id + ".lvl." + lvl + ".type", type.toString()); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("UPDATE `ids` SET type='" + type.toString() + "' WHERE id='" + id + "' AND lvl='" + lvl + "'"); } public void setOnlyAdmins(String id, boolean onlyAdmins) throws IOException, SQLException { config.set("IDs." + id + ".onlyAdmins", onlyAdmins); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("UPDATE `ids` SET onlyadmin=" + onlyAdmins + " WHERE id='" + id + "'"); } public void setReason(String id, String reason) throws IOException, SQLException { config.set("IDs." + id + ".reason", reason); config.save(configFile); - if(isMySQLused()) + if (isMySQLused()) database.update("UPDATE `ids` SET reason='" + reason + "' WHERE id='" + id + "'"); } @@ -99,7 +99,7 @@ public void reassignLvls(String id) throws SQLException, ExecutionException, Int HashMap type = new HashMap(); HashMap duration = new HashMap(); - for(Object lvl : config.getSection("IDs." + id + ".lvl").getKeys()) { + for (Object lvl : config.getSection("IDs." + id + ".lvl").getKeys()) { lvls.add(lvl.toString()); type.put(lvl.toString(), Type.valueOf(config.getString("IDs." + id + ".lvl." + lvl + ".type"))); duration.put(lvl.toString(), config.getLong("IDs." + id + ".lvl." + lvl + ".duration")); @@ -108,7 +108,7 @@ public void reassignLvls(String id) throws SQLException, ExecutionException, Int int count = 1; - for(String lvl : lvls) { + for (String lvl : lvls) { Type tmpType = type.get(lvl); long tmpDuration = duration.get(lvl); @@ -120,7 +120,7 @@ public void reassignLvls(String id) throws SQLException, ExecutionException, Int config.save(configFile); - if(isMySQLused()) { + if (isMySQLused()) { ResultSet rs = database.getResult("SELECT * FROM `ids` WHERE id='" + id + "' ORDER BY lvl ASC;"); int count2 = 1; @@ -162,8 +162,8 @@ public long getDuration(String id, String lvl) { public int getLastLvl(String id) { int lastLvl = 0; - for(Object lvl : config.getSection("IDs." + id + ".lvl").getKeys()) { - if(lastLvl < Integer.valueOf(lvl.toString())) + for (Object lvl : config.getSection("IDs." + id + ".lvl").getKeys()) { + if (lastLvl < Integer.valueOf(lvl.toString())) lastLvl = Integer.valueOf(lvl.toString()); } return lastLvl; diff --git a/src/main/java/net/coalcube/bansystem/core/util/ServerSocket.java b/src/main/java/net/coalcube/bansystem/core/util/ServerSocket.java index 0bf0fbe..42d603b 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/ServerSocket.java +++ b/src/main/java/net/coalcube/bansystem/core/util/ServerSocket.java @@ -10,7 +10,7 @@ public class ServerSocket { public ServerSocket(int port) throws IOException { java.net.ServerSocket serverSocket = new java.net.ServerSocket(port); - System.out.println("Starting listening on Port "+port); + System.out.println("Starting listening on Port " + port); while (true) { Socket socket = serverSocket.accept(); @@ -25,7 +25,7 @@ public ServerSocket(int port) throws IOException { while ((line = br.readLine()) != null) { pw.println(line); pw.flush(); - if(line.equals("quit")) { + if (line.equals("quit")) { break; } diff --git a/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java b/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java index 9f3adaa..399c1c9 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java +++ b/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java @@ -37,23 +37,23 @@ public TimeFormatUtil(ConfigurationUtil config) { public String getFormattedRemainingTime(long remainingMillis) { return this.formatRemainingTime(remainingMillis); } - + /** * Formats the remaining time. * * @param remainingMillis the remaining time in milliseconds. Use {@code -1L} for "never" and - * {@code 0L} (or negative) for "now". + * {@code 0L} (or negative) for "now". * @return a localised, human-readable representation of the duration */ public String formatRemainingTime(long remainingMillis) { if (remainingMillis == -1L) { return this.config.getMessage("TimeFormat.never"); } - + if (remainingMillis <= 0L) { return this.formatUnit("TimeFormat.seconds", "%sec%", 0); } - + long seconds = remainingMillis / MILLIS_PER_SECOND; long minutes = seconds / SECONDS_PER_MINUTE; long hours = minutes / MINUTES_PER_HOUR; @@ -100,14 +100,14 @@ private String formatUnit(String messageKey, String placeholder, long value) { private String joinTimeParts(List parts) { int size = parts.size(); if (size == 1) { - return parts.get(0); + return parts.get(0); } - + String and = " " + this.config.getMessage("and") + " "; if (size == 2) { - return parts.get(0) + and + parts.get(1); + return parts.get(0) + and + parts.get(1); } - + List firstParts = parts.subList(0, size - 1); String lastPart = parts.get(size - 1); return String.join(", ", firstParts) + and + lastPart; diff --git a/src/main/java/net/coalcube/bansystem/core/util/URLUtil.java b/src/main/java/net/coalcube/bansystem/core/util/URLUtil.java index 17d0b13..46f67a2 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/URLUtil.java +++ b/src/main/java/net/coalcube/bansystem/core/util/URLUtil.java @@ -40,19 +40,19 @@ public boolean isVPN(String ip) throws IOException { if (!ip.equals("127.0.0.1") || !ip.equals(config.getString("VPN.serverIP"))) { JSONObject jsonObject; - if(config.getString("VPN.apikey").isEmpty()) { + if (config.getString("VPN.apikey").isEmpty()) { jsonObject = readJsonFromUrl("https://vpnapi.io/api/" + ip); } else { jsonObject = readJsonFromUrl("https://vpnapi.io/api/" + ip + "?key=" + config.getString("VPN.apikey")); } - if(jsonObject.has("security")) { + if (jsonObject.has("security")) { JSONObject structure = (JSONObject) jsonObject.get("security"); - if(structure.get("vpn").toString().equals("true")) + if (structure.get("vpn").toString().equals("true")) return true; } else { BanSystem.getInstance().sendConsoleMessage(configurationUtil.getMessage("prefix") - + "§cBei der VPN Abfrage ist ein Fehler aufgetreten: " - + jsonObject.getString("message")); + + "§cBei der VPN Abfrage ist ein Fehler aufgetreten: " + + jsonObject.getString("message")); } return false; } diff --git a/src/main/java/net/coalcube/bansystem/core/util/UpdateChecker.java b/src/main/java/net/coalcube/bansystem/core/util/UpdateChecker.java index feefc81..0de605b 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/UpdateChecker.java +++ b/src/main/java/net/coalcube/bansystem/core/util/UpdateChecker.java @@ -18,13 +18,15 @@ public UpdateChecker(int projectID) { newVersion = BanSystem.getInstance().getVersion(); try { checkURL = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + projectID); - } catch(MalformedURLException e) { + } catch (MalformedURLException e) { BanSystem.getInstance().getConsole().sendMessage("§cCould not connect to Spigotmc.org!"); } } + public String getResourceUrl() { return "https://spigotmc.org/resources/" + project; } + public boolean checkForUpdates() throws Exception { URLConnection con = checkURL.openConnection(); newVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine(); diff --git a/src/main/java/net/coalcube/bansystem/core/util/WebHook.java b/src/main/java/net/coalcube/bansystem/core/util/WebHook.java index 1917d34..0356528 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/WebHook.java +++ b/src/main/java/net/coalcube/bansystem/core/util/WebHook.java @@ -1,10 +1,7 @@ package net.coalcube.bansystem.core.util; import javax.net.ssl.HttpsURLConnection; -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.image.BufferedImage; +import java.awt.*; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Array; @@ -167,18 +164,38 @@ public String getTitle() { return title; } + public EmbedObject setTitle(String title) { + this.title = title; + return this; + } + public String getDescription() { return description; } + public EmbedObject setDescription(String description) { + this.description = description; + return this; + } + public String getUrl() { return url; } + public EmbedObject setUrl(String url) { + this.url = url; + return this; + } + public Color getColor() { return color; } + public EmbedObject setColor(Color color) { + this.color = color; + return this; + } + public Footer getFooter() { return footer; } @@ -187,10 +204,20 @@ public Thumbnail getThumbnail() { return thumbnail; } + public EmbedObject setThumbnail(String url) { + this.thumbnail = new Thumbnail(url); + return this; + } + public Image getImage() { return image; } + public EmbedObject setImage(String url) { + this.image = new Image(url); + return this; + } + public Author getAuthor() { return author; } @@ -199,41 +226,11 @@ public List getFields() { return fields; } - public EmbedObject setTitle(String title) { - this.title = title; - return this; - } - - public EmbedObject setDescription(String description) { - this.description = description; - return this; - } - - public EmbedObject setUrl(String url) { - this.url = url; - return this; - } - - public EmbedObject setColor(Color color) { - this.color = color; - return this; - } - public EmbedObject setFooter(String text, String icon) { this.footer = new Footer(text, icon); return this; } - public EmbedObject setThumbnail(String url) { - this.thumbnail = new Thumbnail(url); - return this; - } - - public EmbedObject setImage(String url) { - this.image = new Image(url); - return this; - } - public EmbedObject setAuthor(String name, String url, String icon) { this.author = new Author(name, url, icon); return this; diff --git a/src/main/java/net/coalcube/bansystem/core/uuidfetcher/UUIDFetcher.java b/src/main/java/net/coalcube/bansystem/core/uuidfetcher/UUIDFetcher.java index 4b866f3..aba093d 100644 --- a/src/main/java/net/coalcube/bansystem/core/uuidfetcher/UUIDFetcher.java +++ b/src/main/java/net/coalcube/bansystem/core/uuidfetcher/UUIDFetcher.java @@ -27,12 +27,9 @@ public class UUIDFetcher { * @see UUIDFetcher#getUUIDAt(String, long) */ public static final long FEBRUARY_2015 = 1422748800000L; - - private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); - private static final String UUID_URL = "https://api.mojang.com/users/profiles/minecraft/%s?at=%d"; private static final String NAME_URL = "https://sessionserver.mojang.com/session/minecraft/profile/%s"; - + private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); private static Map uuidCache = new HashMap<>(); private static Map nameCache = new HashMap<>(); @@ -86,7 +83,7 @@ public static UUID getUUIDAt(String name, long timestamp) { return UUIDFetcher.uuidCache.get(name); } try { - if(BanSystem.getInstance().getBanManager().isSavedBedrockPlayer(name)) { + if (BanSystem.getInstance().getBanManager().isSavedBedrockPlayer(name)) { UUID uuid = BanSystem.getInstance().getBanManager().getSavedBedrockUUID(name); uuidCache.put(name, uuid); return uuid; @@ -130,12 +127,12 @@ public static void getName(UUID uuid, Consumer action) { */ public static String getName(UUID uuid) { - if(nameCache.containsKey(uuid)) { + if (nameCache.containsKey(uuid)) { return nameCache.get(uuid); } try { - if(BanSystem.getInstance().getBanManager().isSavedBedrockPlayer(uuid)) { + if (BanSystem.getInstance().getBanManager().isSavedBedrockPlayer(uuid)) { String name = BanSystem.getInstance().getBanManager().getSavedBedrockUsername(uuid); nameCache.put(uuid, name); return name; @@ -150,7 +147,7 @@ public static String getName(UUID uuid) { } catch (IOException e) { return null; } - if(jsonObject != null && jsonObject.has("name")) { + if (jsonObject != null && jsonObject.has("name")) { String name = jsonObject.getString("name"); nameCache.put(uuid, name); return name; @@ -190,7 +187,7 @@ private static JSONObject readJsonFromUrl(String url) throws IOException, JSONEx try (InputStream is = new URL(url).openStream()) { BufferedReader rd = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String jsonText = readAll(rd); - if(jsonText == null) + if (jsonText == null) return null; JSONObject jsonObject = new JSONObject(jsonText); return jsonObject; @@ -203,7 +200,7 @@ private static String readAll(Reader rd) throws IOException { while ((cp = rd.read()) != -1) { sb.append((char) cp); } - if(sb.length() == 0){ + if (sb.length() == 0) { return null; } return sb.toString(); diff --git a/src/main/java/net/coalcube/bansystem/spigot/BanSystemSpigot.java b/src/main/java/net/coalcube/bansystem/spigot/BanSystemSpigot.java index 0ec1754..2ea5246 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/BanSystemSpigot.java +++ b/src/main/java/net/coalcube/bansystem/spigot/BanSystemSpigot.java @@ -37,30 +37,33 @@ public class BanSystemSpigot extends JavaPlugin implements BanSystem { + public static String prefix = "§8§l┃ §cBanSystem §8» §7"; private static Plugin instance; private static BanManager banManager; private static IDManager idManager; private static URLUtil urlUtil; private static ConfigurationUtil configurationUtil; + private static String Banscreen; + private static List blockedCommands, ads, blockedWords; + private static List cachedBannedPlayerNames; + private static List cachedMutedPlayerNames; private BlacklistUtil blacklistUtil; private Database sql; private MySQL mysql; private TimeFormatUtil timeFormatUtil; private YamlDocument config, messages, blacklist; private TextComponent textComponent; - private static String Banscreen; - private static List blockedCommands, ads, blockedWords; private File sqlitedatabase; private String hostname, database, user, pw; private int port; private CommandSender console; - private static List cachedBannedPlayerNames; - private static List cachedMutedPlayerNames; private MetricsAdapter metricsAdapter; - - public static String prefix = "§8§l┃ §cBanSystem §8» §7"; private boolean isUpdateAvailable; + public static Plugin getPlugin() { + return instance; + } + @Override public void onEnable() { super.onEnable(); @@ -124,8 +127,8 @@ public void onEnable() { console.sendMessage(prefix + "§cDebug Message: §e" + e.getMessage()); } try { - if(mysql.isConnected()) { - if(mysql.isOldDatabase()) { + if (mysql.isConnected()) { + if (mysql.isOldDatabase()) { console.sendMessage(prefix + "§7Die MySQL Daten vom dem alten BanSystem wurden §2importiert§7."); } mysql.createTables(config); @@ -136,7 +139,7 @@ public void onEnable() { e.printStackTrace(); } try { - if(mysql.isConnected()) { + if (mysql.isConnected()) { mysql.syncIDs(config); console.sendMessage(prefix + "§7Die Ban IDs wurden §2synchronisiert§7."); } @@ -162,7 +165,7 @@ public void onEnable() { e.printStackTrace(); } try { - if(sqlite.isConnected()) { + if (sqlite.isConnected()) { sqlite.createTables(config); console.sendMessage(prefix + "§7Die SQLite Tabellen wurden §2erstellt§7."); } @@ -215,7 +218,7 @@ public void onEnable() { init(pluginmanager); - if(sql.isConnected()) { + if (sql.isConnected()) { try { sql.updateTables(); } catch (SQLException | ExecutionException | InterruptedException e) { @@ -245,11 +248,6 @@ public void onDisable() { } - @Override - public String getEnvironment() { - return Bukkit.getName(); - } - // create Config files /*private void createConfig() { @@ -287,6 +285,11 @@ public String getEnvironment() { } }*/ + @Override + public String getEnvironment() { + return Bukkit.getName(); + } + private void createFileDatabase() { try { sqlitedatabase = new File(this.getDataFolder(), "database.db"); @@ -358,7 +361,7 @@ public void disconnect(User u, String msg) { private void init(PluginManager pluginManager) { getCommand("ban").setExecutor(new CommandWrapper( - new CMDban(banManager, config, messages, sql, configurationUtil),true)); + new CMDban(banManager, config, messages, sql, configurationUtil), true)); getCommand("check").setExecutor(new CommandWrapper( new CMDcheck(banManager, sql, configurationUtil), true)); getCommand("deletehistory").setExecutor(new CommandWrapper( @@ -449,9 +452,9 @@ public boolean isUpdateAvailable() { private void initCachedBannedPlayerNames() throws SQLException, ExecutionException, InterruptedException { new Thread(() -> { try { - for(Ban ban : banManager.getAllBans()) { + for (Ban ban : banManager.getAllBans()) { String name = UUIDFetcher.getName(ban.getPlayer()); - if(ban.getType() == Type.NETWORK) { + if (ban.getType() == Type.NETWORK) { cachedBannedPlayerNames.add(name); } else { cachedMutedPlayerNames.add(name); @@ -492,8 +495,4 @@ public BanManager getBanManager() { return banManager; } - public static Plugin getPlugin() { - return instance; - } - } diff --git a/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java b/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java index 4fef4ee..d0889d9 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java +++ b/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java @@ -33,27 +33,27 @@ public PlayerCommandPreprocessListener(BanManager banManager, YamlDocument confi @EventHandler(priority = EventPriority.HIGHEST) public void onCommandPreprocess(PlayerCommandPreprocessEvent e) { - if(!BanSystem.getInstance().getSQL().isConnected()) { + if (!BanSystem.getInstance().getSQL().isConnected()) { try { BanSystem.getInstance().getSQL().connect(); } catch (SQLException ex) { return; } } - if(BanSystem.getInstance().getSQL().isConnected()) { + if (BanSystem.getInstance().getSQL().isConnected()) { Player p = e.getPlayer(); String msg = e.getMessage(); boolean startsWithBlockedCommnad = false; - for(Object s : blockedCommands) { - if(msg.startsWith(s.toString())) { + for (Object s : blockedCommands) { + if (msg.startsWith(s.toString())) { startsWithBlockedCommnad = true; } } try { Ban mute = banManager.getBan(p.getUniqueId(), Type.CHAT); - if(mute != null) { - if(mute.getEnd() > System.currentTimeMillis() + if (mute != null) { + if (mute.getEnd() > System.currentTimeMillis() || mute.getEnd() == -1) { if (startsWithBlockedCommnad) { e.setCancelled(true); @@ -76,8 +76,8 @@ public void onCommandPreprocess(PlayerCommandPreprocessEvent e) { "Autounmute; banID: " + mute.getId()); Bukkit.getConsoleSender().sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") .replaceAll("%player%", p.getDisplayName())); - for(Player all : Bukkit.getOnlinePlayers()) { - if(all.hasPermission("bansys.notify")) { + for (Player all : Bukkit.getOnlinePlayers()) { + if (all.hasPermission("bansys.notify")) { all.sendMessage(configurationUtil.getMessage("Ban.Chat.autounmute.success") .replaceAll("%player%", p.getDisplayName())); diff --git a/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotAsyncPlayerChatListener.java b/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotAsyncPlayerChatListener.java index 626cabe..443d9db 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotAsyncPlayerChatListener.java +++ b/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotAsyncPlayerChatListener.java @@ -41,7 +41,7 @@ public void onChat(AsyncPlayerChatEvent e) throws IOException, SQLException, Exe String msg = e.getMessage(); Event event = chatListener.onChat(user, msg); - if(event.isCancelled()) { + if (event.isCancelled()) { e.setCancelled(true); } } diff --git a/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotPlayerConnectionListener.java b/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotPlayerConnectionListener.java index 637ddf2..d09ffa6 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotPlayerConnectionListener.java +++ b/src/main/java/net/coalcube/bansystem/spigot/listener/SpigotPlayerConnectionListener.java @@ -46,11 +46,11 @@ public void onPreLogin(AsyncPlayerPreLoginEvent e) { UUID uuid = e.getUniqueId(); InetAddress ip = e.getAddress(); Database sql = BanSystem.getInstance().getSQL(); - if(!sql.isConnected()) return; + if (!sql.isConnected()) return; Event event = loginListener.onJoin(uuid, e.getName(), ip); - if(event.isCancelled()) { + if (event.isCancelled()) { e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, event.getCancelReason()); } @@ -77,7 +77,7 @@ public void onJoin(PlayerJoinEvent e) { try { Event event = loginListener.onPostJoin(user, ip); - if(event.isCancelled()) { + if (event.isCancelled()) { e.setJoinMessage(""); new BukkitRunnable() { @Override diff --git a/src/main/java/net/coalcube/bansystem/spigot/util/SpigotUser.java b/src/main/java/net/coalcube/bansystem/spigot/util/SpigotUser.java index ffd4093..bc513e4 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/util/SpigotUser.java +++ b/src/main/java/net/coalcube/bansystem/spigot/util/SpigotUser.java @@ -23,7 +23,7 @@ public void sendMessage(String msg) { @Override public void sendMessage(TextComponent msg) { - if(sender instanceof Player) + if (sender instanceof Player) ((Player) sender).spigot().sendMessage(msg); else sender.sendMessage(msg.getText()); @@ -31,7 +31,7 @@ public void sendMessage(TextComponent msg) { @Override public void disconnect(String message) { - if(sender instanceof Player) + if (sender instanceof Player) ((Player) sender).kickPlayer(message); } diff --git a/src/main/java/net/coalcube/bansystem/velocity/BanSystemVelocity.java b/src/main/java/net/coalcube/bansystem/velocity/BanSystemVelocity.java index b65e8d6..823528f 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/BanSystemVelocity.java +++ b/src/main/java/net/coalcube/bansystem/velocity/BanSystemVelocity.java @@ -48,35 +48,35 @@ description = "Punishment System", authors = {"Tobi"}) public class BanSystemVelocity implements BanSystem { + public static String prefix = "§8§l┃ §cBanSystem §8» §7"; + private static BanManager banManager; + private static IDManager idManager; + private static URLUtil urlUtil; + private static ConfigurationUtil configurationUtil; + private static String Banscreen; + private static List blockedCommands, ads, blockedWords; + private static List cachedBannedPlayerNames; + private static List cachedMutedPlayerNames; private final ProxyServer server; private final Logger logger; private final Path dataDirectory; private final Metrics.Factory metricsFactory; private LegacyComponentSerializer lcs; - private static BanManager banManager; - private static IDManager idManager; - private static URLUtil urlUtil; - private static ConfigurationUtil configurationUtil; private BlacklistUtil blacklistUtil; private Database sql; private MySQL mysql; private TimeFormatUtil timeFormatUtil; private YamlDocument config, messages, blacklist; private TextComponent textComponent; - private static String Banscreen; - private static List blockedCommands, ads, blockedWords; private File sqlitedatabase, configFile, messagesFile, blacklistFile; private String hostname, database, user, pw; private int port; - private static List cachedBannedPlayerNames; - private static List cachedMutedPlayerNames; private MetricsAdapter metricsAdapter; - - public static String prefix = "§8§l┃ §cBanSystem §8» §7"; private boolean isUpdateAvailable; @Inject - public BanSystemVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, Metrics.Factory metricsFactory) { + public BanSystemVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, + Metrics.Factory metricsFactory) { this.server = server; this.logger = logger; this.dataDirectory = dataDirectory; @@ -136,8 +136,8 @@ public void onEnable() { sendConsoleMessage(prefix + "§cDebug Message: §e" + e.getMessage()); } try { - if(mysql.isConnected()) { - if(mysql.isOldDatabase()) { + if (mysql.isConnected()) { + if (mysql.isOldDatabase()) { sendConsoleMessage(prefix + "§7Die MySQL Daten vom dem alten BanSystem wurden §2importiert§7."); } mysql.createTables(config); @@ -148,7 +148,7 @@ public void onEnable() { e.printStackTrace(); } try { - if(mysql.isConnected()) { + if (mysql.isConnected()) { mysql.syncIDs(config); sendConsoleMessage(prefix + "§7Die Ban IDs wurden §2synchronisiert§7."); } @@ -174,7 +174,7 @@ public void onEnable() { e.printStackTrace(); } try { - if(sqlite.isConnected()) { + if (sqlite.isConnected()) { sqlite.createTables(config); sendConsoleMessage(prefix + "§7Die SQLite Tabellen wurden §2erstellt§7."); } @@ -184,7 +184,6 @@ public void onEnable() { } } - server.getScheduler() .buildTask(this, () -> { UUIDFetcher.clearCache(); @@ -197,11 +196,12 @@ public void onEnable() { .delay(1, TimeUnit.HOURS) .schedule(); - if (config.getString("VPN.serverIP").equals("00.00.00.00") && config.getBoolean("VPN.enable")) + if (config.getString("VPN.serverIP").equals("00.00.00.00") && config.getBoolean("VPN.enable")) { sendConsoleMessage( prefix + "§cBitte trage die IP des Servers in der config.yml ein."); + } - if(sql.isConnected()) { + if (sql.isConnected()) { try { sql.updateTables(); } catch (SQLException | ExecutionException | InterruptedException e) { @@ -237,8 +237,9 @@ public void onEnable() { public void onDisable() { try { - if (sql.isConnected()) + if (sql.isConnected()) { sql.disconnect(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -251,7 +252,6 @@ public String getEnvironment() { return server.getVersion().getName(); } - // create Config files /*private void createConfig() { try { @@ -310,8 +310,9 @@ public void loadConfig() { for (String screen : messages.getStringList("Ban.Network.Screen")) { if (Banscreen == null) { Banscreen = screen.replaceAll("%P%", prefix) + "\n"; - } else + } else { Banscreen = Banscreen + screen.replaceAll("%P%", prefix) + "\n"; + } } user = config.getString("mysql.user"); hostname = config.getString("mysql.host"); @@ -342,15 +343,17 @@ public Database getSQL() { @Override public User getUser(String name) { - if(server.getPlayer(name).isPresent()) + if (server.getPlayer(name).isPresent()) { return new VelocityUser(server.getPlayer(name).get()); + } return new VelocityUser(null); } @Override public User getUser(UUID uniqueId) { - if(server.getPlayer(uniqueId).isPresent()) + if (server.getPlayer(uniqueId).isPresent()) { return new VelocityUser(server.getPlayer(uniqueId).get()); + } return new VelocityUser(null); } @@ -483,9 +486,9 @@ public boolean isUpdateAvailable() { private void initCachedBannedPlayerNames() throws SQLException, ExecutionException, InterruptedException { new Thread(() -> { try { - for(Ban ban : banManager.getAllBans()) { + for (Ban ban : banManager.getAllBans()) { String name = UUIDFetcher.getName(ban.getPlayer()); - if(ban.getType() == Type.NETWORK) { + if (ban.getType() == Type.NETWORK) { cachedBannedPlayerNames.add(name); } else { cachedMutedPlayerNames.add(name); diff --git a/src/main/java/net/coalcube/bansystem/velocity/CommandWrapper.java b/src/main/java/net/coalcube/bansystem/velocity/CommandWrapper.java index d369cf2..f3f8a07 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/CommandWrapper.java +++ b/src/main/java/net/coalcube/bansystem/velocity/CommandWrapper.java @@ -14,6 +14,7 @@ public class CommandWrapper implements SimpleCommand { public CommandWrapper(Command cmd) { this.cmd = cmd; } + @Override public void execute(final Invocation invocation) { cmd.execute(new VelocityUser(invocation.source()), invocation.arguments()); diff --git a/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityChatEvent.java b/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityChatEvent.java index a9d985e..c2cc0ba 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityChatEvent.java +++ b/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityChatEvent.java @@ -43,7 +43,7 @@ public void onPlayerChat(com.velocitypowered.api.event.player.PlayerChatEvent e) Event event = chatListener.onChat(user, msg); - if(event.isCancelled()) + if (event.isCancelled()) e.setResult(com.velocitypowered.api.event.player.PlayerChatEvent.ChatResult.denied()); } } diff --git a/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityLoginEvent.java b/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityLoginEvent.java index 86e9ead..c4fdd10 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityLoginEvent.java +++ b/src/main/java/net/coalcube/bansystem/velocity/listener/VelocityLoginEvent.java @@ -50,12 +50,13 @@ public void onPlayerLogin(com.velocitypowered.api.event.connection.LoginEvent e) InetAddress ip = player.getRemoteAddress().getAddress(); Event loginEvent = loginListener.onJoin(uuid, player.getUsername(), ip); - if(loginEvent.isCancelled()) { + if (loginEvent.isCancelled()) { Component component = Component.text(loginEvent.getCancelReason()); e.setResult(ResultedEvent.ComponentResult.denied(component)); } } + @Subscribe(order = PostOrder.EARLY) public void onPostPlayerLogin(com.velocitypowered.api.event.connection.PostLoginEvent e) { Player player = e.getPlayer(); @@ -69,7 +70,7 @@ public void onPostPlayerLogin(com.velocitypowered.api.event.connection.PostLogin } catch (SQLException | ExecutionException | InterruptedException ex) { throw new RuntimeException(ex); } - if(event.isCancelled()) { + if (event.isCancelled()) { user.disconnect(event.getCancelReason()); } } diff --git a/src/main/java/net/coalcube/bansystem/velocity/util/VelocityConfig.java b/src/main/java/net/coalcube/bansystem/velocity/util/VelocityConfig.java index e6a14c0..9f17d2d 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/util/VelocityConfig.java +++ b/src/main/java/net/coalcube/bansystem/velocity/util/VelocityConfig.java @@ -41,6 +41,7 @@ public VelocityConfig(File configFile, String sectionPath) { } } + @Override public String getString(String key) { return (String) getParameterValue(key); @@ -63,16 +64,16 @@ public List getKeys() { String[] keys = sectionPath.split("\\."); // Split the path by dot Map section = yamldata; List sectionList = new ArrayList<>(); - int i=0; + int i = 0; for (String key : keys) { i++; - if(i == keys.length) { - for(String sectionkey : ((Map)section.get(key)).keySet()) { + if (i == keys.length) { + for (String sectionkey : ((Map) section.get(key)).keySet()) { sectionList.add(sectionkey); } } else { - if(section.get(key) instanceof Map) { + if (section.get(key) instanceof Map) { section = (Map) section.get(key); } else { System.err.println("Key not found or reached a non-map value"); @@ -120,9 +121,9 @@ public Object get(String path) { private Object getParameterValue(String path) { String[] keys = path.split("\\."); Object value = null; - int i=1; - for(String key : keys) { - if(i == 1) { + int i = 1; + for (String key : keys) { + if (i == 1) { value = yamldata.get(keys[0]); } else { if (value instanceof Map) { @@ -148,22 +149,22 @@ private void setParameterValue(String path, Object value) throws IOException { Map tmpYamlData2 = new LinkedHashMap<>(); Map lastMap = new LinkedHashMap<>(); - if(keys.length == 1) { + if (keys.length == 1) { root.put(path, lastMap); } else { - for(String entry : yamldata.keySet()) { - if(entry.equalsIgnoreCase(keys[0])) { + for (String entry : yamldata.keySet()) { + if (entry.equalsIgnoreCase(keys[0])) { // path: VPN.autoban.ID value: 12 - int i=1; - for(String key : keys) { + int i = 1; + for (String key : keys) { System.out.println("key: " + key); - if(i==1) { + if (i == 1) { lastMap = yamldata; } - if(i==keys.length) { + if (i == keys.length) { lastMap.put(key, value); } else { - if(lastMap.get(key) != null) { + if (lastMap.get(key) != null) { lastMap = (Map) lastMap.get(key); } else { lastMap = new LinkedHashMap<>(); @@ -174,24 +175,24 @@ private void setParameterValue(String path, Object value) throws IOException { } String newPath = path; - for(int y=keys.length-1; y>0;y--) { + for (int y = keys.length - 1; y > 0; y--) { String currentKey; System.out.println("y: " + y); - if(newPath.contains(".")) { + if (newPath.contains(".")) { newPath = newPath.substring(0, newPath.lastIndexOf(".")); } System.out.println("newPath: " + newPath); - if(newPath.contains(".")) { + if (newPath.contains(".")) { currentKey = newPath.substring(newPath.lastIndexOf(".") + 1, newPath.length()); } else { currentKey = newPath; } - if(getParameterValue(newPath) == null) { + if (getParameterValue(newPath) == null) { // bansys ids edit 1 add lvl 1123 CHAT System.out.println("currentKey: " + currentKey); - System.out.println("keys[keys.length-2]: " + keys[keys.length-2]); - if(keys[keys.length-2].equalsIgnoreCase(currentKey)) { + System.out.println("keys[keys.length-2]: " + keys[keys.length - 2]); + if (keys[keys.length - 2].equalsIgnoreCase(currentKey)) { tmpYamlData1 = lastMap; System.out.println("tmpYamlData1 = lastMap"); } else { @@ -203,15 +204,15 @@ private void setParameterValue(String path, Object value) throws IOException { } System.out.println("tmpYamlData1: " + tmpYamlData1); - if(!tmpYamlData2.isEmpty()) { - for(String keyset : tmpYamlData2.keySet()) { + if (!tmpYamlData2.isEmpty()) { + for (String keyset : tmpYamlData2.keySet()) { tmpYamlData1.put(keyset, tmpYamlData2.get(keyset)); } System.out.println("puttet tmpYamlData2 onto tmp1"); System.out.println("tmpYamlData1: " + tmpYamlData1); } - if(newPath.contains(".")) { + if (newPath.contains(".")) { tmpYamlData2 = new LinkedHashMap<>(); tmpYamlData2.put(currentKey, tmpYamlData1); System.out.println("tmpYamlData2 path: " + currentKey); diff --git a/src/main/java/net/coalcube/bansystem/velocity/util/VelocityUser.java b/src/main/java/net/coalcube/bansystem/velocity/util/VelocityUser.java index ee9602a..56394dc 100644 --- a/src/main/java/net/coalcube/bansystem/velocity/util/VelocityUser.java +++ b/src/main/java/net/coalcube/bansystem/velocity/util/VelocityUser.java @@ -21,7 +21,7 @@ public VelocityUser(CommandSource sender) { @SuppressWarnings("deprecation") @Override public void sendMessage(String msg) { - if(getUniqueId() == null) { + if (getUniqueId() == null) { LegacyComponentSerializer lcs = LegacyComponentSerializer.legacySection(); sender.sendMessage(lcs.deserialize(msg)); } else { @@ -32,7 +32,7 @@ public void sendMessage(String msg) { @Override public void sendMessage(TextComponent msg) { - if(getUniqueId() == null) { + if (getUniqueId() == null) { LegacyComponentSerializer lcs = LegacyComponentSerializer.legacySection(); sender.sendMessage(lcs.deserialize(msg.getText())); } else { @@ -44,7 +44,7 @@ public void sendMessage(TextComponent msg) { @Override public void disconnect(String message) { - if(sender instanceof Player) { + if (sender instanceof Player) { LegacyComponentSerializer lcs = LegacyComponentSerializer.legacySection(); ((Player) sender).disconnect(lcs.deserialize(message)); } @@ -67,7 +67,7 @@ public Object getRawUser() { @Override public UUID getUniqueId() { - if(sender == null) + if (sender == null) return null; return sender instanceof Player ? ((Player) sender).getUniqueId() : null; } diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index 1947842..9d82199 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -10,7 +10,7 @@ commands: bansys: kick: history: - aliases: [hist] + aliases: [ hist ] check: deletehistory: delhistory: \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 11f943c..8389ade 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,7 +10,7 @@ commands: bansys: kick: history: - aliases: [hist] + aliases: [ hist ] check: deletehistory: delhistory: From c61321e810f82e35c60002b9f21be8e589d6d98b Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:53:19 +0100 Subject: [PATCH 02/11] change(dependencies): update Maven plugin and library versions Upgraded maven-compiler-plugin to 3.14.1, maven-shade-plugin to 3.6.1, and various dependencies (e.g., velocity-api to 3.4.0-SNAPSHOT, gson to 2.13.2, and more) --- pom.xml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 3417519..c1b7d48 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.14.0 + 3.14.1 1.8 1.8 @@ -44,10 +44,8 @@ ${project.name} ${project.version} - ${project.name} ${project.version} - false @@ -56,12 +54,11 @@ org.apache.maven.plugins maven-shade-plugin - 3.6.0 + 3.6.1 org.bstats - net.coalcube.bansystem @@ -103,13 +100,13 @@ com.velocitypowered velocity-api - 3.3.0-SNAPSHOT + 3.4.0-SNAPSHOT provided org.geysermc.floodgate api - 2.2.0-SNAPSHOT + 2.2.5-SNAPSHOT provided @@ -117,7 +114,7 @@ org.xerial sqlite-jdbc - 3.50.1.0 + 3.51.0.0 compile @@ -126,7 +123,7 @@ com.google.code.gson gson - 2.13.1 + 2.13.2 org.json @@ -136,13 +133,13 @@ org.yaml snakeyaml - 2.4 + 2.5 com.mysql mysql-connector-j - 9.3.0 + 9.5.0 From 79af1d4fd27c58bcf3a13f04d122f587337bd868 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:57:27 +0100 Subject: [PATCH 03/11] add(repository): add OpenCollab releases repository to Maven configuration --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index c1b7d48..c19bd52 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,10 @@ opencollab-snapshot https://repo.opencollab.dev/maven-snapshots/ + + opencollab-releases + https://repo.opencollab.dev/maven-releases/ + papermc https://repo.papermc.io/repository/maven-public/ From 3ec574f35b25a6935cf38e51a5328920415d6539 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:07:49 +0100 Subject: [PATCH 04/11] refactor(core): replace deprecated getFormattedRemainingTime with formatRemainingTime Standardized all occurrences of getFormattedRemainingTime to the newer formatRemainingTime method for consistency and streamlined functionality. --- .../bansystem/core/command/CMDban.java | 20 +++++++++---------- .../bansystem/core/command/CMDbansystem.java | 12 +++++------ .../bansystem/core/command/CMDcheck.java | 8 ++++---- .../bansystem/core/command/CMDhistory.java | 10 +++------- .../bansystem/core/listener/ChatListener.java | 20 +++++++++---------- .../core/listener/LoginListener.java | 11 +++++----- .../bansystem/core/util/TimeFormatUtil.java | 7 ------- .../PlayerCommandPreprocessListener.java | 2 +- 8 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDban.java b/src/main/java/net/coalcube/bansystem/core/command/CMDban.java index 69ad4bc..b8b5081 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDban.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDban.java @@ -243,7 +243,7 @@ public void execute(User user, String[] args) { .replaceAll("%P%", configurationUtil.getMessage("prefix")) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%creator%", creatorName) .replaceAll("%enddate%", formattedEndDate) .replaceAll("%lvl%", String.valueOf(lvl)) @@ -256,7 +256,7 @@ public void execute(User user, String[] args) { .replaceAll("%reason%", reason) .replaceAll("%player%", target.getDisplayName()) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%creator%", creatorName) .replaceAll("%enddate%", formattedEndDate) .replaceAll("%lvl%", String.valueOf(lvl)) @@ -264,12 +264,11 @@ public void execute(User user, String[] args) { } } - String banSuccess = configurationUtil.getMessage("Ban.success") .replaceAll("%Player%", Objects.requireNonNull(name)) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%banner%", creatorName) .replaceAll("%type%", type.toString()) .replaceAll("%enddate%", formattedEndDate) @@ -285,7 +284,7 @@ public void execute(User user, String[] args) { .replaceAll("%player%", Objects.requireNonNull(name)) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%banner%", creatorName) .replaceAll("%enddate%", formattedEndDate) .replaceAll("%type%", type.toString()) @@ -297,7 +296,7 @@ public void execute(User user, String[] args) { .replaceAll("%player%", Objects.requireNonNull(name)) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%banner%", creatorName) .replaceAll("%enddate%", formattedEndDate) .replaceAll("%type%", type.toString()) @@ -344,11 +343,10 @@ public List suggest(User user, String[] args) { } private boolean hasPermissionForAnyID(User user) { - for (Integer key : ids) { - if (user.hasPermission("bansys.ban." + key)) - return true; - } - return false; + if (ids == null || ids.isEmpty()) return false; + return ids.stream() + .map(String::valueOf) + .anyMatch(id -> user.hasPermission("bansys.ban." + id)); } private void setParameters(User user, String[] args) throws UnknownHostException { diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java b/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java index 50df792..c00983d 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDbansystem.java @@ -159,9 +159,9 @@ public void execute(User user, String[] args) { String formattedDuration; if (duration == -1) - formattedDuration = timeFormatUtil.getFormattedRemainingTime(duration); + formattedDuration = timeFormatUtil.formatRemainingTime(duration); else - formattedDuration = timeFormatUtil.getFormattedRemainingTime(duration * 1000); + formattedDuration = timeFormatUtil.formatRemainingTime(duration * 1000); String createSuccess = configurationUtil.getMessage("bansystem.ids.create.success") .replaceAll("%ID%", id) @@ -258,9 +258,9 @@ public void execute(User user, String[] args) { try { String formattedDuration; if (duration != -1) - formattedDuration = timeFormatUtil.getFormattedRemainingTime(duration * 1000); + formattedDuration = timeFormatUtil.formatRemainingTime(duration * 1000); else - formattedDuration = timeFormatUtil.getFormattedRemainingTime(duration); + formattedDuration = timeFormatUtil.formatRemainingTime(duration); idManager.addLvl(id, duration, type, creator); banManager.log("added BanID-Lvl", creator, "", @@ -380,7 +380,7 @@ public void execute(User user, String[] args) { if (duration != -1) duration = duration * 1000; - String formattedDuration = timeFormatUtil.getFormattedRemainingTime(duration); + String formattedDuration = timeFormatUtil.formatRemainingTime(duration); String setLvlDurationSuccess = configurationUtil.getMessage("bansystem.ids.edit.setlvlduration.success") .replaceAll("%ID%", id) @@ -600,7 +600,7 @@ public void execute(User user, String[] args) { if (rawduration != -1) rawduration = rawduration * 1000; - String duration = timeFormatUtil.getFormattedRemainingTime(rawduration); + String duration = timeFormatUtil.formatRemainingTime(rawduration); String lvls = configurationUtil.getMessage("bansystem.ids.edit.show.lvls") .replaceAll("%lvl%", lvl.toString()) .replaceAll("%duration%", duration) diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java b/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java index 064a6b4..e4e5d7b 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDcheck.java @@ -94,8 +94,8 @@ public void execute(User user, String[] args) { String bannernetwork = ban.getCreator(); String reasonchat = mute.getReason(); String reasonnetwork = ban.getReason(); - String reamingtimechat = BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime(mute.getRemainingTime()); - String reamingtimenetwork = BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime(ban.getRemainingTime()); + String reamingtimechat = BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime(mute.getRemainingTime()); + String reamingtimenetwork = BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime(ban.getRemainingTime()); String lvlchat = String.valueOf(bm.getLevel(uuid, mute.getReason())); String lvlnetwork = String.valueOf(bm.getLevel(uuid, ban.getReason())); String idchat = mute.getId(); @@ -144,7 +144,7 @@ public void execute(User user, String[] args) { String player = name; String banner = mute.getCreator(); String reason = mute.getReason(); - String reamingtime = BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime(mute.getRemainingTime()); + String reamingtime = BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime(mute.getRemainingTime()); String lvl = String.valueOf(bm.getLevel(uuid, mute.getReason())); try { @@ -179,7 +179,7 @@ public void execute(User user, String[] args) { String banner = ban.getCreator(); String reason = ban.getReason(); String reamingtime = BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(ban.getRemainingTime()); + .formatRemainingTime(ban.getRemainingTime()); int lvl = bm.getLevel(uuid, ban.getReason()); try { diff --git a/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java b/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java index fdda1ba..e493e7f 100644 --- a/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java +++ b/src/main/java/net/coalcube/bansystem/core/command/CMDhistory.java @@ -116,7 +116,7 @@ public int compare(Date o1, Date o2) { if (history.getHistoryType().equals(HistoryType.BAN)) { String id = "Not Found"; - String duration = timeFormatUtil.getFormattedRemainingTime(history.getDuration()); + String duration = timeFormatUtil.formatRemainingTime(history.getDuration()); String endDate; if (history.getEndDate() != null) { endDate = simpleDateFormat.format(history.getEndDate()); @@ -203,16 +203,12 @@ public int compare(Date o1, Date o2) { } } - /* - /command arg0+arg1 | permission - /history | bansys.history.show - */ - @Override public List suggest(User user, String[] args) { if (!user.hasPermission("bansys.history.show")) { - return List.of(); + return new ArrayList<>(); } + List suggests = new ArrayList<>(); List players = BanSystem.getInstance().getAllPlayers(); diff --git a/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java b/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java index 5475e4f..6da8d93 100644 --- a/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java +++ b/src/main/java/net/coalcube/bansystem/core/listener/ChatListener.java @@ -85,7 +85,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio sender.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") .replaceAll("%reason%", ban.getReason()) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(ban.getRemainingTime())) + .formatRemainingTime(ban.getRemainingTime())) .replaceAll("%id%", ban.getId())); bansystem.getConsole().sendMessage("§8[§c§lMUTED§r§8] §f" + sender.getDisplayName() + "§f: " + message); } else { @@ -146,7 +146,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio String banscreen = BanSystem.getInstance().getBanScreen(); banscreen = banscreen.replaceAll("%P%", configurationUtil.getMessage("prefix")); banscreen = banscreen.replaceAll("%reason%", reason); - banscreen = banscreen.replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime(duration)); + banscreen = banscreen.replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime(duration)); banscreen = banscreen.replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()); banscreen = banscreen.replaceAll("%enddate%", enddate); banscreen = banscreen.replaceAll("%lvl%", String.valueOf(lvl)); @@ -157,7 +157,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio } else { sender.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") .replaceAll("%reason%", reason) - .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime(duration)) + .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime(duration)) .replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()) .replaceAll("%enddate%", enddate) .replaceAll("%lvl%", String.valueOf(lvl)) @@ -170,7 +170,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio .replaceAll("%message%", message) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance() - .getTimeFormatUtil().getFormattedRemainingTime(duration)) + .getTimeFormatUtil().formatRemainingTime(duration)) .replaceAll("%id%", ban.getId())); for (User all : bansystem.getAllPlayers()) { @@ -180,7 +180,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio .replaceAll("%message%", message) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance() - .getTimeFormatUtil().getFormattedRemainingTime(duration)) + .getTimeFormatUtil().formatRemainingTime(duration)) .replaceAll("%id%", ban.getId())); } } @@ -229,7 +229,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio banscreen = banscreen.replaceAll("%P%", configurationUtil.getMessage("prefix")); banscreen = banscreen.replaceAll("%reason%", reason); banscreen = banscreen.replaceAll("%reamingtime%", BanSystem.getInstance() - .getTimeFormatUtil().getFormattedRemainingTime(duration)); + .getTimeFormatUtil().formatRemainingTime(duration)); banscreen = banscreen.replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()); banscreen = banscreen.replaceAll("%enddate%", enddate); banscreen = banscreen.replaceAll("%lvl%", String.valueOf(lvl)); @@ -241,7 +241,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio sender.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()) .replaceAll("%enddate%", enddate) .replaceAll("%lvl%", String.valueOf(lvl)) @@ -253,7 +253,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio .replaceAll("%message%", message) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%id%", ban.getId())); for (User all : bansystem.getAllPlayers()) { if (all.hasPermission("bansys.notify") && (all != sender)) { @@ -262,7 +262,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio .replaceAll("%message%", message) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%id%", ban.getId())); } } @@ -291,7 +291,7 @@ public Event onChat(User sender, String message) throws SQLException, IOExceptio } else { String humanReadableReamingTime = BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(tmpReamingTime); + .formatRemainingTime(tmpReamingTime); event.setCancelled(true); sender.sendMessage(configurationUtil.getMessage("chatdelay") diff --git a/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java b/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java index fc2e3aa..1796026 100644 --- a/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java +++ b/src/main/java/net/coalcube/bansystem/core/listener/LoginListener.java @@ -10,6 +10,7 @@ import net.coalcube.bansystem.core.util.*; import net.coalcube.bansystem.core.uuidfetcher.UUIDFetcher; import org.bstats.charts.SimplePie; +import org.geysermc.floodgate.api.FloodgateApi; import java.io.IOException; import java.net.InetAddress; @@ -62,7 +63,7 @@ public Event onJoin(UUID uuid, String name, InetAddress inetAddress) { try { if (!banManager.isSavedBedrockPlayer(uuid) && UUIDFetcher.getName(uuid) == null) { - if (org.geysermc.floodgate.api.FloodgateApi.getInstance().getPlayer(uuid) != null) { + if (FloodgateApi.getInstance().getPlayer(uuid) != null) { banManager.saveBedrockUser(uuid, name); } } @@ -82,7 +83,7 @@ public Event onJoin(UUID uuid, String name, InetAddress inetAddress) { e.setCancelReason(banScreen .replaceAll("%reason%", ban.getReason()) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(ban.getRemainingTime())) + .formatRemainingTime(ban.getRemainingTime())) .replaceAll("%creator%", ban.getCreator()) .replaceAll("%enddate%", enddate) .replaceAll("&", "§") @@ -167,7 +168,7 @@ public Event onPostJoin(User user, InetAddress inetAddress) throws SQLException, String banScreen = BanSystem.getInstance().getBanScreen() .replaceAll("%reason%", ban.getReason()) .replaceAll("%reamingtime%", - BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime( + BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime( ban.getRemainingTime())) .replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()) .replaceAll("%enddate%", endDate) @@ -182,7 +183,7 @@ public Event onPostJoin(User user, InetAddress inetAddress) throws SQLException, .replaceAll("%player%", Objects.requireNonNull(user.getDisplayName())) .replaceAll("%reason%", reason) .replaceAll("%reamingtime%", BanSystem.getInstance().getTimeFormatUtil() - .getFormattedRemainingTime(duration)) + .formatRemainingTime(duration)) .replaceAll("%banner%", bansystem.getConsole().getName()) .replaceAll("%enddate%", endDate) .replaceAll("%type%", type.toString()) @@ -299,7 +300,7 @@ public Event onPostJoin(User user, InetAddress inetAddress) throws SQLException, String banScreen = BanSystem.getInstance().getBanScreen() .replaceAll("%reason%", ban.getReason()) .replaceAll("%reamingtime%", - BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime( + BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime( ban.getRemainingTime())) .replaceAll("%creator%", BanSystem.getInstance().getConsole().getName()) .replaceAll("%enddate%", endDate) diff --git a/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java b/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java index 399c1c9..5bdda83 100644 --- a/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java +++ b/src/main/java/net/coalcube/bansystem/core/util/TimeFormatUtil.java @@ -31,13 +31,6 @@ public TimeFormatUtil(ConfigurationUtil config) { this.config = Objects.requireNonNull(config, "ConfigurationUtil must not be null"); } - /** - * @deprecated use #formatRemainingTime(long remainingMillis) - */ - public String getFormattedRemainingTime(long remainingMillis) { - return this.formatRemainingTime(remainingMillis); - } - /** * Formats the remaining time. * diff --git a/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java b/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java index d0889d9..cc03773 100644 --- a/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java +++ b/src/main/java/net/coalcube/bansystem/spigot/listener/PlayerCommandPreprocessListener.java @@ -58,7 +58,7 @@ public void onCommandPreprocess(PlayerCommandPreprocessEvent e) { if (startsWithBlockedCommnad) { e.setCancelled(true); - String reamingTime = BanSystem.getInstance().getTimeFormatUtil().getFormattedRemainingTime( + String reamingTime = BanSystem.getInstance().getTimeFormatUtil().formatRemainingTime( mute.getRemainingTime()); p.sendMessage(configurationUtil.getMessage("Ban.Chat.Screen") From e2a51f2589e5786dd31aa30ca8492f7a93b38477 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:12:17 +0100 Subject: [PATCH 05/11] change(build): update Java version to 11 Updated Java version requirement and configuration from 1.8 to 11 in POM files and README for compatibility and modernization. --- BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml | 2 +- BanSystem-SpigotChatAdapter/pom.xml | 2 +- README.md | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml index d61b657..1587aa9 100644 --- a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml +++ b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml @@ -55,7 +55,7 @@ - 1.8 + 11 UTF-8 diff --git a/BanSystem-SpigotChatAdapter/pom.xml b/BanSystem-SpigotChatAdapter/pom.xml index 129457b..9847e96 100644 --- a/BanSystem-SpigotChatAdapter/pom.xml +++ b/BanSystem-SpigotChatAdapter/pom.xml @@ -12,7 +12,7 @@ BanSystem-SpigotChatAdapter - 1.8 + 11 UTF-8 diff --git a/README.md b/README.md index 539c4b5..cc8f269 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Ein umfangreiches Bestrafungssystem für Minecraft Server. Umfasst viele Funktio ## Anforderungen -- **mindestens Java 8** +- **mindestens Java 11** - **BungeeCord, Spigot oder Velocity Server** - MySQL Datenbank (optional) diff --git a/pom.xml b/pom.xml index c19bd52..b30e05c 100644 --- a/pom.xml +++ b/pom.xml @@ -34,8 +34,8 @@ maven-compiler-plugin 3.14.1 - 1.8 - 1.8 + 11 + 11 From 30119562ad70804e9c3760aea21eb7c5e5cdc5ea Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:15:14 +0100 Subject: [PATCH 06/11] change(ci): enhance build workflow with matrix builds and conditional steps - Added Java version matrix support for better testing coverage. - Split build steps for PRs and pushes with conditional logic. - Improved artifact handling and caching for Maven builds. --- .github/workflows/build.yml | 47 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 932ba6f..cc7ba8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,34 +1,45 @@ -name: Build artifact +name: Build on: push: - branches: - - master + branches: [ master ] pull_request: + branches: [ master ] jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [ '11' ] + steps: - # Step 1: Checkout the code - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 - # Step 2: Set up JDK 21 (or another version if needed) - - name: Set up JDK 21 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v4 with: - java-version: '21' - distribution: 'temurin' + distribution: temurin + java-version: ${{ matrix.java }} + cache: maven + + - name: Validate & Build (no tests on PRs) + if: github.event_name == 'pull_request' + run: mvn -B -ntp -DskipTests=true clean package - # Step 3: Build with Maven - - name: Build with Maven - run: mvn clean package + - name: Test & Build + if: github.event_name != 'pull_request' + run: mvn -B -ntp clean verify - # Step 4: Upload artifact - - name: Upload Plugin Artifact + - name: Upload Artifacts + if: success() uses: actions/upload-artifact@v4 with: - name: minecraft-plugin - path: target/*.jar + name: build-artifacts-${{ matrix.java }} + path: | + target/*.jar + !target/original-*.jar + if-no-files-found: warn \ No newline at end of file From af4273db5529e52c893f6aea7382cc318fbba40d Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:17:44 +0100 Subject: [PATCH 07/11] change(ci): include develop branch in build workflow trigger --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc7ba8e..0a7bfba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: [ master, develop ] jobs: build: From f65771509ce4876555969a983a52a7bd0f170556 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:19:05 +0100 Subject: [PATCH 08/11] change(build): bump version to 3.3 in configuration files --- pom.xml | 2 +- src/main/resources/bungee.yml | 2 +- src/main/resources/plugin.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b30e05c..3d23727 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.coalcube.bansystem BanSystem - 3.2 + 3.3 diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index 9d82199..c51a12d 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -1,5 +1,5 @@ name: BanSystem -version: 3.2 +version: 3.3 author: Tobias Herzig main: net.coalcube.bansystem.bungee.BanSystemBungee commands: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 8389ade..88c0ae3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: BanSystem -version: 3.2 +version: 3.3 author: Tobias Herzig main: net.coalcube.bansystem.spigot.BanSystemSpigot commands: From 41808911b36f04abd4bede8c339c2d6d2cec9c12 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Wed, 12 Nov 2025 16:22:05 +0100 Subject: [PATCH 09/11] change(build): update Java version to 17 Updated Java version requirement and configuration from 11 to 17 in POM files, README, and CI workflow for compatibility and modernization. --- .github/workflows/build.yml | 2 +- BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml | 2 +- BanSystem-SpigotChatAdapter/pom.xml | 2 +- README.md | 2 +- pom.xml | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a7bfba..0320cf4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - java: [ '11' ] + java: [ '17' ] steps: - name: Checkout diff --git a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml index 1587aa9..a282065 100644 --- a/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml +++ b/BanSystem-SpigotChatAdapter/dependency-reduced-pom.xml @@ -55,7 +55,7 @@ - 11 + 17 UTF-8 diff --git a/BanSystem-SpigotChatAdapter/pom.xml b/BanSystem-SpigotChatAdapter/pom.xml index 9847e96..0aead77 100644 --- a/BanSystem-SpigotChatAdapter/pom.xml +++ b/BanSystem-SpigotChatAdapter/pom.xml @@ -12,7 +12,7 @@ BanSystem-SpigotChatAdapter - 11 + 17 UTF-8 diff --git a/README.md b/README.md index cc8f269..da7f7d0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Ein umfangreiches Bestrafungssystem für Minecraft Server. Umfasst viele Funktio ## Anforderungen -- **mindestens Java 11** +- **mindestens Java 17** - **BungeeCord, Spigot oder Velocity Server** - MySQL Datenbank (optional) diff --git a/pom.xml b/pom.xml index 3d23727..6d93d28 100644 --- a/pom.xml +++ b/pom.xml @@ -34,8 +34,8 @@ maven-compiler-plugin 3.14.1 - 11 - 11 + 17 + 17 From d96f6780cdda43f05e35044c26eb69954b08a56e Mon Sep 17 00:00:00 2001 From: antisocialtobi <46757149+antisocialtobi@users.noreply.github.com> Date: Wed, 12 Nov 2025 17:28:45 +0100 Subject: [PATCH 10/11] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da7f7d0..afaf6cf 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,8 @@ Ein umfangreiches Bestrafungssystem für Minecraft Server. Umfasst viele Funktio ## Installation 1. Lade dir das Plugin herunter. -2. Ziehe das Plugin in den Plugins-Ordner (bei Verwendung eines Proxys nur in den jeweiligen Plugins-Ordner ziehen * - *nicht in die Unterserver**). +2. Ziehe das Plugin in den Plugins-Ordner (bei Verwendung eines Proxys nur in den jeweiligen Plugins-Ordner ziehen + **nicht in die Unterserver**). 3. Server starten. ### Ab der Version 1.19.1 From 91d22dc57a55d2c5c494612b3c58d0925b7758f8 Mon Sep 17 00:00:00 2001 From: Julian <53055251+NoJokeFNA@users.noreply.github.com> Date: Thu, 13 Nov 2025 09:37:54 +0100 Subject: [PATCH 11/11] Correct formatting for ban level explanation Fix formatting issues in the README regarding ban levels. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index afaf6cf..33dec08 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ automatisch gebannt werden. Das ID System ist komplett variabel, d.h. man kann IDs abändern, entfernen und hinzufügen. Es lassen sich alle IDs mithilfe von `/ban` auflisten. Die Zeit ist in Sekunden gerechnet, z.B. ein Tag sind `86400 Sekunden` oder für ein Jahr `31536000 Sekunden`. -Für jede ID gibt es auch Level, d.h. wenn ein Spieler **zweimal** für den **gleichen Grund gebannt wird**, wird dieser * -*länger gebannt**, insofern ein zweites Level bei der ID angegeben wurde. +Für jede ID gibt es auch Level, d.h. wenn ein Spieler **zweimal** für den **gleichen Grund gebannt wird**, wird dieser +**länger gebannt**, insofern ein zweites Level bei der ID angegeben wurde. Falls ein Spieler schon mal für alle Level gebannt wurde, wird dieser für das letzte Level nochmal gebannt. ## VPN-Check API-Key