Compare commits

..

110 Commits

Author SHA1 Message Date
13e04475f0 FS-326 & quick formatting fix
The formatting of DiscordToMinecraft was adjusted in addition to make it look nicer
2021-07-29 17:06:31 -06:00
adc7b4a754 FS-333
According to Intellij, `bukkitTelnet instanceof BukkitTelnet` can replace the nullcheck. If this is not the case, then I apologize profoundly for my IDE's mistakes (again)
2021-07-29 05:58:14 -06:00
40498c03f4 FS-334
If Codacy complains about Line 365 being potentially combinable with Line 363, please kindly tell it to fuck off
2021-07-29 05:54:00 -06:00
cc9c07d498 FS-335 2021-07-29 05:49:37 -06:00
5fa3f9f26a FS-337
I hate Codacy
2021-07-29 05:48:11 -06:00
a79b2cbe0f FS-338 2021-07-29 05:45:21 -06:00
6c8d1934e7 FS-313 2021-07-29 05:38:30 -06:00
a1de7ac9ff FS-314 2021-07-29 05:35:28 -06:00
a37364d07e Correct JDK Version in README (#92)
It's currently wrong so needed updating.
2021-07-16 11:43:46 +01:00
939e98b759 Update badges (#88)
Remove TravisCI
Add Github Maven Build Action 
Add CodeQL Badge
2021-07-08 20:48:41 +01:00
17b051e2a7 Retired support for 2021.02 fully. (#72) 2021-06-07 16:26:15 +01:00
77a05f22a8 TotalFreedomMod May Update 2021-06-07 16:26:15 +01:00
5c3ef1f107 Bump version 2021-06-07 16:26:15 +01:00
53c5991971 Addresses FS-224 (#70) 2021-06-07 16:26:15 +01:00
ff760a6c11 Use long instead of int and use offset to check time (FS-181) (#69)
* Use long instead of int and use offset to check time (FS-181)

* Remove star import
2021-06-07 16:26:15 +01:00
63069ff9ec Calculate the player count without offline players (FS-247) (#68)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-06-07 16:26:15 +01:00
5e63b71861 Small modification to new TFGuilds (FS-255) (#67) 2021-06-07 16:26:15 +01:00
b72782de4f Add //g to blocked commands (#62)
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-06-07 16:26:15 +01:00
de9556c550 Name change for Fleek (#64) 2021-06-07 16:26:15 +01:00
6590504545 Added new dependency to allow TFM to compile (#65) 2021-06-07 16:26:15 +01:00
8d1e8dcf05 Switched from -c to -ci (#63)
Resolves FS-219
2021-06-07 16:26:15 +01:00
07b5076717 Bug fixes, improvements, and removals (FS-192) (#46)
* Three fixes

* Fixes /tempban throwing a NullPointerException when trying to get a player who isn't on the server but was in the past
* Fixes /tempban banning players for 24 hours regardless of the duration defined
* Fixes /list -t throwing a NullPointerException when performed from a non-player source (such as Telnet)

* Removes hubworld entriely

* Configurable blacklists for tag, muted commands, and wildcard

Changes:
* Moves globally blocked commands to the `global` subsection of the original `blocked_commands` section. You *will* need to update your configurations
* /wildcard's command blacklist is now configurable under the `wildcard` section in `blocked_commands`.
* The commands muted players can't use are now configurable under the `muted` section in `blocked_commands`.
* Removes some commented-out globally blocked command entries.

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-06-07 16:26:15 +01:00
6fb9507a4c Why overcomplicating things is a horrifically bad idea (#55)
The longer I look into this plugin's code, the angrier I will become.

This fixes 2 bugs in the /potion command:
- Fixes non-admins being able to clear other players
- Fixes NPE caused when trying to add potion effects to players who are not on the server as a non-admin.

Both of these issues are caused by overcomplicating seemingly simple solutions, hence the name of this commit.

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-06-07 16:26:15 +01:00
879a524bb4 Remove a number of wipe commands we don't want anyway
We shouldn't be wiping any of this data within the server now anyway so let's not tempt fate again.
2021-06-07 16:26:15 +01:00
c60b451ce7 grammar fix 2021-06-07 16:26:15 +01:00
f85f3e32ea Fixes FS-137 2021-06-07 16:26:15 +01:00
57b3351047 ok, done (FS-156) 2021-06-07 16:26:15 +01:00
dd10eb3f5e Update Command_ride.java 2021-06-07 16:26:15 +01:00
4e577f97fa Enable downward Sync from main (#60)
We want to make sure anything on the main branch which is commited makes it's way down to the dev and other branches.
2021-05-28 15:22:07 +01:00
caaa067096 Update Security Matrix (#59)
* Update Security Matrix

Updating the full security matrix.

* Yay for consistency

* I hate Markdown / Markup / Whatever the fuck this is.
2021-05-04 13:30:17 +01:00
9e676143b8 2021.04 Release
Formal Release for 2021.04
2021-05-03 15:19:42 +01:00
c8b20bc255 RC2 Release 2021-05-02 13:12:37 +01:00
f240a15af3 Force the count to be zero if the value is negative (FS-216) (#56) 2021-05-01 23:58:03 +10:00
6073712fdf Bump Version
Bump Version to 2021.04-RC01
2021-04-26 20:46:11 +01:00
d11d55b218 Vanished admins are no longer being counted (FS-148) (#41) 2021-04-24 14:06:28 +10:00
debb95fb4c video dev man (#51) 2021-04-24 13:03:11 +10:00
b9f7ab3ec3 Change punishment from kicking to muting on spam (FS-97) (#45) 2021-04-22 21:54:29 +10:00
2cdf1e66a6 Disables block gravity and makes it togglable (FS-89) (#50)
* Disables block gravity by default (FS-89)

* Combine these checks as Codacy ever so kindly suggested
2021-04-19 17:34:36 +10:00
20c2c4c96e Delete /wipeuserdata (FS-196) (#49) 2021-04-15 22:07:22 +10:00
d5238150d0 Curse be gone (#47)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-04-13 14:13:47 +10:00
64a4e70c41 Merge pull request #48 from AtlasMediaGroup/abhi-fix
Strip role/user mentions (FS-191)
2021-04-12 16:45:13 -05:00
0c2f0a714c [+] Fix #replace() 2021-04-12 16:31:48 +05:30
4c67553bdd [+] Whitespace change! 2021-04-12 16:26:06 +05:30
ffab5e3c12 [+] Allman style formating 2021-04-12 16:01:31 +05:30
f7556a4861 [+] Remove redundant comments 2021-04-12 15:59:27 +05:30
385fc77771 [+] Done all the requested changes! 2021-04-12 15:44:51 +05:30
b852ea1822 [+] Update my account in developers list 2021-04-12 14:44:27 +05:30
4a5a3a1a2d [+] Fix FS-191 2021-04-12 13:57:58 +05:30
37762e5470 Merge pull request #39 from AtlasMediaGroup/Elmon11-patch-2
clearinv option in smite (FS-161)
2021-04-11 22:15:26 +01:00
85d90090c8 Merge branch 'development' into Elmon11-patch-2 2021-04-11 18:41:54 +01:00
09930c2d9a Merge pull request #43 from VideoGameSmash12/development
Consistency fixes (across 46 commands), additional CoreProtect integration (/dispfill and /setlever), and a critical bugfix (/setlever) (FS-162)
2021-04-10 12:56:32 +01:00
7ae1ab035a Merge branch 'development' into development 2021-04-10 12:50:52 +01:00
2bd1787663 Updated supported versions for TFM. 2021-04-10 12:45:56 +01:00
765b7dcc4b Merge branch 'development' into development 2021-04-10 12:39:47 +01:00
091381a076 Merge pull request #44 from AtlasMediaGroup/FS-145
Update JDA version and location (FS-145)
2021-04-10 12:39:08 +01:00
27dfd71b2e Update JDA version and location (FS-145) 2021-04-09 21:20:33 +10:00
16e06bd932 Forgot I had this there 2021-04-07 19:45:03 -06:00
a33c310757 Fucking shit 2021-04-07 19:41:13 -06:00
df21bdfa7e Other bug fixes
Credit to Fleek for some of the code here.

Bugs that were fixed:
* [Media] showing up with an extra space at the beginning of blank messages with attachments
* Admin chat using incorrect colors for its ranks in messages from Discord to Minecraft
* Admin notes not sending to admins, only admin impostors
2021-04-07 19:40:19 -06:00
d7e2c0da42 Merge branch 'development' into Elmon11-patch-2 2021-04-07 11:52:16 +10:00
a7529b41fb Oops 2021-04-05 18:08:24 -06:00
c4fce3f0f9 Right, so this change applies only to commands. For the sake of code consistency, I tried to change as many as possible to use FreedomCommand.msg instead of CommandSender.sendMessage for their messages. Here are a list of the files containing those changes:
* Command_adminworld.java
* Command_adventure.java
* Command_banip.java
* Command_blockedit.java
* Command_blockpvp.java
* Command_cage.java
* Command_cartsit.java
* Command_clearchat.java
* Command_clearinventory.java
* Command_commandlist.java
* Command_creative.java
* Command_deop.java
* Command_deopall.java
* Command_dispfill.java
* Command_doom.java
* Command_gcmd.java
* Command_hubworld.java
* Command_inspect.java
* Command_list.java
* Command_lockup.java
* Command_manageshop.java
* Command_manuallyverify.java
* Command_masterbuilderworld.java
* Command_mbconfig.java
* Command_moblimiter.java
* Command_mp44.java
* Command_mute.java
* Command_nickfilter.java
* Command_op.java
* Command_opall.java
* Command_opme.java
* Command_potion.java (Also corrected the inconsistent "player not found" message's color)
* Command_rank.java
* Command_ride.java
* Command_saconfig.java
* Command_scare.java
* Command_setplayerlimit.java
* Command_settotalvotes.java
* Command_smite.java
* Command_spectator.java
* Command_survival.java
* Command_unblockcmd.java
* Command_uncage.java
* Command_unmute.java
* Command_verifynoadmin.java

Here are some commands I added functionality to:
* Command_dispfill.java: Added some code that hooks into the CoreProtect API to log the items being removed from and added into the dispensers.
* Command_setlever.java: Added some code that hooks into the CoreProtect API to log the levers being interacted with.

Here's a command I fixed a critical bug in:
* Command_setlever.java
2021-04-05 17:13:26 -06:00
27f5f18962 FS-143 Resolution (#42)
* Bump to patch version.

* Fixes FS-143

Various changes to make it work better with logging and things like that.
2021-04-06 07:11:12 +10:00
dca5e30291 Actually display assistant exec in game (#37)
* Actually display assistant exec in game

* Update RankManager.java

* Update ConfigEntry.java

* Update FUtil.java

Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-04-04 22:24:06 +10:00
09a435053e Merge pull request #40 from AtlasMediaGroup/phoenix-patch-1
Remove /premium
2021-03-31 17:12:56 -05:00
14309275fb Remove /premium 2021-03-31 15:16:01 -05:00
2375e92d90 Merge pull request #36 from AtlasMediaGroup/tfm-bugfix-001
FS-143
2021-03-26 15:43:22 +00:00
97672c2fff Update DiscordToAdminChatListener.java
This is the only way we can load media after [Discord] and [Formatting] without rewriting the method
2021-03-22 09:57:09 -05:00
5837b05a35 Merge branch 'tfm-bugfix-001' of https://github.com/AtlasMediaGroup/TotalFreedomMod into tfm-bugfix-001 2021-03-21 14:02:51 -05:00
b3b68ebd13 Switch to Allman Formatting 2021-03-21 14:02:43 -05:00
2dbbb5c262 Intellij says this is fine so if it breaks again gg 2021-03-21 19:07:07 +01:00
e45655edbb im a clown 2021-03-21 18:33:38 +01:00
9713fcabd6 Should work fingers crossed 2021-03-21 18:25:28 +01:00
dc10c40578 noclear option in smite 2021-03-21 13:57:24 +01:00
db3c190b2b Merge branch 'development' into tfm-bugfix-001 2021-03-21 16:11:13 +11:00
2725857364 Merge pull request #38 from AtlasMediaGroup/FS-147
Fix ban expiration (FS-147)
2021-03-20 22:14:10 -05:00
9f291f675c Use 'toEpochMilli()' instead (FS-147) 2021-03-21 13:44:55 +11:00
561c192c27 Fix bans not expiring (FS-147) 2021-03-21 12:21:15 +11:00
086dec28ac Merge branch 'development' into tfm-bugfix-001 2021-03-19 23:31:31 +00:00
b03870c0aa SQL Fixes
:)
2021-03-19 10:39:58 -05:00
f5c08cd28b Merge pull request #34 from AtlasMediaGroup/2021.02-release
Bump version to 2021.02 Release
2021-03-19 14:26:02 +00:00
2a87271642 Should fix FS-143 2021-03-19 08:58:29 -05:00
3b57aec0e8 Merge branch 'development' into 2021.02-release 2021-03-18 23:57:10 +00:00
efac65bc76 Merge pull request #35 from AtlasMediaGroup/FS-58
Fix checkstyle & other formatting
2021-03-18 23:17:25 +00:00
9c8fe6c590 Fix checkstyle & other formatting
This should help clear a lot of the "Security" alerts resolving FS-58
2021-03-18 22:42:52 +00:00
9f52cdf753 Merge branch 'development' into 2021.02-release 2021-03-18 22:28:53 +00:00
216234ea01 Merge pull request #32 from AtlasMediaGroup/FS-33
Properly fix FS-33
2021-03-18 16:20:06 -05:00
881dead392 Merge branch 'development' into 2021.02-release 2021-03-19 08:04:36 +11:00
ff2bca26aa Merge branch 'development' into FS-33 2021-03-18 19:58:10 +00:00
89ad934aa6 Bump version to 2021.02 Release 2021-03-18 19:18:11 +00:00
d0a195647c Merge pull request #33 from AtlasMediaGroup/FS-93
Fixed permission not setting for new players (FS-93)
2021-03-17 09:06:45 -05:00
eb05b05042 Fixed FS-93
- Players no longer need to relog, just need to be opped to get permissions.
- Removed redundant PlayerJoinEvent code as it's already been executed (See RankManager class).
2021-03-16 20:21:31 +11:00
b9c1970d20 Update player's permission when opping. 2021-03-16 19:56:29 +11:00
9eca9ac5b2 Remove double storage
It is unnecessary as the information is already stored in a map (Username, IPs)
2021-03-08 11:34:48 +11:00
5b577fae07 Add myself to developer list 2021-03-07 20:46:30 +11:00
452a8755c2 Properly fix FS-33 2021-03-07 20:43:25 +11:00
2fb8f224e7 Bump release to 2021.02-RC03 2021-03-06 23:38:46 +00:00
b6a2c8e021 Merge pull request #29 from AtlasMediaGroup/abhi-test
Added myself to TFM
2021-03-06 20:32:04 +00:00
f0a25fde0c Merge branch 'development' into abhi-test 2021-03-06 20:03:19 +00:00
4324497831 Merge pull request #31 from AtlasMediaGroup/Wild1145-patch-1
Tell CodeQL we're using Java 11 hopefully
2021-03-06 20:03:02 +00:00
14c53b7370 Merge branch 'development' into Wild1145-patch-1 2021-03-06 19:47:48 +00:00
0396b8ad86 Merge pull request #30 from AtlasMediaGroup/frontdoor-and-banExpiry-only
fix banning/?? Resolves FS-130
2021-03-06 19:46:57 +00:00
8ee7486afc Merge branch 'development' into frontdoor-and-banExpiry-only 2021-03-06 19:38:01 +00:00
694d9614c5 Tell Maven to also build Java 11 for once 2021-03-06 19:28:38 +00:00
150e25072a Tell CodeQL we're using Java 11 hopefully 2021-03-06 19:14:46 +00:00
7d990ae2c0 [+] Remove .idea 2021-03-06 23:50:23 +05:30
0dd5a26efa Merge branch 'frontdoor-and-banExpiry-only' of https://github.com/AtlasMediaGroup/TotalFreedomMod into frontdoor-and-banExpiry-only 2021-03-06 12:12:59 -06:00
5c097c83cb Here's to hoping this fixes that stupid ban crap. 2021-03-06 12:00:32 -06:00
a85dd014a0 Added .idea in gitignore 2021-03-06 13:05:42 +05:30
342df43f85 Added myself to TFM 2021-03-06 13:04:36 +05:30
103 changed files with 945 additions and 1546 deletions

View File

@ -37,6 +37,12 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
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: 11
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v1

43
.github/workflows/downstream.yml vendored Normal file
View File

@ -0,0 +1,43 @@
# This is a basic workflow to help you get started with Actions
name: Downstream Branch Updates
on:
schedule:
- cron: '20 7 * * *'
# scheduled at 07:00 every Monday and Thursday
workflow_dispatch: # click the button on Github repo!
jobs:
sync_with_upstream:
runs-on: ubuntu-latest
name: Sync main with upstream latest
steps:
# Step 1: run a standard checkout action, provided by github
- name: Checkout main
uses: actions/checkout@v2
with:
ref: main
# submodules: 'recursive' ### may be needed in your situation
# Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch
- name: Pull (Fast-Forward) upstream changes
id: sync
uses: aormsby/Fork-Sync-With-Upstream-action@v2.1
with:
upstream_repository: AtlasMediaGroup/TotalFreedomMod
upstream_branch: main
target_branch: main
git_pull_args: --ff-only # optional arg use, defaults to simple 'pull'
# Step 3: Display a message if 'sync' step had new commits (simple test)
- name: Check for new commits
if: steps.sync.outputs.has_new_commits
run: echo "There were new commits."
# Step 4: Print a helpful timestamp for your records (not required, just nice)
- name: Timestamp
run: date

View File

@ -12,6 +12,6 @@ jobs:
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 1.8 java-version: 11
- name: Build with Maven - name: Build with Maven
run: mvn -B package --file pom.xml run: mvn -B package --file pom.xml

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ manifest.mf
/.idea/workspace.xml /.idea/workspace.xml
/.idea/uiDesigner.xml /.idea/uiDesigner.xml
/.idea/libraries /.idea/libraries
/.idea/
*.iml *.iml
# Maven excludes # Maven excludes

View File

@ -1,3 +1,3 @@
# Contributing to TotalFreedomMod # # 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).

View File

@ -1,4 +1,5 @@
# TotalFreedom General License # # TotalFreedom General License
_Version 2.0, 27th February 2015_ _Version 2.0, 27th February 2015_
Copyright (c) 2011 Steven Lawson Copyright (c) 2011 Steven Lawson
@ -7,7 +8,8 @@ Copyright (c) 2012 Jerom van der Sar
All rights reserved. All rights reserved.
##### 1. Definitions ##### ##### 1. Definitions
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License. "Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
@ -30,8 +32,9 @@ All rights reserved.
"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 ##### ##### 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.
@ -47,8 +50,10 @@ All rights reserved.
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor. 7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
##### 3. Submission of Contributions ##### ##### 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 ##### ##### 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.

View File

@ -1,16 +1,17 @@
# TotalFreedomMod [![Build Status](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod.svg?branch=development)](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/29c0f964da304666bd654bc7b1d556db)](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=AtlasMediaGroup/TotalFreedomMod&amp;utm_campaign=Badge_Grade) # TotalFreedomMod [![Maven-Build](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/maven.yml/badge.svg)](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/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 ### ### Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md). For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md) For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
### Compiling ### ### Compiling
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now. You need Maven to build. You'd also need to set the JDK version to Java 11 as that is the current standard as of now.

View File

@ -2,16 +2,34 @@
## Supported Versions ## Supported Versions
We currently support the code running on the "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, we support the following versions: In terms of plugin releases, our support matrix is as follows:
| Version | Supported | ### Actively Supported
| ------- | ------------------ | These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions.
| 2020.11 | :white_check_mark: |
| 6.0.x (Pre-Release) | :x: | | Version | Supported | Support End: |
| < 2020.11 | :x: | | ------------------- | ------------------ | ------------------------------ |
| < 5.x | :x: | | 2021.05 | :white_check_mark: | No Earlier than August 2021 |
### 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.04 | :white_check_mark: | July 2021 |
### 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.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 ## Reporting a Vulnerability

View File

@ -2,20 +2,16 @@
<!DOCTYPE module PUBLIC <!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN" "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker"> <module name="Checker">
<property name="charset" value="UTF-8"/> <property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/> <property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/> <property name="fileExtensions" value="java, properties, xml"/>
<module name="SuppressionFilter"> <module name="SuppressionFilter">
<property name="file" value="supressions.xml"/> <property name="file" value="supressions.xml"/>
</module> </module>
<module name="FileTabCharacter"> <module name="FileTabCharacter">
<property name="eachLine" value="true"/> <property name="eachLine" value="true"/>
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">
<module name="OuterTypeFilename"/> <module name="OuterTypeFilename"/>
<module name="IllegalTokenText"> <module name="IllegalTokenText">
@ -91,7 +87,7 @@
value="Local variable name ''{0}'' must match pattern ''{1}''."/> value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
<module name="ClassTypeParameterName"> <module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9][_]*[T]$)"/> <property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|([A-Z][a-zA-Z0-9]*[_][a-zA-Z0-9]*$)"/>
<message key="name.invalidPattern" <message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/> value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module> </module>
@ -112,7 +108,8 @@
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/> value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module> </module>
<module name="OverloadMethodsDeclarationOrder"/> <module name="OverloadMethodsDeclarationOrder"/>
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html --> <module name="CustomImportOrder"/>
<!-- http://checkstyle.sourceforge.net/config_imports.html -->
<module name="MethodParamPad"/> <module name="MethodParamPad"/>
<module name="OperatorWrap"> <module name="OperatorWrap">
<property name="option" value="NL"/> <property name="option" value="NL"/>

22
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId> <artifactId>TotalFreedomMod</artifactId>
<version>2021.02-RC02</version> <version>2021.05</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
@ -75,9 +75,9 @@
</repository> </repository>
<repository> <repository>
<id>jcenter</id> <id>dv8tion</id>
<name>jcenter-bintray</name> <name>m2-dv8tion</name>
<url>https://jcenter.bintray.com</url> <url>https://m2.dv8tion.net/releases/</url>
</repository> </repository>
<repository> <repository>
@ -191,7 +191,7 @@
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>4.2.0_224</version> <version>4.2.1_255</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -252,9 +252,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.TotalFreedomMC</groupId> <groupId>com.github.AtlasMediaGroup</groupId>
<artifactId>TFGuilds</artifactId> <artifactId>TFGuilds</artifactId>
<version>db036fb187</version> <version>master-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -277,6 +277,11 @@
<version>5.4.2</version> <version>5.4.2</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>0.3.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -434,7 +439,8 @@
<relocations> <relocations>
<relocation> <relocation>
<pattern>io.papermc.lib</pattern> <pattern>io.papermc.lib</pattern>
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern> <!-- Replace this --> <shadedPattern>me.totalfreedom.totalfreedommod.paperlib
</shadedPattern> <!-- Replace this -->
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.ArrayList; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync; import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -11,10 +10,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.Map;
public class AntiSpam extends FreedomService public class AntiSpam extends FreedomService
{ {
@ -22,7 +23,7 @@ public class AntiSpam extends FreedomService
public static final int TICKS_PER_CYCLE = 2 * 10; public static final int TICKS_PER_CYCLE = 2 * 10;
// //
public BukkitTask cycleTask = null; public BukkitTask cycleTask = null;
List<Player> markedForDeath = new ArrayList<>(); private Map<Player, Integer> muteCounts = new HashMap<>();
@Override @Override
public void onStart() public void onStart()
@ -67,23 +68,26 @@ public class AntiSpam extends FreedomService
return; return;
} }
String message = event.getMessage().trim();
final FPlayer playerdata = plugin.pl.getPlayerSync(player); final FPlayer playerdata = plugin.pl.getPlayerSync(player);
int count = muteCounts.getOrDefault(player, 0);
int minutes = ConfigEntry.ANTISPAM_MINUTES.getInteger();
// Check for spam // Check for spam
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE) if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE && !playerdata.isMuted())
{ {
if (!markedForDeath.contains(player)) count++;
{ muteCounts.put(player, count);
markedForDeath.add(player);
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
FSync.autoEject(player, "Kicked for spamming chat.");
playerdata.resetMsgCount(); int time = count * minutes;
playerdata.setMuted(true, time);
event.setCancelled(true); FSync.bcastMsg(String.format("%s has automatically been muted for %d minutes for spamming chat.",
} player.getName(),
time),
ChatColor.RED);
playerdata.resetMsgCount();
event.setCancelled(true);
} }
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2) else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
{ {
@ -122,10 +126,4 @@ public class AntiSpam extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerKick(PlayerKickEvent event)
{
markedForDeath.remove(event.getPlayer());
}
} }

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.io.File;
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList; import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
import me.totalfreedom.totalfreedommod.config.YamlConfig; import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig; import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
@ -9,8 +8,11 @@ import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.util.FileUtil; import org.bukkit.util.FileUtil;
import java.io.File;
public class BackupManager extends FreedomService public class BackupManager extends FreedomService
{ {
@Override @Override
public void onStart() public void onStart()
{ {
@ -42,16 +44,16 @@ public class BackupManager extends FreedomService
config.load(); config.load();
// Weekly // Weekly
if (!config.isInt(save + ".weekly")) if (!config.isLong(save + ".weekly"))
{ {
performBackup(file, "weekly"); performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime()); config.set(save + ".weekly", FUtil.getUnixTime());
} }
else else
{ {
int lastBackupWeekly = config.getInt(save + ".weekly"); long lastBackupWeekly = config.getLong(save + ".weekly");
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime()) if (FUtil.parseLongOffset(lastBackupWeekly, "1w") < FUtil.getUnixTime())
{ {
performBackup(file, "weekly"); performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime()); config.set(save + ".weekly", FUtil.getUnixTime());
@ -65,16 +67,16 @@ public class BackupManager extends FreedomService
} }
// Daily // Daily
if (!config.isInt(save + ".daily")) if (!config.isLong(save + ".daily"))
{ {
performBackup(file, "daily"); performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime()); config.set(save + ".daily", FUtil.getUnixTime());
} }
else else
{ {
int lastBackupDaily = config.getInt(save + ".daily"); long lastBackupDaily = config.getLong(save + ".daily");
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime()) if (FUtil.parseLongOffset(lastBackupDaily, "1d") < FUtil.getUnixTime())
{ {
performBackup(file, "daily"); performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime()); config.set(save + ".daily", FUtil.getUnixTime());
@ -98,5 +100,4 @@ public class BackupManager extends FreedomService
final File newYaml = new File(backupFolder, file + "." + type + ".bak"); final File newYaml = new File(backupFolder, file + "." + type + ".bak");
FileUtil.copy(oldYaml, newYaml); FileUtil.copy(oldYaml, newYaml);
} }
} }

View File

@ -159,24 +159,20 @@ public class ChatManager extends FreedomService
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true); FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message); plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
for (Player player : server.getOnlinePlayers()) server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
{ {
if (plugin.al.isAdmin(player)) Admin admin = plugin.al.getAdmin(player);
{ if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
Admin admin = plugin.al.getAdmin(player); String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(admin.getAcFormat())) ChatColor color = getColor(display);
{ String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
String format = admin.getAcFormat(); player.sendMessage(FUtil.colorize(msg));
ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
} }
} else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
});
} }
public void reportAction(Player reporter, Player reported, String report) public void reportAction(Player reporter, Player reported, String report)

View File

@ -240,17 +240,9 @@ public class LoginProcess extends FreedomService
if (noteCount != 0) if (noteCount != 0)
{ {
String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + "."; String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
.tooltip("Click here to view them.")
.runCommand("/notes " + player.getName() + " list");
FLog.info(noteMessage); FLog.info(noteMessage);
for (Player p : server.getOnlinePlayers()) plugin.al.messageAllAdmins(ChatColor.GOLD + noteMessage);
{ plugin.al.messageAllAdmins(ChatColor.GOLD + "Do " + ChatColor.YELLOW + "/notes " + player.getName() + " list" + ChatColor.GOLD + " to view them.");
if (plugin.al.isAdminImpostor(p))
{
notice.send(p);
}
}
} }
} }

View File

@ -1,13 +1,11 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync; import me.totalfreedom.totalfreedommod.util.FSync;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -20,7 +18,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
public class Muter extends FreedomService public class Muter extends FreedomService
{ {
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
public final List<String> MUTED_PLAYERS = new ArrayList<>(); public final List<String> MUTED_PLAYERS = new ArrayList<>();
@Override @Override
@ -88,7 +85,7 @@ public class Muter extends FreedomService
cmdName = command.getName().toLowerCase(); cmdName = command.getName().toLowerCase();
} }
if (MUTE_COMMANDS.contains(cmdName)) if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
{ {
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted."); player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -46,7 +46,7 @@ public class SavedFlags extends FreedomService
return flags; return flags;
} }
public boolean getSavedFlag(String flag) throws Exception public boolean getSavedFlag(String flag) throws IllegalStateException
{ {
Boolean flagValue = null; Boolean flagValue = null;
@ -66,7 +66,7 @@ public class SavedFlags extends FreedomService
} }
else else
{ {
throw new Exception(); throw new IllegalStateException("Attempt to get non-existent flag " + flag);
} }
} }

View File

@ -28,7 +28,6 @@ import me.totalfreedom.totalfreedommod.command.CommandLoader;
import me.totalfreedom.totalfreedommod.config.MainConfig; import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.discord.Discord; import me.totalfreedom.totalfreedommod.discord.Discord;
import me.totalfreedom.totalfreedommod.freeze.Freezer; import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.CurseListener;
import me.totalfreedom.totalfreedommod.fun.ItemFun; import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads; import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer; import me.totalfreedom.totalfreedommod.fun.Landminer;
@ -116,7 +115,6 @@ public class TotalFreedomMod extends JavaPlugin
public Monitors mo; public Monitors mo;
public MovementValidator mv; public MovementValidator mv;
public ServerPing sp; public ServerPing sp;
public CurseListener cul;
public ItemFun it; public ItemFun it;
public Landminer lm; public Landminer lm;
public MP44 mp; public MP44 mp;
@ -129,7 +127,6 @@ public class TotalFreedomMod extends JavaPlugin
public Sitter st; public Sitter st;
public VanishHandler vh; public VanishHandler vh;
public Pterodactyl ptero; public Pterodactyl ptero;
//public HubWorldRestrictions hwr;
// //
// Bridges // Bridges
public BukkitTelnetBridge btb; public BukkitTelnetBridge btb;
@ -368,7 +365,6 @@ public class TotalFreedomMod extends JavaPlugin
private void initFun() private void initFun()
{ {
// Fun // Fun
cul = new CurseListener();
it = new ItemFun(); it = new ItemFun();
lm = new Landminer(); lm = new Landminer();
mp = new MP44(); mp = new MP44();

View File

@ -25,17 +25,9 @@ public class Admin
private boolean active = true; private boolean active = true;
private Rank rank = Rank.ADMIN; private Rank rank = Rank.ADMIN;
private Date lastLogin = new Date(); private Date lastLogin = new Date();
private Boolean commandSpy = false; private Boolean commandSpy = false;
private Boolean potionSpy = false; private Boolean potionSpy = false;
private String acFormat = null; private String acFormat = null;
private String pteroID = null; private String pteroID = null;
public Admin(Player player) public Admin(Player player)

View File

@ -22,8 +22,7 @@ import org.bukkit.entity.Player;
public class AdminList extends FreedomService public class AdminList extends FreedomService
{ {
public static final List<String> vanished = new ArrayList<>(); public static final List<String> vanished = new ArrayList<>();
public final List<String> verifiedNoAdmin = new ArrayList<>(); public final Map<String, List<String>> verifiedNoAdmin = Maps.newHashMap();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
// Only active admins below // Only active admins below
private final Set<Admin> activeAdmins = Sets.newHashSet(); private final Set<Admin> activeAdmins = Sets.newHashSet();
@ -240,8 +239,7 @@ public class AdminList extends FreedomService
public boolean isVerifiedAdmin(Player player) public boolean isVerifiedAdmin(Player player)
{ {
// Fix of issue FS-33 return verifiedNoAdmin.containsKey(player.getName()) && verifiedNoAdmin.get(player.getName()).contains(FUtil.getIp(player));
return !verifiedNoAdmin.contains(player.getName()) || verifiedNoAdminIps.containsKey(player.getName()) && !verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
} }
public boolean isIdentityMatched(Player player) public boolean isIdentityMatched(Player player)
@ -404,13 +402,8 @@ public class AdminList extends FreedomService
return ipTable; return ipTable;
} }
public List<String> getVerifiedNoAdmin() public Map<String, List<String>> getVerifiedNoAdmin()
{ {
return verifiedNoAdmin; return verifiedNoAdmin;
} }
public Map<String, List<String>> getVerifiedNoAdminIps()
{
return verifiedNoAdminIps;
}
} }

View File

@ -169,7 +169,7 @@ public class Ban
public boolean isExpired() public boolean isExpired()
{ {
return hasExpiry() && expiryUnix < FUtil.getUnixTime(); return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
} }
public String bakeKickMessage() public String bakeKickMessage()

View File

@ -14,6 +14,7 @@ import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.data.AnaloguePowerable; import org.bukkit.block.data.AnaloguePowerable;
import org.bukkit.block.data.Powerable; import org.bukkit.block.data.Powerable;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -30,6 +31,7 @@ import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent; import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -144,12 +146,9 @@ public class EventBlocker extends FreedomService
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean()) if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
{ {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof Tameable) if (entity instanceof Tameable && ((Tameable) entity).isTamed())
{ {
if (((Tameable)entity).isTamed()) event.setCancelled(true);
{
event.setCancelled(true);
}
} }
} }
} }
@ -212,6 +211,15 @@ public class EventBlocker extends FreedomService
} }
} }
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event)
{
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) public void onBlockPhysics(BlockPhysicsEvent event)
{ {

View File

@ -101,12 +101,9 @@ public class BukkitTelnetBridge extends FreedomService
try try
{ {
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet"); final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
if (bukkitTelnet != null) if (bukkitTelnet instanceof BukkitTelnet)
{ {
if (bukkitTelnet instanceof BukkitTelnet) bukkitTelnetPlugin = (BukkitTelnet) bukkitTelnet;
{
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
}
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -1,11 +1,7 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import java.io.File; import java.io.File;
import java.sql.Connection; import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -228,11 +224,12 @@ public class CoreProtectBridge extends FreedomService
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString(); String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false"; String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
connection = DriverManager.getConnection("jdbc:sql://" + url); connection = DriverManager.getConnection("jdbc:sql://" + url);
final Statement statement = connection.createStatement(); final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
statement.setQueryTimeout(30); statement.setQueryTimeout(30);
// Obtain world ID from CoreProtect database // Obtain world ID from CoreProtect database
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'"); statement.setString(1, world.getName());
ResultSet resultSet = statement.executeQuery();
String worldID = null; String worldID = null;
while (resultSet.next()) while (resultSet.next())
{ {
@ -250,7 +247,10 @@ public class CoreProtectBridge extends FreedomService
// Iterate through each table and delete their data if the world ID matches // Iterate through each table and delete their data if the world ID matches
for (String table : tables) for (String table : tables)
{ {
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID); final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
statement1.setString(1, table);
statement1.setString(2, worldID);
statement1.executeQuery();
} }
connection.close(); connection.close();
@ -362,93 +362,90 @@ public class CoreProtectBridge extends FreedomService
} }
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{ {
if (block != null) if (block != null && data.hasInspection())
{ {
if (data.hasInspection()) BlockState blockState = block.getRelative(event.getBlockFace()).getState();
{ Block placedBlock = blockState.getBlock();
BlockState blockState = block.getRelative(event.getBlockFace()).getState(); event.setCancelled(true);
Block placedBlock = blockState.getBlock(); List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
event.setCancelled(true);
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
if (lookup.isEmpty())
{
lookup = coreProtect.blockLookup(block, -1);
}
int cooldownTime = 3;
if (cooldown.containsKey(player.getName()))
{
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
if (secondsLeft > 0L)
{
event.setCancelled(true);
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
return;
}
}
if (!plugin.al.isAdmin(player))
{
cooldown.put(player.getName(), System.currentTimeMillis());
}
if (lookup != null)
{
if (lookup.isEmpty()) if (lookup.isEmpty())
{ {
lookup = coreProtect.blockLookup(block, -1); player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
return;
} }
int cooldownTime = 3; HISTORY_MAP.remove(event.getPlayer());
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
if (cooldown.containsKey(player.getName())) player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
for (String[] value : lookup)
{ {
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime); CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
if (secondsLeft > 0L) BlockData bl = result.getBlockData();
String s;
String st = "";
if (result.getActionString().equals("Placement"))
{ {
event.setCancelled(true); s = " placed ";
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
return;
} }
else if (result.getActionString().equals("Removal"))
{
s = " broke ";
}
else
{
s = " interacted with ";
}
if (result.isRolledBack())
{
st += "§m";
}
int time = (int)(System.currentTimeMillis() / 1000L);
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
} }
if (!plugin.al.isAdmin(player)) List<String> page = paged.getPage(1);
for (String entries : page)
{ {
cooldown.put(player.getName(), System.currentTimeMillis()); player.sendMessage(entries);
} }
if (lookup != null) player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
{
if (lookup.isEmpty())
{
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
return;
}
HISTORY_MAP.remove(event.getPlayer());
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
for (String[] value : lookup)
{
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
BlockData bl = result.getBlockData();
String s;
String st = "";
if (result.getActionString().equals("Placement"))
{
s = " placed ";
}
else if (result.getActionString().equals("Removal"))
{
s = " broke ";
}
else
{
s = " interacted with ";
}
if (result.isRolledBack())
{
st += "§m";
}
int time = (int)(System.currentTimeMillis() / 1000L);
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
}
List<String> page = paged.getPage(1);
for (String entries : page)
{
player.sendMessage(entries);
}
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
}
} }
} }
} }

View File

@ -30,13 +30,10 @@ public class TFGuildsBridge extends FreedomService
try try
{ {
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds"); final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
if (tfGuilds != null && tfGuilds.isEnabled()) if (tfGuilds != null && tfGuilds.isEnabled() && tfGuilds instanceof TFGuilds)
{ {
if (tfGuilds instanceof TFGuilds) enabled = true;
{ return true;
enabled = true;
return true;
}
} }
} }
catch (NoClassDefFoundError ex) catch (NoClassDefFoundError ex)
@ -53,6 +50,6 @@ public class TFGuildsBridge extends FreedomService
{ {
return false; return false;
} }
return Common.IN_GUILD_CHAT.contains(player); return Common.GUILD_CHAT.contains(player);
} }
} }

View File

@ -15,7 +15,6 @@ public class WorldGuardBridge extends FreedomService
@Override @Override
public void onStart() public void onStart()
{ {
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld()); plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
} }

View File

@ -137,7 +137,7 @@ public class Command_adminworld extends FreedomCommand
{ {
return noPerms(); return noPerms();
} }
sender.sendMessage(ex.getMessage()); msg(ex.getMessage());
return true; return true;
} }

View File

@ -19,7 +19,7 @@ public class Command_adventure extends FreedomCommand
{ {
if (isConsole()) if (isConsole())
{ {
sender.sendMessage("When used from the console, you must define a target player."); msg("When used from the console, you must define a target player.");
return true; return true;
} }
@ -46,7 +46,7 @@ public class Command_adventure extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -72,8 +72,8 @@ public class Command_banip extends FreedomCommand
{ {
// Broadcast // Broadcast
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip); FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP"); String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
player.sendMessage(message); msg(player, message, ChatColor.RED);
} }
} }

View File

@ -92,7 +92,7 @@ public class Command_blockedit extends FreedomCommand
final Player player2 = getPlayer(args[0]); final Player player2 = getPlayer(args[0]);
if (player2 == null) if (player2 == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -93,7 +93,7 @@ public class Command_blockpvp extends FreedomCommand
final Player p = getPlayer(args[0]); final Player p = getPlayer(args[0]);
if (p == null) if (p == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -42,14 +42,14 @@ public class Command_cage extends FreedomCommand
Player player = getPlayer(args[0]); Player player = getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }
final FPlayer fPlayer = plugin.pl.getPlayer(player); final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (fPlayer.getCageData().isCaged()) if (fPlayer.getCageData().isCaged())
{ {
sender.sendMessage(ChatColor.RED + "That player is already caged."); msg("That player is already caged.", ChatColor.RED);
return true; return true;
} }
@ -80,7 +80,7 @@ public class Command_cage extends FreedomCommand
outerMaterial = Material.matchMaterial(args[2]); outerMaterial = Material.matchMaterial(args[2]);
break; break;
} }
sender.sendMessage(ChatColor.RED + "Invalid block!"); msg("Invalid block!", ChatColor.RED);
break; break;
} }
} }

View File

@ -23,7 +23,7 @@ public class Command_cartsit extends FreedomCommand
if (targetPlayer == null) if (targetPlayer == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }
} }
@ -32,7 +32,7 @@ public class Command_cartsit extends FreedomCommand
{ {
if (targetPlayer == null) if (targetPlayer == null)
{ {
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>"); msg("When used from the console, you must define a target player: /cartsit <player>");
return true; return true;
} }
} }

View File

@ -20,7 +20,7 @@ public class Command_clearchat extends FreedomCommand
{ {
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
player.sendMessage(""); msg(player, "");
} }
} }
} }

View File

@ -52,7 +52,7 @@ public class Command_clearinventory extends FreedomCommand
player.getInventory().clear(); player.getInventory().clear();
msg("Cleared " + player.getName() + "'s inventory."); msg("Cleared " + player.getName() + "'s inventory.");
player.sendMessage(sender.getName() + " has cleared your inventory."); msg(player, sender.getName() + " has cleared your inventory.");
} }
} }
else else

View File

@ -43,7 +43,7 @@ public class Command_commandlist extends FreedomCommand
Collections.sort(commands); Collections.sort(commands);
sender.sendMessage(StringUtils.join(commands, ", ")); msg(StringUtils.join(commands, ", "));
return true; return true;
} }

View File

@ -19,7 +19,7 @@ public class Command_creative extends FreedomCommand
{ {
if (isConsole()) if (isConsole())
{ {
sender.sendMessage("When used from the console, you must define a target player."); msg("When used from the console, you must define a target player.");
return true; return true;
} }
@ -46,7 +46,7 @@ public class Command_creative extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -1,64 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Curse someone - sends a cursed texture pack to the specified player.", usage = "/<command> <player>")
public class Command_curse extends FreedomCommand
{
/* The only problem with this is someone can prevent themself from being cursed by declining to download the
resource pack. However, if they hit yes, then you can curse them whenever you want and they can't stop it unless
they go into their server settings. and set server resource packs to prompt or disabled */
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!FUtil.isExecutive(sender.getName()))
{
return noPerms();
}
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (plugin.cul.cursedPlayers.containsKey(player))
{
msg("Already attempting to curse!", ChatColor.RED);
return true;
}
player.setResourcePack("http://play.totalfreedom.me/cursed.zip");
msg("Attempting to curse " + player.getName(), ChatColor.GREEN);
plugin.cul.cursedPlayers.put(player, playerSender);
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && FUtil.isExecutive(sender.getName()))
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View File

@ -32,15 +32,14 @@ public class Command_deop extends FreedomCommand
final List<String> matchedPlayerNames = new ArrayList<>(); final List<String> matchedPlayerNames = new ArrayList<>();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName) if ((player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName)) || player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
&& player.isOp() && !plugin.al.isVanished(player.getName()))
{ {
if (player.isOp() && !plugin.al.isVanished(player.getName())) matchedPlayerNames.add(player.getName());
{ player.setOp(false);
matchedPlayerNames.add(player.getName()); msg(player, YOU_ARE_NOT_OP);
player.setOp(false); plugin.rm.updateDisplay(player);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
}
} }
} }

View File

@ -19,7 +19,8 @@ public class Command_deopall extends FreedomCommand
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
player.setOp(false); player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP); msg(player, YOU_ARE_NOT_OP);
plugin.rm.updateDisplay(player);
} }
return true; return true;

View File

@ -43,7 +43,7 @@ public class Command_dispfill extends FreedomCommand
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
sender.sendMessage("Invalid radius."); msg("Invalid radius.");
return true; return true;
} }
@ -60,7 +60,7 @@ public class Command_dispfill extends FreedomCommand
} }
else else
{ {
sender.sendMessage("Skipping invalid item: " + searchItem); msg("Skipping invalid item: " + searchItem);
} }
} }
@ -80,7 +80,8 @@ public class Command_dispfill extends FreedomCommand
{ {
if (targetBlock.getType().equals(Material.DISPENSER)) if (targetBlock.getType().equals(Material.DISPENSER))
{ {
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation())); msg("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
plugin.cpb.getCoreProtectAPI().logContainerTransaction(sender.getName(), targetBlock.getLocation());
setDispenserContents(targetBlock, itemsArray); setDispenserContents(targetBlock, itemsArray);
affected++; affected++;
} }
@ -89,7 +90,7 @@ public class Command_dispfill extends FreedomCommand
} }
} }
sender.sendMessage("Done. " + affected + " dispenser(s) filled."); msg("Done. " + affected + " dispenser(s) filled.");
} }
else else
{ {

View File

@ -36,7 +36,7 @@ public class Command_doom extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -251,21 +251,18 @@ public class Command_enchant extends FreedomCommand
return getEnchantments(item); return getEnchantments(item);
} }
} }
else if (args.length == 3) else if (args.length == 3 && args[0].equalsIgnoreCase("add"))
{ {
if (args[0].equals("add")) Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase());
if (enchantment != null)
{ {
Enchantment enchantment = Enchantment.getByName(args[1].toUpperCase()); if (!unsafe)
if (enchantment != null)
{ {
if (!unsafe) return stringNumberRange(1, enchantment.getMaxLevel());
{ }
return stringNumberRange(1, enchantment.getMaxLevel()); else
} {
else return Collections.singletonList("[level]");
{
return Collections.singletonList("[level]");
}
} }
} }
} }

View File

@ -23,7 +23,7 @@ public class Command_gcmd extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -26,7 +26,7 @@ public class Command_glow extends FreedomCommand
playerSender.addPotionEffect(glow); playerSender.addPotionEffect(glow);
glowing = true; glowing = true;
} }
msg("You " + (glowing ? "are now" : "no longer") + " glowing."); msg("You are " + (glowing ? "now" : "no longer") + " glowing.");
return true; return true;
} }
} }

View File

@ -1,202 +0,0 @@
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.rank.Rank;
import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "HubWorld management stuff",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "hw,hub")
public class Command_hubworld extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
CommandMode commandMode = null;
if (args.length == 0)
{
commandMode = CommandMode.TELEPORT;
}
else if (args.length >= 2)
{
if ("time".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.TIME;
}
else if ("weather".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.WEATHER;
}
}
if (commandMode == null)
{
return false;
}
try
{
switch (commandMode)
{
case TELEPORT:
{
if (!(sender instanceof Player) || playerSender == null)
{
return false;
}
World hubWorld = null;
try
{
hubWorld = plugin.wm.hubworld.getWorld();
}
catch (Exception ignored)
{
}
if (hubWorld == null || playerSender.getWorld() == hubWorld)
{
msg("Going to the main world.");
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
}
else
{
msg("Going to the hub world");
plugin.wm.hubworld.sendToWorld(playerSender);
}
break;
}
case TIME:
{
assertCommandPerms(sender, playerSender);
if (args.length == 2)
{
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
if (timeOfDay != null)
{
plugin.wm.hubworld.setTimeOfDay(timeOfDay);
msg("Hub world time set to: " + timeOfDay.name());
}
else
{
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
}
}
else
{
return false;
}
break;
}
case WEATHER:
{
assertCommandPerms(sender, playerSender);
if (args.length == 2)
{
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
if (weatherMode != null)
{
plugin.wm.hubworld.setWeatherMode(weatherMode);
msg("Hub world weather set to: " + weatherMode.name());
}
else
{
msg("Invalid weather mode. Can be: off, rain, storm");
}
}
else
{
return false;
}
break;
}
default:
{
return false;
}
}
}
catch (PermissionDeniedException ex)
{
if (ex.getMessage().isEmpty())
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
return true;
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return Collections.emptyList();
}
if (args.length == 1)
{
return Arrays.asList("time", "weather");
}
else if (args.length == 2)
{
if (args[0].equals("time"))
{
return Arrays.asList("morning", "noon", "evening", "night");
}
else if (args[0].equals("weather"))
{
return Arrays.asList("off", "rain", "storm");
}
}
return Collections.emptyList();
}
// TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{
if (!(sender instanceof Player) || playerSender == null || !plugin.al.isAdmin(playerSender))
{
throw new PermissionDeniedException();
}
}
private enum CommandMode
{
TELEPORT, TIME, WEATHER
}
private static class PermissionDeniedException extends Exception
{
private static final long serialVersionUID = 1L;
private PermissionDeniedException()
{
super("");
}
private PermissionDeniedException(String string)
{
super(string);
}
}
}

View File

@ -39,7 +39,7 @@ public class Command_inspect extends FreedomCommand
} }
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
sender.sendMessage(ChatColor.RED + "Invalid number"); msg("Invalid number", ChatColor.RED);
} }
} }
@ -48,19 +48,19 @@ public class Command_inspect extends FreedomCommand
{ {
if (pageIndex < 1 || pageIndex > paged.getPageCount()) if (pageIndex < 1 || pageIndex > paged.getPageCount())
{ {
sender.sendMessage(ChatColor.RED + "Not a valid page number"); msg("Not a valid page number", ChatColor.RED);
return true; return true;
} }
sender.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- "); msg("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- ", ChatColor.WHITE);
List<String> page = paged.getPage(pageIndex); List<String> page = paged.getPage(pageIndex);
for (String entries : page) for (String entries : page)
{ {
sender.sendMessage(entries); msg(entries);
} }
sender.sendMessage("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>"); msg("Page " + pageIndex + "/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>", ChatColor.WHITE);
return true; return true;
} }
} }

View File

@ -1,7 +1,5 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -14,10 +12,14 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH) @CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -i | -f | -v]", aliases = "who,lsit") @CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-s | -i | -f | -v]", aliases = "who,lsit")
public class Command_list extends FreedomCommand public class Command_list extends FreedomCommand
{ {
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{ {
if (args.length > 1) if (args.length > 1)
@ -29,7 +31,10 @@ public class Command_list extends FreedomCommand
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
names.add(player.getName()); if (!plugin.al.isVanished(player.getName()))
{
names.add(player.getName());
}
} }
msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE); msg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
return true; return true;
@ -83,7 +88,7 @@ public class Command_list extends FreedomCommand
List<String> n = new ArrayList<>(); List<String> n = new ArrayList<>();
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender) && plugin.al.getAdmin(playerSender).getRank().isAtLeast(Rank.ADMIN)) if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
{ {
List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins(); List<Admin> connectedAdmins = plugin.btb.getConnectedAdmins();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size()) onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(connectedAdmins.size())
@ -96,7 +101,7 @@ public class Command_list extends FreedomCommand
} }
else else
{ {
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size()) onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(FUtil.getFakePlayerCount())
.append(ChatColor.BLUE) .append(ChatColor.BLUE)
.append(" out of a maximum ") .append(" out of a maximum ")
.append(ChatColor.RED) .append(ChatColor.RED)
@ -141,13 +146,13 @@ public class Command_list extends FreedomCommand
.append(StringUtils.join(n, ChatColor.WHITE + ", ")); .append(StringUtils.join(n, ChatColor.WHITE + ", "));
if (senderIsConsole) if (senderIsConsole)
{ {
sender.sendMessage(ChatColor.stripColor(onlineStats.toString())); msg(ChatColor.stripColor(onlineStats.toString()));
sender.sendMessage(ChatColor.stripColor(onlineUsers.toString())); msg(ChatColor.stripColor(onlineUsers.toString()));
} }
else else
{ {
sender.sendMessage(onlineStats.toString()); msg(onlineStats.toString());
sender.sendMessage(onlineUsers.toString()); msg(onlineUsers.toString());
} }
n.clear(); n.clear();
return true; return true;

View File

@ -53,7 +53,7 @@ public class Command_lockup extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }
@ -70,7 +70,7 @@ public class Command_lockup extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -54,7 +54,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]); Player player = getPlayer(args[3]);
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins()); msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
} }
} }
else else
@ -64,7 +64,7 @@ public class Command_manageshop extends FreedomCommand
PlayerData playerData = plugin.pl.getData(player); PlayerData playerData = plugin.pl.getData(player);
playerData.setCoins(playerData.getCoins() + amount); playerData.setCoins(playerData.getCoins() + amount);
plugin.pl.save(playerData); plugin.pl.save(playerData);
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins()); msg(player, sender.getName() + " gave you " + amount + " coins. Your new balance is " + playerData.getCoins(), ChatColor.GREEN);
} }
msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN); msg("Successfully added " + amount + " coins to all online players.", ChatColor.GREEN);
} }
@ -97,7 +97,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]); Player player = getPlayer(args[3]);
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins()); msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
} }
} }
else else
@ -111,7 +111,7 @@ public class Command_manageshop extends FreedomCommand
playerData.setCoins(0); playerData.setCoins(0);
} }
plugin.pl.save(playerData); plugin.pl.save(playerData);
player.sendMessage(ChatColor.RED + sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins()); msg(player, sender.getName() + " took " + amount + " coins from you. Your new balance is " + playerData.getCoins(), ChatColor.RED);
} }
msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN); msg("Successfully took " + amount + " coins from all online players.", ChatColor.GREEN);
} }
@ -138,7 +138,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]); Player player = getPlayer(args[3]);
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.GREEN + sender.getName() + " set your coin balance to " + amount); msg(player, sender.getName() + " set your coin balance to " + amount, ChatColor.GREEN);
} }
return true; return true;
} }
@ -183,7 +183,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]); Player player = getPlayer(args[3]);
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.GREEN + sender.getName() + " gave the " + item.getName() + " to you"); msg(player, sender.getName() + " gave the " + item.getName() + " to you", ChatColor.GREEN);
} }
return true; return true;
} }
@ -208,7 +208,7 @@ public class Command_manageshop extends FreedomCommand
Player player = getPlayer(args[3]); Player player = getPlayer(args[3]);
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.RED + sender.getName() + " took the " + item.getName() + " from you"); msg(player, sender.getName() + " took the " + item.getName() + " from you", ChatColor.RED);
} }
return true; return true;
} }

View File

@ -48,12 +48,12 @@ public class Command_manuallyverify extends FreedomCommand
FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false); FUtil.adminAction(sender.getName(), "Manually verifying player " + player.getName(), false);
player.setOp(true); player.setOp(true);
player.sendMessage(YOU_ARE_OP); msg(player, YOU_ARE_OP);
if (plugin.pl.getPlayer(player).getFreezeData().isFrozen()) if (plugin.pl.getPlayer(player).getFreezeData().isFrozen())
{ {
plugin.pl.getPlayer(player).getFreezeData().setFrozen(false); plugin.pl.getPlayer(player).getFreezeData().setFrozen(false);
player.sendMessage(ChatColor.GRAY + "You have been unfrozen."); msg(player, "You have been unfrozen.");
} }
plugin.pl.verify(player, null); plugin.pl.verify(player, null);

View File

@ -138,7 +138,7 @@ public class Command_masterbuilderworld extends FreedomCommand
{ {
return noPerms(); return noPerms();
} }
sender.sendMessage(ex.getMessage()); msg(ex.getMessage());
return true; return true;
} }

View File

@ -129,7 +129,7 @@ public class Command_mbconfig extends FreedomCommand
plugin.pl.verify(player, null); plugin.pl.verify(player, null);
plugin.rm.updateDisplay(player); plugin.rm.updateDisplay(player);
player.setOp(true); player.setOp(true);
player.sendMessage(YOU_ARE_OP); msg(player, YOU_ARE_OP);
} }
} }
else if (!data.isMasterBuilder()) else if (!data.isMasterBuilder())

View File

@ -65,7 +65,7 @@ public class Command_moblimiter extends FreedomCommand
if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean()) if (ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{ {
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + "."); msg("Moblimiter enabled. Maximum mobcount set to: " + ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
msg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + "."); msg("Dragon: " + (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
msg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + "."); msg("Giant: " + (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");

View File

@ -45,7 +45,7 @@ public class Command_mp44 extends FreedomCommand
{ {
playerdata.disarmMP44(); playerdata.disarmMP44();
sender.sendMessage(ChatColor.GREEN + "mp44 Disarmed."); msg("mp44 Disarmed.", ChatColor.GREEN);
} }
return true; return true;

View File

@ -109,7 +109,7 @@ public class Command_mute extends FreedomCommand
final Player player = getPlayer(args[0]); final Player player = getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -7,7 +7,6 @@ import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -81,7 +80,7 @@ public class Command_nickfilter extends FreedomCommand
if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender)) if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{ {
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName); msg("Can't find player by nickname: " + displayName);
return true; return true;
} }
} }
@ -101,7 +100,7 @@ public class Command_nickfilter extends FreedomCommand
if (!nickMatched) if (!nickMatched)
{ {
sender.sendMessage("No nicknames replaced in command."); msg("No nicknames replaced in command.");
return true; return true;
} }
@ -113,7 +112,7 @@ public class Command_nickfilter extends FreedomCommand
return true; return true;
} }
sender.sendMessage("Sending command: \"" + newCommand + "\"."); msg("Sending command: \"" + newCommand + "\".");
server.dispatchCommand(sender, newCommand); server.dispatchCommand(sender, newCommand);
return true; return true;

View File

@ -40,7 +40,8 @@ public class Command_op extends FreedomCommand
{ {
matchedPlayerNames.add(player.getName()); matchedPlayerNames.add(player.getName());
player.setOp(true); player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP); msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player);
} }
} }
} }

View File

@ -21,7 +21,8 @@ public class Command_opall extends FreedomCommand
if (!player.isOp()) if (!player.isOp())
{ {
player.setOp(true); player.setOp(true);
player.sendMessage(FreedomCommand.YOU_ARE_OP); msg(player, YOU_ARE_OP);
plugin.rm.updateDisplay(player);
} }
} }

View File

@ -16,7 +16,8 @@ public class Command_opme extends FreedomCommand
{ {
FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false); FUtil.adminAction(sender.getName(), "Opping " + sender.getName(), false);
sender.setOp(true); sender.setOp(true);
sender.sendMessage(FreedomCommand.YOU_ARE_OP); msg(YOU_ARE_OP);
plugin.rm.updateDisplay(playerSender);
return true; return true;
} }
} }

View File

@ -65,7 +65,7 @@ public class Command_potion extends FreedomCommand
Player target = playerSender; Player target = playerSender;
if (args.length == 2) if (args.length == 2)
{ {
if (!plugin.al.isAdmin(sender) && !target.equals(getPlayer(sender.getName()))) if (!plugin.al.isAdmin(sender) && !args[1].equalsIgnoreCase(sender.getName()))
{ {
msg(ChatColor.RED + "Only admins can clear potion effects from other players."); msg(ChatColor.RED + "Only admins can clear potion effects from other players.");
return true; return true;
@ -104,9 +104,9 @@ public class Command_potion extends FreedomCommand
if (args.length == 5) if (args.length == 5)
{ {
if (!plugin.al.isAdmin(sender) && !getPlayer(args[4]).equals(getPlayer(sender.getName()))) if (!plugin.al.isAdmin(sender) && !args[4].equalsIgnoreCase(sender.getName()))
{ {
sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players."); msg("Only admins can apply potion effects to other players.", ChatColor.RED);
return true; return true;
} }
@ -114,7 +114,7 @@ public class Command_potion extends FreedomCommand
if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender)) if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender))
{ {
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED); msg(PLAYER_NOT_FOUND);
return true; return true;
} }
} }
@ -122,7 +122,7 @@ public class Command_potion extends FreedomCommand
{ {
if (senderIsConsole) if (senderIsConsole)
{ {
sender.sendMessage("You must specify a target player when using this command from the console."); msg("You must specify a target player when using this command from the console.");
return true; return true;
} }
} }
@ -130,7 +130,7 @@ public class Command_potion extends FreedomCommand
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]); PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
if (potion_effect_type == null) if (potion_effect_type == null)
{ {
sender.sendMessage(ChatColor.AQUA + "Invalid potion effect type."); msg("Invalid potion effect type.", ChatColor.AQUA);
return true; return true;
} }

View File

@ -1,83 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Validates if a given account is premium, or cracked.", usage = "/<command> <player>", aliases = "prem")
public class Command_premium extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
final String name;
if (player != null)
{
name = player.getName();
}
else
{
name = args[0];
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
urlConnection.setRequestProperty("User-Agent", "");
String message;
/*old code
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
*/
try
{
if (urlConnection.getResponseCode() == 200)
{
message = ChatColor.GREEN + "Yes";
}
else
{
message = ChatColor.RED + "No";
}
FSync.playerMsg(sender, "Player " + name + " is premium: " + message);
}
catch (IOException e)
{
FSync.playerMsg(sender, ChatColor.RED + "There was an error on trying to connect to the API server");
}
}
catch (IOException ex)
{
FLog.severe(ex);
msg("There was an error querying the API server.", ChatColor.RED);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -39,7 +39,7 @@ public class Command_rank extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -26,7 +26,7 @@ public class Command_ride extends FreedomCommand
final FPlayer fPlayer = plugin.pl.getPlayer(playerSender); final FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
if (fPlayer.getCageData().isCaged()) if (fPlayer.getCageData().isCaged())
{ {
msg("You cannot used this command while caged."); msg("You cannot use this command while caged.");
return true; return true;
} }
@ -52,7 +52,7 @@ public class Command_ride extends FreedomCommand
} }
msg("Request accepted."); msg("Request accepted.");
requester.sendMessage(ChatColor.GRAY + "Your request has been accepted."); msg(requester, "Your request has been accepted.");
if (requester.getWorld() != playerSender.getWorld()) if (requester.getWorld() != playerSender.getWorld())
{ {
@ -80,7 +80,7 @@ public class Command_ride extends FreedomCommand
} }
msg("Request denied."); msg("Request denied.");
RIDE_REQUESTS.remove(playerSender); RIDE_REQUESTS.remove(playerSender);
requester.sendMessage(ChatColor.GRAY + "Your request has been denied."); msg(requester, "Your request has been denied.");
return true; return true;
} }
@ -123,10 +123,10 @@ public class Command_ride extends FreedomCommand
if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName())) if (playerData.getRideMode().equals("ask") && !FUtil.isExecutive(playerSender.getName()))
{ {
msg("Sent a request to the player.", ChatColor.GREEN); msg("Sent a request to the player.", ChatColor.GREEN);
player.sendMessage(ChatColor.AQUA + sender.getName() + " has requested to ride you."); msg(player, sender.getName() + " has requested to ride you.", ChatColor.AQUA);
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you."); msg(player, "Type " + ChatColor.GREEN + "/ride accept" + ChatColor.AQUA + " to allow the player to ride you.", ChatColor.AQUA);
player.sendMessage(ChatColor.AQUA + "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission."); msg(player, "Type " + ChatColor.RED + "/ride deny" + ChatColor.AQUA + " to deny the player permission.", ChatColor.AQUA);
player.sendMessage(ChatColor.AQUA + "Request will expire in 30 seconds."); msg(player, "Request will expire in 30 seconds.", ChatColor.AQUA);
RIDE_REQUESTS.put(player, playerSender); RIDE_REQUESTS.put(player, playerSender);
new BukkitRunnable() new BukkitRunnable()
@ -139,8 +139,8 @@ public class Command_ride extends FreedomCommand
} }
RIDE_REQUESTS.remove(player); RIDE_REQUESTS.remove(player);
playerSender.sendMessage(ChatColor.RED + "It has been 30 seconds and " + player.getName() + " has not accepted your request."); msg(playerSender, "It has been 30 seconds and " + player.getName() + " has not accepted your request.", ChatColor.RED);
player.sendMessage(ChatColor.RED + "Request expired."); msg(player, "Request expired.", ChatColor.RED);
} }
}.runTaskLater(plugin, 20 * 30); }.runTaskLater(plugin, 20 * 30);
return true; return true;

View File

@ -220,7 +220,6 @@ public class Command_saconfig extends FreedomCommand
if (plugin.al.isVerifiedAdmin(player)) if (plugin.al.isVerifiedAdmin(player))
{ {
plugin.al.verifiedNoAdmin.remove(player.getName()); plugin.al.verifiedNoAdmin.remove(player.getName());
plugin.al.verifiedNoAdminIps.remove(player.getName());
} }
plugin.al.save(admin); plugin.al.save(admin);
@ -244,7 +243,7 @@ public class Command_saconfig extends FreedomCommand
if (!player.isOp()) if (!player.isOp())
{ {
player.setOp(true); player.setOp(true);
player.sendMessage(YOU_ARE_OP); msg(player, YOU_ARE_OP);
} }
return true; return true;
} }

View File

@ -38,7 +38,7 @@ public class Command_scare extends FreedomCommand
} }
msg("Scared " + player.getName()); msg("Scared " + player.getName());
player.sendMessage(ChatColor.RED + "ZING"); msg(player, "ZING", ChatColor.RED);
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4); player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -39,6 +40,12 @@ public class Command_setlever extends FreedomCommand
return true; return true;
} }
if (x > 29999998 || x < -29999998 || y > 29999998 || y < -29999998 || z > 29999998 || z < -29999998)
{
msg("Coordinates cannot be larger than 29999998 or smaller than -29999998 blocks.");
return true;
}
World world = null; World world = null;
final String needleWorldName = args[3].trim(); final String needleWorldName = args[3].trim();
final List<World> worlds = server.getWorlds(); final List<World> worlds = server.getWorlds();
@ -72,6 +79,8 @@ public class Command_setlever extends FreedomCommand
caster.setPowered(leverOn); caster.setPowered(leverOn);
state.setBlockData(data); state.setBlockData(data);
state.update(); state.update();
plugin.cpb.getCoreProtectAPI().logInteraction(sender.getName(), leverLocation);
} }
else else
{ {

View File

@ -21,7 +21,7 @@ public class Command_setplayerlimit extends FreedomCommand
Player player = Bukkit.getPlayer(args[0]); Player player = Bukkit.getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -55,7 +55,7 @@ public class Command_settotalvotes extends FreedomCommand
if (player != null) if (player != null)
{ {
player.sendMessage(ChatColor.GREEN + sender.getName() + " has set your total votes to " + votes); msg(player, sender.getName() + " has set your total votes to " + votes, ChatColor.GREEN);
} }
return true; return true;

View File

@ -15,21 +15,21 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]") @CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-ci | -q]")
public class Command_smite extends FreedomCommand public class Command_smite extends FreedomCommand
{ {
public static void smite(CommandSender sender, Player player) public static void smite(CommandSender sender, Player player)
{ {
smite(sender, player, null, false); smite(sender, player, null, false, false);
} }
public static void smite(CommandSender sender, Player player, String reason) public static void smite(CommandSender sender, Player player, String reason)
{ {
smite(sender, player, reason, false); smite(sender, player, reason, false, false);
} }
public static void smite(CommandSender sender, Player player, String reason, Boolean silent) public static void smite(CommandSender sender, Player player, String reason, Boolean silent, Boolean clearinv)
{ {
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60); player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
@ -44,7 +44,7 @@ public class Command_smite extends FreedomCommand
} }
else else
{ {
sender.sendMessage(ChatColor.GRAY + "Smitten " + player.getName() + " quietly."); sender.sendMessage("Smitten " + player.getName() + " quietly.");
} }
// Deop // Deop
@ -54,7 +54,10 @@ public class Command_smite extends FreedomCommand
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
// Clear inventory // Clear inventory
player.getInventory().clear(); if (clearinv)
{
player.getInventory().clear();
}
// Strike with lightning effect // Strike with lightning effect
final Location targetPos = player.getLocation(); final Location targetPos = player.getLocation();
@ -88,6 +91,7 @@ public class Command_smite extends FreedomCommand
String reason = null; String reason = null;
boolean silent = false; boolean silent = false;
boolean clearinv = false;
if (args.length >= 2) if (args.length >= 2)
{ {
if (args[args.length - 1].equalsIgnoreCase("-q")) if (args[args.length - 1].equalsIgnoreCase("-q"))
@ -102,6 +106,18 @@ public class Command_smite extends FreedomCommand
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " "); reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
} }
} }
else if (args[args.length - 1].equalsIgnoreCase("-ci"))
{
if (args[args.length - 1].equalsIgnoreCase("-ci"))
{
clearinv = true;
}
if (args.length >= 3)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
}
}
else else
{ {
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
@ -112,11 +128,11 @@ public class Command_smite extends FreedomCommand
if (player == null) if (player == null)
{ {
msg(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }
smite(sender, player, reason, silent); smite(sender, player, reason, silent, clearinv);
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason)); plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.SMITE, reason));

View File

@ -18,7 +18,7 @@ public class Command_spectator extends FreedomCommand
{ {
if (isConsole()) if (isConsole())
{ {
sender.sendMessage("When used from the console, you must define a target player."); msg("When used from the console, you must define a target player.");
return true; return true;
} }
@ -31,7 +31,7 @@ public class Command_spectator extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -19,7 +19,7 @@ public class Command_survival extends FreedomCommand
{ {
if (isConsole()) if (isConsole())
{ {
sender.sendMessage("When used from the console, you must define a target player."); msg("When used from the console, you must define a target player.");
return true; return true;
} }
@ -46,7 +46,7 @@ public class Command_survival extends FreedomCommand
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -1,7 +1,8 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
@ -19,9 +20,6 @@ import org.bukkit.entity.Player;
public class Command_tag extends FreedomCommand public class Command_tag extends FreedomCommand
{ {
public static final List<String> FORBIDDEN_WORDS = Arrays.asList(
"admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
@ -170,7 +168,7 @@ public class Command_tag extends FreedomCommand
if (!plugin.al.isAdmin(sender)) if (!plugin.al.isAdmin(sender))
{ {
for (String word : FORBIDDEN_WORDS) for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
{ {
if (rawTag.contains(word)) if (rawTag.contains(word))
{ {
@ -261,7 +259,7 @@ public class Command_tag extends FreedomCommand
if (!plugin.al.isAdmin(sender)) if (!plugin.al.isAdmin(sender))
{ {
for (String word : FORBIDDEN_WORDS) for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
{ {
if (rawTag.contains(word)) if (rawTag.contains(word))
{ {

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -43,7 +44,7 @@ public class Command_tagnyan extends FreedomCommand
if (!plugin.al.isAdmin(sender)) if (!plugin.al.isAdmin(sender))
{ {
for (String word : Command_tag.FORBIDDEN_WORDS) for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
{ {
if (rawTag.contains(word)) if (rawTag.contains(word))
{ {

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -33,7 +34,7 @@ public class Command_tagrainbow extends FreedomCommand
return true; return true;
} }
for (String word : Command_tag.FORBIDDEN_WORDS) for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
{ {
if (rawTag.contains(word)) if (rawTag.contains(word))
{ {

View File

@ -13,6 +13,8 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -44,6 +46,9 @@ public class Command_tempban extends FreedomCommand
} }
} }
final String username;
final List<String> ips = new ArrayList<>();
final Player player = getPlayer(args[0]); final Player player = getPlayer(args[0]);
final PlayerData entry; final PlayerData entry;
if (player == null) if (player == null)
@ -55,15 +60,18 @@ public class Command_tempban extends FreedomCommand
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly."); msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
return true; return true;
} }
username = entry.getName();
ips.addAll(entry.getIps());
} }
else else
{ {
entry = plugin.pl.getData(player); entry = plugin.pl.getData(player);
username = player.getName();
ips.add(FUtil.getIp(player));
} }
final List<String> ips = new ArrayList<>(entry.getIps());
assert player != null; final StringBuilder message = new StringBuilder("Temporarily banned " + username);
final StringBuilder message = new StringBuilder("Temporarily banned " + player.getName());
Date expires = FUtil.parseDateOffset("30m"); Date expires = FUtil.parseDateOffset("30m");
message.append(" until ").append(date_format.format(expires)); message.append(" until ").append(date_format.format(expires));
@ -80,16 +88,36 @@ public class Command_tempban extends FreedomCommand
message.append(", Reason: \"").append(reason).append("\""); message.append(", Reason: \"").append(reason).append("\"");
} }
Ban ban;
if (player != null)
{
ban = Ban.forPlayer(player, sender, expires, reason);
}
else
{
ban = Ban.forPlayerName(username, sender, expires, reason);
}
for (String ip : ips)
{
ban.addIp(ip);
}
plugin.bm.addBan(ban);
if (!quiet) if (!quiet)
{ {
// Strike with lightning if (player != null)
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++)
{ {
for (int z = -1; z <= 1; z++) // Strike with lightning
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++)
{ {
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); for (int z = -1; z <= 1; z++)
Objects.requireNonNull(targetPos.getWorld()).strikeLightningEffect(strike_pos); {
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
Objects.requireNonNull(targetPos.getWorld()).strikeLightningEffect(strike_pos);
}
} }
} }
@ -97,21 +125,22 @@ public class Command_tempban extends FreedomCommand
} }
else else
{ {
msg("Quietly temporarily banned " + player.getName() + "."); msg("Quietly temporarily banned " + username + ".");
} }
if (player != null)
Ban ban;
ban = Ban.forPlayer(player, sender, null, reason);
for (String ip : ips)
{ {
ban.addIp(ip); player.kickPlayer(ban.bakeKickMessage());
for (Player p : Bukkit.getOnlinePlayers())
{
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
{
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
}
}
} }
plugin.bm.addBan(ban);
player.kickPlayer(ban.bakeKickMessage()); plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.TEMPBAN, reason));
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
return true; return true;
} }
} }

View File

@ -54,6 +54,7 @@ public class Command_toggle extends FreedomCommand
msg("- landmines"); msg("- landmines");
msg("- mp44"); msg("- mp44");
msg("- tossmob"); msg("- tossmob");
msg("- gravity");
return false; return false;
} }
@ -297,6 +298,12 @@ public class Command_toggle extends FreedomCommand
toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED); toggle("Tossmob is", ConfigEntry.TOSSMOB_ENABLED);
break; break;
} }
case "gravity":
{
toggle("Block gravity is", ConfigEntry.ALLOW_GRAVITY);
break;
}
} }
return true; return true;
} }
@ -320,7 +327,7 @@ public class Command_toggle extends FreedomCommand
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk", "waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs", "firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives", "unsafeenchs",
"bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives", "bells", "armorstands", "structureblocks", "jigsaws", "grindstones", "jukeboxes", "spawners", "4chan", "beehives",
"respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob"); "respawnanchors", "autotp", "autoclear", "minecarts", "mp44", "landmines", "tossmob", "gravity");
} }
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -24,7 +24,7 @@ public class Command_unblockcmd extends FreedomCommand
Player player = getPlayer(args[0]); Player player = getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -25,7 +25,7 @@ public class Command_uncage extends FreedomCommand
Player player = getPlayer(args[0]); Player player = getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -37,7 +37,7 @@ public class Command_unmute extends FreedomCommand
final Player player = getPlayer(args[0]); final Player player = getPlayer(args[0]);
if (player == null) if (player == null)
{ {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND); msg(PLAYER_NOT_FOUND);
return true; return true;
} }

View File

@ -34,36 +34,32 @@ public class Command_verifynoadmin extends FreedomCommand
if (plugin.al.isAdminImpostor(player)) if (plugin.al.isAdminImpostor(player))
{ {
if (!plugin.al.verifiedNoAdmin.contains(player.getName()))
{
plugin.al.verifiedNoAdmin.add(player.getName());
}
String ip = FUtil.getIp(player); String ip = FUtil.getIp(player);
if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName())) if (!plugin.al.verifiedNoAdmin.containsKey(player.getName()))
{ {
List<String> ips = new ArrayList<>(); List<String> ips = new ArrayList<>();
ips.add(ip); ips.add(ip);
plugin.al.verifiedNoAdminIps.put(player.getName(), ips); plugin.al.verifiedNoAdmin.put(player.getName(), ips);
} }
else else
{ {
List<String> ips = plugin.al.verifiedNoAdminIps.get(player.getName()); List<String> ips = plugin.al.verifiedNoAdmin.get(player.getName());
if (!ips.contains(ip)) if (!ips.contains(ip))
{ {
ips.add(ip); ips.add(ip);
plugin.al.verifiedNoAdmin.remove(player.getName()); plugin.al.verifiedNoAdmin.remove(player.getName());
plugin.al.verifiedNoAdminIps.put(player.getName(), ips); plugin.al.verifiedNoAdmin.put(player.getName(), ips);
} }
} }
plugin.rm.updateDisplay(player); plugin.rm.updateDisplay(player);
FUtil.adminAction(sender.getName(), "Verified " + player.getName() + ", without admin permissions.", true); FUtil.adminAction(sender.getName(), "Verified " + player.getName() + ", without admin permissions.", true);
player.setOp(true); player.setOp(true);
player.sendMessage(YOU_ARE_OP); msg(player, YOU_ARE_OP);
final FPlayer fPlayer = plugin.pl.getPlayer(player); final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (fPlayer.getFreezeData().isFrozen()) if (fPlayer.getFreezeData().isFrozen())
{ {
fPlayer.getFreezeData().setFrozen(false); fPlayer.getFreezeData().setFrozen(false);
player.sendMessage(ChatColor.GRAY + "You have been unfrozen."); msg(player, "You have been unfrozen.");
} }
msg("Verified " + player.getName() + " but didn't give them admin permissions", ChatColor.GREEN); msg("Verified " + player.getName() + " but didn't give them admin permissions", ChatColor.GREEN);
} }

View File

@ -3,6 +3,8 @@ package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -15,14 +17,6 @@ import org.bukkit.entity.Player;
public class Command_wildcard extends FreedomCommand public class Command_wildcard extends FreedomCommand
{ {
public static final List<String> BLOCKED_COMMANDS = Arrays.asList(
"wildcard",
"gtfo",
"doom",
"slconfig",
"smite"
);
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ {
@ -52,7 +46,7 @@ public class Command_wildcard extends FreedomCommand
aliases = Arrays.asList(fCmd.getAliases().split(",")); aliases = Arrays.asList(fCmd.getAliases().split(","));
} }
for (String blockedCommand : BLOCKED_COMMANDS) for (String blockedCommand : ConfigEntry.WILDCARD_BLOCKED_COMMANDS.getStringList())
{ {
if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand)) if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
{ {

View File

@ -1,37 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Wipes the CoreProtect data for the flatlands", usage = "/<command>")
public class Command_wipecoreprotectdata extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.cpb.isEnabled())
{
msg("CoreProtect is not enabled on this server");
return true;
}
FUtil.adminAction(sender.getName(), "Wiping CoreProtect data for the flatlands", true);
new BukkitRunnable()
{
@Override
public void run()
{
plugin.cpb.clearDatabase(plugin.wm.flatlands.getWorld());
}
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -1,53 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/<command>")
public class Command_wipeflatlands extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
plugin.sf.setSavedFlag("do_wipe_flatlands", true);
if (!ConfigEntry.FLATLANDS_GENERATE.getBoolean())
{
msg("Flatlands generation is disabled, therefore it cannot be wiped.");
return true;
}
FUtil.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
World flatlands = plugin.wm.flatlands.getWorld();
if (plugin.wgb.isEnabled())
{
plugin.wgb.wipeRegions(flatlands);
}
for (Player player : server.getOnlinePlayers())
{
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
}
if (plugin.cpb.isEnabled())
{
plugin.cpb.clearDatabase(flatlands, true);
}
else
{
server.shutdown();
}
return true;
}
}

View File

@ -1,40 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Wipes all logged punishments or punishments for a specific user.", usage = "/<command> <username | -a>")
public class Command_wipepunishments extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
if (args[0].equalsIgnoreCase("-a"))
{
FUtil.adminAction(sender.getName(), "Wiping the punishment history", true);
msg("Wiped " + plugin.pul.clear() + " punishments.");
}
else
{
String username = args[0];
FUtil.adminAction(sender.getName(), "Wiping the punishment history for " + username, true);
msg("Wiped " + plugin.pul.clear(username) + " punishments for " + username + ".");
}
return true;
}
}

View File

@ -1,73 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Wipe all WorldGuard regions for a specified world.", usage = "/<command> <world>")
public class Command_wiperegions extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.wgb.isEnabled())
{
msg("WorldGuard is not enabled.");
return true;
}
if (args.length != 1)
{
return false;
}
World world = server.getWorld(args[0]);
if (world == null)
{
msg("There is no world named \"" + args[0] + "\"", ChatColor.RED);
return true;
}
int regionsWiped = plugin.wgb.wipeRegions(world);
if (regionsWiped != 0)
{
FUtil.adminAction(sender.getName(), "Wiped all regions in " + world.getName(), true);
msg("Wiped " + regionsWiped + " regions in " + world.getName());
}
else
{
msg(ChatColor.RED + "No regions were found in \"" + world.getName() + "\"");
}
return true;
}
public List<String> getAllWorldNames()
{
List<String> names = new ArrayList<>();
for (World world : server.getWorlds())
{
names.add(world.getName());
}
return names;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return getAllWorldNames();
}
return Collections.emptyList();
}
}

View File

@ -1,46 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.File;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes all essentials playerdata", usage = "/<command>")
public class Command_wipeuserdata extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!server.getPluginManager().isPluginEnabled("Essentials"))
{
msg("Essentials is not enabled on this server.");
return true;
}
FUtil.adminAction(sender.getName(), "Wiping Essentials and world player data", true);
for (World w : Bukkit.getWorlds())
{
if (w.getName().equals(plugin.wm.adminworld.getWorld().getName()))
{
continue;
}
FUtil.deleteFolder(new File(Objects.requireNonNull(server.getPluginManager().getPlugin("Essentials")).getDataFolder(), "userdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "playerdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Objects.requireNonNull(Bukkit.getServer().getWorld(w.getName())).getWorldFolder().getName() + "playerdata"));
msg("Deleted all player data.");
return true;
}
return false;
}
}

View File

@ -1,34 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import com.earth2me.essentials.Essentials;
import java.io.File;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes all Essentials warps", usage = "/<command>")
public class Command_wipewarps extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.esb.isEnabled())
{
msg("Essentials is not enabled on this server.");
return true;
}
Essentials essentials = plugin.esb.getEssentialsPlugin();
File warps = new File(essentials.getDataFolder(), "warps");
FUtil.adminAction(sender.getName(), "Wiping Essentials warps", true);
FUtil.deleteFolder(warps);
//noinspection ResultOfMethodCallIgnored
warps.mkdir();
essentials.reload();
msg("All warps deleted.");
return true;
}
}

View File

@ -34,6 +34,7 @@ public enum ConfigEntry
ALLOW_RESPAWN_ANCHORS(Boolean.class, "allow.respawnanchors"), ALLOW_RESPAWN_ANCHORS(Boolean.class, "allow.respawnanchors"),
AUTO_TP(Boolean.class, "allow.auto_tp"), AUTO_TP(Boolean.class, "allow.auto_tp"),
AUTO_CLEAR(Boolean.class, "allow.auto_clear"), AUTO_CLEAR(Boolean.class, "allow.auto_clear"),
ALLOW_GRAVITY(Boolean.class, "allow.gravity"),
// //
BLOCKED_CHATCODES(String.class, "blocked_chatcodes"), BLOCKED_CHATCODES(String.class, "blocked_chatcodes"),
// //
@ -57,7 +58,7 @@ public enum ConfigEntry
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"), SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
SERVER_OWNERS(List.class, "server.owners"), SERVER_OWNERS(List.class, "server.owners"),
SERVER_EXECUTIVES(List.class, "server.executives"), SERVER_EXECUTIVES(List.class, "server.executives"),
SERVER_ASSTISTANT_EXECUTIVES(List.class, "server.assistant_executives"), SERVER_ASSISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"), SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
SERVER_BAN_URL(String.class, "server.ban_url"), SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"), SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
@ -82,6 +83,7 @@ public enum ConfigEntry
DISCORD_NEW_ADMIN_ROLE_ID(String.class, "discord.admin_role_id"), DISCORD_NEW_ADMIN_ROLE_ID(String.class, "discord.admin_role_id"),
DISCORD_SENIOR_ADMIN_ROLE_ID(String.class, "discord.senior_admin_role_id"), DISCORD_SENIOR_ADMIN_ROLE_ID(String.class, "discord.senior_admin_role_id"),
DISCORD_DEVELOPER_ROLE_ID(String.class, "discord.developer_role_id"), DISCORD_DEVELOPER_ROLE_ID(String.class, "discord.developer_role_id"),
DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID(String.class, "discord.assistant_executive_role_id"),
DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"), DISCORD_EXECUTIVE_ROLE_ID(String.class, "discord.executive_role_id"),
DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"), DISCORD_SERVER_OWNER_ROLE_ID(String.class, "discord.server_owner_role_id"),
// //
@ -153,7 +155,10 @@ public enum ConfigEntry
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"), EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
FREECAM_TRIGGER_COUNT(Integer.class, "freecam_trigger_count"), FREECAM_TRIGGER_COUNT(Integer.class, "freecam_trigger_count"),
SERVICE_CHECKER_URL(String.class, "service_checker_url"), SERVICE_CHECKER_URL(String.class, "service_checker_url"),
BLOCKED_COMMANDS(List.class, "blocked_commands"), BLOCKED_COMMANDS(List.class, "blocked_commands.global"),
MUTED_BLOCKED_COMMANDS(List.class, "blocked_commands.muted"),
WILDCARD_BLOCKED_COMMANDS(List.class, "blocked_commands.wildcard"),
FORBIDDEN_WORDS(List.class, "forbidden_words"),
HOST_SENDER_NAMES(List.class, "host_sender_names"), HOST_SENDER_NAMES(List.class, "host_sender_names"),
FAMOUS_PLAYERS(List.class, "famous_players"), FAMOUS_PLAYERS(List.class, "famous_players"),
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"), ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
@ -162,7 +167,8 @@ public enum ConfigEntry
MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"), MASTER_BUILDER_INFO(List.class, "masterbuilderinfo"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"), AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
TOGGLE_CHAT(Boolean.class, "toggle_chat"), TOGGLE_CHAT(Boolean.class, "toggle_chat"),
DEVELOPER_MODE(Boolean.class, "developer_mode"); DEVELOPER_MODE(Boolean.class, "developer_mode"),
ANTISPAM_MINUTES(Integer.class, "antispam_minutes");
// //
private final Class<?> type; private final Class<?> type;
private final String configName; private final String configName;

View File

@ -13,6 +13,8 @@ import java.util.Objects;
import java.util.SplittableRandom; import java.util.SplittableRandom;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
@ -60,6 +62,7 @@ public class Discord extends FreedomService
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR;
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>(); public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
public Boolean enabled = false; public Boolean enabled = false;
private final Pattern DISCORD_MENTION_PATTERN = Pattern.compile("(<@!?([0-9]{16,20})>)");
public static String getMD5(String string) public static String getMD5(String string)
{ {
@ -408,6 +411,15 @@ public class Discord extends FreedomService
message = StringUtils.remove(message, "§"); message = StringUtils.remove(message, "§");
} }
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
while (DISCORD_MENTION_MATCHER.find())
{
String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, mention.replace("@",""));
}
if (enabled && !chat_channel_id.isEmpty()) if (enabled && !chat_channel_id.isEmpty())
{ {
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);
@ -433,6 +445,15 @@ public class Discord extends FreedomService
message = StringUtils.remove(message, "§"); message = StringUtils.remove(message, "§");
} }
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
while (DISCORD_MENTION_MATCHER.find())
{
String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, mention.replace("@",""));
}
if (enabled && !chat_channel_id.isEmpty()) if (enabled && !chat_channel_id.isEmpty())
{ {
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.discord; package me.totalfreedom.totalfreedommod.discord;
import com.google.common.base.Strings;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -18,10 +19,10 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public class DiscordToAdminChatListener extends ListenerAdapter public class DiscordToAdminChatListener extends ListenerAdapter
{ {
DiscordToMinecraftListener dtml = new DiscordToMinecraftListener(); DiscordToMinecraftListener dtml = new DiscordToMinecraftListener();
public static net.md_5.bungee.api.ChatColor getColor(Displayable display) public static net.md_5.bungee.api.ChatColor getColor(Displayable display)
@ -36,100 +37,112 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{ {
Member member = event.getMember(); Member member = event.getMember();
String tag = dtml.getDisplay(member); String tag = dtml.getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
Message msg = event.getMessage(); Message msg = event.getMessage();
for (Player player : Bukkit.getOnlinePlayers()) String mediamessage = ChatColor.YELLOW + "[Media]";
{
if (TotalFreedomMod.getPlugin().al.isAdmin(player)) StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
{ String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player); + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
String format = admin.getAcFormat(); + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
if (format != null) logmessage.append(lm);
{
Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member))
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
message.append(FUtil.colorize(m));
}
else
{
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
message.append(m);
}
}
}
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getAttachments().isEmpty()) if (!msg.getAttachments().isEmpty())
{ {
for (Message.Attachment attachment : msg.getAttachments())
{
if (attachment.getUrl() == null)
{
continue;
}
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]"); logmessage.append(mediamessage); // Actually for logging...
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append("[Media]"); // for logging
}
} }
FLog.info(logmessage.toString());
for (Player player : Bukkit.getOnlinePlayers()) Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player ->
{ {
if (TotalFreedomMod.getPlugin().al.isAdmin(player)) StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format))
{ {
player.spigot().sendMessage(builder.create()); Displayable display = getDisplay(member);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", display.getAbbr())
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m));
} }
} else
FLog.info(message.toString()); {
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
builder.append(m);
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
TextComponent text = new TextComponent(mediamessage);
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ");
}
builder.append(text);
}
}
player.spigot().sendMessage(builder.create());
});
} }
} }
// Needed to display tags in custom AC messages // Needed to display tags in custom AC messages
public String getDisplay(Member member) public Displayable getDisplay(Member member)
{ {
Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString()); Guild server = Discord.bot.getGuildById(ConfigEntry.DISCORD_SERVER_ID.getString());
// Server Owner // Server Owner
if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString()))) if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SERVER_OWNER_ROLE_ID.getString())))
{ {
return Title.OWNER.getAbbr(); return Title.OWNER;
} }
// Developers // Developers
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_DEVELOPER_ROLE_ID.getString())))
{ {
return Title.DEVELOPER.getAbbr(); return Title.DEVELOPER;
} }
// Executives // Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_EXECUTIVE_ROLE_ID.getString())))
{ {
return Title.EXECUTIVE.getAbbr(); return Title.EXECUTIVE;
}
// Assistant Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString())))
{
return Title.ASSTEXEC;
} }
// Senior Admins // Senior Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString())))
{ {
return Rank.SENIOR_ADMIN.getAbbr(); return Rank.SENIOR_ADMIN;
} }
// Admins // Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_NEW_ADMIN_ROLE_ID.getString())))
{ {
return Rank.ADMIN.getAbbr(); return Rank.ADMIN;
} }
// Master Builders // Master Builders
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_MASTER_BUILDER_ROLE_ID.getString())))
{ {
return Title.MASTER_BUILDER.getAbbr(); return Title.MASTER_BUILDER;
} }
// OP, returning null breaks? // OP, returning null breaks?
else else
{ {
return Rank.OP.getAbbr(); return Rank.OP;
} }
} }
} }

View File

@ -22,46 +22,47 @@ public class DiscordToMinecraftListener extends ListenerAdapter
public void onMessageReceived(MessageReceivedEvent event) public void onMessageReceived(MessageReceivedEvent event)
{ {
String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString(); String chat_channel_id = ConfigEntry.DISCORD_CHAT_CHANNEL_ID.getString();
if (event.getMember() != null && !chat_channel_id.isEmpty() && event.getChannel().getId().equals(chat_channel_id)) if (event.getMember() != null && !chat_channel_id.isEmpty()
&& event.getChannel().getId().equals(chat_channel_id)
&& !event.getAuthor().getId().equals(Discord.bot.getSelfUser().getId()))
{ {
if (!event.getAuthor().getId().equals(Discord.bot.getSelfUser().getId())) Member member = event.getMember();
String tag = getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord"
+ ChatColor.DARK_GRAY + "]");
Message msg = event.getMessage();
if (tag != null)
{ {
Member member = event.getMember(); message.append(" ").append(tag);
String tag = getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "]");
Message msg = event.getMessage();
if (tag != null)
{
message.append(" ").append(tag);
}
message.append(" ").append(ChatColor.RED).append(ChatColor.stripColor(member.getEffectiveName())).append(ChatColor.DARK_GRAY).append(":").append(ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay()));
message.append(" ").append(ChatColor.stripColor(msg.getContentDisplay())); // for logging
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
attachment.getUrl();
builder.append(" ");
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append(" [Media]"); // for logging
}
}
for (Player player : Bukkit.getOnlinePlayers())
{
if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord())
{
player.spigot().sendMessage(builder.create());
}
}
FLog.info(message.toString());
} }
message.append(" ").append(ChatColor.RED).append(ChatColor.stripColor(member.getEffectiveName()))
.append(ChatColor.DARK_GRAY).append(":").append(ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getContentDisplay().isEmpty())
{
builder.append(" ").append(ChatColor.stripColor(msg.getContentDisplay()));
message.append(" ").append(ChatColor.stripColor(msg.getContentDisplay())); // for logging
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
attachment.getUrl();
builder.append(" ");
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append(" [Media]"); // for logging
}
}
for (Player player : Bukkit.getOnlinePlayers())
{
if (TotalFreedomMod.getPlugin().pl.getData(player).doesDisplayDiscord())
{
player.spigot().sendMessage(builder.create());
}
}
FLog.info(message.toString());
} }
} }
@ -84,6 +85,11 @@ public class DiscordToMinecraftListener extends ListenerAdapter
{ {
return Title.EXECUTIVE.getColoredTag(); return Title.EXECUTIVE.getColoredTag();
} }
// Assistant Executives
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_ASSISTANT_EXECUTIVE_ROLE_ID.getString())))
{
return Title.ASSTEXEC.getColoredTag();
}
// Senior Admins // Senior Admins
else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString()))) else if (member.getRoles().contains(server.getRoleById(ConfigEntry.DISCORD_SENIOR_ADMIN_ROLE_ID.getString())))
{ {

View File

@ -1,52 +0,0 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.HashMap;
import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
import static org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
public class CurseListener extends FreedomService
{
public HashMap<Player, Player> cursedPlayers = new HashMap<Player, Player>();
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.MONITOR)
public void onResourcePackStatus(PlayerResourcePackStatusEvent event)
{
Player player = event.getPlayer();
PlayerResourcePackStatusEvent.Status cursed = event.getStatus();
Player cursedBy = cursedPlayers.get(player);
if (cursed.equals(Status.ACCEPTED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Casting curse on " + player.getName() + "...");
}
else if (cursed.equals(Status.DECLINED))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to start cast on " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.SUCCESSFULLY_LOADED))
{
cursedBy.sendMessage(ChatColor.GREEN + "Successfully cursed + " + player.getName() + "!");
cursedPlayers.remove(player);
}
else if (cursed.equals(Status.FAILED_DOWNLOAD))
{
cursedBy.sendMessage(ChatColor.RED + "Failed to cast curse on " + player.getName() + "!");
cursedPlayers.remove(player);
}
}
}

View File

@ -1,7 +1,7 @@
package me.totalfreedom.totalfreedommod.httpd.module; package me.totalfreedom.totalfreedommod.httpd.module;
import java.util.Collection;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD; import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -10,6 +10,8 @@ import org.bukkit.entity.Player;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import java.util.Collection;
public class Module_list extends HTTPDModule public class Module_list extends HTTPDModule
{ {
@ -95,7 +97,7 @@ public class Module_list extends HTTPDModule
responseObject.put("master_builders", masterbuilders); responseObject.put("master_builders", masterbuilders);
responseObject.put("operators", operators); responseObject.put("operators", operators);
responseObject.put("imposters", imposters); responseObject.put("imposters", imposters);
responseObject.put("online", server.getOnlinePlayers().size()); responseObject.put("online", FUtil.getFakePlayerCount());
responseObject.put("max", server.getMaxPlayers()); responseObject.put("max", server.getMaxPlayers());
final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString()); final NanoHTTPD.Response response = new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_JSON, responseObject.toString());
@ -108,7 +110,9 @@ public class Module_list extends HTTPDModule
final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers(); final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
body.append("<p>There are ").append(onlinePlayers.size()).append("/").append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n"); int count = onlinePlayers.size() - AdminList.vanished.size();
body.append("<p>There are ").append(count < 0 ? 0 : count).append("/")
.append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
body.append("<ul>\r\n"); body.append("<ul>\r\n");

View File

@ -117,10 +117,4 @@ public class PermissionManager extends FreedomService
setPermissions(player); setPermissions(player);
} }
} }
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerJoin(PlayerJoinEvent event)
{
setPermissions(event.getPlayer());
}
} }

View File

@ -289,7 +289,7 @@ public class FPlayer
return unmuteTask != null; return unmuteTask != null;
} }
public void setMuted(boolean muted) public void setMuted(boolean muted, int minutes)
{ {
FUtil.cancel(unmuteTask); FUtil.cancel(unmuteTask);
plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName()); plugin.mu.MUTED_PLAYERS.remove(getPlayer().getName());
@ -324,7 +324,12 @@ public class FPlayer
plugin.mu.MUTED_PLAYERS.remove(getName()); plugin.mu.MUTED_PLAYERS.remove(getName());
} }
} }
}.runTaskLater(plugin, AUTO_PURGE_TICKS); }.runTaskLater(plugin, minutes * (60L * 20L));
}
public void setMuted(boolean muted)
{
setMuted(muted, 5);
} }
public BukkitTask getLockupScheduleID() public BukkitTask getLockupScheduleID()

View File

@ -62,6 +62,11 @@ public class RankManager extends FreedomService
return Title.EXECUTIVE; return Title.EXECUTIVE;
} }
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && plugin.al.isAdmin(player))
{
return Title.ASSTEXEC;
}
if (plugin.al.isVerifiedAdmin(player)) if (plugin.al.isVerifiedAdmin(player))
{ {
return Title.VERIFIED_ADMIN; return Title.VERIFIED_ADMIN;

View File

@ -227,7 +227,7 @@ public class Shop extends FreedomService
ItemStack itemStack = new ItemStack(Material.BLAZE_ROD); ItemStack itemStack = new ItemStack(Material.BLAZE_ROD);
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
assert itemMeta != null; assert itemMeta != null;
itemMeta.setDisplayName(FUtil.colorize("&bL&3i&bg&3h&bt&3i&bn&3g &b&bR&3o&bd")); itemMeta.setDisplayName(FUtil.colorize("&bL&3i&bg&3h&bt&3n&bi&3n&bg &3R&bo&3d"));
itemMeta.setLore(Arrays.asList(ChatColor.AQUA + "Strike others down with the power of lightning.", ChatColor.RED + ChatColor.ITALIC.toString() + "The classic way to exterminate annoyances.")); itemMeta.setLore(Arrays.asList(ChatColor.AQUA + "Strike others down with the power of lightning.", ChatColor.RED + ChatColor.ITALIC.toString() + "The classic way to exterminate annoyances."));
itemMeta.addEnchant(Enchantment.CHANNELING, 1, false); itemMeta.addEnchant(Enchantment.CHANNELING, 1, false);
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);

View File

@ -1,33 +1,5 @@
package me.totalfreedom.totalfreedommod.util; package me.totalfreedom.totalfreedommod.util;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SplittableRandom;
import java.util.TimeZone;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -48,6 +20,18 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
public class FUtil public class FUtil
@ -71,9 +55,12 @@ public class FUtil
"458de06f-36a5-4e1b-aaa6-ec1d1751c5b6", // SupItsDillon "458de06f-36a5-4e1b-aaa6-ec1d1751c5b6", // SupItsDillon
"c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu "c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu
"38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch "38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch
"ba5aafba-9012-418f-9819-a7020d591068" // TFTWPhoenix "ba5aafba-9012-418f-9819-a7020d591068", // TFTWPhoenix
"d6dd9740-40db-45f5-ab16-4ee16a633009", // Abhi
"2e06e049-24c8-42e4-8bcf-d35372af31e6", // NotInSync
"f97c0d7b-6413-4558-a409-88f09a8f9adb" // videogamesm12
); );
public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix"); public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix", "abhithedev", "NotInSync", "videogamesm12");
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>(); public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList( public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
ChatColor.DARK_RED, ChatColor.DARK_RED,
@ -137,7 +124,7 @@ public class FUtil
public static boolean isExecutive(String name) public static boolean isExecutive(String name)
{ {
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSTISTANT_EXECUTIVES.getStringList().contains(name); return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
} }
public static boolean isDeveloper(Player player) public static boolean isDeveloper(Player player)
@ -271,7 +258,7 @@ public class FUtil
public static Response sendRequest(String endpoint, String method, List<String> headers, String body) throws IOException public static Response sendRequest(String endpoint, String method, List<String> headers, String body) throws IOException
{ {
URL url = new URL(endpoint); URL url = new URL(endpoint);
HttpURLConnection connection = (HttpURLConnection)url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(method); connection.setRequestMethod(method);
@ -390,7 +377,8 @@ public class FUtil
} }
} }
private static final List<String> regxList = new ArrayList<String>(){{ private static final List<String> regxList = new ArrayList<String>()
{{
add("y"); add("y");
add("mo"); add("mo");
add("w"); add("w");
@ -400,11 +388,13 @@ public class FUtil
add("s"); add("s");
}}; }};
private static long a(String parse) { private static long a(String parse)
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
regxList.forEach(obj -> { regxList.forEach(obj -> {
if (parse.endsWith(obj)) { if (parse.endsWith(obj))
{
sb.append(parse.split(obj)[0]); sb.append(parse.split(obj)[0]);
} }
}); });
@ -412,7 +402,8 @@ public class FUtil
return Long.parseLong(sb.toString()); return Long.parseLong(sb.toString());
} }
private static TimeUnit verify(String arg) { private static TimeUnit verify(String arg)
{
TimeUnit unit = null; TimeUnit unit = null;
for (String c : regxList) for (String c : regxList)
{ {
@ -458,6 +449,16 @@ public class FUtil
return Date.from(instant); return Date.from(instant);
} }
public static long parseLongOffset(long unix, String... time)
{
Instant instant = Instant.ofEpochMilli(unix);
for (String arg : time)
{
instant = instant.plusSeconds(verify(arg).get() * a(arg));
}
return FUtil.getUnixTime(Date.from(instant));
}
public static String playerListToNames(Set<OfflinePlayer> players) public static String playerListToNames(Set<OfflinePlayer> players)
{ {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
@ -550,7 +551,7 @@ public class FUtil
{ {
Field field = checkClass.getDeclaredField(name); Field field = checkClass.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return (T)field.get(from); return (T) field.get(from);
} }
catch (NoSuchFieldException | IllegalAccessException ignored) catch (NoSuchFieldException | IllegalAccessException ignored)
@ -605,12 +606,12 @@ public class FUtil
public static Date getUnixDate(long unix) public static Date getUnixDate(long unix)
{ {
return new Date(unix * 1000); return new Date(unix);
} }
public static long getUnixTime() public static long getUnixTime()
{ {
return System.currentTimeMillis() / 1000L; return Instant.now().toEpochMilli();
} }
public static long getUnixTime(Date date) public static long getUnixTime(Date date)
@ -620,7 +621,7 @@ public class FUtil
return 0; return 0;
} }
return date.getTime() / 1000L; return date.getTime();
} }
public static String getNMSVersion() public static String getNMSVersion()
@ -632,7 +633,7 @@ public class FUtil
public static int randomInteger(int min, int max) public static int randomInteger(int min, int max)
{ {
int range = max - min + 1; int range = max - min + 1;
return (int)(Math.random() * range) + min; return (int) (Math.random() * range) + min;
} }
public static String randomString(int length) public static String randomString(int length)
@ -770,7 +771,7 @@ public class FUtil
{ {
c1values[i] = Math.round(c1values[i] + factor * (c2values[i] - c1values[i])); c1values[i] = Math.round(c1values[i] + factor * (c2values[i] - c1values[i]));
} }
return Color.fromRGB((int)c1values[0], (int)c1values[1], (int)c1values[2]); return Color.fromRGB((int) c1values[0], (int) c1values[1], (int) c1values[2]);
} }
public static boolean isValidIPv4(String ip) public static boolean isValidIPv4(String ip)
@ -835,8 +836,22 @@ public class FUtil
}.runTaskLater(TotalFreedomMod.getPlugin(), delay); }.runTaskLater(TotalFreedomMod.getPlugin(), delay);
} }
public static int getFakePlayerCount()
{
int i = TotalFreedomMod.getPlugin().al.vanished.size();
for (String name : TotalFreedomMod.getPlugin().al.vanished)
{
if (Bukkit.getPlayer(name) == null)
{
i--;
}
}
return getServer().getOnlinePlayers().size() - i;
}
public static class PaginationList<T> extends ArrayList<T> public static class PaginationList<T> extends ArrayList<T>
{ {
private final int epp; private final int epp;
public PaginationList(int epp) public PaginationList(int epp)
@ -854,7 +869,7 @@ public class FUtil
public int getPageCount() public int getPageCount()
{ {
return (int)Math.ceil((double)size() / (double)epp); return (int) Math.ceil((double) size() / (double) epp);
} }
public List<T> getPage(int page) public List<T> getPage(int page)

View File

@ -1,102 +0,0 @@
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.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public final class HubWorld extends CustomWorld
{
private static final String GENERATION_PARAMETERS = ConfigEntry.FLATLANDS_GENERATE_PARAMS.getString();
//
private WorldWeather weather = WorldWeather.OFF;
private WorldTime time = WorldTime.INHERIT;
public HubWorld()
{
super("hubworld");
}
@Override
public void sendToWorld(Player player)
{
super.sendToWorld(player);
}
// TODO: Replace instances of org.bukkit.Sign with a non deprecated version. This might include more boilerplate.
@SuppressWarnings("deprecation")
@Override
protected World generateWorld()
{
final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
final World world = server.createWorld(worldCreator);
assert world != null;
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
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.material.Sign signData = (org.bukkit.material.Sign)welcomeSign.getData();
signData.setFacingDirection(BlockFace.NORTH);
welcomeSign.setLine(0, ChatColor.GREEN + "Hub World");
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
welcomeSign.update();
plugin.gr.commitGameRules();
return world;
}
public WorldWeather getWeatherMode()
{
return weather;
}
public void setWeatherMode(final WorldWeather weatherMode)
{
this.weather = weatherMode;
try
{
weatherMode.setWorldToWeather(getWorld());
}
catch (Exception ignored)
{
}
}
public WorldTime getTimeOfDay()
{
return time;
}
public void setTimeOfDay(final WorldTime timeOfDay)
{
this.time = timeOfDay;
try
{
timeOfDay.setWorldToTime(getWorld());
}
catch (Exception ignored)
{
}
}
}

View File

@ -20,14 +20,12 @@ public class WorldManager extends FreedomService
public Flatlands flatlands; public Flatlands flatlands;
public AdminWorld adminworld; public AdminWorld adminworld;
public MasterBuilderWorld masterBuilderWorld; public MasterBuilderWorld masterBuilderWorld;
public HubWorld hubworld;
public WorldManager() public WorldManager()
{ {
this.flatlands = new Flatlands(); this.flatlands = new Flatlands();
this.adminworld = new AdminWorld(); this.adminworld = new AdminWorld();
this.masterBuilderWorld = new MasterBuilderWorld(); this.masterBuilderWorld = new MasterBuilderWorld();
this.hubworld = new HubWorld();
} }
@Override @Override
@ -36,7 +34,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld(); flatlands.getWorld();
adminworld.getWorld(); adminworld.getWorld();
masterBuilderWorld.getWorld(); masterBuilderWorld.getWorld();
hubworld.getWorld();
// Disable weather // Disable weather
if (ConfigEntry.DISABLE_WEATHER.getBoolean()) if (ConfigEntry.DISABLE_WEATHER.getBoolean())
@ -57,7 +54,6 @@ public class WorldManager extends FreedomService
flatlands.getWorld().save(); flatlands.getWorld().save();
adminworld.getWorld().save(); adminworld.getWorld().save();
masterBuilderWorld.getWorld().save(); masterBuilderWorld.getWorld().save();
hubworld.getWorld().save();
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -73,10 +69,6 @@ public class WorldManager extends FreedomService
{ {
return; return;
} }
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
} }
catch (Exception ignored) catch (Exception ignored)
{ {
@ -101,10 +93,6 @@ public class WorldManager extends FreedomService
{ {
return; return;
} }
else if (event.getWorld().equals(hubworld.getWorld()) && hubworld.getWeatherMode() != WorldWeather.OFF)
{
return;
}
} }
catch (Exception ignored) catch (Exception ignored)
{ {

Some files were not shown because too many files have changed in this diff Show More