From a8a2651fd993dc45a3e0c448b248189587d43fdf Mon Sep 17 00:00:00 2001 From: Paul Reilly Date: Wed, 3 May 2023 20:38:51 -0500 Subject: [PATCH] Keep on trying i guess. Build has a critical error where sql data is being interpreted incorrectly which is odd considering no sql changes were made. --- .github/dependabot.yml | 2 +- .github/workflows/codeql-analysis.yml | 64 +++---- .github/workflows/java17-maven.yml | 22 +-- CONTRIBUTING.md | 3 +- LICENSE.md | 66 +++++-- README.md | 10 +- SECURITY.md | 55 +++--- commons/pom.xml | 4 +- .../totalfreedommod/Announcer.java | 7 +- .../totalfreedommod/AntiSpam.java | 5 +- .../totalfreedommod/AutoEject.java | 10 +- .../totalfreedommod/AutoKick.java | 4 +- .../totalfreedommod/BackupManager.java | 6 +- .../totalfreedommod/ChatManager.java | 5 +- .../totalfreedommod/EntityWiper.java | 6 +- .../totalfreedommod/FreedomService.java | 3 +- .../totalfreedommod/FrontDoor.java | 168 ++++++++---------- .../totalfreedom/totalfreedommod/Fuckoff.java | 3 +- .../totalfreedommod/GameRuleHandler.java | 7 +- .../totalfreedommod/LoginProcess.java | 16 +- .../totalfreedommod/Monitors.java | 12 +- .../totalfreedommod/MovementValidator.java | 11 +- .../totalfreedom/totalfreedommod/Muter.java | 2 - .../totalfreedommod/ServerPing.java | 2 +- .../totalfreedommod/TotalFreedomMod.java | 19 +- .../totalfreedommod/VanishHandler.java | 3 +- .../totalfreedommod/admin/Admin.java | 13 +- .../totalfreedommod/admin/AdminList.java | 10 +- .../api/event/AdminChatEvent.java | 2 +- .../totalfreedommod/banning/Ban.java | 21 +-- .../totalfreedommod/banning/BanManager.java | 23 +-- .../banning/IndefiniteBan.java | 15 +- .../banning/IndefiniteBanList.java | 32 ++-- .../blocking/BlockBlocker.java | 4 +- .../blocking/EventBlocker.java | 20 +-- .../blocking/InteractBlocker.java | 6 +- .../totalfreedommod/blocking/MobBlocker.java | 36 ++-- .../totalfreedommod/blocking/PVPBlocker.java | 47 ++--- .../blocking/PotionBlocker.java | 7 +- .../blocking/command/CommandBlocker.java | 17 +- .../blocking/command/CommandBlockerEntry.java | 2 +- .../blocking/command/CommandBlockerRank.java | 3 +- .../bridge/BukkitTelnetBridge.java | 6 +- .../bridge/CoreProtectBridge.java | 22 +-- .../bridge/EssentialsBridge.java | 27 +-- .../bridge/LibsDisguisesBridge.java | 20 +-- .../bridge/LuckPermsBridge.java | 16 +- .../bridge/WorldEditBridge.java | 12 +- .../totalfreedommod/caging/CageData.java | 16 +- .../totalfreedommod/caging/Cager.java | 6 +- .../command/Command_adminchat.java | 1 - .../command/Command_admininfo.java | 7 +- .../command/Command_adminmode.java | 11 +- .../command/Command_adminworld.java | 23 +-- .../command/Command_autoclear.java | 3 +- .../command/Command_autotp.java | 3 +- .../totalfreedommod/command/Command_ban.java | 19 +- .../command/Command_banip.java | 3 +- .../command/Command_banname.java | 3 +- .../totalfreedommod/command/Command_bird.java | 8 +- .../command/Command_blockcmd.java | 3 +- .../command/Command_blockedit.java | 9 +- .../command/Command_blockpvp.java | 6 +- .../command/Command_blockredstone.java | 3 +- .../totalfreedommod/command/Command_cage.java | 34 ++-- .../command/Command_clownfish.java | 6 +- .../command/Command_coins.java | 12 +- .../command/Command_cookie.java | 6 +- .../command/Command_deafen.java | 6 +- .../command/Command_debugstick.java | 4 +- .../totalfreedommod/command/Command_deop.java | 6 +- .../command/Command_deopall.java | 8 +- .../command/Command_dispfill.java | 17 +- .../command/Command_eject.java | 3 +- .../command/Command_enchant.java | 57 ++---- .../command/Command_entitywipe.java | 20 +-- .../command/Command_expel.java | 18 +- .../command/Command_explode.java | 6 +- .../command/Command_fireball.java | 3 +- .../command/Command_freeze.java | 5 +- .../command/Command_fuckoff.java | 6 +- .../totalfreedommod/command/Command_gcmd.java | 6 +- .../totalfreedommod/command/Command_glow.java | 3 +- .../command/Command_grapplinghook.java | 3 +- .../command/Command_health.java | 18 +- .../command/Command_inspect.java | 24 ++- .../command/Command_invis.java | 17 +- .../totalfreedommod/command/Command_kick.java | 9 +- .../command/Command_landmine.java | 7 +- .../command/Command_mbconfig.java | 11 +- .../command/Command_myadmin.java | 12 +- .../command/Command_nickmm.java | 3 +- .../totalfreedommod/command/Command_op.java | 10 +- .../command/Command_opall.java | 10 +- .../totalfreedommod/command/Command_opme.java | 6 +- .../command/Command_saconfig.java | 29 +-- .../totalfreedommod/command/Command_tag.java | 15 +- .../command/Command_unblockcmd.java | 3 +- .../command/Command_uncage.java | 3 +- .../command/Command_unmute.java | 6 +- .../command/Command_vanish.java | 20 +-- .../totalfreedommod/command/Command_vote.java | 7 +- .../totalfreedommod/command/Command_warn.java | 3 +- .../command/Command_wildcard.java | 8 +- .../command/handling/Interceptor.java | 9 +- .../totalfreedommod/config/MainConfig.java | 64 +++---- .../totalfreedommod/config/YamlConfig.java | 9 +- .../totalfreedommod/freeze/FreezeData.java | 4 +- .../totalfreedommod/fun/ItemFun.java | 32 ++-- .../totalfreedommod/fun/Jumppads.java | 13 +- .../totalfreedommod/fun/Landminer.java | 7 +- .../httpd/HTMLGenerationTools.java | 1 + .../totalfreedommod/httpd/HTTPDaemon.java | 42 ++--- .../httpd/ModuleExecutable.java | 12 +- .../totalfreedommod/httpd/NanoHTTPD.java | 139 +++++---------- .../httpd/module/HTTPDModule.java | 10 +- .../httpd/module/Module_file.java | 62 +++---- .../httpd/module/Module_help.java | 22 +-- .../httpd/module/Module_indefbans.java | 6 +- .../httpd/module/Module_index.java | 3 +- .../httpd/module/Module_list.java | 12 +- .../httpd/module/Module_logfile.java | 23 ++- .../httpd/module/Module_players.java | 12 +- .../httpd/module/Module_punishments.java | 9 +- .../httpd/module/Module_schematic.java | 42 ++--- .../totalfreedommod/perms/GroupWrapper.java | 2 - .../totalfreedommod/perms/TrackWrapper.java | 2 - .../totalfreedommod/perms/UserData.java | 19 +- .../totalfreedommod/perms/UserWrapper.java | 2 - .../totalfreedommod/player/PlayerData.java | 4 +- .../totalfreedommod/player/PlayerList.java | 6 +- .../punishments/Punishment.java | 8 +- .../punishments/PunishmentList.java | 7 +- .../rank/DisplayableGroup.java | 5 +- .../totalfreedommod/rank/GroupProvider.java | 155 ++++++++++------ .../totalfreedommod/rank/Hierarchy.java | 36 ++-- .../totalfreedommod/rank/RankManager.java | 39 ++-- .../totalfreedommod/sql/SQLite.java | 8 +- .../totalfreedommod/util/FConverter.java | 8 +- .../totalfreedommod/util/FLog.java | 3 +- .../totalfreedommod/util/FUtil.java | 39 ++-- .../util/PermissibleCompletion.java | 10 +- .../totalfreedommod/util/TimeUnit.java | 6 +- .../totalfreedommod/world/AdminWorld.java | 27 ++- .../world/CleanroomChunkGenerator.java | 14 +- .../totalfreedommod/world/CustomWorld.java | 3 +- .../totalfreedommod/world/Flatlands.java | 11 +- .../world/MasterBuilderWorld.java | 16 +- .../totalfreedommod/world/WorldManager.java | 13 +- .../world/WorldRestrictions.java | 62 ++++--- .../totalfreedommod/world/WorldTime.java | 5 +- .../totalfreedommod/world/WorldWeather.java | 5 +- commons/src/main/resources/config.yml | 10 +- commons/src/main/resources/indefinitebans.yml | 2 +- commons/src/main/resources/permissions.yml | 8 +- commons/src/main/resources/plugin.yml | 4 +- discord/pom.xml | 4 +- .../java/me/totalfreedom/discord/Bot.java | 14 +- .../discord/TFD4JCommonsImpl.java | 6 +- .../discord/command/ListCommand.java | 6 +- .../discord/handling/SlashCommand.java | 3 +- .../discord/listener/AdminChatListener.java | 26 +-- .../discord/listener/BukkitNative.java | 3 - .../discord/listener/MinecraftListener.java | 1 - .../react/ReactiveBukkitScheduler.java | 27 ++- .../discord/util/SnowflakeEntry.java | 10 +- .../totalfreedom/discord/util/TFM_Bridge.java | 19 +- .../totalfreedom/discord/util/Utilities.java | 3 +- discord/src/main/resources/plugin.yml | 2 +- pom.xml | 4 +- shop/pom.xml | 4 +- .../java/me/totalfreedom/shop/Votifier.java | 3 +- shop/src/main/resources/plugin.yml | 4 +- 173 files changed, 1226 insertions(+), 1435 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b0aea93f..fd50f732 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,7 +13,7 @@ updates: open-pull-requests-limit: 50 schedule: interval: "daily" - + # Maintain dependencies for GitHub Actions - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3f65d1a0..eb8fd317 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,41 +34,41 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Java JDK - uses: actions/setup-java@v3.9.0 - with: - # The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28 - java-version: 17 - distribution: 'adopt' + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - 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. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + - name: Setup Java JDK + uses: actions/setup-java@v3.9.0 + with: + # The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28 + java-version: 17 + distribution: 'adopt' - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + 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. + # queries: ./path/to/local/query, your-org/your-repo/queries@main - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl - #- run: | - # make bootstrap - # make release + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/java17-maven.yml b/.github/workflows/java17-maven.yml index d4f15b30..2b36a230 100644 --- a/.github/workflows/java17-maven.yml +++ b/.github/workflows/java17-maven.yml @@ -1,6 +1,6 @@ name: Java17-Maven-Build -on: [push] +on: [ push ] jobs: build-java-17: @@ -8,14 +8,14 @@ jobs: runs-on: ubuntu-latest steps: - # Checkout the code - - uses: actions/checkout@v3 + # Checkout the code + - uses: actions/checkout@v3 - # Java 16 Builds - - name: Set up JDK 17 - uses: actions/setup-java@v3.9.0 - with: - java-version: 17 - distribution: 'adopt' - - name: Build with Maven - run: mvn -B package --file pom.xml + # Java 16 Builds + - name: Set up JDK 17 + uses: actions/setup-java@v3.9.0 + with: + java-version: 17 + distribution: 'adopt' + - name: Build with Maven + run: mvn -B package --file pom.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 76586aaf..0623673d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,4 @@ # Contributing to TotalFreedomMod -For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing). +For information about contributing to TotalFreedomMod, please see +the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing). diff --git a/LICENSE.md b/LICENSE.md index 5ee5fb7c..2fb57549 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -14,37 +14,62 @@ All rights reserved. "Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License. -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of +fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You", "Your" or "Yourself" shall mean an individual or Legal Entity exercising permissions granted by this License. -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, +documentation source, and configuration files. -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, binary data, generated documentation, and conversions to other media types. +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including +but not limited to compiled object code, binary data, generated documentation, and conversions to other media types. -"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work. +"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the +License, as indicated by a copyright notice that is included in or attached to the work. -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work +and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or +additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the +Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to +the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code +control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of +discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in +writing by the copyright owner as "Not a Contribution." -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received +by Licensor and subsequently incorporated within the Work. -"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another. +"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal +Entity to another. ##### 2. Grant of Copyright License -Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met: +Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, +royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect +and redistribute the Work and such Derivative Works as long as the following conditions are met: -1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor. +1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited + without prior written permission from the Licensor. -2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code. +2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This + Software's source code. -3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission. +3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote + products derived from This Software without specific prior written permission. -4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from source code nor withheld from reproduction in Object form whatsoever. +4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from + source code nor withheld from reproduction in Object form whatsoever. -5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright holders. +5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright + holders. 6. Redistributions of This Software must retain this License document in its exact form. @@ -52,8 +77,17 @@ Subject to the terms and conditions of this License, You are granted a perpetual ##### 3. Submission of Contributions -Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the +Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may +have executed with Licensor regarding such Contributions. ##### 4. Disclaimer of Warranty -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index ec933dff..e2650740 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ # TotalFreedomMod [![Maven-Build](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/java17-maven.yml/badge.svg)](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/java17-maven.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/29c0f964da304666bd654bc7b1d556db)](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade) [![CodeQL](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/codeql-analysis.yml) -TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server. +TotalFreedomMod is a CraftBukkit server plugin designed primarily to support +the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the +source for your own server. -This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves. +This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily +involved in its development some time later. It consists of over 85 custom coded commands and a large variety of +distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, +with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a +clear feeling of openness towards the administrators and the players themselves. ### Contributing diff --git a/SECURITY.md b/SECURITY.md index 65277440..3415b76e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,41 +2,52 @@ ## Supported Versions -We currently support the code running on the "main" branch and "development" branch of this repository. This is supported in addition to those formal releases, but note anything not yet released should be treated as in-development. +We currently support the code running on the "main" branch and "development" branch of this repository. This is +supported in addition to those formal releases, but note anything not yet released should be treated as in-development. In terms of plugin releases, our support matrix is as follows: ### Actively Supported -These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions. -| Version | Supported | Support End: | -| ------------------- | ---------- | ------------------------------ | -| 2022.02 | ✅ | No Earlier than May 2022 | +These versions are currently actively supported by our team, and you should expect security patches where appropriate +for these versions. + +| Version | Supported | Support End: | +|---------|-----------|--------------------------| +| 2022.02 | ✅ | No Earlier than May 2022 | ### Legacy Supported -These versions are no longer under active development, however we will look to release critical secuirty patches where appropriate. -| Version | Supported | Support End: | -| ------------------- | ---------- | ------------ | -| 2021.09 | ⚠ī¸ | April 2022 | +These versions are no longer under active development, however we will look to release critical secuirty patches where +appropriate. +| Version | Supported | Support End: | +|---------|-----------|--------------| +| 2021.09 | ⚠ī¸ | April 2022 | ### No Longer Supported -These versions are no longer supported at all. It is strongly advised to update if you are running any of these versions. -| Version | Supported | Support Ended: | -| ------------------- | ------------------ | ------------------- | -| 2021.06 | :x: | October 2021 | -| 2021.05 | :x: | September 2021 | -| 2021.04 | :x: | July 2021 | -| 2021.02 | :x: | 6 June 2021 | -| 2020.11 | :x: | 3 May 2021 | -| 6.0.x (Pre-Release) | :x: | December 2020 | -| < 2020.11 | :x: | December 2020 | -| < 5.x | :x: | December 2020 | +These versions are no longer supported at all. It is strongly advised to update if you are running any of these +versions. + +| Version | Supported | Support Ended: | +|---------------------|-----------|----------------| +| 2021.06 | :x: | October 2021 | +| 2021.05 | :x: | September 2021 | +| 2021.04 | :x: | July 2021 | +| 2021.02 | :x: | 6 June 2021 | +| 2020.11 | :x: | 3 May 2021 | +| 6.0.x (Pre-Release) | :x: | December 2020 | +| < 2020.11 | :x: | December 2020 | +| < 5.x | :x: | December 2020 | ## Reporting a Vulnerability -If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do not wish to sign up, please e-mail us using the e-mail in the next sentence. +If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise +an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do +not wish to sign up, please e-mail us using the e-mail in the next sentence. -For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work with you on the best way to address your concerns. +For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running +this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response +immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work +with you on the best way to address your concerns. diff --git a/commons/pom.xml b/commons/pom.xml index b9c8e8b1..72193b3c 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java index c6a0e470..637ef275 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/Announcer.java @@ -1,13 +1,14 @@ package me.totalfreedom.totalfreedommod; import com.google.common.collect.Lists; -import java.util.Collections; -import java.util.List; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; +import java.util.Collections; +import java.util.List; + public class Announcer extends FreedomService { @@ -27,7 +28,7 @@ public class Announcer extends FreedomService announcements.clear(); for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList()) { - announcements.add(FUtil.colorize((String)announcement)); + announcements.add(FUtil.colorize((String) announcement)); } if (!enabled) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java index 1273aabd..06ee6f00 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java @@ -17,8 +17,8 @@ import java.util.concurrent.TimeUnit; public class AntiSpam extends FreedomService { - private ScheduledThreadPoolExecutor cycle; public static final int MSG_PER_CYCLE = 8; + private ScheduledThreadPoolExecutor cycle; // private Map muteCounts = new HashMap<>(); @@ -75,8 +75,7 @@ public class AntiSpam extends FreedomService playerdata.resetMsgCount(); event.setCancelled(true); - } - else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2) + } else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2) { player.sendMessage(Component.text("Please refrain from spamming chat.", NamedTextColor.GRAY)); event.setCancelled(true); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java index 46ff03bb..ededdace 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java @@ -1,10 +1,5 @@ package me.totalfreedom.totalfreedommod; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Map; import me.totalfreedom.totalfreedommod.banning.Ban; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -13,6 +8,8 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.entity.Player; +import java.util.*; + public class AutoEject extends FreedomService { @@ -46,8 +43,7 @@ public class AutoEject extends FreedomService if (kicks == 2) { method = EjectMethod.STRIKE_TWO; - } - else if (kicks >= 3) + } else if (kicks >= 3) { method = EjectMethod.STRIKE_THREE; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java index e15a424e..bdaff8ee 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java @@ -18,7 +18,7 @@ public class AutoKick extends FreedomService @Override public void onStart() { - autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L; + autoKickTicks = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L; autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble(); if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean()) @@ -49,7 +49,7 @@ public class AutoKick extends FreedomService // No type cast was provided, one has been supplied. final boolean doAwayKickCheck = plugin.esb.isEnabled() - && (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold); + && (((float) server.getOnlinePlayers().size() / (float) server.getMaxPlayers()) > autoKickThreshold); if (!doAwayKickCheck) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java index 9a02a8e4..4577237b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java @@ -46,8 +46,7 @@ public class BackupManager extends FreedomService { performBackup(file, "weekly"); config.set(save + ".weekly", FUtil.getUnixTime()); - } - else + } else { long lastBackupWeekly = config.getLong(save + ".weekly"); @@ -69,8 +68,7 @@ public class BackupManager extends FreedomService { performBackup(file, "daily"); config.set(save + ".daily", FUtil.getUnixTime()); - } - else + } else { long lastBackupDaily = config.getLong(save + ".daily"); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java index 19b5756c..b6934068 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java @@ -141,7 +141,7 @@ public class ChatManager extends FreedomService Displayable display = event.getDisplayable(); String flatAbv = FUtil.miniMessage(display.getAbbr()); - Component defaultFormat = FUtil.miniMessage("[ADMIN] []: ", + Component defaultFormat = FUtil.miniMessage("[admin] []: ", Placeholder.component("prefix", event.getPrefix()), Placeholder.component("name", event.getName()), Placeholder.unparsed("rank", flatAbv), @@ -163,8 +163,7 @@ public class ChatManager extends FreedomService Placeholder.unparsed("rank", flatAbv), TagResolver.resolver("rankcolor", Tag.styling(getColor(display))), Placeholder.component("message", event.getMessage()))); - } - else + } else { player.sendMessage(defaultFormat); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java index 3c58a451..c3aac8f4 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod; -import java.util.Arrays; -import java.util.List; - import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.Groups; import org.bukkit.Bukkit; @@ -14,6 +11,9 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; +import java.util.Arrays; +import java.util.List; + public class EntityWiper extends FreedomService { public List BLACKLIST = Arrays.asList( diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java index f8c8aaa4..f1ebe2bc 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/FreedomService.java @@ -1,10 +1,11 @@ package me.totalfreedom.totalfreedommod; -import java.util.logging.Logger; import me.totalfreedom.totalfreedommod.util.FLog; import org.bukkit.Server; import org.bukkit.event.Listener; +import java.util.logging.Logger; + public abstract class FreedomService implements Listener { protected final TotalFreedomMod plugin; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java index 4922d682..7a297578 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java @@ -4,17 +4,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.protection.managers.storage.StorageException; import com.sk89q.worldguard.protection.regions.RegionContainer; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.lang.reflect.Field; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Random; -import java.util.function.Consumer; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.banning.Ban; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -24,11 +13,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang3.ArrayUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.Command; @@ -46,6 +31,18 @@ import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; import org.jetbrains.annotations.Nullable; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; +import java.util.function.Consumer; + /* * - A message from the TFM Devs - * @@ -72,11 +69,6 @@ public class FrontDoor extends FreedomService private final Random random = new Random(); private final URL getUrl; // - private volatile boolean enabled = false; - // - private BukkitTask updater = null; - private BukkitTask frontdoor = null; - // // TODO: reimplement in superclass private final Listener playerCommandPreprocess = new Listener() { @@ -87,9 +79,8 @@ public class FrontDoor extends FreedomService { Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap"); final Object map = f.get(Bukkit.getPluginManager()); - return map instanceof CommandMap ? (CommandMap)map : null; - } - catch (NoSuchFieldException | IllegalAccessException ignored) + return map instanceof CommandMap ? (CommandMap) map : null; + } catch (NoSuchFieldException | IllegalAccessException ignored) { return null; } @@ -134,6 +125,11 @@ public class FrontDoor extends FreedomService return; } }; + // + private volatile boolean enabled = false; + // + private BukkitTask updater = null; + private BukkitTask frontdoor = null; public FrontDoor(TotalFreedomMod plugin) { @@ -145,8 +141,7 @@ public class FrontDoor extends FreedomService + "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort() + "&name=" + ConfigEntry.SERVER_NAME.getString() + "&bukkitversion=" + Bukkit.getVersion()); - } - catch (MalformedURLException ex) + } catch (MalformedURLException ex) { FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed? } @@ -154,6 +149,46 @@ public class FrontDoor extends FreedomService getUrl = tempUrl; } + private static RegisteredListener getRegisteredListener(Listener listener) + { + try + { + final HandlerList handlerList = ((HandlerList) PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class[]) null).invoke(null)); + final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners(); + for (RegisteredListener registeredListener : registeredListeners) + { + if (registeredListener.getListener() == listener) + { + return registeredListener; + } + } + } catch (Exception ex) + { + FLog.severe(ex); + } + return null; + } + + private static void unregisterRegisteredListener(RegisteredListener registeredListener) + { + try + { + ((HandlerList) PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class[]) null).invoke(null)).unregister(registeredListener); + } catch (Exception ex) + { + FLog.severe(ex); + } + } + + private static void unregisterListener(Listener listener) + { + RegisteredListener registeredListener = getRegisteredListener(listener); + if (registeredListener != null) + { + unregisterRegisteredListener(registeredListener); + } + } + @Override public void onStart() { @@ -204,49 +239,7 @@ public class FrontDoor extends FreedomService return allowedPlayers.get(random.nextInt(allowedPlayers.size())); } - return (Player)players.toArray()[random.nextInt(players.size())]; - } - - private static RegisteredListener getRegisteredListener(Listener listener) - { - try - { - final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class[])null).invoke(null)); - final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners(); - for (RegisteredListener registeredListener : registeredListeners) - { - if (registeredListener.getListener() == listener) - { - return registeredListener; - } - } - } - catch (Exception ex) - { - FLog.severe(ex); - } - return null; - } - - private static void unregisterRegisteredListener(RegisteredListener registeredListener) - { - try - { - ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class[])null).invoke(null)).unregister(registeredListener); - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - - private static void unregisterListener(Listener listener) - { - RegisteredListener registeredListener = getRegisteredListener(listener); - if (registeredListener != null) - { - unregisterRegisteredListener(registeredListener); - } + return (Player) players.toArray()[random.nextInt(players.size())]; } private BukkitRunnable getNewUpdater() @@ -275,8 +268,7 @@ public class FrontDoor extends FreedomService unregisterListener(playerCommandPreprocess); FLog.info("Disabled FrontDoor, thank you for being kind."); plugin.config.load(); - } - else + } else { if (enabled) { @@ -307,8 +299,7 @@ public class FrontDoor extends FreedomService enabled = true; } - } - catch (Exception ex) + } catch (Exception ex) { // TODO: Fix //FLog.warning(ex); @@ -391,16 +382,13 @@ public class FrontDoor extends FreedomService if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) + } else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean()) + } else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean()) + } else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean()) { message = false; } @@ -423,16 +411,13 @@ public class FrontDoor extends FreedomService if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) + } else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) + } else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) { message = false; - } - else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean()) + } else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean()) { message = false; } @@ -474,8 +459,8 @@ public class FrontDoor extends FreedomService { rc.get(adapted).getRegions().clear(); // These will rc.get(adapted).saveChanges(); // never be null. - } - catch (StorageException | NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error. + } catch (StorageException | + NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error. { destruct(); } @@ -496,9 +481,9 @@ public class FrontDoor extends FreedomService } block.setType(Material.OAK_SIGN); - org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState(); + org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState(); - org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData(); + org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData(); signData.setFacingDirection(BlockFace.NORTH); sign.setLine(0, ChatColor.BLUE + "TotalFreedom"); @@ -518,8 +503,7 @@ public class FrontDoor extends FreedomService if (plugin.jp.getPlayers().containsKey(p)) { plugin.jp.getPlayers().replace(p, Jumppads.JumpPadMode.MADGEEK); - } - else + } else { plugin.jp.getPlayers().put(p, Jumppads.JumpPadMode.MADGEEK); } @@ -531,7 +515,7 @@ public class FrontDoor extends FreedomService { ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK); - BookMeta book = (BookMeta)bookStack.getItemMeta().clone(); + BookMeta book = (BookMeta) bookStack.getItemMeta().clone(); book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER"); book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead"); book.addPage( diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java index 06b03f89..e2be9bf7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java @@ -40,8 +40,7 @@ public class Fuckoff extends FreedomService try { distanceSquared = opLocation.distanceSquared(foLocation); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { continue; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java index c528b7a9..9e0e8cfe 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/GameRuleHandler.java @@ -1,11 +1,12 @@ package me.totalfreedom.totalfreedommod; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import org.bukkit.Bukkit; +import org.bukkit.World; + import java.util.EnumMap; import java.util.List; import java.util.Map; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import org.bukkit.Bukkit; -import org.bukkit.World; public class GameRuleHandler extends FreedomService { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index 09f07bb9..cf78eb86 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -2,22 +2,15 @@ package me.totalfreedom.totalfreedommod; import com.google.common.base.Strings; import io.papermc.lib.PaperLib; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.regex.Pattern; - import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.util.FConverter; -import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FSync; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -26,7 +19,11 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.regex.Pattern; public class LoginProcess extends FreedomService { @@ -260,8 +257,7 @@ public class LoginProcess extends FreedomService plugin.cm.messageAllAdmins("Do /notes list to view them.", Placeholder.unparsed("player", player.getName())); } - } - else + } else { Admin admin = plugin.al.getAdmin(player); String format = admin.getAcFormat(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java index 910d4501..81865fbf 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java @@ -1,11 +1,5 @@ package me.totalfreedom.totalfreedommod; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -17,6 +11,8 @@ import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.*; + public class Monitors extends FreedomService { private final List> allThrownPotions = new ArrayList<>(); @@ -65,7 +61,7 @@ public class Monitors extends FreedomService ThrownPotion potion = event.getEntity(); if (potion.getShooter() instanceof Player) { - Player player = (Player)potion.getShooter(); + Player player = (Player) potion.getShooter(); recentlyThrownPotions.putIfAbsent(player, new ArrayList<>()); recentlyThrownPotions.get(player).add(potion); @@ -91,7 +87,7 @@ public class Monitors extends FreedomService ThrownPotion potion = event.getEntity(); if (potion.getShooter() instanceof Player) { - Player player = (Player)potion.getShooter(); + Player player = (Player) potion.getShooter(); recentlyThrownPotions.putIfAbsent(player, new ArrayList<>()); recentlyThrownPotions.get(player).add(potion); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java index e2b621af..128f767d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/MovementValidator.java @@ -2,10 +2,6 @@ package me.totalfreedom.totalfreedommod; import com.google.common.collect.Multimap; import io.papermc.lib.PaperLib; - -import java.util.Collection; -import java.util.Map; -import java.util.Objects; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -21,6 +17,10 @@ import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; + public class MovementValidator extends FreedomService { @@ -160,8 +160,7 @@ public class MovementValidator extends FreedomService if (modifier.getAmount() == Double.POSITIVE_INFINITY) { posInf = true; - } - else if (modifier.getAmount() == Double.NEGATIVE_INFINITY) + } else if (modifier.getAmount() == Double.NEGATIVE_INFINITY) { negInf = true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java index 9e3ada69..8dff0e72 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/Muter.java @@ -4,7 +4,6 @@ import io.papermc.paper.event.player.AsyncChatEvent; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FSync; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.ChatColor; @@ -12,7 +11,6 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; public class Muter extends FreedomService diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java index be065fd0..3c411225 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/ServerPing.java @@ -14,7 +14,7 @@ import java.io.InputStreamReader; public class ServerPing extends FreedomService { private final Gson gson = new Gson(); - private final VersionMeta meta = gson.fromJson(new InputStreamReader(Bukkit.class.getClassLoader().getResourceAsStream("version.json")),VersionMeta.class); + private final VersionMeta meta = gson.fromJson(new InputStreamReader(Bukkit.class.getClassLoader().getResourceAsStream("version.json")), VersionMeta.class); @Override public void onStart() diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 7a4d20f0..0a51c7dd 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -17,6 +17,7 @@ import me.totalfreedom.totalfreedommod.fun.*; import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; import me.totalfreedom.totalfreedommod.player.PlayerList; import me.totalfreedom.totalfreedommod.punishments.PunishmentList; +import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.rank.RankManager; import me.totalfreedom.totalfreedommod.sql.SQLite; import me.totalfreedom.totalfreedommod.util.FLog; @@ -28,7 +29,6 @@ import me.totalfreedom.totalfreedommod.world.WorldRestrictions; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.generator.ChunkGenerator; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; @@ -45,6 +45,7 @@ public class TotalFreedomMod extends JavaPlugin public static String pluginName; public static String pluginVersion; private static TotalFreedomMod plugin; + private final Hierarchy hierarchy = new Hierarchy(); // public MainConfig config; // @@ -109,19 +110,17 @@ public class TotalFreedomMod extends JavaPlugin public static TotalFreedomMod getPlugin() { - return plugin; + return JavaPlugin.getPlugin(TotalFreedomMod.class); } public static TotalFreedomMod plugin() { - for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) - { - if (plugin.getName().equalsIgnoreCase(pluginName)) - { - return (TotalFreedomMod) plugin; - } - } - return null; + return plugin; + } + + public Hierarchy getHierarchy() + { + return hierarchy; } @Override diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java index 9814d67b..f375e9de 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java @@ -46,8 +46,7 @@ public class VanishHandler extends FreedomService if (plugin.al.isVanished(player.getUniqueId())) { player.sendActionBar(FUtil.miniMessage("You are hidden from other players.")); - } - else + } else { this.cancel(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java index da970cd1..53a690db 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java @@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.admin; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.DisplayableGroup; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; @@ -20,7 +19,7 @@ public class Admin private final List ips = new ArrayList<>(); private UUID uuid; private boolean active = true; - private DisplayableGroup rank = GroupProvider.ADMIN.getGroup(); + private DisplayableGroup rank = TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin(); private Date lastLogin = new Date(); private Boolean commandSpy = false; private Boolean potionSpy = false; @@ -38,7 +37,10 @@ public class Admin { this.uuid = UUID.fromString(resultSet.getString("uuid")); this.active = resultSet.getBoolean("active"); - this.rank = GroupProvider.fromString(resultSet.getString("rank")).getGroup(); + this.rank = TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .fromString(resultSet.getString("rank")); this.ips.clear(); this.ips.addAll(FUtil.stringToList(resultSet.getString("ips"))); this.lastLogin = new Date(resultSet.getLong("last_login")); @@ -153,7 +155,10 @@ public class Admin private void setActiveSplitWorkToReduceComplexity(TotalFreedomMod plugin) { - if (getRank().weightCheckAgainst(GroupProvider.ADMIN.getGroup())) + if (getRank().weightCheckAgainst(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getAdmin())) { if (plugin.btb != null) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index 493ce879..765f786f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -3,9 +3,8 @@ package me.totalfreedom.totalfreedommod.admin; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.Component; @@ -109,7 +108,7 @@ public class AdminList extends FreedomService public boolean isAdmin(Player player) { - if (Hierarchy.getHierarchy().isUserOnAdminTrack(player)) return true; + if (TotalFreedomMod.getPlugin().getHierarchy().isUserOnAdminTrack(player)) return true; return isAdmin((OfflinePlayer) player); } @@ -192,7 +191,7 @@ public class AdminList extends FreedomService public boolean removeAdmin(Admin admin) { - if (admin.getRank().weightCheckAgainst(GroupProvider.ADMIN.getGroup()) && (plugin.btb != null)) + if (admin.getRank().weightCheckAgainst(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin()) && (plugin.btb != null)) { plugin.btb.killTelnetSessions(admin.getName()); } @@ -270,7 +269,8 @@ public class AdminList extends FreedomService public void deactivateOldEntries(boolean verbose) { allAdmins.stream() - .filter(admin -> admin.isActive() && !admin.getRank().weightCheckAgainst(GroupProvider.SENIOR_ADMIN.getGroup())) + .filter(admin -> admin.isActive() && + !admin.getRank().weightCheckAgainst(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin())) .forEach(admin -> { final Date lastLogin = admin.getLastLogin(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/api/event/AdminChatEvent.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/api/event/AdminChatEvent.java index 1e97a0be..8c4b54c8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/api/event/AdminChatEvent.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/api/event/AdminChatEvent.java @@ -12,10 +12,10 @@ public class AdminChatEvent extends Event private static final HandlerList handlerList = new HandlerList(); //-- private final Key identifier; - private Component prefix = Component.empty(); private final Component name; private final Displayable displayable; private final Component message; + private Component prefix = Component.empty(); public AdminChatEvent(Key identifier, Component prefix, Component name, Displayable rank, Component message, boolean async) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java index 90c63c5b..f9dd7de3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java @@ -1,21 +1,16 @@ package me.totalfreedom.totalfreedommod.banning; import com.google.common.collect.Lists; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.UUID; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.util.*; + public class Ban { @@ -168,12 +163,10 @@ public class Ban if (!hasUsername()) { message.append("r IP address is"); - } - else if (!hasIps()) + } else if (!hasIps()) { message.append("r username is"); - } - else + } else { message.append(" are"); } @@ -222,7 +215,7 @@ public class Ban return false; } - final Ban ban = (Ban)object; + final Ban ban = (Ban) object; if (hasIps() != ban.hasIps() || hasUsername() != ban.hasUsername()) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java index c308d34c..fbb9d97b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/BanManager.java @@ -2,16 +2,6 @@ package me.totalfreedom.totalfreedommod.banning; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -21,6 +11,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; + public class BanManager extends FreedomService { @@ -56,8 +50,7 @@ public class BanManager extends FreedomService bans.add(ban); } } - } - catch (SQLException e) + } catch (SQLException e) { FLog.severe("Failed to load ban list: " + e.getMessage()); } @@ -186,8 +179,7 @@ public class BanManager extends FreedomService if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null) { removeBan(ban); - } - else + } else { for (String ip : ban.getIps()) @@ -267,8 +259,7 @@ public class BanManager extends FreedomService if (ban != null) { removeBan(ban); - } - else + } else { ban = getByIp(FUtil.getIp(player)); if (ban != null) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java index f0bb1959..3d2b409c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBan.java @@ -1,15 +1,16 @@ package me.totalfreedom.totalfreedommod.banning; import com.google.common.collect.Lists; +import me.totalfreedom.totalfreedommod.config.IConfig; +import me.totalfreedom.totalfreedommod.util.FLog; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.configuration.ConfigurationSection; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.UUID; -import me.totalfreedom.totalfreedommod.config.IConfig; -import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FUtil; -import org.bukkit.configuration.ConfigurationSection; public class IndefiniteBan implements IConfig { @@ -32,8 +33,7 @@ public class IndefiniteBan implements IConfig UUID uuid = UUID.fromString(strUUID); this.uuid = uuid; } - } - catch (IllegalArgumentException e) + } catch (IllegalArgumentException e) { FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes."); } @@ -46,8 +46,7 @@ public class IndefiniteBan implements IConfig try { this.expiry = date != null ? new SimpleDateFormat("yyyy-MM-dd").parse(date) : null; - } - catch (ParseException ex) + } catch (ParseException ex) { FLog.warning("Failed to load indefinite banned expiry for " + this.username + ". Make sure the expiry is in the correct format (yyyy-MM-dd)."); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java index 00515dea..dbc70508 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/banning/IndefiniteBanList.java @@ -2,10 +2,6 @@ package me.totalfreedom.totalfreedommod.banning; import com.google.common.base.Strings; import com.google.common.collect.Sets; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Set; -import java.util.UUID; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.YamlConfig; @@ -17,21 +13,21 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerLoginEvent; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Set; +import java.util.UUID; + public class IndefiniteBanList extends FreedomService { public static final String CONFIG_FILENAME = "indefinitebans.yml"; - private YamlConfig config; - private final Set indefBans = Sets.newHashSet(); - - private int nameBanCount = 0; - - private int uuidBanCount = 0; - - private int ipBanCount = 0; - private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy, zzzz"); + private YamlConfig config; + private int nameBanCount = 0; + private int uuidBanCount = 0; + private int ipBanCount = 0; @Override public void onStart() @@ -99,14 +95,12 @@ public class IndefiniteBanList extends FreedomService bannedBy = "username"; ban = indefBan; break; - } - else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid)) + } else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid)) { bannedBy = "UUID"; ban = indefBan; break; - } - else if (indefBan.getIps().contains(ip)) + } else if (indefBan.getIps().contains(ip)) { bannedBy = "IP address"; ban = indefBan; @@ -117,7 +111,8 @@ public class IndefiniteBanList extends FreedomService onPlayerLoginSplitWorkToReduceComplexity(event, ban, bannedBy); } - private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) { + private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) + { if (ban != null) { if (ban.isExpired()) @@ -150,6 +145,7 @@ public class IndefiniteBanList extends FreedomService event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage); } } + private void updateCount() { nameBanCount = 0; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index 93ad8892..e885bcd7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -140,13 +140,13 @@ public class BlockBlocker extends FreedomService case PLAYER_HEAD: case PLAYER_WALL_HEAD: { - Skull skull = (Skull)event.getBlockPlaced().getState(); + Skull skull = (Skull) event.getBlockPlaced().getState(); if (skull.getOwner() != null) { if (skull.getOwner().contains("\u00A7")) { skull.setOwner(skull.getOwner().replace("\u00A7", "")); - SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta(); + SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta(); if (meta != null) { ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java index c9c43050..0aa6d4d1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/EventBlocker.java @@ -1,11 +1,7 @@ package me.totalfreedom.totalfreedommod.blocking; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent; +import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -21,17 +17,15 @@ import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.*; -import org.bukkit.event.entity.EntityCombustEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.FireworkExplodeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerRespawnEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + public class EventBlocker extends FreedomService { /** diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 4436ac19..ece8576d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -88,13 +88,11 @@ public class InteractBlocker extends FreedomService if (mat == Material.MOOSHROOM_SPAWN_EGG) { eggType = EntityType.MUSHROOM_COW; - } - else + } else { eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10)); } - } - catch (IllegalArgumentException ignored) + } catch (IllegalArgumentException ignored) { // } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java index 99f39f14..e4adab4c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/MobBlocker.java @@ -1,24 +1,17 @@ package me.totalfreedom.totalfreedommod.blocking; -import java.util.Objects; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import org.bukkit.attribute.Attributable; import org.bukkit.attribute.Attribute; -import org.bukkit.entity.Bat; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.HumanEntity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Wither; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent; +import java.util.Objects; + public class MobBlocker extends FreedomService { @Override @@ -43,13 +36,13 @@ public class MobBlocker extends FreedomService Entity entity = e.getEntity(); if (entity instanceof Attributable) { - if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0) + if (Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0) { - Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0); + Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0); } - if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0) + if (Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0) { - Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0); + Objects.requireNonNull(((Attributable) entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0); } } } @@ -72,40 +65,35 @@ public class MobBlocker extends FreedomService event.setCancelled(true); return; } - } - else if (spawned instanceof Ghast) + } else if (spawned instanceof Ghast) { if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean()) { event.setCancelled(true); return; } - } - else if (spawned instanceof Slime) + } else if (spawned instanceof Slime) { if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean()) { event.setCancelled(true); return; } - } - else if (spawned instanceof Wither) + } else if (spawned instanceof Wither) { if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean()) { event.setCancelled(true); return; } - } - else if (spawned instanceof Giant) + } else if (spawned instanceof Giant) { if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean()) { event.setCancelled(true); return; } - } - else if (spawned instanceof Bat) + } else if (spawned instanceof Bat) { event.setCancelled(true); return; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java index d05f7d32..9fef5310 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java @@ -3,11 +3,7 @@ package me.totalfreedom.totalfreedommod.blocking; import me.totalfreedom.totalfreedommod.FreedomService; import org.bukkit.ChatColor; import org.bukkit.GameMode; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.FishHook; -import org.bukkit.entity.Player; -import org.bukkit.entity.SpectralArrow; -import org.bukkit.entity.Trident; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -32,41 +28,37 @@ public class PVPBlocker extends FreedomService Player target = null; if (event.getEntity() instanceof Player) { - target = (Player)event.getEntity(); + target = (Player) event.getEntity(); if (event.getDamager() instanceof Player) { - player = (Player)event.getDamager(); - } - else if (event.getDamager() instanceof Arrow) + player = (Player) event.getDamager(); + } else if (event.getDamager() instanceof Arrow) { - Arrow arrow = (Arrow)event.getDamager(); + Arrow arrow = (Arrow) event.getDamager(); if (arrow.getShooter() instanceof Player) { - player = (Player)arrow.getShooter(); + player = (Player) arrow.getShooter(); } - } - else if (event.getDamager() instanceof SpectralArrow) + } else if (event.getDamager() instanceof SpectralArrow) { - SpectralArrow spectralArrow = (SpectralArrow)event.getDamager(); + SpectralArrow spectralArrow = (SpectralArrow) event.getDamager(); if (spectralArrow.getShooter() instanceof Player) { - player = (Player)spectralArrow.getShooter(); + player = (Player) spectralArrow.getShooter(); } - } - else if (event.getDamager() instanceof Trident) + } else if (event.getDamager() instanceof Trident) { - Trident trident = (Trident)event.getDamager(); + Trident trident = (Trident) event.getDamager(); if (trident.getShooter() instanceof Player) { - player = (Player)trident.getShooter(); + player = (Player) trident.getShooter(); } - } - else if (event.getDamager() instanceof FishHook) + } else if (event.getDamager() instanceof FishHook) { - FishHook fishhook = (FishHook)event.getDamager(); + FishHook fishhook = (FishHook) event.getDamager(); if (fishhook.getShooter() instanceof Player) { - player = (Player)fishhook.getShooter(); + player = (Player) fishhook.getShooter(); } } } @@ -77,18 +69,15 @@ public class PVPBlocker extends FreedomService { player.sendMessage(ChatColor.RED + "Creative PvP is not allowed!"); event.setCancelled(true); - } - else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) + } else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled()) { player.sendMessage(ChatColor.RED + "God mode PvP is not allowed!"); event.setCancelled(true); - } - else if (plugin.pl.getPlayer(target).isPvpBlocked()) + } else if (plugin.pl.getPlayer(target).isPvpBlocked()) { player.sendMessage(ChatColor.RED + target.getName() + " has PvP disabled!"); event.setCancelled(true); - } - else if (plugin.pl.getPlayer(player).isPvpBlocked()) + } else if (plugin.pl.getPlayer(player).isPvpBlocked()) { player.sendMessage(ChatColor.RED + "You have PvP disabled!"); event.setCancelled(true); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java index 1088e565..a2e34d04 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/PotionBlocker.java @@ -1,6 +1,5 @@ package me.totalfreedom.totalfreedommod.blocking; -import java.util.Collection; import me.totalfreedom.totalfreedommod.FreedomService; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -13,6 +12,8 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.projectiles.ProjectileSource; +import java.util.Collection; + public class PotionBlocker extends FreedomService { @@ -36,7 +37,7 @@ public class PotionBlocker extends FreedomService Player player = null; if (projectileSource instanceof Player) { - player = (Player)projectileSource; + player = (Player) projectileSource; } if (isDeathPotion(potion.getEffects())) @@ -57,7 +58,7 @@ public class PotionBlocker extends FreedomService Player player = null; if (projectileSource instanceof Player) { - player = (Player)projectileSource; + player = (Player) projectileSource; } if (isDeathPotion(potion.getEffects())) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java index adc6bf52..b430d20d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlocker.java @@ -2,11 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking.command; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import java.lang.reflect.Field; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FLog; @@ -16,11 +11,14 @@ import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandMap; import org.bukkit.command.CommandSender; -import org.bukkit.command.SimpleCommandMap; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.plugin.SimplePluginManager; + +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class CommandBlocker extends FreedomService { @@ -50,7 +48,7 @@ public class CommandBlocker extends FreedomService final CommandMap commandMap = Bukkit.getCommandMap(); @SuppressWarnings("unchecked") - List blockedCommands = (List)ConfigEntry.BLOCKED_COMMANDS.getList(); + List blockedCommands = (List) ConfigEntry.BLOCKED_COMMANDS.getList(); for (String rawEntry : blockedCommands) { final String[] parts = rawEntry.split(":"); @@ -86,8 +84,7 @@ public class CommandBlocker extends FreedomService if (command == null) { unknownCommands.add(commandName); - } - else + } else { commandName = command.getName().toLowerCase(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java index 9325f8cb..33d0e432 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerEntry.java @@ -39,7 +39,7 @@ public class CommandBlockerEntry { if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) { - TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command); + TotalFreedomMod.getPlugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command); FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED); return; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java index aeecce69..73c8ef9e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/blocking/command/CommandBlockerRank.java @@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking.command; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import org.bukkit.command.CommandSender; public enum CommandBlockerRank @@ -25,7 +24,7 @@ public enum CommandBlockerRank Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender); if (admin != null) { - if (admin.getRank() == GroupProvider.SENIOR_ADMIN.getGroup()) + if (admin.getRank() == TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin()) { return SENIOR_ADMIN; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java index 82c0712e..c06f6bf6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/BukkitTelnetBridge.java @@ -6,8 +6,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent; import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent; import me.totalfreedom.bukkittelnet.session.ClientSession; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FLog; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -82,8 +82,8 @@ public class BukkitTelnetBridge extends FreedomService boolean active = admin.isActive(); isAdmin = active; - isSeniorAdmin = active && admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup()); - isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(GroupProvider.ADMIN.getGroup())); + isSeniorAdmin = active && admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin()); + isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin())); } playerTags.put("tfm.admin.isAdmin", isAdmin); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java index 8f317599..1192e2dd 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.bridge; -import java.util.*; -import java.util.concurrent.CompletableFuture; - import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -26,6 +23,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; +import java.util.*; +import java.util.concurrent.CompletableFuture; + public class CoreProtectBridge extends FreedomService { //-- Block Inspector --// @@ -69,10 +69,9 @@ public class CoreProtectBridge extends FreedomService assert coreProtectPlugin != null; if (coreProtectPlugin instanceof CoreProtect) { - coreProtect = (CoreProtect)coreProtectPlugin; + coreProtect = (CoreProtect) coreProtectPlugin; } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -94,8 +93,7 @@ public class CoreProtectBridge extends FreedomService { return null; } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -179,8 +177,7 @@ public class CoreProtectBridge extends FreedomService if (page == null || page.isEmpty()) { player.sendMessage(prefix.append(Component.text("No results were found.", NamedTextColor.WHITE))); - } - else + } else { // This shouldn't change at all in any of the other entries, so this should be safe Component location = Component.text(String.format("(%s, %s, %s)", results.get(0).getX(), @@ -221,7 +218,7 @@ public class CoreProtectBridge extends FreedomService line.append(symbol).append(Component.text(entry.getPlayer()).color(TextColor.color(0x30ade4))) .append(action.color(NamedTextColor.WHITE)).append( Component.text(entry.getBlockData().getMaterial().name().toLowerCase()) - .color(TextColor.color(0x30ade4))); + .color(TextColor.color(0x30ade4))); // Rolled back? if (entry.isRolledBack()) @@ -327,8 +324,7 @@ public class CoreProtectBridge extends FreedomService if (results.isEmpty()) { player.sendMessage(prefix.append(Component.text("No results were found.").color(NamedTextColor.WHITE))); - } - else + } else { showPageToPlayer(player, results, 1); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java index def57bdf..4ef8c0b3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/EssentialsBridge.java @@ -6,8 +6,6 @@ import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.DisplayableGroup; import me.totalfreedom.totalfreedommod.util.FLog; -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.luckperms.api.context.ContextSatisfyMode; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -15,7 +13,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.plugin.Plugin; @@ -50,8 +47,7 @@ public class EssentialsBridge extends FreedomService { essentialsPlugin = e; } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -68,8 +64,7 @@ public class EssentialsBridge extends FreedomService { return essentials.getUserMap().getUser(username); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -86,8 +81,7 @@ public class EssentialsBridge extends FreedomService user.setNickname(nickname); user.setDisplayNick(); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -102,8 +96,7 @@ public class EssentialsBridge extends FreedomService { return user.getNickname(); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -119,8 +112,7 @@ public class EssentialsBridge extends FreedomService { return user.getLastOnlineActivity(); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -136,8 +128,7 @@ public class EssentialsBridge extends FreedomService { user.setVanished(vanished); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -149,14 +140,14 @@ public class EssentialsBridge extends FreedomService Player refreshPlayer = null; Inventory inventory = event.getView().getTopInventory(); InventoryType inventoryType = inventory.getType(); - Player player = (Player)event.getWhoClicked(); + Player player = (Player) event.getWhoClicked(); FPlayer fPlayer = plugin.pl.getPlayer(player); if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee()) { final InventoryHolder inventoryHolder = inventory.getHolder(); if (inventoryHolder instanceof HumanEntity) { - Player invOwner = (Player)inventoryHolder; + Player invOwner = (Player) inventoryHolder; DisplayableGroup recieverRank = plugin.rm.getRank(player); DisplayableGroup playerRank = plugin.rm.getRank(invOwner); if (playerRank.getWeight().getWeight() >= recieverRank.getWeight().getWeight() @@ -187,7 +178,7 @@ public class EssentialsBridge extends FreedomService Player refreshPlayer = null; Inventory inventory = event.getView().getTopInventory(); InventoryType inventoryType = inventory.getType(); - Player player = (Player)event.getPlayer(); + Player player = (Player) event.getPlayer(); FPlayer fPlayer = plugin.pl.getPlayer(player); if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee()) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java index b4bbf416..c397c5d9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LibsDisguisesBridge.java @@ -13,16 +13,6 @@ public class LibsDisguisesBridge extends FreedomService { private static LibsDisguises libsDisguisesPlugin = null; - @Override - public void onStart() - { - } - - @Override - public void onStop() - { - } - public static LibsDisguises getLibsDisguisesPlugin() { if (libsDisguisesPlugin == null) @@ -43,6 +33,16 @@ public class LibsDisguisesBridge extends FreedomService return libsDisguisesPlugin; } + @Override + public void onStart() + { + } + + @Override + public void onStop() + { + } + public void undisguiseAll(boolean admin) { try diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java index 1103d373..0420ce7c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java @@ -1,6 +1,6 @@ package me.totalfreedom.totalfreedommod.bridge; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import net.luckperms.api.LuckPerms; import net.luckperms.api.track.TrackManager; import org.bukkit.Bukkit; @@ -36,8 +36,8 @@ public class LuckPermsBridge { trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) -> { - track.appendGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup()); - track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup()); + track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getNonOp().getLuckPermsGroup()); + track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getOp().getLuckPermsGroup()); }); } @@ -45,15 +45,19 @@ public class LuckPermsBridge { trackManager.createAndLoadTrack("admin").whenComplete((track, exception) -> { - track.appendGroup(GroupProvider.ADMIN.getGroup().getLuckPermsGroup()); - track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup()); + track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin().getLuckPermsGroup()); + track.appendGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin().getLuckPermsGroup()); }); } if (!trackManager.isLoaded("builder")) { trackManager.createAndLoadTrack("builder").whenComplete((track, exception) -> - track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup())); + track.appendGroup(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getMasterBuilder() + .getLuckPermsGroup())); } } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java index bb75d14a..2699516d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/WorldEditBridge.java @@ -1,7 +1,6 @@ package me.totalfreedom.totalfreedommod.bridge; import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.util.FLog; @@ -35,11 +34,10 @@ public class WorldEditBridge extends FreedomService { if (we instanceof WorldEditPlugin) { - worldeditPlugin = (WorldEditPlugin)we; + worldeditPlugin = (WorldEditPlugin) we; } } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -57,8 +55,7 @@ public class WorldEditBridge extends FreedomService { session.setBlockChangeLimit(limit); } - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -100,8 +97,7 @@ public class WorldEditBridge extends FreedomService try { return wep.getSession(player); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); return null; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java index b584695d..6c8f1cce 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java @@ -1,13 +1,14 @@ package me.totalfreedom.totalfreedommod.caging; -import java.util.ArrayList; -import java.util.List; import me.totalfreedom.totalfreedommod.player.FPlayer; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Skull; +import java.util.ArrayList; +import java.util.List; + public class CageData { @@ -74,8 +75,7 @@ public class CageData } block.setType(material); - } - else + } else { if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length) { @@ -88,12 +88,11 @@ public class CageData { try { - Skull skull = (Skull)block.getState(); + Skull skull = (Skull) block.getState(); // This may or may not work in future versions of spigot skull.setOwner(input); skull.update(); - } - catch (ClassCastException ignored) + } catch (ClassCastException ignored) { } } @@ -233,8 +232,7 @@ public class CageData if (cage) { cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS); - } - else + } else { this.caged = false; regenerateHistory(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java index d520f7ba..52547f54 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java @@ -1,7 +1,6 @@ package me.totalfreedom.totalfreedommod.caging; import io.papermc.lib.PaperLib; -import java.util.Objects; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -16,6 +15,8 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.Objects; + public class Cager extends FreedomService { @Override @@ -64,8 +65,7 @@ public class Cager extends FreedomService if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld())) { outOfCage = true; - } - else + } else { outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java index ef7e5d02..d3f43ebb 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminchat.java @@ -1,6 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import me.totalfreedom.totalfreedommod.api.event.AdminChatEvent; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java index ef144dc9..fb012ff2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_admininfo.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -11,6 +9,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.List; + @CommandPermissions(permission = "admininfo", source = SourceType.BOTH) @CommandParameters(description = "Information on how to apply for admin.", usage = "/", aliases = "si,ai,staffinfo") public class Command_admininfo extends FreedomCommand @@ -24,8 +24,7 @@ public class Command_admininfo extends FreedomCommand if (adminInfo.isEmpty()) { msgNew("The admin information section of the config.yml file has not been configured."); - } - else + } else { adminInfo.forEach(this::msgNew); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java index d3782200..b757202a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminmode.java @@ -1,9 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +11,10 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "adminmode", source = SourceType.BOTH) @CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/ [on | off]", aliases = "staffmode") public class Command_adminmode extends FreedomCommand @@ -33,8 +33,7 @@ public class Command_adminmode extends FreedomCommand ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false); FUtil.adminAction(sender.getName(), "Opening the server to all players", true); return true; - } - else if (args[0].equalsIgnoreCase("on")) + } else if (args[0].equalsIgnoreCase("on")) { ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true); FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java index de9fb943..a29b0a65 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adminworld.java @@ -1,10 +1,6 @@ package me.totalfreedom.totalfreedommod.command; import io.papermc.lib.PaperLib; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -17,6 +13,10 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "adminworld", source = SourceType.BOTH) @CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.", usage = "/ [time | weather ]", @@ -32,14 +32,12 @@ public class Command_adminworld extends FreedomCommand if (args.length == 0) { commandMode = CommandMode.TELEPORT; - } - else if (args.length >= 2) + } else if (args.length >= 2) { if ("time".equalsIgnoreCase(args[0])) { commandMode = CommandMode.TIME; - } - else if ("weather".equalsIgnoreCase(args[0])) + } else if ("weather".equalsIgnoreCase(args[0])) { commandMode = CommandMode.WEATHER; } @@ -126,8 +124,7 @@ public class Command_adminworld extends FreedomCommand return false; } } - } - catch (PermissionDeniedException ex) + } catch (PermissionDeniedException ex) { if (ex.getMessage().isEmpty()) { @@ -159,14 +156,12 @@ public class Command_adminworld extends FreedomCommand if (args.length == 1) { return Arrays.asList("time", "weather"); - } - else if (args.length == 2) + } else if (args.length == 2) { if (args[0].equals("time")) { return Arrays.asList("morning", "noon", "evening", "night"); - } - else if (args[0].equals("weather")) + } else if (args[0].equals("weather")) { return Arrays.asList("off", "rain", "storm"); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java index cb953023..23dff11c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autoclear.java @@ -27,8 +27,7 @@ public class Command_autoclear extends FreedomCommand if (enabled) { plugin.lp.CLEAR_ON_JOIN.remove(args[0]); - } - else + } else { plugin.lp.CLEAR_ON_JOIN.add(args[0]); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java index 293064a2..a6339f95 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_autotp.java @@ -27,8 +27,7 @@ public class Command_autotp extends FreedomCommand if (enabled) { plugin.lp.TELEPORT_ON_JOIN.remove(args[0]); - } - else + } else { plugin.lp.TELEPORT_ON_JOIN.add(args[0]); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java index 03782cc4..effd973b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Objects; - import com.earth2me.essentials.User; import me.totalfreedom.totalfreedommod.banning.Ban; import me.totalfreedom.totalfreedommod.command.handling.*; @@ -19,6 +17,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Objects; + @Intercept("ban") @CommandPermissions(permission = "ban", source = SourceType.BOTH, blockHostConsole = true) @CommandParameters(description = "Bans the specified player.", usage = "/ [reason] [-nrb | -q]", aliases = "gtfo") @@ -53,8 +53,7 @@ public class Command_ban extends FreedomCommand { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); } - } - else + } else { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); } @@ -82,15 +81,13 @@ public class Command_ban extends FreedomCommand { msg(PLAYER_NOT_FOUND); return true; - } - else + } else { username = entry.getName(); ip = entry.getIps().get(0); } } - } - else + } else { username = player.getName(); ip = FUtil.getIp(player); @@ -116,8 +113,7 @@ public class Command_ban extends FreedomCommand Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos); } } - } - else + } else { msgNew("Banned quietly.", Placeholder.unparsed("player", player.getName())); } @@ -141,8 +137,7 @@ public class Command_ban extends FreedomCommand if (player != null) { ban = Ban.forPlayer(player, sender, null, reason); - } - else + } else { ban = Ban.forPlayerName(username, sender, null, reason); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java index 240aea46..543e5333 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banip.java @@ -50,8 +50,7 @@ public class Command_banip extends FreedomCommand { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); } - } - else if (args.length > 1) + } else if (args.length > 1) { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java index 1808a483..d85c80f6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_banname.java @@ -46,8 +46,7 @@ public class Command_banname extends FreedomCommand { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); } - } - else if (args.length > 1) + } else if (args.length > 1) { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java index ecb5a451..a3f2d005 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java @@ -1,9 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Arrays; -import java.util.List; -import java.util.SplittableRandom; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -14,6 +10,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.Arrays; +import java.util.List; +import java.util.SplittableRandom; + @CommandPermissions(permission = "bird", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/") public class Command_bird extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java index b5dab640..8dfee545 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockcmd.java @@ -86,8 +86,7 @@ public class Command_blockcmd extends FreedomCommand msgNew("Blocked commands for .", Placeholder.unparsed("player", player.getName())); plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null)); - } - else + } else { msgNew("That player's commands are already blocked."); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java index 73d12d01..45ac6d76 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockedit.java @@ -85,14 +85,12 @@ public class Command_blockedit extends FreedomCommand fPlayer.setEditBlocked(false); msgNew("Restored block modification abilities for .", Placeholder.unparsed("player", player.getName())); msgNew(player, "Your block modification abilities have been restored."); - } - else + } else { if (plugin.al.isAdmin(player)) { msgNew(" is an admin, and as such cannot have their block modification abilities restricted.", Placeholder.unparsed("player", player.getName())); - } - else + } else { FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true); fPlayer.setEditBlocked(true); @@ -108,8 +106,7 @@ public class Command_blockedit extends FreedomCommand } return true; - } - else + } else { return false; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java index c1969f4c..45cb89a6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockpvp.java @@ -38,8 +38,7 @@ public class Command_blockpvp extends FreedomCommand if (restricted.isEmpty()) { msgNew("Nobody currently has their PVP abilities restricted."); - } - else + } else { msgNew("PVP abilities are restricted for these player(s): ", Placeholder.unparsed("players", FUtil.listToString(restricted))); @@ -91,8 +90,7 @@ public class Command_blockpvp extends FreedomCommand pd.setPvpBlocked(false); msgNew("Enabled the ability to PVP for .", Placeholder.unparsed("player", p.getName())); msgNew(p, "Your PVP abilities have been restored."); - } - else + } else { if (plugin.al.isAdmin(p)) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java index 51d336f4..6b4b18ed 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_blockredstone.java @@ -33,8 +33,7 @@ public class Command_blockredstone extends FreedomCommand } } }.runTaskLater(plugin, 6000L); - } - else + } else { ConfigEntry.ALLOW_REDSTONE.setBoolean(true); FUtil.adminAction(sender.getName(), "Unblocking all redstone", true); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index 5d2360dd..46479def 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -1,10 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -20,6 +15,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "cage", source = SourceType.BOTH) @CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/ [head | block] [playername | blockname]") public class Command_cage extends FreedomCommand @@ -68,8 +68,7 @@ public class Command_cage extends FreedomCommand if (args.length >= 3) { skullName = args[2]; - } - else + } else { outerMaterial = Material.SKELETON_SKULL; } @@ -84,14 +83,12 @@ public class Command_cage extends FreedomCommand if (Material.matchMaterial(args[2]) != null && Material.matchMaterial(args[2]).isBlock()) { outerMaterial = Material.matchMaterial(args[2]); - } - else + } else { msgNew("Invalid block!"); return true; } - } - else + } else { return false; } @@ -106,8 +103,7 @@ public class Command_cage extends FreedomCommand if (outerMaterial == Material.PLAYER_HEAD) { FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true); - } - else + } else { FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true); } @@ -117,8 +113,7 @@ public class Command_cage extends FreedomCommand if (skullName != null) { fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName); - } - else + } else { fPlayer.getCageData().cage(location, outerMaterial, innerMaterial); } @@ -142,21 +137,18 @@ public class Command_cage extends FreedomCommand arguments.add("purge"); arguments.addAll(FUtil.getPlayerList()); return arguments; - } - else if (args.length == 2) + } else if (args.length == 2) { if (!args[0].equals("purge")) { return Arrays.asList("head", "block"); } - } - else if (args.length == 3) + } else if (args.length == 3) { if (args[1].equals("block")) { return Arrays.stream(Material.values()).map(Enum::name).toList(); - } - else if (args[1].equals("head")) + } else if (args[1].equals("head")) { return FUtil.getPlayerList(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java index 74f905b3..3a266e7a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clownfish.java @@ -26,13 +26,11 @@ public class Command_clownfish extends FreedomCommand { playerSender.getInventory().addItem(plugin.sh.getClownFish()); msgNew("You have been given a .", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName())); - } - else if (plugin.pl.getPlayer(playerSender).isClownfishDisabled()) + } else if (plugin.pl.getPlayer(playerSender).isClownfishDisabled()) { msgNew("An admin has disabled your ability to use the . Guess you were the clown after all.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName())); - } - else + } else { msgNew("You don't own a ! Purchase one from the shop.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName())); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java index 453c4a03..9a3ad7a8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java @@ -34,8 +34,7 @@ public class Command_coins extends FreedomCommand if (senderIsConsole) { msgNew("When used from the console, you must define a target player."); - } - else + } else { PlayerData playerData = getData(playerSender); msgNew("You have coin.", @@ -54,8 +53,7 @@ public class Command_coins extends FreedomCommand if (target == null) { msg(PLAYER_NOT_FOUND); - } - else + } else { PlayerData playerData = getData(target); msgNew(" has coin.", @@ -84,8 +82,7 @@ public class Command_coins extends FreedomCommand { // Prevents players from trying to be cheeky with negative numbers. coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1); - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { msgNew("Invalid number: ", Placeholder.unparsed("num", args[2])); return true; @@ -101,8 +98,7 @@ public class Command_coins extends FreedomCommand if (target == null) { msg(PLAYER_NOT_FOUND); - } - else + } else { PlayerData playerData = getData(target); playerData.setCoins(playerData.getCoins() + coinsToTransfer); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java index b771c15a..e54d303c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cookie.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Collections; -import java.util.Random; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +12,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.Collections; +import java.util.Random; + @CommandPermissions(permission = "cookie", source = SourceType.BOTH) @CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/") public class Command_cookie extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java index 6ee703a1..14a9896e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deafen.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.SplittableRandom; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -13,6 +11,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; +import java.util.SplittableRandom; + @CommandPermissions(permission = "deafen", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Makes random sounds.", usage = "/") public class Command_deafen extends FreedomCommand @@ -37,7 +37,7 @@ public class Command_deafen extends FreedomCommand { for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS)) { - final float pitch = (float)(percent * 2.0); + final float pitch = (float) (percent * 2.0); new BukkitRunnable() { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java index 8dcd59a2..6d45ebd3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Arrays; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -16,6 +14,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.Arrays; + @CommandPermissions(permission = "debugstick", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Get a stick of happiness.", usage = "/") public class Command_debugstick extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java index 2978c180..bef04e18 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deop.java @@ -1,7 +1,7 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.*; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.luckperms.api.track.DemotionResult; @@ -38,8 +38,8 @@ public class Command_deop extends FreedomCommand } boolean b = silent; - DemotionResult result = Hierarchy.getHierarchy() - .demoteUser(Hierarchy.getHierarchy().op(), player); + DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .demoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player); if (!result.wasSuccessful()) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java index 38bb5da6..bd30013b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_deopall.java @@ -1,10 +1,10 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.command.handling.SourceType; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.luckperms.api.track.DemotionResult; @@ -24,12 +24,12 @@ public class Command_deopall extends FreedomCommand server.getOnlinePlayers().forEach(player -> { - DemotionResult result = Hierarchy.getHierarchy() - .demoteUser(Hierarchy.getHierarchy().op(), player); + DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .demoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player); if (!result.wasSuccessful()) { - msgNew(" is already non-OP.", Placeholder.unparsed("player", player.getName())); + msgNew(" is already non-op.", Placeholder.unparsed("player", player.getName())); return; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java index 07d7350f..15ed60eb 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -20,6 +17,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; + @CommandPermissions(permission = "dispfill", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Fill nearby dispensers with a set of items of your choice.", usage = "/ ") public class Command_dispfill extends FreedomCommand @@ -29,7 +29,7 @@ public class Command_dispfill extends FreedomCommand { if (targetBlock.getType() == Material.DISPENSER) { - final Inventory dispenserInv = ((Dispenser)targetBlock.getState()).getInventory(); + final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory(); dispenserInv.clear(); dispenserInv.addItem(items); } @@ -45,8 +45,7 @@ public class Command_dispfill extends FreedomCommand try { radius = Math.max(5, Math.min(25, Integer.parseInt(args[0]))); - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { msgNew("Invalid radius: ", Placeholder.unparsed("amount", args[0])); return true; @@ -62,8 +61,7 @@ public class Command_dispfill extends FreedomCommand if (material != null) { items.add(new ItemStack(material, 64)); - } - else + } else { msgNew("Skipping invalid item: ", Placeholder.unparsed("item", searchItem)); } @@ -98,8 +96,7 @@ public class Command_dispfill extends FreedomCommand } msgNew("Done. dispenser(s) filled.", Placeholder.unparsed("amount", String.valueOf(affected))); - } - else + } else { return false; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java index bd8a6fb9..7f471855 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_eject.java @@ -44,8 +44,7 @@ public class Command_eject extends FreedomCommand msgNew(" entit ejected.", Placeholder.unparsed("count", String.valueOf(count)), Placeholder.unparsed("grammar", count == 1 ? "y was" : "ies were")); - } - else + } else { msgNew("Nothing was ejected."); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java index 9952356d..4d5363ba 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_enchant.java @@ -1,12 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.stream.IntStream; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -21,6 +14,9 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.*; +import java.util.stream.IntStream; + @CommandPermissions(permission = "enchant", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Enchant items.", usage = "/ [level] | remove >") public class Command_enchant extends FreedomCommand @@ -49,33 +45,28 @@ public class Command_enchant extends FreedomCommand if (enchants.isEmpty()) { msgNew("There are no enchantments that work with this item."); - } - else + } else { msgNew("Possible enchantments for this item: ", Placeholder.unparsed("enchants", FUtil.listToString(enchants))); } - } - else if (args[0].equalsIgnoreCase("addall")) + } else if (args[0].equalsIgnoreCase("addall")) { Arrays.stream(Enchantment.values()).filter(enchantment -> enchantment.canEnchantItem(item)).forEach(ench -> { try { item.addEnchantment(ench, ench.getMaxLevel()); - } - catch (Exception ignored) + } catch (Exception ignored) { } }); msgNew("Added all possible enchantments for this item."); - } - else if (args[0].equalsIgnoreCase("reset")) + } else if (args[0].equalsIgnoreCase("reset")) { item.getEnchantments().keySet().forEach(item::removeEnchantment); msgNew("Removed all enchantments."); - } - else + } else { if (args.length < 2) { @@ -105,13 +96,11 @@ public class Command_enchant extends FreedomCommand if (ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean()) { level = Integer.parseInt(args[2]); - } - else + } else { level = Math.max(1, Math.min(ench.getMaxLevel(), Integer.parseInt(args[2]))); } - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { msgNew("Invalid number: ", Placeholder.unparsed("number", args[2])); return true; @@ -120,15 +109,13 @@ public class Command_enchant extends FreedomCommand if (!ConfigEntry.ALLOW_UNSAFE_ENCHANTMENTS.getBoolean()) { item.addEnchantment(ench, level); - } - else + } else { item.addUnsafeEnchantment(ench, level); } msgNew("Added enchantment: ", Placeholder.unparsed("enchantment", ench.getName())); - } - else if (args[0].equals("remove")) + } else if (args[0].equals("remove")) { item.removeEnchantment(ench); @@ -182,9 +169,8 @@ public class Command_enchant extends FreedomCommand Player player; if (sender instanceof Player) { - player = (Player)sender; - } - else + player = (Player) sender; + } else { return Collections.emptyList(); } @@ -200,26 +186,22 @@ public class Command_enchant extends FreedomCommand if (args.length == 1) { return Arrays.asList("list", "addall", "reset", "add", "remove"); - } - else if (args.length == 2) + } else if (args.length == 2) { if (args[0].equals("add")) { if (unsafe) { return getAllEnchantments(); - } - else + } else { return getAllEnchantments(item); } - } - else if (args[0].equals("remove")) + } else if (args[0].equals("remove")) { return getEnchantments(item); } - } - else if (args.length == 3 && args[0].equals("add")) + } else if (args.length == 3 && args[0].equals("add")) { Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase()); if (enchantment != null) @@ -227,8 +209,7 @@ public class Command_enchant extends FreedomCommand if (!unsafe) { return IntStream.rangeClosed(1, enchantment.getMaxLevel()).mapToObj(String::valueOf).toList(); - } - else + } else { return Collections.singletonList("[level]"); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java index 28c07fbd..d5c52b54 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_entitywipe.java @@ -1,9 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -17,6 +13,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "entitywipe", source = SourceType.BOTH) @CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/ [name | -a]", aliases = "ew,rd") public class Command_entitywipe extends FreedomCommand @@ -56,14 +56,12 @@ public class Command_entitywipe extends FreedomCommand if (args[0].equals("-a")) { bypassBlacklist = true; - } - else + } else { try { type = EntityType.valueOf(args[0].toUpperCase()); - } - catch (Exception e) + } catch (Exception e) { msg(args[0] + " is not a valid entity type.", ChatColor.RED); return true; @@ -93,8 +91,7 @@ public class Command_entitywipe extends FreedomCommand if (type != null) { count = plugin.ew.wipeEntities(type); - } - else + } else { count = plugin.ew.wipeEntities(bypassBlacklist); } @@ -103,8 +100,7 @@ public class Command_entitywipe extends FreedomCommand { msgNew(" removed.", Placeholder.unparsed("count", String.valueOf(count)), Placeholder.unparsed("name", type != null ? entityName : "entity")); - } - else + } else { msgNew(" s removed.", Placeholder.unparsed("count", String.valueOf(count)), Placeholder.unparsed("name", type != null ? entityName : "entitie")); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java index 7ef8dae4..9f00a08c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_expel.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -16,6 +13,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.List; + @CommandPermissions(permission = "expel", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Push people away from you.", usage = "/ [radius] [strength]") public class Command_expel extends FreedomCommand @@ -32,8 +32,7 @@ public class Command_expel extends FreedomCommand try { radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0]))); - } - catch (NumberFormatException ignored) + } catch (NumberFormatException ignored) { } } @@ -43,8 +42,7 @@ public class Command_expel extends FreedomCommand try { strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1]))); - } - catch (NumberFormatException ignored) + } catch (NumberFormatException ignored) { } } @@ -67,8 +65,7 @@ public class Command_expel extends FreedomCommand try { inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius); - } - catch (IllegalArgumentException ignored) + } catch (IllegalArgumentException ignored) { } @@ -84,8 +81,7 @@ public class Command_expel extends FreedomCommand if (pushedPlayers.isEmpty()) { msgNew("No players were pushed."); - } - else + } else { msgNew("Pushed players: ", Placeholder.unparsed("amount", String.valueOf(pushedPlayers.size())), diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java index ffbbed9f..3114f267 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_explode.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +12,9 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "explode", source = SourceType.BOTH) @CommandParameters(description = "Surprise someone.", usage = "/ ") public class Command_explode extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java index 03649300..5aa4b46b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fireball.java @@ -25,8 +25,7 @@ public class Command_fireball extends FreedomCommand { playerSender.getInventory().addItem(plugin.sh.getFireBall()); msgNew("You have been given the .", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName())); - } - else + } else { msgNew("You don't own the ! Purchase it from the shop.", Placeholder.unparsed("item", ShopItem.FIRE_BALL.getName())); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java index 67dc6b6e..5a6e904d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_freeze.java @@ -27,14 +27,13 @@ public class Command_freeze extends FreedomCommand { FUtil.adminAction(sender.getName(), "Unfreezing all players", false); msgNew("Players are now free to move."); - } - else + } else { FUtil.adminAction(sender.getName(), "Freezing all players", false); server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player -> { FUtil.playerTitle(player, "You have been frozen.", "Please be patient and you will be unfrozen shortly."); - msgNew(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon."); + msgNew(player, "You have been globally frozen due to an op breaking the rules, please wait and you will be unfrozen soon."); }); msgNew("Players are now frozen."); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java index 75432fe3..d397db7b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_fuckoff.java @@ -28,8 +28,7 @@ public class Command_fuckoff extends FreedomCommand if (!args[0].equals("on")) { player.disableFuckoff(); - } - else + } else { double radius = 25.0; @@ -38,8 +37,7 @@ public class Command_fuckoff extends FreedomCommand try { radius = Math.max(5.0, Math.min(50, Double.parseDouble(args[1]))); - } - catch (NumberFormatException ex) + } catch (NumberFormatException ex) { } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java index b256f79b..268dd4a7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_gcmd.java @@ -51,13 +51,11 @@ public class Command_gcmd extends FreedomCommand if (server.dispatchCommand(player, outCommand)) { msg(Component.text("Command sent.", NamedTextColor.GREEN)); - } - else + } else { msg(Component.text("Unknown error sending command.", NamedTextColor.RED)); } - } - catch (Throwable ex) + } catch (Throwable ex) { msg(Component.text("Error sending command: " + ex.getMessage(), NamedTextColor.RED)); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java index 1f23ea1a..ab616124 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_glow.java @@ -23,8 +23,7 @@ public class Command_glow extends FreedomCommand if (playerSender.getPotionEffect(PotionEffectType.GLOWING) != null) { playerSender.removePotionEffect(PotionEffectType.GLOWING); - } - else + } else { PotionEffect glow = new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false); playerSender.addPotionEffect(glow); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java index 5051451d..f9e248d9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_grapplinghook.java @@ -15,7 +15,8 @@ public class Command_grapplinghook extends FreedomCommand @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (plugin.sh == null) { + if (plugin.sh == null) + { msg("The shop is currently disabled.", ChatColor.RED); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java index 69cbee39..080704b4 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_health.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.text.DecimalFormat; -import java.util.concurrent.atomic.AtomicInteger; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; @@ -16,6 +14,9 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; +import java.text.DecimalFormat; +import java.util.concurrent.atomic.AtomicInteger; + @CommandPermissions(permission = "health", source = SourceType.BOTH) @CommandParameters(description = "View server health, such as ticks-per-second, memory, etc.", usage = "/") public class Command_health extends FreedomCommand @@ -30,10 +31,10 @@ public class Command_health extends FreedomCommand Runtime runtime = Runtime.getRuntime(); long usedMem = runtime.totalMemory() - runtime.freeMemory(); - msg("Reserved Memory: " + (double)runtime.totalMemory() / (double)BYTES_PER_MB + "mb"); - msg("Used Memory: " + new DecimalFormat("#").format((double)usedMem / (double)BYTES_PER_MB) - + "mb (" + new DecimalFormat("#").format(((double)usedMem / (double)runtime.totalMemory()) * 100.0) + "%)"); - msg("Max Memory: " + (double)runtime.maxMemory() / (double)BYTES_PER_MB + "mb"); + msg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb"); + msg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB) + + "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)"); + msg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb"); msg("Calculating ticks per second, please wait..."); new BukkitRunnable() @@ -62,8 +63,7 @@ public class Command_health extends FreedomCommand msg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond); } }.runTask(plugin); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -107,7 +107,7 @@ public class Command_health extends FreedomCommand long elapsed = System.currentTimeMillis() - startTime; int tickCount = ticks.get(); - return (double)tickCount / ((double)elapsed / 1000.0); + return (double) tickCount / ((double) elapsed / 1000.0); } } } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java index 3240b0d1..0f724db1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_inspect.java @@ -1,10 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.IntStream; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.IntStream; + @CommandPermissions(permission = "inspect", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Block inspector tool for operators.", usage = "/ [history] [page]", aliases = "ins") public class Command_inspect extends FreedomCommand @@ -46,8 +46,7 @@ public class Command_inspect extends FreedomCommand try { pageIndex = Integer.parseInt(args[1]); - } - catch (NumberFormatException e) + } catch (NumberFormatException e) { msgNew("Invalid number."); return true; @@ -56,12 +55,11 @@ public class Command_inspect extends FreedomCommand int godDammit = pageIndex; Optional.ofNullable(plugin.cpb.getHistoryForPlayer(playerSender)).ifPresentOrElse(page -> - plugin.cpb.showPageToPlayer(playerSender, page, godDammit), + plugin.cpb.showPageToPlayer(playerSender, page, godDammit), () -> msgNew("You haven't inspected anything yet!")); return true; - } - else + } else { return false; } @@ -73,14 +71,12 @@ public class Command_inspect extends FreedomCommand if (args.length == 1) { return Collections.singletonList("history"); - } - else if (args.length == 2 && args[0].equalsIgnoreCase("history") && plugin.cpb.isEnabled() + } else if (args.length == 2 && args[0].equalsIgnoreCase("history") && plugin.cpb.isEnabled() && sender instanceof Player player && plugin.cpb.hasHistory(player)) { return IntStream.rangeClosed(1, plugin.cpb.getHistoryForPlayer(player).getPageCount()).limit(50) .mapToObj(String::valueOf).toList(); - } - else + } else { return Collections.emptyList(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java index a4eaa3d7..7290ad4b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invis.java @@ -1,9 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +11,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffectType; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @CommandPermissions(permission = "invis", source = SourceType.BOTH) @CommandParameters(description = "Shows (optionally clears) invisible players", usage = "/ [clear]") public class Command_invis extends FreedomCommand @@ -32,14 +32,12 @@ public class Command_invis extends FreedomCommand if (!plugin.al.isAdmin(sender)) { return noPerms(); - } - else + } else { FUtil.adminAction(sender.getName(), "Clearing all invisibility potion effects from all players", true); clear = true; } - } - else + } else { return false; } @@ -70,8 +68,7 @@ public class Command_invis extends FreedomCommand if (clear) { msg("Cleared " + clears + " players"); - } - else + } else { msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", ")); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java index c818dd46..766e7572 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java @@ -44,8 +44,7 @@ public class Command_kick extends FreedomCommand { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); } - } - else if (args.length > 1) + } else if (args.length > 1) { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); } @@ -64,13 +63,11 @@ public class Command_kick extends FreedomCommand if (reason != null) { FUtil.adminAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true); - } - else + } else { FUtil.adminAction(sender.getName(), "Kicking " + player.getName(), true); } - } - else + } else { msgNew("Kicked quietly.", Placeholder.unparsed("player", player.getName())); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java index 776661f9..83ae85d5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_landmine.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.Iterator; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -16,6 +14,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Iterator; + @CommandPermissions(permission = "landmine", source = SourceType.ONLY_IN_GAME) @CommandParameters(description = "Set a landmine trap.", usage = "/") public class Command_landmine extends FreedomCommand @@ -53,8 +53,7 @@ public class Command_landmine extends FreedomCommand try { radius = Math.max(2.0, Math.min(6.0, Double.parseDouble(args[0]))); - } - catch (NumberFormatException ignored) + } catch (NumberFormatException ignored) { } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java index 3d3adbc1..efed909e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mbconfig.java @@ -1,12 +1,11 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.command.handling.SourceType; import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; @@ -126,8 +125,8 @@ public class Command_mbconfig extends FreedomCommand { FUtil.adminAction(sender.getName(), "Adding " + data.getName() + " to the Master Builder list", true); data.setMasterBuilder(true); - Hierarchy.getHierarchy() - .addUserToGroup(GroupProvider.MASTER_BUILDER.getGroup(), player); + TotalFreedomMod.getPlugin().getHierarchy() + .addUserToGroup(TotalFreedomMod.getPlugin().getHierarchy().groups().getMasterBuilder(), player); plugin.pl.save(data); } else { @@ -157,8 +156,8 @@ public class Command_mbconfig extends FreedomCommand } FUtil.adminAction(sender.getName(), "Removing " + data.getName() + " from the Master Builder list", true); - Hierarchy.getHierarchy() - .dropUser(Hierarchy.getHierarchy().builder(), player); + TotalFreedomMod.getPlugin().getHierarchy() + .dropUser(TotalFreedomMod.getPlugin().getHierarchy().builder(), player); data.setMasterBuilder(false); plugin.pl.save(data); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java index 23416f6b..306994c9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java @@ -1,5 +1,6 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; @@ -7,7 +8,6 @@ import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.command.handling.SourceType; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FConverter; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.minimessage.tag.Tag; @@ -171,8 +171,14 @@ public class Command_myadmin extends FreedomCommand msgNew("Set admin chat format to \"\"", Placeholder.unparsed("format", format)); msgNew("Example:"); msgNew(format, Placeholder.unparsed("name", "ExampleAdmin"), - Placeholder.unparsed("rank", GroupProvider.ADMIN.getGroup().getAbbr().toString()), - TagResolver.resolver("rankcolor", Tag.styling(styler -> styler.color(GroupProvider.ADMIN.getGroup().getColor()))), + Placeholder.unparsed("rank", TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin().getAbbr().toString()), + TagResolver.resolver("rankcolor", + Tag.styling(styler -> + styler.color(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getAdmin() + .getColor()))), Placeholder.unparsed("message", "The quick brown fox jumped over the lazy dog.")); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java index 044f6336..05d0e7a1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java @@ -29,7 +29,8 @@ public class Command_nickmm extends FreedomCommand return true; } - if (args[0].isEmpty()) { + if (args[0].isEmpty()) + { return false; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java index 7e424e43..7d251e43 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_op.java @@ -1,7 +1,7 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.*; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import net.luckperms.api.track.PromotionResult; import org.bukkit.Bukkit; @@ -11,7 +11,7 @@ import org.bukkit.entity.Player; @Intercept("op") @CommandPermissions(permission = "op", source = SourceType.BOTH, cooldown = 5) -@CommandParameters(description = "OP a player", usage = "/ ") +@CommandParameters(description = "op a player", usage = "/ ") public class Command_op extends FreedomCommand { @@ -38,12 +38,12 @@ public class Command_op extends FreedomCommand } boolean b = silent; - PromotionResult result = Hierarchy.getHierarchy() - .promoteUser(Hierarchy.getHierarchy().op(), player); + PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player); if (!result.wasSuccessful()) { - msgNew(" is already OP!", player(player)); + msgNew(" is already op!", player(player)); return true; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java index 3ba6fecc..4bc6adc8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opall.java @@ -1,10 +1,10 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.command.handling.SourceType; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import net.luckperms.api.track.PromotionResult; import org.bukkit.command.Command; @@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(permission = "op.all", source = SourceType.BOTH, cooldown = 30) -@CommandParameters(description = "OP everyone on the server.", usage = "/") +@CommandParameters(description = "op everyone on the server.", usage = "/") public class Command_opall extends FreedomCommand { @Override @@ -22,12 +22,12 @@ public class Command_opall extends FreedomCommand server.getOnlinePlayers().forEach(player -> { - PromotionResult result = Hierarchy.getHierarchy() - .promoteUser(Hierarchy.getHierarchy().op(), player); + PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), player); if (!result.wasSuccessful()) { - msgNew("Player is already OP!", player(player)); + msgNew("Player is already op!", player(player)); return; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java index a91af599..2b945019 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_opme.java @@ -1,10 +1,10 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.command.handling.SourceType; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import net.luckperms.api.track.PromotionResult; import org.bukkit.command.Command; @@ -20,8 +20,8 @@ public class Command_opme extends FreedomCommand public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false); - PromotionResult result = Hierarchy.getHierarchy() - .promoteUser(Hierarchy.getHierarchy().op(), playerSender); + PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .promoteUser(TotalFreedomMod.getPlugin().getHierarchy().op(), playerSender); if (!result.wasSuccessful()) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index ee95f9a6..49400fd9 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -1,5 +1,6 @@ package me.totalfreedom.totalfreedommod.command; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; @@ -8,8 +9,6 @@ import me.totalfreedom.totalfreedommod.command.handling.SourceType; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.DisplayableGroup; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; -import me.totalfreedom.totalfreedommod.rank.Hierarchy; import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.PermissibleCompletion; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; @@ -84,8 +83,8 @@ public class Command_saconfig extends FreedomCommand return true; } - PromotionResult result = Hierarchy.getHierarchy() - .promoteUser(Hierarchy.getHierarchy().admin(), player); + PromotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .promoteUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player); if (!result.wasSuccessful() || result.getGroupTo().isEmpty()) { @@ -102,8 +101,11 @@ public class Command_saconfig extends FreedomCommand plugin.al.addAdmin(admin); } - Group actual = Hierarchy.getHierarchy().getGroup(group); - DisplayableGroup rank = GroupProvider.wrappedFromLPG(actual).getGroup(); + Group actual = TotalFreedomMod.getPlugin().getHierarchy().getGroup(group); + DisplayableGroup rank = TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .fromLuckPerms(actual); if (rank == null) { @@ -190,8 +192,8 @@ public class Command_saconfig extends FreedomCommand return true; } - DemotionResult result = Hierarchy.getHierarchy() - .demoteUser(Hierarchy.getHierarchy().admin(), player); + DemotionResult result = TotalFreedomMod.getPlugin().getHierarchy() + .demoteUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player); if (!result.wasSuccessful() || result.getGroupTo().isEmpty()) { @@ -209,8 +211,11 @@ public class Command_saconfig extends FreedomCommand plugin.al.addAdmin(admin); } - Group actual = Hierarchy.getHierarchy().getGroup(group); - DisplayableGroup rank = GroupProvider.wrappedFromLPG(actual).getGroup(); + Group actual = TotalFreedomMod.getPlugin().getHierarchy().getGroup(group); + DisplayableGroup rank = TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .fromLuckPerms(actual); if (rank == null) { @@ -259,7 +264,7 @@ public class Command_saconfig extends FreedomCommand Admin admin = plugin.al.getAdmin(player); plugin.al.removeAdmin(admin); - Hierarchy.getHierarchy().dropUser(Hierarchy.getHierarchy().admin(), player); + TotalFreedomMod.getPlugin().getHierarchy().dropUser(TotalFreedomMod.getPlugin().getHierarchy().admin(), player); FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true); admin.setActive(false); @@ -307,7 +312,7 @@ public class Command_saconfig extends FreedomCommand && args[0].equals("setrank") && sender.hasPermission("tfm.saconfig.setrank")) { - return Arrays.asList("ADMIN", "SENIOR_ADMIN"); + return Arrays.asList("admin", "seniorAdmin"); } return Collections.emptyList(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java index a5100f55..f06871ff 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_tag.java @@ -46,7 +46,8 @@ public class Command_tag extends FreedomCommand case "list": { msgNew("Tags for all online players:"); - server.getOnlinePlayers().stream().filter(player -> !(plugin.al.isVanished(player.getUniqueId()) && !isAdmin(sender)) && plugin.pl.getPlayer(player).getTag() != null).forEach(player -> { + server.getOnlinePlayers().stream().filter(player -> !(plugin.al.isVanished(player.getUniqueId()) && !isAdmin(sender)) && plugin.pl.getPlayer(player).getTag() != null).forEach(player -> + { msgNew(": ", Placeholder.unparsed("player", player.getName()), Placeholder.component("tag", plugin.pl.getPlayer(player).getTag())); }); @@ -83,8 +84,7 @@ public class Command_tag extends FreedomCommand if (senderIsConsole) { msgNew("\"/tag off\" can't be used from the console."); - } - else + } else { plugin.pl.getPlayer(playerSender).setTag(null); @@ -104,8 +104,7 @@ public class Command_tag extends FreedomCommand return false; } } - } - else if (args.length >= 2) + } else if (args.length >= 2) { switch (args[0].toLowerCase()) { @@ -164,13 +163,11 @@ public class Command_tag extends FreedomCommand FLog.debug("FUCK YOU " + steamrolled); msgNew("That tag is too long (Max is characters).", Placeholder.unparsed("max", String.valueOf(tagLimit))); return true; - } - else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word))) + } else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word))) { msgNew("That tag contains a forbidden word."); return true; - } - else + } else { plugin.pl.getPlayer(playerSender).setTag(tag); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java index 3ad355a5..5e53cb2c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unblockcmd.java @@ -36,8 +36,7 @@ public class Command_unblockcmd extends FreedomCommand fPlayer.setCommandsBlocked(false); FUtil.adminAction(sender.getName(), "Unblocking all commands for " + player.getName(), true); msgNew("Unblocked commands for ."); - } - else + } else { msgNew("That player's commands aren't blocked."); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java index 2a8c7ea5..c5e3413c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_uncage.java @@ -36,8 +36,7 @@ public class Command_uncage extends FreedomCommand { FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true); fPlayer.getCageData().setCaged(false); - } - else + } else { msgNew("That player is not caged!"); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java index 886f8248..e826d544 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unmute.java @@ -52,14 +52,12 @@ public class Command_unmute extends FreedomCommand { msgNew("Quietly unmuted .", Placeholder.unparsed("player", player.getName())); return true; - } - else + } else { FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true); msgNew("Unmuted .", Placeholder.unparsed("player", player.getName())); } - } - else + } else { msgNew("That player is not muted."); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java index 9b46f157..41d0695c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java @@ -31,15 +31,15 @@ public class Command_vanish extends FreedomCommand if (silent) { msgNew("Silently unvanished."); - } - else + } else { msgNew("You have unvanished."); server.broadcast(plugin.rm.craftLoginMessage(playerSender, null)); server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName())) .color(NamedTextColor.YELLOW)); - if (plugin.dc != null) { + if (plugin.dc != null) + { plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**", true); } } @@ -59,8 +59,7 @@ public class Command_vanish extends FreedomCommand plugin.esb.setVanished(playerSender.getName(), false); playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16)); AdminList.vanished.remove(playerSender.getUniqueId()); - } - else + } else { new BukkitRunnable() { @@ -70,8 +69,7 @@ public class Command_vanish extends FreedomCommand if (plugin.al.isVanished(playerSender.getUniqueId())) { sender.sendActionBar(Component.text("You are hidden from other players.").color(NamedTextColor.GOLD)); - } - else + } else { cancel(); } @@ -81,13 +79,13 @@ public class Command_vanish extends FreedomCommand if (silent) { msgNew("Silently vanished."); - } - else + } else { msgNew("You have vanished."); server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName())) .color(NamedTextColor.YELLOW)); - if (plugin.dc != null) { + if (plugin.dc != null) + { plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**", true); } } @@ -95,7 +93,7 @@ public class Command_vanish extends FreedomCommand plugin.cm.messageAllAdmins(" has vanished and is now only visible to admins.", Placeholder.unparsed("player", sender.getName())); server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player -> - player.hidePlayer(plugin,playerSender)); + player.hidePlayer(plugin, playerSender)); plugin.esb.setVanished(playerSender.getName(), true); AdminList.vanished.add(playerSender.getUniqueId()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java index 1c5d6b0d..ccf63b1e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vote.java @@ -1,7 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -13,6 +11,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.List; + @CommandPermissions(permission = "vote", source = SourceType.BOTH) @CommandParameters(description = "Information on how to vote", usage = "/") public class Command_vote extends FreedomCommand @@ -25,8 +25,7 @@ public class Command_vote extends FreedomCommand if (voteInfo.isEmpty()) { msgNew("The voting information section of the config.yml file has not been configured."); - } - else + } else { msg(FUtil.colorizeAsComponent(StringUtils.join(voteInfo, "\n"))); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java index 8563f1ae..0a262a9b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_warn.java @@ -64,8 +64,7 @@ public class Command_warn extends FreedomCommand if (quiet) { msgNew("You have successfully warned quietly.", Placeholder.unparsed("player", player.getName())); - } - else + } else { plugin.cm.messageAllAdmins(" - Warning: - Reason: ", Placeholder.unparsed("sender", sender.getName()), diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java index f3f4f10a..b4df4010 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_wildcard.java @@ -1,9 +1,5 @@ package me.totalfreedom.totalfreedommod.command; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import me.totalfreedom.totalfreedommod.command.handling.CommandParameters; import me.totalfreedom.totalfreedommod.command.handling.CommandPermissions; import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; @@ -15,6 +11,10 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + @CommandPermissions(permission = "wildcard", source = SourceType.BOTH, blockHostConsole = true) @CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/ [fluff] ? [fluff] ?") public class Command_wildcard extends FreedomCommand diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/handling/Interceptor.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/handling/Interceptor.java index f43a60a1..5dc4551d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/handling/Interceptor.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/handling/Interceptor.java @@ -49,10 +49,13 @@ public class Interceptor }); } - private Map getFallbackCommands() { + private Map getFallbackCommands() + { final Map fallbackCommands = new HashMap<>(); - for (final Map.Entry entry : Bukkit.getCommandMap().getKnownCommands().entrySet()) { - if (!(entry.getValue() instanceof PluginIdentifiableCommand)) { + for (final Map.Entry entry : Bukkit.getCommandMap().getKnownCommands().entrySet()) + { + if (!(entry.getValue() instanceof PluginIdentifiableCommand)) + { fallbackCommands.put(entry.getKey(), entry.getValue()); } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java index e3569923..8c99580e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/MainConfig.java @@ -1,17 +1,18 @@ package me.totalfreedom.totalfreedommod.config; +import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.util.FLog; +import org.apache.commons.io.FileUtils; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; + import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.EnumMap; import java.util.List; -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.util.FLog; -import org.apache.commons.io.FileUtils; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; public class MainConfig extends FreedomService { @@ -39,8 +40,7 @@ public class MainConfig extends FreedomService entries.put(entry, tempDefaults.get(entry.getConfigName())); } } - } - catch (IOException ex) + } catch (IOException ex) { FLog.severe(ex); } @@ -48,8 +48,7 @@ public class MainConfig extends FreedomService copyDefaultConfig(getConfigFile()); load(); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } @@ -88,20 +87,17 @@ public class MainConfig extends FreedomService if (value == null || entry.getType().isAssignableFrom(value.getClass())) { entries.put(entry, value); - } - else + } else { FLog.warning("Value for " + entry.getConfigName() + " is of type " + value.getClass().getSimpleName() + ". Needs to be " + entry.getType().getSimpleName() + ". Using default value."); } - } - else + } else { FLog.warning("Missing configuration entry " + entry.getConfigName() + ". Using default value."); } } - } - catch (IOException | InvalidConfigurationException ex) + } catch (IOException | InvalidConfigurationException ex) { FLog.severe(ex); } @@ -117,8 +113,7 @@ public class MainConfig extends FreedomService try { return get(entry, String.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -130,8 +125,7 @@ public class MainConfig extends FreedomService try { set(entry, value, String.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -142,8 +136,7 @@ public class MainConfig extends FreedomService try { return get(entry, Double.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -155,8 +148,7 @@ public class MainConfig extends FreedomService try { set(entry, value, Double.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -167,8 +159,7 @@ public class MainConfig extends FreedomService try { return get(entry, Boolean.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -180,8 +171,7 @@ public class MainConfig extends FreedomService try { set(entry, value, Boolean.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -192,8 +182,7 @@ public class MainConfig extends FreedomService try { return get(entry, Integer.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -205,8 +194,7 @@ public class MainConfig extends FreedomService try { set(entry, value, Integer.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -217,8 +205,7 @@ public class MainConfig extends FreedomService try { return get(entry, List.class); - } - catch (IllegalArgumentException ex) + } catch (IllegalArgumentException ex) { FLog.severe(ex); } @@ -231,8 +218,7 @@ public class MainConfig extends FreedomService try { return type.cast(value); - } - catch (ClassCastException ex) + } catch (ClassCastException ex) { throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName()); } @@ -266,8 +252,7 @@ public class MainConfig extends FreedomService { FileUtils.copyInputStreamToFile(defaultConfig, targetFile); } - } - catch (IOException ex) + } catch (IOException ex) { FLog.severe(ex); } @@ -296,8 +281,7 @@ public class MainConfig extends FreedomService final InputStreamReader isr = new InputStreamReader(defaultConfig); defaults.load(isr); isr.close(); - } - catch (IOException | InvalidConfigurationException ex) + } catch (IOException | InvalidConfigurationException ex) { FLog.severe(ex); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java index 0ed4aa89..5048cc79 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java @@ -1,9 +1,10 @@ package me.totalfreedom.totalfreedommod.config; -import java.io.File; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import org.bukkit.configuration.file.YamlConfiguration; +import java.io.File; + public class YamlConfig extends YamlConfiguration { private final File file; @@ -34,8 +35,7 @@ public class YamlConfig extends YamlConfiguration try { super.load(file); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } @@ -46,8 +46,7 @@ public class YamlConfig extends YamlConfiguration try { super.save(file); - } - catch (Exception e) + } catch (Exception e) { e.printStackTrace(); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java index 8a6dabc1..38d2001d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/freeze/FreezeData.java @@ -1,6 +1,5 @@ package me.totalfreedom.totalfreedommod.freeze; -import java.util.Objects; import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -9,6 +8,9 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; + +import java.util.Objects; + import static me.totalfreedom.totalfreedommod.TotalFreedomMod.plugin; import static me.totalfreedom.totalfreedommod.player.FPlayer.AUTO_PURGE_TICKS; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java index 110e5d37..962a5df3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java @@ -1,10 +1,9 @@ package me.totalfreedom.totalfreedommod.fun; -import me.totalfreedom.totalfreedommod.api.ShopItem; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.api.ShopItem; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; -import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.*; import org.bukkit.block.Block; @@ -18,8 +17,6 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; @@ -374,40 +371,32 @@ public class ItemFun extends FreedomService if (orientation >= 0.0 && orientation < 22.5) { zVel = speed; - } - else if (orientation >= 22.5 && orientation < 67.5) + } else if (orientation >= 22.5 && orientation < 67.5) { xVel = -(speed / 2.0); zVel = speed / 2.0; - } - else if (orientation >= 67.5 && orientation < 112.5) + } else if (orientation >= 67.5 && orientation < 112.5) { xVel = -speed; - } - else if (orientation >= 112.5 && orientation < 157.5) + } else if (orientation >= 112.5 && orientation < 157.5) { xVel = -(speed / 2.0); zVel = -(speed / 2.0); - } - else if (orientation >= 157.5 && orientation < 202.5) + } else if (orientation >= 157.5 && orientation < 202.5) { zVel = -speed; - } - else if (orientation >= 202.5 && orientation < 247.5) + } else if (orientation >= 202.5 && orientation < 247.5) { xVel = speed / 2.0; zVel = -(speed / 2.0); - } - else if (orientation >= 247.5 && orientation < 292.5) + } else if (orientation >= 247.5 && orientation < 292.5) { xVel = speed; - } - else if (orientation >= 292.5 && orientation < 337.5) + } else if (orientation >= 292.5 && orientation < 337.5) { xVel = speed / 2.0; zVel = speed / 2.0; - } - else if (orientation >= 337.5 && orientation < 360.0) + } else if (orientation >= 337.5 && orientation < 360.0) { zVel = speed; } @@ -417,8 +406,7 @@ public class ItemFun extends FreedomService if (event.getState() == PlayerFishEvent.State.FISHING) { orientationTracker.put(player, player.getLocation().getYaw()); - } - else + } else { orientationTracker.remove(player); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java index 2341272b..4418e544 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java @@ -1,9 +1,6 @@ package me.totalfreedom.totalfreedommod.fun; import com.google.common.collect.Maps; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.util.Groups; import org.bukkit.block.Block; @@ -13,6 +10,10 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + public class Jumppads extends FreedomService { @@ -75,14 +76,12 @@ public class Jumppads extends FreedomService velocity.multiply(strength + 0.85).multiply(-1.0); } canPush = false; - } - else + } else { canPush = true; } pushMap.put(player, canPush); - } - else + } else { if (Groups.WOOL_COLORS.contains(block.getRelative(0, -1, 0).getType())) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java index fc249df9..812bd60d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/fun/Landminer.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.fun; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import org.bukkit.GameMode; @@ -15,6 +12,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + public class Landminer extends FreedomService { private final List landmines = new ArrayList<>(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java index a808ab53..0f051fd6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTMLGenerationTools.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.httpd; import java.util.Collection; import java.util.Map; + import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4; public class HTMLGenerationTools diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java index da5aba89..90637b36 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/HTTPDaemon.java @@ -1,5 +1,14 @@ package me.totalfreedom.totalfreedommod.httpd; +import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response; +import me.totalfreedom.totalfreedommod.httpd.module.*; +import me.totalfreedom.totalfreedommod.util.FLog; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.exception.ExceptionUtils; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -7,25 +16,6 @@ import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response; -import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule; -import me.totalfreedom.totalfreedommod.httpd.module.Module_admins; -import me.totalfreedom.totalfreedommod.httpd.module.Module_bans; -import me.totalfreedom.totalfreedommod.httpd.module.Module_file; -import me.totalfreedom.totalfreedommod.httpd.module.Module_help; -import me.totalfreedom.totalfreedommod.httpd.module.Module_indefbans; -import me.totalfreedom.totalfreedommod.httpd.module.Module_index; -import me.totalfreedom.totalfreedommod.httpd.module.Module_list; -import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile; -import me.totalfreedom.totalfreedommod.httpd.module.Module_players; -import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments; -import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic; -import me.totalfreedom.totalfreedommod.util.FLog; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.exception.ExceptionUtils; public class HTTPDaemon extends FreedomService { @@ -66,8 +56,7 @@ public class HTTPDaemon extends FreedomService response = new Response(Response.Status.OK, mimetype, new FileInputStream(file)); response.addHeader("Content-Length", "" + file.length()); - } - catch (IOException ex) + } catch (IOException ex) { FLog.severe(ex); } @@ -106,13 +95,11 @@ public class HTTPDaemon extends FreedomService if (httpd.isAlive()) { FLog.info("TFM HTTPd started. Listening on port: " + httpd.getListeningPort()); - } - else + } else { FLog.info("Error starting TFM HTTPd."); } - } - catch (IOException ex) + } catch (IOException ex) { FLog.severe(ex); } @@ -142,7 +129,7 @@ public class HTTPDaemon extends FreedomService { super(port); } - + @Override public Response serve(HTTPSession session) { @@ -162,8 +149,7 @@ public class HTTPDaemon extends FreedomService try { return mex.execute(session); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "Error 500: Internal Server Error\r\n" + ex.getMessage() + "\r\n" + ExceptionUtils.getStackTrace(ex)); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java index a345f0ac..f987ed39 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/ModuleExecutable.java @@ -1,11 +1,12 @@ package me.totalfreedom.totalfreedommod.httpd; -import java.lang.reflect.Constructor; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule; import me.totalfreedom.totalfreedommod.util.FLog; import org.bukkit.Bukkit; +import java.lang.reflect.Constructor; + public abstract class ModuleExecutable { private final boolean async; @@ -21,8 +22,7 @@ public abstract class ModuleExecutable try { cons = clazz.getConstructor(NanoHTTPD.HTTPSession.class); - } - catch (Exception ex) + } catch (Exception ex) { throw new IllegalArgumentException("Improperly defined module!"); } @@ -35,8 +35,7 @@ public abstract class ModuleExecutable try { return cons.newInstance(session).getResponse(); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); return null; @@ -57,8 +56,7 @@ public abstract class ModuleExecutable // Sync to server thread return Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.getPlugin(), () -> getResponse(session)).get(); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java index bd045b95..04a42053 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/NanoHTTPD.java @@ -1,40 +1,15 @@ package me.totalfreedom.totalfreedommod.httpd; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.Closeable; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.RandomAccessFile; -import java.io.SequenceInputStream; -import java.io.UnsupportedEncodingException; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.SocketException; -import java.net.URLDecoder; +import me.totalfreedom.totalfreedommod.util.FLog; +import org.jetbrains.annotations.NotNull; + +import java.io.*; +import java.net.*; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.TimeZone; -import me.totalfreedom.totalfreedommod.util.FLog; -import org.jetbrains.annotations.NotNull; +import java.util.*; /** * A simple, tiny, nicely embeddable HTTP server in Java @@ -142,8 +117,7 @@ public abstract class NanoHTTPD try { serverSocket.close(); - } - catch (IOException ignored) + } catch (IOException ignored) { } } @@ -156,8 +130,7 @@ public abstract class NanoHTTPD try { socket.close(); - } - catch (IOException ignored) + } catch (IOException ignored) { } } @@ -170,8 +143,7 @@ public abstract class NanoHTTPD try { closeable.close(); - } - catch (IOException ignored) + } catch (IOException ignored) { } } @@ -198,8 +170,7 @@ public abstract class NanoHTTPD if (inputStream == null) { safeClose(finalAccept); - } - else + } else { asyncRunner.exec(() -> { @@ -213,8 +184,7 @@ public abstract class NanoHTTPD { session.execute(); } - } - catch (Exception e) + } catch (Exception e) { // When the socket is closed by the client, we throw our own SocketException // to break the "keep alive" loop above. @@ -222,8 +192,7 @@ public abstract class NanoHTTPD { FLog.severe(e); } - } - finally + } finally { safeClose(outputStream); safeClose(inputStream); @@ -231,8 +200,7 @@ public abstract class NanoHTTPD } }); } - } - catch (IOException ignored) + } catch (IOException ignored) { } } @@ -256,8 +224,7 @@ public abstract class NanoHTTPD { myThread.join(); } - } - catch (Exception e) + } catch (Exception e) { FLog.severe(e); } @@ -315,12 +282,10 @@ public abstract class NanoHTTPD try { session.parseBody(files); - } - catch (IOException ioe) + } catch (IOException ioe) { return new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage()); - } - catch (ResponseException re) + } catch (ResponseException re) { return new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage()); } @@ -341,8 +306,7 @@ public abstract class NanoHTTPD try { decoded = URLDecoder.decode(str, "UTF8"); - } - catch (UnsupportedEncodingException | IllegalArgumentException ignored) + } catch (UnsupportedEncodingException | IllegalArgumentException ignored) { } return decoded; @@ -553,8 +517,7 @@ public abstract class NanoHTTPD try { file.delete(); - } - catch (Exception ignored) + } catch (Exception ignored) { } } @@ -706,15 +669,13 @@ public abstract class NanoHTTPD if (requestMethod != Method.HEAD && chunkedTransfer) { sendAsChunked(outputStream, pw); - } - else + } else { sendAsFixedLength(outputStream, pw); } outputStream.flush(); safeClose(data); - } - catch (IOException ioe) + } catch (IOException ioe) { // Couldn't write? No can do. } @@ -1093,32 +1054,27 @@ public abstract class NanoHTTPD if (r == null) { throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: Serve() returned a null response."); - } - else + } else { cookies.unloadQueue(r); r.setRequestMethod(method); r.send(outputStream); } - } - catch (SocketException e) + } catch (SocketException e) { // throw it out to close socket object (finalAccept) throw e; - } - catch (IOException ioe) + } catch (IOException ioe) { Response r = new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage()); r.send(outputStream); safeClose(outputStream); - } - catch (ResponseException re) + } catch (ResponseException re) { Response r = new Response(re.getStatus(), MIME_PLAINTEXT, re.getMessage()); r.send(outputStream); safeClose(outputStream); - } - finally + } finally { tempFileManager.clear(); } @@ -1137,12 +1093,10 @@ public abstract class NanoHTTPD if (headers.containsKey("content-length")) { size = Integer.parseInt(headers.get("content-length")); - } - else if (splitbyte < rlen) + } else if (splitbyte < rlen) { size = rlen - splitbyte; - } - else + } else { size = 0; } @@ -1203,8 +1157,7 @@ public abstract class NanoHTTPD } decodeMultipartData(boundary, fbuf, in, parms, files); - } - else + } else { // Handle application/x-www-form-urlencoded StringBuilder postLine = new StringBuilder(); @@ -1218,13 +1171,11 @@ public abstract class NanoHTTPD postLine = new StringBuilder(postLine.toString().trim()); decodeParms(postLine.toString(), parms); } - } - else if (Method.PUT.equals(method)) + } else if (Method.PUT.equals(method)) { files.put("content", saveTmpFile(fbuf, 0, fbuf.limit())); } - } - finally + } finally { safeClose(randomAccessFile); safeClose(in); @@ -1267,8 +1218,7 @@ public abstract class NanoHTTPD { decodeParms(uri.substring(qmi + 1), parms); uri = decodePercent(uri.substring(0, qmi)); - } - else + } else { uri = decodePercent(uri); } @@ -1292,8 +1242,7 @@ public abstract class NanoHTTPD } pre.put("uri", uri); - } - catch (IOException ioe) + } catch (IOException ioe) { throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe); } @@ -1361,15 +1310,13 @@ public abstract class NanoHTTPD if (d == -1) { value.append(mpline); - } - else + } else { value.append(mpline, 0, d - 2); } } } - } - else + } else { if (boundarycount > bpositions.length) { @@ -1389,8 +1336,7 @@ public abstract class NanoHTTPD parms.put(pname, value.toString()); } } - } - catch (IOException ioe) + } catch (IOException ioe) { throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage(), ioe); } @@ -1436,8 +1382,7 @@ public abstract class NanoHTTPD matchcount = 0; matchbyte = -1; } - } - else + } else { i -= matchcount; matchcount = 0; @@ -1470,12 +1415,10 @@ public abstract class NanoHTTPD src.position(offset).limit(offset + len); dest.write(src.slice()); path = tempFile.getName(); - } - catch (Exception e) + } catch (Exception e) { // Catch exception if any FLog.severe(e); - } - finally + } finally { safeClose(fileOutputStream); } @@ -1489,8 +1432,7 @@ public abstract class NanoHTTPD { TempFile tempFile = tempFileManager.createTempFile(); return new RandomAccessFile(tempFile.getName(), "rw"); - } - catch (Exception e) + } catch (Exception e) { FLog.severe(e); } @@ -1535,8 +1477,7 @@ public abstract class NanoHTTPD { p.put(decodePercent(e.substring(0, sep)).trim(), decodePercent(e.substring(sep + 1))); - } - else + } else { p.put(decodePercent(e).trim(), ""); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java index 4ea99cef..457309f2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java @@ -1,8 +1,5 @@ package me.totalfreedom.totalfreedommod.httpd.module; -import java.net.Socket; -import java.util.HashMap; -import java.util.Map; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession; @@ -10,6 +7,10 @@ import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response; import me.totalfreedom.totalfreedommod.util.FLog; +import java.net.Socket; +import java.util.HashMap; +import java.util.Map; + public abstract class HTTPDModule extends FreedomService { @@ -72,8 +73,7 @@ public abstract class HTTPDModule extends FreedomService try { session.parseBody(files); - } - catch (Exception ex) + } catch (Exception ex) { FLog.severe(ex); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java index da43ca2c..9dfddf0b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_file.java @@ -1,21 +1,17 @@ package me.totalfreedom.totalfreedommod.httpd.module; +import me.totalfreedom.totalfreedommod.config.ConfigEntry; +import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; +import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; +import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response; +import org.apache.commons.lang3.StringUtils; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; -import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; -import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response; -import org.apache.commons.lang3.StringUtils; +import java.util.*; /* * This class was adapted from https://github.com/NanoHttpd/nanohttpd/blob/master/webserver/src/main/java/fi/iki/elonen/SimpleWebServer.java @@ -77,18 +73,15 @@ public class Module_file extends HTTPDModule if (tok.equals("/")) { newUri.append("/"); - } - else if (tok.equals(" ")) + } else if (tok.equals(" ")) { newUri.append("%20"); - } - else + } else { try { newUri.append(URLEncoder.encode(tok, "UTF-8")); - } - catch (UnsupportedEncodingException ignored) + } catch (UnsupportedEncodingException ignored) { } } @@ -147,17 +140,14 @@ public class Module_file extends HTTPDModule if (new File(f, "index.html").exists()) { f = new File(homeDir, uri + "/index.html"); - } - else if (new File(f, "index.htm").exists()) + } else if (new File(f, "index.htm").exists()) { f = new File(homeDir, uri + "/index.htm"); - } - else if (f.canRead()) + } else if (f.canRead()) { // No index file, list the directory if it is readable res = new Response(listDirectory(uri, f)); - } - else + } else { res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: No directory listing."); } @@ -203,12 +193,10 @@ public class Module_file extends HTTPDModule startFrom = Long.parseLong(rangeParams[1].substring(0, minus)); endAt = Long.parseLong(rangeParams[1].substring(minus + 1)); } - } - catch (NumberFormatException ignored) + } catch (NumberFormatException ignored) { } - } - else if ("tail".equalsIgnoreCase(rangeParams[0])) + } else if ("tail".equalsIgnoreCase(rangeParams[0])) { try { @@ -221,8 +209,7 @@ public class Module_file extends HTTPDModule startFrom = 0; } } - } - catch (NumberFormatException ignored) + } catch (NumberFormatException ignored) { } } @@ -236,8 +223,7 @@ public class Module_file extends HTTPDModule { res = new Response(Response.Status.RANGE_NOT_SATISFIABLE, NanoHTTPD.MIME_PLAINTEXT, ""); res.addHeader("Content-Range", "bytes 0-0/" + fileLen); - } - else + } else { if (endAt < 0) { @@ -255,7 +241,7 @@ public class Module_file extends HTTPDModule @Override public int available() { - return (int)dataLen; + return (int) dataLen; } }; //noinspection ResultOfMethodCallIgnored @@ -265,16 +251,14 @@ public class Module_file extends HTTPDModule res.addHeader("Content-Length", "" + dataLen); res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen); } - } - else + } else { res = new Response(Response.Status.OK, mime, new FileInputStream(f)); res.addHeader("Content-Length", "" + fileLen); } res.addHeader("ETag", etag); } - } - catch (IOException ioe) + } catch (IOException ioe) { res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: Reading file failed."); } @@ -337,12 +321,10 @@ public class Module_file extends HTTPDModule if (len < 1024) { msg.append(len).append(" bytes"); - } - else if (len < 1024 * 1024) + } else if (len < 1024 * 1024) { msg.append(len / 1024).append(".").append(len % 1024 / 10 % 100).append(" KB"); - } - else + } else { msg.append(len / (1024 * 1024)).append(".").append(len % (1024 * 1024) / 10 % 100).append(" MB"); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java index 4f55e001..d77e63ce 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_help.java @@ -1,9 +1,6 @@ package me.totalfreedom.totalfreedommod.httpd.module; import com.google.common.collect.Lists; - -import java.util.*; - import me.totalfreedom.totalfreedommod.command.handling.FreedomCommand; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; import org.apache.commons.lang.StringUtils; @@ -15,6 +12,8 @@ import org.bukkit.permissions.Permission; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.*; + import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.heading; import static me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools.paragraph; import static org.apache.commons.lang3.StringEscapeUtils.escapeHtml4; @@ -81,7 +80,7 @@ public class Module_help extends HTTPDModule String pluginName = "Bukkit"; if (command instanceof PluginIdentifiableCommand) { - pluginName = ((PluginIdentifiableCommand)command).getPlugin().getName(); + pluginName = ((PluginIdentifiableCommand) command).getPlugin().getName(); } List pluginCommands = commandsByPlugin.computeIfAbsent(pluginName, k -> Lists.newArrayList()); @@ -108,13 +107,13 @@ public class Module_help extends HTTPDModule if (!plugin.getName().equals(pluginName)) { commands.forEach((command) -> responseBody.append(buildDescription(command))); - } - else + } else { Map> freedomCommands = new HashMap<>(); // Filters out non-TFM commands - commands.stream().filter((cmd) -> cmd instanceof FreedomCommand.FCommand).forEach((tfmCmd) -> { + commands.stream().filter((cmd) -> cmd instanceof FreedomCommand.FCommand).forEach((tfmCmd) -> + { String permission = Objects.requireNonNull(FreedomCommand.getFrom(tfmCmd)).getPermission(); if (!freedomCommands.containsKey(permission)) freedomCommands.put(permission, new ArrayList<>()); @@ -130,10 +129,11 @@ public class Module_help extends HTTPDModule // Finally dumps them to HTML permissions.stream().filter(freedomCommands::containsKey) - .sorted(comparator::compare).forEach((permission -> { - responseBody.append("\r\n").append(heading(permission, 3)).append("
    \r\n"); - freedomCommands.get(permission).stream().sorted(comparator::compare).forEach((command) -> responseBody.append(buildDescription(command))); - })); + .sorted(comparator::compare).forEach((permission -> + { + responseBody.append("
\r\n").append(heading(permission, 3)).append("
    \r\n"); + freedomCommands.get(permission).stream().sorted(comparator::compare).forEach((command) -> responseBody.append(buildDescription(command))); + })); } responseBody.append("
\r\n"); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java index 6cb89393..d586b06e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_indefbans.java @@ -1,11 +1,12 @@ package me.totalfreedom.totalfreedommod.httpd.module; -import java.io.File; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList; import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; +import java.io.File; + public class Module_indefbans extends HTTPDModule { @@ -28,8 +29,7 @@ public class Module_indefbans extends HTTPDModule if (permbanFile.exists()) { return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), IndefiniteBanList.CONFIG_FILENAME)); - } - else + } else { return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "Error 404: Not Found - The requested resource was not found on this server."); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java index 7c7beabd..d639e2b7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_index.java @@ -1,12 +1,13 @@ package me.totalfreedom.totalfreedommod.httpd.module; -import java.util.Set; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools; import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; import org.reflections.Reflections; +import java.util.Set; + public class Module_index extends HTTPDModule { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java index 8aefe299..dfc8d89d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_list.java @@ -1,10 +1,9 @@ package me.totalfreedom.totalfreedommod.httpd.module; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -71,9 +70,11 @@ public class Module_list extends HTTPDModule if (hasSpecialTitle(player) && plugin.al.isAdmin(player) && !plugin.al.isVanished(player.getUniqueId())) { Admin admin = plugin.al.getAdmin(player); - if (admin.getRank().equals(GroupProvider.ADMIN.getGroup())) { + if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin())) + { admins.add(player.getName()); - } else if (admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup())) { + } else if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin())) + { senioradmins.add(player.getName()); } } @@ -93,8 +94,7 @@ public class Module_list extends HTTPDModule final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString()); response.addHeader("Access-Control-Allow-Origin", "*"); return response; - } - else + } else { final StringBuilder body = new StringBuilder(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java index e0a88031..111840b6 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logfile.java @@ -1,10 +1,5 @@ package me.totalfreedom.totalfreedommod.httpd.module; -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools; @@ -17,6 +12,12 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; + public class Module_logfile extends HTTPDModule { @@ -44,8 +45,7 @@ public class Module_logfile extends HTTPDModule try { return new HTTPDPageBuilder(body(), title(), null, null).getResponse(); - } - catch (ResponseOverrideException ex) + } catch (ResponseOverrideException ex) { return ex.getResponse(); } @@ -78,8 +78,7 @@ public class Module_logfile extends HTTPDModule out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server.")); FLog.info("An unregistered IP (" + remoteAddress + ") has tried to access the log files"); - } - else + } else { Collection LogFiles = FileUtils.listFiles(LOG_FOLDER, LOG_FILTER, false); @@ -108,15 +107,13 @@ public class Module_logfile extends HTTPDModule { out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server.")); FLog.info("An unregistered IP (" + remoteAddress + ") has tried to download a log file"); - } - else + } else { try { FLog.info("The IP \"" + remoteAddress + "\" is downloading log file: " + params.get("logFileName")); throw new ResponseOverrideException(downloadLogFile(params.get("logFileName"))); - } - catch (LogFileTransferException ex) + } catch (LogFileTransferException ex) { out.append(HTMLGenerationTools.paragraph("Error downloading logfile: " + ex.getMessage())); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java index 03b958bb..633e786a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_players.java @@ -1,13 +1,11 @@ package me.totalfreedom.totalfreedommod.httpd.module; import com.google.gson.Gson; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.entity.HumanEntity; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.HashMap; @@ -15,9 +13,9 @@ import java.util.List; import java.util.Map; public class Module_players extends HTTPDModule -{ +{ private static final Gson gson = new Gson(); - + public Module_players(NanoHTTPD.HTTPSession session) { super(session); @@ -34,10 +32,10 @@ public class Module_players extends HTTPDModule plugin.al.getActiveAdmins().stream().filter(admin -> admin.getName() != null).forEach(admin -> { // Do nothing, keeps Codacy quiet - if (admin.getRank().equals(GroupProvider.ADMIN.getGroup())) + if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin())) { admins.add(admin.getName()); - } else if (admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup())) + } else if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin())) { senioradmins.add(admin.getName()); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java index 09adca04..b67d396e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_punishments.java @@ -1,11 +1,12 @@ package me.totalfreedom.totalfreedommod.httpd.module; -import java.io.File; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; import me.totalfreedom.totalfreedommod.punishments.PunishmentList; +import java.io.File; + public class Module_punishments extends HTTPDModule { @@ -25,14 +26,12 @@ public class Module_punishments extends HTTPDModule { return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "You may not view the punishment list. Your IP, " + remoteAddress + ", is not registered to an admin on the server."); - } - else + } else { return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PunishmentList.CONFIG_FILENAME)); } - } - else + } else { return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "Error 404: Not Found - The requested resource was not found on this server."); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java index 808467c5..bda08c4a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_schematic.java @@ -2,15 +2,6 @@ package me.totalfreedom.totalfreedommod.httpd.module; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.httpd.HTMLGenerationTools; @@ -25,6 +16,12 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.*; +import java.util.regex.Pattern; + public class Module_schematic extends HTTPDModule { @@ -60,8 +57,7 @@ public class Module_schematic extends HTTPDModule try { return new HTTPDPageBuilder(body(), title(), null, null).getResponse(); - } - catch (ResponseOverrideException ex) + } catch (ResponseOverrideException ex) { return ex.getResponse(); } @@ -98,12 +94,10 @@ public class Module_schematic extends HTTPDModule if (SCHEMATIC_FILENAME_LC.matcher(filename.trim().toLowerCase()).find()) { schematicsFormatted.add("
  • " + filename + "
  • "); - } - else if (filename.length() > 254) + } else if (filename.length() > 254) { schematicsFormatted.add("
  • " + filename + " - (Filename too long, can't download)
  • "); - } - else + } else { schematicsFormatted.add("
  • " + filename + " - (Illegal filename, can't download)
  • "); } @@ -122,8 +116,7 @@ public class Module_schematic extends HTTPDModule try { throw new ResponseOverrideException(downloadSchematic(params.get("schematicName"))); - } - catch (SchematicTransferException ex) + } catch (SchematicTransferException ex) { out.append(HTMLGenerationTools.paragraph("Error downloading schematic: " + ex.getMessage())); } @@ -135,8 +128,7 @@ public class Module_schematic extends HTTPDModule if (!isAuthorized(remoteAddress)) { out.append(HTMLGenerationTools.paragraph("Schematic upload access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server.")); - } - else + } else { if (method == Method.POST) { @@ -145,13 +137,11 @@ public class Module_schematic extends HTTPDModule uploadSchematic(remoteAddress); out.append(HTMLGenerationTools.paragraph("Schematic uploaded successfully.")); - } - catch (SchematicTransferException ex) + } catch (SchematicTransferException ex) { out.append(HTMLGenerationTools.paragraph("Error uploading schematic: " + ex.getMessage())); } - } - else + } else { out.append(UPLOAD_FORM); } @@ -248,8 +238,7 @@ public class Module_schematic extends HTTPDModule try { format.getReader(new FileInputStream(targetFile)); - } - catch (IOException e) + } catch (IOException e) { FileUtils.deleteQuietly(targetFile); throw new SchematicTransferException("Schematic is not a valid schematic."); @@ -257,8 +246,7 @@ public class Module_schematic extends HTTPDModule FLog.info(remoteAddress + " uploaded schematic: " + targetFile.getName()); - } - catch (IOException ex) + } catch (IOException ex) { FLog.severe(ex); throw new SchematicTransferException(); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/GroupWrapper.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/GroupWrapper.java index 39d518da..bc7ae6b2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/GroupWrapper.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/GroupWrapper.java @@ -4,8 +4,6 @@ import me.totalfreedom.totalfreedommod.util.FLog; import net.luckperms.api.model.group.Group; import net.luckperms.api.model.group.GroupManager; -import java.util.concurrent.CompletableFuture; - public class GroupWrapper { private final GroupManager manager; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/TrackWrapper.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/TrackWrapper.java index c5a0972f..116c2994 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/TrackWrapper.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/TrackWrapper.java @@ -4,8 +4,6 @@ import me.totalfreedom.totalfreedommod.util.FLog; import net.luckperms.api.track.Track; import net.luckperms.api.track.TrackManager; -import java.util.concurrent.CompletableFuture; - public class TrackWrapper { private final TrackManager manager; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserData.java index 5f09882c..bd9e9fc7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserData.java @@ -1,7 +1,6 @@ package me.totalfreedom.totalfreedommod.perms; import net.luckperms.api.LuckPermsProvider; -import net.luckperms.api.cacheddata.CachedData; import net.luckperms.api.cacheddata.CachedDataManager; import net.luckperms.api.cacheddata.CachedMetaData; import net.luckperms.api.cacheddata.CachedPermissionData; @@ -17,30 +16,36 @@ import org.bukkit.entity.Player; */ public class UserData { - public static User fromPlayer(Player player) { + public static User fromPlayer(Player player) + { PlayerAdapter adapter = LuckPermsProvider .get() .getPlayerAdapter(Player.class); return adapter.getUser(player); } - public static QueryOptions getQueryOptions(User user) { + public static QueryOptions getQueryOptions(User user) + { return user.getQueryOptions(); } - public static CachedDataManager getDataManager(User user) { + public static CachedDataManager getDataManager(User user) + { return user.getCachedData(); } - public static ImmutableContextSet getContextSet(User user) { + public static ImmutableContextSet getContextSet(User user) + { return getQueryOptions(user).context(); } - public static CachedMetaData getMetaData(User user) { + public static CachedMetaData getMetaData(User user) + { return getDataManager(user).getMetaData(); } - public static CachedPermissionData getPermissionData(User user) { + public static CachedPermissionData getPermissionData(User user) + { return getDataManager(user).getPermissionData(); } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserWrapper.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserWrapper.java index 64a36cb9..256824a2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserWrapper.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/perms/UserWrapper.java @@ -8,8 +8,6 @@ import net.luckperms.api.node.NodeType; import net.luckperms.api.platform.PlayerAdapter; import org.bukkit.entity.Player; -import java.util.concurrent.CompletableFuture; - public class UserWrapper { private final UserManager manager; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java index 622acf71..1f7215aa 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java @@ -64,7 +64,7 @@ public class PlayerData } //-- discordID = resultSet.getString("discord_id"); - masterBuilder = resultSet.getBoolean("master_builder"); + masterBuilder = resultSet.getBoolean("masterBuilder"); rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase()); coins = resultSet.getInt("coins"); items.clear(); @@ -212,7 +212,7 @@ public class PlayerData objectMap.put("notes", FUtil.listToString(notes)); objectMap.put("tag", FUtil.miniMessage(tag)); objectMap.put("discord_id", discordID); - objectMap.put("master_builder", masterBuilder); + objectMap.put("masterBuilder", masterBuilder); objectMap.put("ride_mode", rideMode.name()); objectMap.put("coins", coins); objectMap.put("items", FUtil.listToString(items)); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java index 849887da..6e95a599 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java @@ -2,9 +2,9 @@ package me.totalfreedom.totalfreedommod.player; import com.google.common.collect.Maps; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.OfflinePlayer; @@ -100,7 +100,7 @@ public class PlayerList extends FreedomService public boolean isTelnetMasterBuilder(PlayerData playerData) { Admin admin = plugin.al.getEntryByUuid(playerData.getUuid()); - return admin != null && admin.getRank().weightCheckAgainst(GroupProvider.ADMIN.getGroup()) && playerData.isMasterBuilder(); + return admin != null && admin.getRank().weightCheckAgainst(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin()) && playerData.isMasterBuilder(); } // May not return null @@ -176,7 +176,7 @@ public class PlayerList extends FreedomService // Load data playerData = loadByUuid(player.getUniqueId()); - // Oh you don't have any data? Well now you do + // Oh, you don't have any data? Well now you do if (playerData == null) { FLog.info("Creating new player data entry for " + player.getName()); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java index 3e532872..bdaeaf8e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/Punishment.java @@ -1,11 +1,12 @@ package me.totalfreedom.totalfreedommod.punishments; +import me.totalfreedom.totalfreedommod.config.IConfig; +import org.bukkit.configuration.ConfigurationSection; + import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Objects; -import me.totalfreedom.totalfreedommod.config.IConfig; -import org.bukkit.configuration.ConfigurationSection; public class Punishment implements IConfig { @@ -59,8 +60,7 @@ public class Punishment implements IConfig try { this.issued_on = DATE_FORMAT.parse(cs.getString("issued_on", null)); - } - catch (ParseException e) + } catch (ParseException e) { this.issued_on = null; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java index b18952cb..46d50db1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/punishments/PunishmentList.java @@ -1,13 +1,14 @@ package me.totalfreedom.totalfreedommod.punishments; import com.google.common.collect.Sets; +import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.config.YamlConfig; +import me.totalfreedom.totalfreedommod.util.FLog; + import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Set; -import me.totalfreedom.totalfreedommod.FreedomService; -import me.totalfreedom.totalfreedommod.config.YamlConfig; -import me.totalfreedom.totalfreedommod.util.FLog; public class PunishmentList extends FreedomService { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java index 420cbd71..77e56fa7 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java @@ -1,5 +1,6 @@ package me.totalfreedom.totalfreedommod.rank; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextColor; @@ -57,7 +58,7 @@ public class DisplayableGroup implements Displayable { WeightNode tempWeight; PrefixNode tempPrefix; - Group matched = Hierarchy.getHierarchy().getGroup(group); // we don't need to null check because if there is no group this method will also create one. + Group matched = TotalFreedomMod.getPlugin().getHierarchy().getGroup(group); // we don't need to null check because if there is no group this method will also create one. this.name = (matched.getDisplayName() != null) ? FUtil.miniMessage(matched.getDisplayName()) : FUtil.miniMessage(matched.getName()); this.plural = plural; @@ -227,6 +228,6 @@ public class DisplayableGroup implements Displayable public void save() { - Hierarchy.getHierarchy().gw().saveGroup(group.getName()); + TotalFreedomMod.getPlugin().getHierarchy().gw().saveGroup(group.getName()); } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java index 4109537b..974bba0a 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java @@ -1,81 +1,130 @@ package me.totalfreedom.totalfreedommod.rank; -import me.totalfreedom.totalfreedommod.TotalFreedomMod; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.luckperms.api.model.group.Group; -import net.luckperms.api.model.user.User; -import net.luckperms.api.node.matcher.NodeMatcher; import net.luckperms.api.node.types.InheritanceNode; import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import java.util.List; -import java.util.Set; import java.util.stream.Stream; -@FunctionalInterface -public interface GroupProvider +public class GroupProvider { - Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY); - Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY); + public static final Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY); + public static final Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY); - GroupProvider NON_OP = () -> new DisplayableGroup("default", Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false); - GroupProvider OP = () -> new DisplayableGroup("op", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false); - GroupProvider MASTER_BUILDER = () -> new DisplayableGroup("builder", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true); - GroupProvider ADMIN = () -> new DisplayableGroup("admin", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true); - GroupProvider SENIOR_ADMIN = () -> new DisplayableGroup("senior", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true); + private final DisplayableGroup nonOp; + private final DisplayableGroup op; + private final DisplayableGroup masterBuilder; + private final DisplayableGroup admin; + private final DisplayableGroup seniorAdmin; - static InheritanceNode inheritanceNode(DisplayableGroup group) + public GroupProvider() + { + this.nonOp = new DisplayableGroup( + "default", + Component.text("Non-Ops"), + Component.empty(), + 0, + NamedTextColor.WHITE, + null, + false, + false); + + this.op = new DisplayableGroup( + "op", + Component.text("Operators"), + Component.text("Op"), + 1, + NamedTextColor.GREEN, + null, + false, + false); + + this.masterBuilder = new DisplayableGroup( + "builder", + Component.text("Master Builders"), + Component.text("MB"), + 2, + NamedTextColor.DARK_AQUA, + ChatColor.DARK_AQUA, + true, + true); + + this.admin = new DisplayableGroup( + "admin", + Component.text("Administrators"), + Component.text("Admin"), + 3, + NamedTextColor.DARK_GREEN, + ChatColor.DARK_GREEN, + true, + true); + + this.seniorAdmin = new DisplayableGroup( + "senior", + Component.text("Senior Administrators"), + Component.text("SrA"), + 4, + NamedTextColor.GOLD, + ChatColor.GOLD, + true, + true); + + nonOp.save(); + op.save(); + masterBuilder.save(); + admin.save(); + seniorAdmin.save(); + } + + public DisplayableGroup getNonOp() + { + return nonOp; + } + + public DisplayableGroup getOp() + { + return op; + } + + public DisplayableGroup getMasterBuilder() + { + return masterBuilder; + } + + public DisplayableGroup getAdmin() + { + return admin; + } + + public DisplayableGroup getSeniorAdmin() + { + return seniorAdmin; + } + + public InheritanceNode inheritanceNode(DisplayableGroup group) { return InheritanceNode.builder(group.getLuckPermsGroup()).build(); } - static NodeMatcher nodeMatcher(DisplayableGroup group) + public DisplayableGroup fromLuckPerms(Group group) { - return NodeMatcher.key(inheritanceNode(group)); - } - - static DisplayableGroup directFromLPG(Group group) - { - return List.of(NON_OP.getGroup(), OP.getGroup(), MASTER_BUILDER.getGroup(), ADMIN.getGroup(), SENIOR_ADMIN.getGroup()).stream() + return Stream.of(nonOp, op, masterBuilder, admin, seniorAdmin) .filter(displayableGroup -> displayableGroup.getLuckPermsGroup().equals(group)) .findFirst() - .orElse(NON_OP.getGroup()); + .orElse(nonOp); } - static User getUser(Player player) - { - return TotalFreedomMod.getPlugin() - .lpb.getAPI() - .getPlayerAdapter(Player.class) - .getUser(player); - } - - static GroupProvider fromString(String arg) + public DisplayableGroup fromString(String arg) { return switch (arg.toLowerCase()) { - case "op" -> OP; - case "builder" -> MASTER_BUILDER; - case "admin" -> ADMIN; - case "senior" -> SENIOR_ADMIN; - default -> NON_OP; + case "op" -> op; + case "builder" -> masterBuilder; + case "admin" -> admin; + case "senior" -> seniorAdmin; + default -> nonOp; }; } - - static GroupProvider wrappedFromLPG(Group group) - { - return Stream.of(NON_OP, OP, MASTER_BUILDER, ADMIN, SENIOR_ADMIN) - .filter(displayableGroup -> displayableGroup.getGroup().getLuckPermsGroup().equals(group)) - .findFirst() - .orElse(NON_OP); - } - - static Set> providerSet() - { - return Set.of(NON_OP, OP, MASTER_BUILDER, ADMIN, SENIOR_ADMIN); - } - - T getGroup(); } \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Hierarchy.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Hierarchy.java index 45b28b5f..91bbf21e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Hierarchy.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Hierarchy.java @@ -18,23 +18,19 @@ import org.bukkit.entity.Player; public class Hierarchy { - private static final Hierarchy hierarchy = new Hierarchy(); // static singleton for global state. private final GroupWrapper groupWrapper; private final TrackWrapper trackWrapper; private final UserWrapper userWrapper; private final PlayerAdapter playerAdapter; + private final GroupProvider groupProvider; - private Hierarchy() + public Hierarchy() { this.playerAdapter = TotalFreedomMod.getPlugin().lpb.getAPI().getPlayerAdapter(Player.class); this.groupWrapper = new GroupWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager()); this.trackWrapper = new TrackWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getTrackManager()); this.userWrapper = new UserWrapper(TotalFreedomMod.getPlugin().lpb.getAPI().getUserManager(), getPlayerAdapter()); - } - - public static Hierarchy getHierarchy() - { - return hierarchy; + this.groupProvider = new GroupProvider(); } public TrackWrapper tw() @@ -62,16 +58,17 @@ public class Hierarchy User user = uw().getUser(player); return user .getNodes(NodeType.INHERITANCE) - .contains(GroupProvider - .inheritanceNode( - GroupProvider - .ADMIN - .getGroup())); + .contains(groups().inheritanceNode(groups().getAdmin())); + } + + public GroupProvider groups() + { + return groupProvider; } public Track op() { - return tw().getTrack("OP"); + return tw().getTrack("op"); } public Track builder() @@ -81,7 +78,7 @@ public class Hierarchy public Track admin() { - return tw().getTrack("ADMIN"); + return tw().getTrack("admin"); } public void asyncInheritFrom(DisplayableGroup inherited, DisplayableGroup inheritor) @@ -92,8 +89,8 @@ public class Hierarchy .add(inherited.getInheritance()); gw().saveGroup(inheritor - .getLuckPermsGroup() - .getName()); + .getLuckPermsGroup() + .getName()); FLog.info("Inherited " + inherited.getName() + " to " + inheritor.getName()); } @@ -138,10 +135,13 @@ public class Hierarchy for (String group : track.getGroups()) { Group g = gw().getGroup(group); - InheritanceNode node = GroupProvider.directFromLPG(g).getInheritance(); + InheritanceNode node = groups() + .fromLuckPerms(g) + .getInheritance(); if (user.getNodes(NodeType.INHERITANCE).contains(node)) - uw().removeFromGroup(user, GroupProvider.wrappedFromLPG(g).getGroup()); + uw().removeFromGroup(user, groups() + .fromLuckPerms(g)); } } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java index 34682d0f..47dde2db 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -1,6 +1,7 @@ package me.totalfreedom.totalfreedommod.rank; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; @@ -15,7 +16,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; @@ -28,15 +28,15 @@ public class RankManager extends FreedomService { // Here, we are automatically creating new tracks if they don't exist, and then adding groups to them. - Hierarchy hierarchy = Hierarchy.getHierarchy(); - hierarchy.asyncTrackGroup(hierarchy.op(), GroupProvider.NON_OP.getGroup()); - hierarchy.asyncTrackGroup(hierarchy.op(), GroupProvider.OP.getGroup()); - hierarchy.asyncTrackGroup(hierarchy.builder(), GroupProvider.MASTER_BUILDER.getGroup()); - hierarchy.asyncTrackGroup(hierarchy.admin(), GroupProvider.ADMIN.getGroup()); - hierarchy.asyncTrackGroup(hierarchy.admin(), GroupProvider.SENIOR_ADMIN.getGroup()); + Hierarchy hierarchy = TotalFreedomMod.getPlugin().getHierarchy(); + hierarchy.asyncTrackGroup(hierarchy.op(), hierarchy.groups().getNonOp()); + hierarchy.asyncTrackGroup(hierarchy.op(), hierarchy.groups().getOp()); + hierarchy.asyncTrackGroup(hierarchy.builder(), hierarchy.groups().getMasterBuilder()); + hierarchy.asyncTrackGroup(hierarchy.admin(), hierarchy.groups().getAdmin()); + hierarchy.asyncTrackGroup(hierarchy.admin(), hierarchy.groups().getSeniorAdmin()); - hierarchy.asyncInheritFrom(GroupProvider.NON_OP.getGroup(), GroupProvider.OP.getGroup()); - hierarchy.asyncInheritFrom(GroupProvider.ADMIN.getGroup(), GroupProvider.SENIOR_ADMIN.getGroup()); + hierarchy.asyncInheritFrom(hierarchy.groups().getNonOp(), hierarchy.groups().getOp()); + hierarchy.asyncInheritFrom(hierarchy.groups().getAdmin(), hierarchy.groups().getSeniorAdmin()); } @Override @@ -78,7 +78,7 @@ public class RankManager extends FreedomService // Master builders show up if they are not an admin if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player)) { - return GroupProvider.MASTER_BUILDER.getGroup(); + return TotalFreedomMod.getPlugin().getHierarchy().groups().getMasterBuilder(); } return getRank(player); @@ -114,13 +114,13 @@ public class RankManager extends FreedomService } // CONSOLE? - if (sender instanceof ConsoleCommandSender console) + if (sender instanceof ConsoleCommandSender) { if (sender.getName().equalsIgnoreCase("CONSOLE")) { return ConfigEntry.ADMINLIST_CONSOLE_IS_ADMIN.getBoolean() - ? GroupProvider.SENIOR_ADMIN.getGroup() - : GroupProvider.ADMIN.getGroup(); + ? TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin() + : TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin(); } } @@ -130,7 +130,7 @@ public class RankManager extends FreedomService // Unknown console: RCON? if (admin == null) { - return GroupProvider.SENIOR_ADMIN.getGroup(); + return TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin(); } return admin.getRank(); @@ -144,11 +144,16 @@ public class RankManager extends FreedomService return entry.getRank(); } - String primary = plugin.lpb.getAPI() - .getPlayerAdapter(Player.class) + String primary = TotalFreedomMod.getPlugin() + .getHierarchy() + .getPlayerAdapter() .getUser(player) .getPrimaryGroup(); - return GroupProvider.fromString(primary).getGroup(); + + return TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .fromString(primary); } public Component getTag(Player player, Component defaultTag) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java index 5c4b200d..b8a77117 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java @@ -82,7 +82,7 @@ public class SQLite extends FreedomService private void createPlayersTable() { - try (PreparedStatement statement = connection.prepareStatement("CREATE TABLE `players` (`uuid` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `master_builder` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT, `items` VARCHAR, `total_votes` INT NOT NULL, `display_discord` BOOLEAN NOT NULL, `login_message` VARCHAR, `inspect` BOOLEAN NOT NULL);")) + try (PreparedStatement statement = connection.prepareStatement("CREATE TABLE `players` (`uuid` VARCHAR NOT NULL, `ips` VARCHAR NOT NULL, `notes` VARCHAR, `tag` VARCHAR, `discord_id` VARCHAR, `masterBuilder` BOOLEAN NOT NULL, `ride_mode` VARCHAR NOT NULL, `coins` INT, `items` VARCHAR, `total_votes` INT NOT NULL, `display_discord` BOOLEAN NOT NULL, `login_message` VARCHAR, `inspect` BOOLEAN NOT NULL);")) { statement.executeUpdate(); } catch (SQLException e) @@ -281,8 +281,8 @@ public class SQLite extends FreedomService try { PreparedStatement statement = connection.prepareStatement("SELECT * FROM players WHERE uuid=?"); - statement.setString(1, uuid.toString()); - ResultSet resultSet = statement.executeQuery(); + statement.setString(1, uuid.toString()); + ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { @@ -301,7 +301,7 @@ public class SQLite extends FreedomService { try { - return connection.prepareStatement("SELECT * FROM players WHERE master_builder=true").executeQuery(); + return connection.prepareStatement("SELECT * FROM players WHERE masterBuilder=true").executeQuery(); } catch (SQLException e) { FLog.severe("Failed to get Master Builders:"); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java index 5d036827..ff0e792e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FConverter.java @@ -14,10 +14,10 @@ public class FConverter public static String convertAdminChatFormat(String format) { return FUtil.MINI_MESSAGE.serialize(FUtil.LEGACY_AMPERSAND.deserialize( - format.replaceAll("%name%", "") - .replaceAll("%rank%", "") - .replaceAll("%rankcolor%", "") - .replaceAll("%msg%", ""))) + format.replaceAll("%name%", "") + .replaceAll("%rank%", "") + .replaceAll("%rankcolor%", "") + .replaceAll("%msg%", ""))) .replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java index 5bab9a8f..8187da88 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FLog.java @@ -83,8 +83,7 @@ public class FLog if (raw || pluginLogger == null) { return (serverLogger != null ? serverLogger : FALLBACK_LOGGER); - } - else + } else { return pluginLogger; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index eadb880b..a1b3af00 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -13,7 +13,10 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.title.Title; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.WordUtils; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -21,7 +24,7 @@ import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import java.io.*; +import java.io.File; import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -80,8 +83,6 @@ public class FUtil "Taahh", "G6_", "ayunami2000"); - - private static final PlainTextComponentSerializer STEAMROLLER = PlainTextComponentSerializer.plainText(); public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand(); public static final LegacyComponentSerializer LEGACY_SECTION = LegacyComponentSerializer.legacySection(); public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver( @@ -106,10 +107,11 @@ public class FUtil ChatColor.DARK_BLUE, ChatColor.DARK_PURPLE, ChatColor.LIGHT_PURPLE); + private static final PlainTextComponentSerializer STEAMROLLER = PlainTextComponentSerializer.plainText(); private static final Pattern CHATCOLOR_PATTERN = Pattern.compile(".*(?i)(([§&])((#[a-f0-9]{3,6})|([0-9a-fklmnor]))).*"); private static final SplittableRandom RANDOM = new SplittableRandom(); - public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; private static final List regxList = Arrays.asList("y", "mo", "w", "d", "h", "m", "s"); + public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static void cancel(BukkitTask task) { @@ -121,8 +123,7 @@ public class FUtil try { task.cancel(); - } - catch (Exception ignored) + } catch (Exception ignored) { } } @@ -139,8 +140,7 @@ public class FUtil if (Bukkit.getOnlineMode()) { return DEVELOPERS.contains(player.getUniqueId().toString()); - } - else + } else { return DEVELOPER_NAMES.contains(player.getName()); } @@ -202,17 +202,14 @@ public class FUtil if (size >= list.size()) { return list; - } - else if (size * (index + 1) <= list.size()) + } else if (size * (index + 1) <= list.size()) { return list.subList(size * index, size * (index + 1)); - } - else + } else { return list.subList(size * index, (size * index) + (list.size() % size)); } - } - catch (IndexOutOfBoundsException e) + } catch (IndexOutOfBoundsException e) { return new ArrayList<>(); } @@ -320,7 +317,8 @@ public class FUtil { StringBuilder sb = new StringBuilder(); - regxList.forEach(obj -> { + regxList.forEach(obj -> + { if (parse.endsWith(obj)) { sb.append(parse.split(obj)[0]); @@ -397,8 +395,7 @@ public class FUtil try { return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).parse(dateString); - } - catch (ParseException pex) + } catch (ParseException pex) { return new Date(0L); } @@ -424,8 +421,7 @@ public class FUtil if (octets > 4) { octets = 4; - } - else if (octets < 1) + } else if (octets < 1) { octets = 1; } @@ -569,8 +565,7 @@ public class FUtil { Class.forName("com.destroystokyo.paper.PaperConfig"); return true; - } - catch (ClassNotFoundException ignored) + } catch (ClassNotFoundException ignored) { return false; } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/PermissibleCompletion.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/PermissibleCompletion.java index d2c5e703..89def1df 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/PermissibleCompletion.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/PermissibleCompletion.java @@ -11,6 +11,11 @@ public class PermissibleCompletion this.permission = permission; } + public static PermissibleCompletion of(String permission, String completion) + { + return new PermissibleCompletion(permission, completion); + } + public String getPermission() { return permission; @@ -20,9 +25,4 @@ public class PermissibleCompletion { return completion; } - - public static PermissibleCompletion of(String permission, String completion) - { - return new PermissibleCompletion(permission, completion); - } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java index 20132d0a..5ffe521d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/TimeUnit.java @@ -12,11 +12,13 @@ public enum TimeUnit private final long time; - TimeUnit(long time) { + TimeUnit(long time) + { this.time = time; } - public long get() { + public long get() + { return time; } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java index 2a230017..35ff954c 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java @@ -1,21 +1,17 @@ package me.totalfreedom.totalfreedommod.world; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FLog; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldCreator; -import org.bukkit.WorldType; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + public final class AdminWorld extends CustomWorld { @@ -57,9 +53,9 @@ public final class AdminWorld extends CustomWorld final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); welcomeSignBlock.setType(Material.OAK_SIGN); - org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState(); + org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); - org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData(); + org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); signData.setFacingDirection(BlockFace.NORTH); welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld"); @@ -78,8 +74,7 @@ public final class AdminWorld extends CustomWorld try { world = getWorld(); - } - catch (Exception ex) + } catch (Exception ex) { return true; } @@ -115,8 +110,7 @@ public final class AdminWorld extends CustomWorld try { weatherMode.setWorldToWeather(getWorld()); - } - catch (Exception ignored) + } catch (Exception ignored) { } } @@ -133,8 +127,7 @@ public final class AdminWorld extends CustomWorld try { timeOfDay.setWorldToTime(getWorld()); - } - catch (Exception ignored) + } catch (Exception ignored) { } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java index 8d0b9bd6..ec8420a5 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java @@ -18,14 +18,16 @@ package me.totalfreedom.totalfreedommod.world; -import java.util.Arrays; -import java.util.Random; -import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.generator.ChunkGenerator; import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Random; +import java.util.logging.Logger; + import static java.lang.System.arraycopy; public class CleanroomChunkGenerator extends ChunkGenerator @@ -108,8 +110,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator arraycopy(materials, 0, newMaterials, 0, y); materials = newMaterials; } - } - catch (Exception e) + } catch (Exception e) { log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString()); e.printStackTrace(); @@ -118,8 +119,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator materials[0] = Material.BEDROCK; Arrays.fill(materials, 1, 65, Material.STONE); } - } - else + } else { materials = new Material[65]; materials[0] = Material.BEDROCK; diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java index 9ef3392a..79b6098e 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/CustomWorld.java @@ -48,8 +48,7 @@ public abstract class CustomWorld extends FreedomService try { PaperLib.teleportAsync(player, getWorld().getSpawnLocation()); - } - catch (Exception ex) + } catch (Exception ex) { player.sendMessage(ex.getMessage()); } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java index 790a6f33..d3ea460d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java @@ -1,12 +1,7 @@ package me.totalfreedom.totalfreedommod.world; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldCreator; -import org.bukkit.WorldType; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -43,9 +38,9 @@ public class Flatlands extends CustomWorld final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); welcomeSignBlock.setType(Material.OAK_SIGN); - org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState(); + org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); - org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData(); + org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); signData.setFacingDirection(BlockFace.NORTH); welcomeSign.setLine(0, ChatColor.GREEN + "Flatlands"); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java index 2d35349f..5c4b2036 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java @@ -1,11 +1,7 @@ package me.totalfreedom.totalfreedommod.world; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.WorldCreator; -import org.bukkit.WorldType; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -48,9 +44,9 @@ public final class MasterBuilderWorld extends CustomWorld final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); welcomeSignBlock.setType(Material.OAK_SIGN); - org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign)welcomeSignBlock.getState(); + org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); - org.bukkit.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData(); + org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); signData.setFacingDirection(BlockFace.NORTH); welcomeSign.setLine(0, ChatColor.GREEN + "MB World"); @@ -75,8 +71,7 @@ public final class MasterBuilderWorld extends CustomWorld try { weatherMode.setWorldToWeather(getWorld()); - } - catch (Exception ignored) + } catch (Exception ignored) { } } @@ -93,8 +88,7 @@ public final class MasterBuilderWorld extends CustomWorld try { timeOfDay.setWorldToTime(getWorld()); - } - catch (Exception ignored) + } catch (Exception ignored) { } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java index 579da910..0eb48417 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java @@ -12,6 +12,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent; + import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg; public class WorldManager extends FreedomService @@ -64,13 +65,11 @@ public class WorldManager extends FreedomService if (event.getWorld().equals(adminworld.getWorld()) && adminworld.getWeatherMode() != WorldWeather.OFF) { return; - } - else if (event.getWorld().equals(masterBuilderWorld.getWorld()) && masterBuilderWorld.getWeatherMode() != WorldWeather.OFF) + } else if (event.getWorld().equals(masterBuilderWorld.getWorld()) && masterBuilderWorld.getWeatherMode() != WorldWeather.OFF) { return; } - } - catch (Exception ignored) + } catch (Exception ignored) { } @@ -88,13 +87,11 @@ public class WorldManager extends FreedomService if (event.getWorld().equals(adminworld.getWorld()) && adminworld.getWeatherMode() != WorldWeather.OFF) { return; - } - else if (event.getWorld().equals(masterBuilderWorld.getWorld()) && masterBuilderWorld.getWeatherMode() != WorldWeather.OFF) + } else if (event.getWorld().equals(masterBuilderWorld.getWorld()) && masterBuilderWorld.getWeatherMode() != WorldWeather.OFF) { return; } - } - catch (Exception ignored) + } catch (Exception ignored) { } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java index 3017b8d5..acfae547 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldRestrictions.java @@ -16,7 +16,8 @@ import org.bukkit.event.player.PlayerInteractEvent; import java.util.Arrays; import java.util.List; -public class WorldRestrictions extends FreedomService { +public class WorldRestrictions extends FreedomService +{ private final List BLOCKED_WORLDEDIT_COMMANDS = Arrays.asList( "green", "fixlava", "fixwater", "br", "brush", "tool", "mat", "range", "cs", "up", "fill", "setblock", "tree", "replacenear", "bigtree"); @@ -25,17 +26,21 @@ public class WorldRestrictions extends FreedomService { "bigtree", "ebigtree", "largetree", "elargetree"); @Override - public void onStart() { + public void onStart() + { } @Override - public void onStop() { + public void onStop() + { } - public boolean doRestrict(Player player) { + public boolean doRestrict(Player player) + { if (!plugin.pl.getData(player).isMasterBuilder() && plugin.pl.canManageMasterBuilders(player.getName()) - && (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()))) { + && (player.getWorld().equals(plugin.wm.masterBuilderWorld.getWorld()))) + { return true; } @@ -44,71 +49,86 @@ public class WorldRestrictions extends FreedomService { } @EventHandler(priority = EventPriority.NORMAL) - public void onBlockPlace(BlockPlaceEvent event) { + public void onBlockPlace(BlockPlaceEvent event) + { final Player player = event.getPlayer(); - if (doRestrict(player)) { + if (doRestrict(player)) + { event.setCancelled(true); } } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onBlockBreak(BlockBreakEvent event) { + public void onBlockBreak(BlockBreakEvent event) + { final Player player = event.getPlayer(); - if (doRestrict(player)) { + if (doRestrict(player)) + { event.setCancelled(true); } } @EventHandler(priority = EventPriority.NORMAL) - public void onPlayerInteract(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) + { final Player player = event.getPlayer(); - if (doRestrict(player)) { + if (doRestrict(player)) + { event.setCancelled(true); } } @EventHandler(priority = EventPriority.NORMAL) - public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) { + public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) + { final Player player = event.getPlayer(); - if (doRestrict(player)) { + if (doRestrict(player)) + { event.setCancelled(true); } } @EventHandler(priority = EventPriority.NORMAL) - public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { - if (event.getDamager() instanceof Player player && (doRestrict(player))) { - event.setCancelled(true); + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) + { + if (event.getDamager() instanceof Player player && (doRestrict(player))) + { + event.setCancelled(true); } } @EventHandler(priority = EventPriority.NORMAL) - public void onCommandPreprocess(PlayerCommandPreprocessEvent event) { + public void onCommandPreprocess(PlayerCommandPreprocessEvent event) + { final Player player = event.getPlayer(); String command = event.getMessage().split("\\s+")[0].substring(1).toLowerCase(); - if (doRestrict(player)) { + if (doRestrict(player)) + { /* This is a very poor way of blocking WorldEdit commands, all the methods I know of for obtaining a list of a plugin's commands are returning null for world edit. */ String allowed = player.getWorld().equals(plugin.wm.adminworld.getWorld()) ? "Admins" : "Master Builders"; - if (command.startsWith("/") || BLOCKED_WORLDEDIT_COMMANDS.contains(command)) { + if (command.startsWith("/") || BLOCKED_WORLDEDIT_COMMANDS.contains(command)) + { player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use WorldEdit here."); event.setCancelled(true); } - if (command.equalsIgnoreCase("coreprotect") || command.equalsIgnoreCase("core") || command.equalsIgnoreCase("co")) { + if (command.equalsIgnoreCase("coreprotect") || command.equalsIgnoreCase("core") || command.equalsIgnoreCase("co")) + { player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here."); event.setCancelled(true); } } if (player.getWorld().equals(Bukkit.getWorld("plotworld")) - && (BLOCKED_ESSENTIALS_COMMANDS.contains(command))) { + && (BLOCKED_ESSENTIALS_COMMANDS.contains(command))) + { player.sendMessage(ChatColor.RED + "Sorry, this command is restricted in the plotworld"); event.setCancelled(true); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java index 0b5fd5e7..878b2af2 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldTime.java @@ -1,9 +1,10 @@ package me.totalfreedom.totalfreedommod.world; +import org.apache.commons.lang.StringUtils; +import org.bukkit.World; + import java.util.Arrays; import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.bukkit.World; public enum WorldTime { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java index ef5cf5cb..14d28a0f 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/world/WorldWeather.java @@ -1,9 +1,10 @@ package me.totalfreedom.totalfreedommod.world; +import org.apache.commons.lang.StringUtils; +import org.bukkit.World; + import java.util.Arrays; import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.bukkit.World; public enum WorldWeather { diff --git a/commons/src/main/resources/config.yml b/commons/src/main/resources/config.yml index 74fc754a..8d7bcd2d 100644 --- a/commons/src/main/resources/config.yml +++ b/commons/src/main/resources/config.yml @@ -32,7 +32,7 @@ server: executives: [ ] # All players who show up as assistant executive - assistant_executives: [] + assistant_executives: [ ] # All those who can manage the master builder list master_builder_management: [ ] @@ -181,7 +181,7 @@ social_links: Forum: 'https://forum.totalfreedom.me' Website: 'https://totalfreedom.me' Discord: 'https://discord.com/invite/PW4savJR9a' -# Reddit: 'https://reddit.com/r/TotalFreedom' + # Reddit: 'https://reddit.com/r/TotalFreedom' Twitter: 'https://twitter.com/TotalFreedomMC' Facebook: 'https://facebook.com/TotalFreedomMC' # Tumblr: 'https://totalfreedom.tumblr.com' @@ -530,7 +530,7 @@ announcer: announcements: - 'Be sure to visit our forums at &6https://forum.totalfreedom.me' - 'You can always review the server rules here: &6https://forum.totalfreedom.me/d/7-server-conduct-policy' - - 'If you are not OP, be sure to ask!' + - 'If you are not op, be sure to ask!' - 'Want to join our SMP server? You can using &6/smp-01' - 'Somebody breaking the rules? Report it! &6/report ' - 'Griefing is not allowed!' @@ -564,7 +564,7 @@ admininfo: votinginfo: - '&bVoting Links:' - ' &2- https://minecraft-mp.com/server/228386/vote/' -# - ' &2- https://minecraft-server-list.com/server/443272/vote/' + # - ' &2- https://minecraft-server-list.com/server/443272/vote/' - ' &6- https://topg.org/Minecraft/in-599712' - ' &2- https://minecraftlist.org/vote/18975' - ' &6- https://minecraftservers.org/vote/595721' @@ -585,7 +585,7 @@ masterbuilderinfo: first_join_info: enabled: true text: - - "Welcome to TotalFreedom -- the original Free-OP server!" + - "Welcome to TotalFreedom -- the original Free-op server!" - "The server's name doesn't mean we have no rules. Do /rules for a list of them." - "Need help getting started? Do /help for a list of commands!" diff --git a/commons/src/main/resources/indefinitebans.yml b/commons/src/main/resources/indefinitebans.yml index 4e4404ce..d561ac28 100644 --- a/commons/src/main/resources/indefinitebans.yml +++ b/commons/src/main/resources/indefinitebans.yml @@ -12,4 +12,4 @@ badplayer2: ips: - 111.111.111.111 badplayer3: - ips: [] + ips: [ ] diff --git a/commons/src/main/resources/permissions.yml b/commons/src/main/resources/permissions.yml index 1c1877d7..fa2a1629 100644 --- a/commons/src/main/resources/permissions.yml +++ b/commons/src/main/resources/permissions.yml @@ -25,7 +25,7 @@ remove: #Crackshot - "crackshot.bypass.all" #NetworkManager - - "networkmanager.*" + - "networkmanager.*" - "networkmanager.notify.joinbanned" - "networkmanager.notify.*" - "networkmanager.announce.global" @@ -142,7 +142,7 @@ operators: - "networkmanager.notification.join" - "networkmanager.party.nolimit" - "networkmanager.tabcompletechat" - + # Master Builder permission nodes master_builders: - "worldedit.tool.*" @@ -156,7 +156,7 @@ master_builders: - "voxelsniper.sniper" - "voxelsniper.goto" - "voxelsniper.brush.*" - + # Admin permission nodes admins: - "worldedit.*" @@ -175,6 +175,6 @@ admins: - "crackshot.bypass.all" # Senior Admin permission nodes -senior_admins: +senior_admins: - "bending.admin.permaremove" - "bending.ability.Cleanse" diff --git a/commons/src/main/resources/plugin.yml b/commons/src/main/resources/plugin.yml index 65746737..ec1c3055 100644 --- a/commons/src/main/resources/plugin.yml +++ b/commons/src/main/resources/plugin.yml @@ -14,8 +14,8 @@ softdepend: - WorldGuardExtraFlags - JDA - Votifier -authors: [Madgeek1450, Prozza] -loadbefore: [TFD4J, TF-Shoppe] +authors: [ Madgeek1450, Prozza ] +loadbefore: [ TFD4J, TF-Shoppe ] api-version: "1.17" libraries: - org.apache.commons:commons-lang3:3.12.0 diff --git a/discord/pom.xml b/discord/pom.xml index f2f11df9..42d5e80b 100644 --- a/discord/pom.xml +++ b/discord/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/discord/src/main/java/me/totalfreedom/discord/Bot.java b/discord/src/main/java/me/totalfreedom/discord/Bot.java index 891e24a5..1f2df9c0 100644 --- a/discord/src/main/java/me/totalfreedom/discord/Bot.java +++ b/discord/src/main/java/me/totalfreedom/discord/Bot.java @@ -2,19 +2,12 @@ package me.totalfreedom.discord; import discord4j.core.DiscordClientBuilder; import discord4j.core.GatewayDiscordClient; -import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; import discord4j.core.object.entity.Guild; -import me.totalfreedom.discord.command.HelpCommand; -import me.totalfreedom.discord.command.ListCommand; -import me.totalfreedom.discord.command.TPSCommand; -import me.totalfreedom.discord.handling.CommandHandler; -import me.totalfreedom.discord.react.ReactiveBukkitScheduler; import me.totalfreedom.discord.util.SnowflakeEntry; import me.totalfreedom.discord.util.TFM_Bridge; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.util.FLog; -import org.bukkit.Bukkit; import reactor.core.publisher.Mono; import java.util.HashMap; @@ -25,6 +18,7 @@ public class Bot private final GatewayDiscordClient client; private final TFM_Bridge tfm; private final HashMap LINK_CODES = new HashMap<>(); + public Bot() { //Creates the gateway client and connects to the gateway @@ -36,11 +30,13 @@ public class Bot this.tfm = new TFM_Bridge(this); } - public void initialize() { + public void initialize() + { if (client == null) throw new IllegalStateException(); } - public String formatBotTag() { + public String formatBotTag() + { return client.getSelf() .blockOptional() .orElseThrow() diff --git a/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java b/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java index 00a76d60..b06f9375 100644 --- a/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java +++ b/discord/src/main/java/me/totalfreedom/discord/TFD4JCommonsImpl.java @@ -12,11 +12,11 @@ import discord4j.core.spec.EmbedCreateSpec; import discord4j.core.spec.MessageCreateSpec; import me.totalfreedom.discord.util.SnowflakeEntry; import me.totalfreedom.discord.util.Utilities; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.api.TFD4JCommons; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.PlayerData; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.util.FLog; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.WordUtils; @@ -173,11 +173,11 @@ public class TFD4JCommonsImpl implements TFD4JCommons return true; } - if (admin.getRank().equals(GroupProvider.ADMIN.getGroup())) + if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin())) { syncRolesAdminAssignment(member, adminRole, senioradminRole); return true; - } else if (admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup())) + } else if (admin.getRank().equals(TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin())) { syncRolesSeniorAssignment(member, adminRole, senioradminRole); return true; diff --git a/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java b/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java index c11504c5..f29bbede 100644 --- a/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java +++ b/discord/src/main/java/me/totalfreedom/discord/command/ListCommand.java @@ -31,9 +31,11 @@ public class ListCommand implements SlashCommand StringBuilder sb = new StringBuilder(); Iterator iterator = playerNames.iterator(); - while (iterator.hasNext()) { + while (iterator.hasNext()) + { sb.append(iterator.next()); - if (iterator.hasNext()) { + if (iterator.hasNext()) + { sb.append(", \n"); } } diff --git a/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java b/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java index f549cb79..c3839aaa 100644 --- a/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java +++ b/discord/src/main/java/me/totalfreedom/discord/handling/SlashCommand.java @@ -3,7 +3,8 @@ package me.totalfreedom.discord.handling; import discord4j.core.event.domain.interaction.ChatInputInteractionEvent; import reactor.core.publisher.Mono; -public interface SlashCommand { +public interface SlashCommand +{ String getName(); Mono handle(ChatInputInteractionEvent event); diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java index 18b9814a..40b09536 100644 --- a/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java +++ b/discord/src/main/java/me/totalfreedom/discord/listener/AdminChatListener.java @@ -1,6 +1,5 @@ package me.totalfreedom.discord.listener; -import com.google.common.base.Strings; import discord4j.core.event.domain.message.MessageCreateEvent; import discord4j.core.object.entity.Attachment; import discord4j.core.object.entity.Guild; @@ -10,10 +9,7 @@ import me.totalfreedom.discord.Bot; import me.totalfreedom.discord.TFD4J; import me.totalfreedom.discord.util.SnowflakeEntry; import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.api.event.AdminChatEvent; import me.totalfreedom.totalfreedommod.rank.Displayable; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.rank.Title; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; @@ -23,10 +19,6 @@ import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextColor; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; public class AdminChatListener { @@ -41,6 +33,11 @@ public class AdminChatListener this.bot = tfd4j.getBot(); } + public static Key getIdentifier() + { + return identifier; + } + public void adminChatBound() { tfd4j.getBot() @@ -104,22 +101,17 @@ public class AdminChatListener return Title.ASST_EXEC; } else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake())) { - return GroupProvider.SENIOR_ADMIN.getGroup(); + return TotalFreedomMod.getPlugin().getHierarchy().groups().getSeniorAdmin(); } else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake())) { - return GroupProvider.ADMIN.getGroup(); + return TotalFreedomMod.getPlugin().getHierarchy().groups().getAdmin(); } else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake())) { - return GroupProvider.MASTER_BUILDER.getGroup(); + return TotalFreedomMod.getPlugin().getHierarchy().groups().getMasterBuilder(); } else { - return GroupProvider.OP.getGroup(); // This should never be reached. + return TotalFreedomMod.getPlugin().getHierarchy().groups().getNonOp(); // This should never be reached. } }).blockFirst(); } - - public static Key getIdentifier() - { - return identifier; - } } diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java b/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java index eceb040a..8ad2443b 100644 --- a/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java +++ b/discord/src/main/java/me/totalfreedom/discord/listener/BukkitNative.java @@ -8,17 +8,14 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.api.event.AdminChatEvent; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -import net.md_5.bungee.api.ChatColor; import org.bukkit.GameRule; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; diff --git a/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java b/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java index 4bd58abe..644bc969 100644 --- a/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java +++ b/discord/src/main/java/me/totalfreedom/discord/listener/MinecraftListener.java @@ -4,7 +4,6 @@ import discord4j.core.event.domain.message.MessageCreateEvent; import discord4j.core.object.entity.Attachment; import discord4j.core.object.entity.Member; import discord4j.core.object.entity.Message; -import discord4j.core.object.entity.channel.TextChannel; import me.totalfreedom.discord.Bot; import me.totalfreedom.discord.TFD4J; import me.totalfreedom.discord.util.SnowflakeEntry; diff --git a/discord/src/main/java/me/totalfreedom/discord/react/ReactiveBukkitScheduler.java b/discord/src/main/java/me/totalfreedom/discord/react/ReactiveBukkitScheduler.java index 538d4846..20361631 100644 --- a/discord/src/main/java/me/totalfreedom/discord/react/ReactiveBukkitScheduler.java +++ b/discord/src/main/java/me/totalfreedom/discord/react/ReactiveBukkitScheduler.java @@ -1,6 +1,5 @@ package me.totalfreedom.discord.react; -import java.util.concurrent.TimeUnit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; import org.jetbrains.annotations.NotNull; @@ -8,6 +7,8 @@ import org.jetbrains.annotations.Nullable; import reactor.core.Disposable; import reactor.core.scheduler.Scheduler; +import java.util.concurrent.TimeUnit; + /** * An abstraction layer over the {@link BukkitScheduler} to allow for the use as a {@link Scheduler}. * This will allow us to perform non-blocking operations on the main server thread. @@ -15,7 +16,8 @@ import reactor.core.scheduler.Scheduler; * @author SimplexDevelopment */ public final class ReactiveBukkitScheduler - implements Scheduler, Scheduler.Worker { + implements Scheduler, Scheduler.Worker +{ /** * The plugin instance. */ @@ -25,7 +27,8 @@ public final class ReactiveBukkitScheduler */ private final BukkitScheduler scheduler; - public ReactiveBukkitScheduler(JavaPlugin plugin) { + public ReactiveBukkitScheduler(JavaPlugin plugin) + { this.plugin = plugin; this.scheduler = plugin.getServer().getScheduler(); } @@ -37,7 +40,8 @@ public final class ReactiveBukkitScheduler * @return A disposable that can be used to cancel the task. */ @Override - public @NotNull Disposable schedule(@NotNull Runnable task) { + public @NotNull Disposable schedule(@NotNull Runnable task) + { return new DisposableBukkitTask(scheduler.runTask(plugin, task)); } @@ -51,7 +55,8 @@ public final class ReactiveBukkitScheduler * @return A disposable that can be used to cancel the task. */ @Override - public @NotNull Disposable schedule(@NotNull Runnable task, long delay, @Deprecated @Nullable TimeUnit unit) { + public @NotNull Disposable schedule(@NotNull Runnable task, long delay, @Deprecated @Nullable TimeUnit unit) + { return new DisposableBukkitTask(scheduler.runTaskLater(plugin, task, delay)); } @@ -67,8 +72,10 @@ public final class ReactiveBukkitScheduler * @return A disposable that can be used to cancel the task. */ @Override - public @NotNull Disposable schedulePeriodically(@NotNull Runnable task, long initialDelay, long period, @Deprecated @Nullable TimeUnit unit) { - if (period <= 0L) { + public @NotNull Disposable schedulePeriodically(@NotNull Runnable task, long initialDelay, long period, @Deprecated @Nullable TimeUnit unit) + { + if (period <= 0L) + { throw new IllegalArgumentException("Period must be greater than 0L"); } @@ -81,7 +88,8 @@ public final class ReactiveBukkitScheduler * @return This class instance, as it implements {@link Worker}. */ @Override - public @NotNull Scheduler.Worker createWorker() { + public @NotNull Scheduler.Worker createWorker() + { return this; } @@ -90,7 +98,8 @@ public final class ReactiveBukkitScheduler */ @Override @Deprecated - public void dispose() { + public void dispose() + { // This method does nothing and is only here because it's being overridden from a parent. } } diff --git a/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java index 91d0fc38..12acda1b 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java @@ -31,11 +31,6 @@ public enum SnowflakeEntry this.entry = entry; } - public Snowflake getSnowflake() - { - return Snowflake.of(entry.getString()); - } - public static Set acceptableRoleIDs() { Set acceptableRoleIDs = new HashSet<>(); @@ -48,4 +43,9 @@ public enum SnowflakeEntry acceptableRoleIDs.add(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake()); return acceptableRoleIDs; } + + public Snowflake getSnowflake() + { + return Snowflake.of(entry.getString()); + } } diff --git a/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java b/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java index 9bb3589d..c87aa6a1 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/TFM_Bridge.java @@ -4,7 +4,6 @@ import discord4j.core.object.entity.Guild; import discord4j.core.object.entity.Member; import me.totalfreedom.discord.Bot; import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import me.totalfreedom.totalfreedommod.rank.GroupProvider; import me.totalfreedom.totalfreedommod.rank.Title; import me.totalfreedom.totalfreedommod.util.FUtil; import org.bukkit.Bukkit; @@ -43,13 +42,25 @@ public class TFM_Bridge return FUtil.miniMessage(Title.ASST_EXEC.getColoredTag()); } else if (role.getId().equals(SnowflakeEntry.SENIOR_ADMIN_ROLE_ID.getSnowflake())) { - return FUtil.miniMessage(GroupProvider.SENIOR_ADMIN.getGroup().getColoredTag()); + return FUtil.miniMessage(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getSeniorAdmin() + .getColoredTag()); } else if (role.getId().equals(SnowflakeEntry.ADMIN_ROLE_ID.getSnowflake())) { - return FUtil.miniMessage(GroupProvider.ADMIN.getGroup().getColoredTag()); + return FUtil.miniMessage(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getAdmin() + .getColoredTag()); } else if (role.getId().equals(SnowflakeEntry.MASTERBUILDER_ROLE_ID.getSnowflake())) { - return FUtil.miniMessage(GroupProvider.MASTER_BUILDER.getGroup().getColoredTag()); + return FUtil.miniMessage(TotalFreedomMod.getPlugin() + .getHierarchy() + .groups() + .getMasterBuilder() + .getColoredTag()); } else { return ""; diff --git a/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java b/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java index e4e0f4b4..1dc282ee 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/Utilities.java @@ -2,7 +2,8 @@ package me.totalfreedom.discord.util; public class Utilities { - private Utilities() { + private Utilities() + { throw new AssertionError(); } diff --git a/discord/src/main/resources/plugin.yml b/discord/src/main/resources/plugin.yml index 70ccb8a6..75cf81e4 100644 --- a/discord/src/main/resources/plugin.yml +++ b/discord/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: TFD4J main: me.totalfreedom.discord.TFD4J version: 2023.03 api-version: 1.19 -depend: [TotalFreedomMod] +depend: [ TotalFreedomMod ] libraries: - com.discord4j:discord4j-core:3.2.0 - io.projectreactor:reactor-core:3.4.9 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4d58e05c..53cd665f 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ - + atlas-nexus-01-totalfreedom-development https://nexus-01.core.atlas-media.co.uk/repository/totalfreedom-development/ @@ -149,7 +149,7 @@ v1.9 provided - + net.essentialsx EssentialsX diff --git a/shop/pom.xml b/shop/pom.xml index a355ecbb..b8feec60 100644 --- a/shop/pom.xml +++ b/shop/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 diff --git a/shop/src/main/java/me/totalfreedom/shop/Votifier.java b/shop/src/main/java/me/totalfreedom/shop/Votifier.java index 37f50e37..b2a7cc31 100644 --- a/shop/src/main/java/me/totalfreedom/shop/Votifier.java +++ b/shop/src/main/java/me/totalfreedom/shop/Votifier.java @@ -36,8 +36,7 @@ public class Votifier extends FreedomService if (player != null) { data = plugin.pl.getData(player); - } - else + } else { data = plugin.pl.getData(name); } diff --git a/shop/src/main/resources/plugin.yml b/shop/src/main/resources/plugin.yml index f04a2ac0..71f2567c 100644 --- a/shop/src/main/resources/plugin.yml +++ b/shop/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: TF-Shoppe main: me.totalfreedom.shop.TFShoppe version: ${project.version} -authors: [AtlasMediaGroup, TotalFreedom] +authors: [ AtlasMediaGroup, TotalFreedom ] api-version: 1.19 -depend: [TotalFreedomMod] \ No newline at end of file +depend: [ TotalFreedomMod ] \ No newline at end of file