Compare commits

..

514 Commits

Author SHA1 Message Date
aca3398d21 TotalFreedomMod Electrum
Version 5.0

This TotalFreedomMod release implements many changes. Most notably, the
internals have been completely revamped. TotalFreedomMod now relies on the
Aero library for core mechanics such as command handling and services.

Another important change is the UUID system. In TotalFreedomMod Electrum,
it has been completely removed. The core reason for this is that the
system as a whole was very bugged. Additionally, it did not solve the
primary reason for its conception: preserving player data when the player
changes their username. This is because TotalFreedomMod servers usually
run in offline-mode. This meaning that some of the players joining do not
have a registerd Mojang UUID whatsoever. All in all, the UUID system was
buggy, and it did not fix the reason it was implemented, so it has been
completely removed. The admin list and the ban list now use usernames and
IPs again.

Lastly, many smaller changes have been implemented. Due to the amount of
changes, they have not been named individualy. Please refer to the issues
below for more details.

Fixes #342
Fixes #350
Fixes #380
Fixes #684
Fixes #704
Fixes #716
Fixes #735
Fixes #745
Fixes #784
Fixes #765
Fixes #791
Fixes #805
Fixes #826
Fixes #883
Fixes #1524
Fixes #1534
Fixes #1536
Fixes #1538
Fixes #1545
Fixes #1546
Fixes #1568
Fixes #1627
Resolves #403
Resolves #435
Resolves #597
Resolves #603
Resolves #628
Resolves #690
Resolves #708
Resolves #747
Resolves #748
Resolves #749
Resolves #764
Resolves #767
Resolves #782
Resolves #809
Resolves #803
Resolves #811
Resolves #813
Resolves #830
Resolves #848
Resolves #856
Resolves #876
Resolves #908
Resolves #992
Resolves #1018
Resolves #1432
Resolves #1446
Resolves #1494
Resolves #1501
Resolves #1526
Resolves #1540
Resolves #1550
Resolves #1560
Resolves #1561
Resolves #1578
Resolves #1613
2016-05-12 21:51:58 +02:00
924f718d5a Fixed bugs in TFM 5.0
Added /saconfig setrank
Added /saconfig reload
Small changes
2016-03-07 21:32:05 +01:00
6edb6be7d9 Many changes for TFM 5.0
Improved admin system
Improved Rank system
Implemented config converter
Improved command handling
Updated Aero
2016-03-06 16:58:59 +01:00
055973aa37 Many changes for TFM 5.0
Refractoring
Reworked /saconfig
Reworked part of the command system
Removed unused config sections
Refractored part of the config
Fixed bugs with admin list
Actually allow CONSOLE to have senior perms
2016-03-02 20:28:01 +01:00
19ced05110 Update to Spigot 1.9-R1 2016-03-01 19:14:14 +01:00
e93ac11172 Use custom service abstraction in favour of Aero's AbstractService
Use Aero's YamlConfig in favour of FConfig
Refractoring
Small edits
2016-03-01 17:47:01 +01:00
7328d20c84 Rename some commands to more fitting alternatives
Preserve old command names as aliases
2016-02-29 22:27:11 +01:00
4586b7519f [Bleeding] Revamped rank system yet again
Refractoring
Bug fixes
Mass format
2016-02-29 21:48:17 +01:00
a0058869c9 Added checkstyle plugin
Moved resources to correct folder
Fixed and improved build information, no longer tracking build.properties
2015-11-22 19:28:32 +01:00
89a317b7df Mavenized project 2015-11-18 21:41:51 +01:00
0c3bc40b03 Completely switched over to service-based events 2015-11-16 00:32:04 +01:00
848f103afa [Bleeding] TotalFreedomMod 5.0
Mass Refractoring, now uses me.totalfreedom.totalfreedommod as package
Uses Aero https://github.com/Pravian/Aero
Revamped command system
Remove all TFM_ prefixes
Revamp rank system
Use new service based system
Cleanup
2015-10-19 19:43:46 +02:00
a7a2db15d6 Track build information in a better way
build.properties replaces buildcreator.properties, buildcreator.default.properties annd buildnumber.properties, but is untracked.
'git describe --tags --always HEAD' is now used to identify the build version, and its result is stored in the build properties file, included with the build. appinfo.properties is removed in favour of build.properties in the compiled jar.
The build number is still tracked, but offline, allowing TFM commits to more easily be merged
2015-09-06 23:05:36 +02:00
6aeb56de07 Block commands right when the TFM is enabled. Fixes #735 2015-09-06 17:05:03 +02:00
400038265b Prevent command arguments from using long number strings. Resolves #782
Mass format
2015-09-06 17:02:06 +02:00
3b87323c41 Remove /permban list. Resolves #805 2015-09-06 16:46:20 +02:00
cdf2dc6760 Limit host console commands even more. Resolves #811 2015-09-06 16:42:02 +02:00
bf1d779b95 Merge with upstream 2015-06-11 22:29:39 +02:00
27004da544 Compile for Spigot-1.8.7-R0.1. Resolves #644 2015-06-11 22:28:55 +02:00
c0c4c25875 Merge branch 'tfm44' into pr/584 2015-06-07 17:39:01 +02:00
adbaf9341d Grammar fix in Command_invis.java 2015-06-07 17:38:30 +02:00
b5c5e60c12 Merge branch 'pr/687' into tfm44 2015-06-07 17:36:25 +02:00
1ed1b352f3 Properly allow Forge clients to log in. Fixes #493 2015-06-07 17:35:56 +02:00
53c898fd76 Merge branch pr/580 2015-06-07 17:30:12 +02:00
acc8f3e2b8 Changed /kicknoob message to be more user-friendly 2015-06-07 17:28:58 +02:00
157eeef867 Merge branch 'tfm43' into tfm44 2015-06-07 17:22:21 +02:00
21c0833f14 Rename dependency names to match wiki 2015-06-07 17:21:05 +02:00
c002fbc537 Handle player online check in AsyncPlayerPreLoginEvent
Apparently, online players with the same username are kicked before PlayerLoginEvent is called. This commit moves the online player check to AsyncPlayerPreloginEvent so the default behaviour can still be modified

Fixes #642
2015-05-30 20:51:49 +02:00
a4d8f4646e Properly block /jail and /unjail
They're both aliases, /togglejail is the actual command
2015-05-30 20:13:11 +02:00
f2dc46d4ef Work around /saconfig clearme bug. Fixes #629 2015-05-30 20:01:10 +02:00
901a327b1e Block/unblock pending commands for non-superadmins
Blocked /jail, /unjail and /blockdata for non-superadmins
Moved /clearhistory, /save-all, /save-on and /save-off to non-autoeject section

Resolves #671, Resolves #670, Resolves #656
2015-05-30 19:58:15 +02:00
580ba0a357 Prevent players moving to illegal positions. Fixes #651 2015-05-30 19:45:22 +02:00
abf52870dd Block /green for non-superadmins. Resolves #594
Moved /restart to the correct section
2015-05-14 15:27:15 +02:00
d48bfde128 Merge branch 'pr/625' into tfm44 2015-05-14 15:19:15 +02:00
7ac7b75ae6 Allow admins to use lava/water buckets 2015-05-14 14:38:15 +02:00
b66614cad9 Block /execute for non-superadmins. Resolves #630 2015-05-14 14:30:51 +02:00
ff70f13e05 Fixed bug where /uuid recalculate would set ranks incorrectly 2015-05-13 14:56:38 +02:00
ea110c01dd Add /overlord 2015-05-13 14:52:01 +02:00
632f3647a8 Blocked /tpall for non-superadmins 2015-05-12 20:43:35 +02:00
80287433eb Properly fixed commandblocker
Rest in peace, terrible, terrible mistake
2015-05-12 20:34:04 +02:00
b18aeb2d38 Work around setFlying() throwing exceptions 2015-05-12 20:17:38 +02:00
68f972c562 Allow players to fly. Fixes #608 2015-05-12 17:18:12 +02:00
994056047a Block /weather for non-superadmins. Resolves #617 2015-05-12 17:13:28 +02:00
f115315341 Block /worldborder for non-superadmins. Resolves #615 2015-05-12 17:08:44 +02:00
57e5395143 Block /title for non-superadmins. Resolves #621 2015-05-12 17:07:41 +02:00
17f3a4ca3d Remove blocked commands from the CommandMap. Resolves #622
Temporarily workaround: Remove blocked command from the CommandMap
In Spigot 1.8.3, cancelling PlayerCommandPreprocessEvent will have no effect
This results in TFM failing to block player commands: The player will get a message,
but the command will still execute. Removing the command from the CommandMap is a
temporary workaround untill the related Spigot issue has been fixed.

https://hub.spigotmc.org/jira/browse/SPIGOT-879
2015-05-12 16:54:51 +02:00
e2d0e9e754 Fixed error when blocking player commands 2015-05-12 16:45:10 +02:00
b167540ad7 Properly cancel blocked commands 2015-05-11 23:05:21 +02:00
0d1ce072dc Reorder prefix assignments, fixes admin prefixes 2015-05-11 22:37:38 +02:00
887a5c6b16 Fixed all admins showing up as Superadmins 2015-05-11 22:21:59 +02:00
ea6bfa8387 Fix commandblocker not blocking properly. Resolves #586 2015-05-10 23:28:13 +02:00
42266c37ea Fixed false positive plugin specific command block. Resolves #575 2015-05-10 23:19:23 +02:00
2dd8e00201 Lowercase commands before mute-block checking. Resolves #312 2015-04-27 00:58:27 +02:00
46cd88a18a Add protected spawnpoints after all worlds have been loaded. Resolves #438 2015-04-27 00:53:07 +02:00
2ff0f6f5d6 Fix Forge clients being unable to log in. Resolves #493 2015-04-27 00:48:33 +02:00
9ff6325469 Add owner to standard prefixes. Resolves #504 2015-04-27 00:45:47 +02:00
ea404985fd Ban IPs in /tban. Resolves #499 2015-04-27 00:39:36 +02:00
8fc25111e2 Synchronize calls in AsyncPlayerChatEvent listener. Resolves #524 2015-04-27 00:31:54 +02:00
4fce1109a1 Merge branch 'master' into pr/553 2015-04-27 00:08:13 +02:00
916fd75003 Added Mumble announcement 2015-04-27 00:07:50 +02:00
aa35aae58f Merge branch 'master' into pr/574 2015-04-26 23:51:18 +02:00
6849fb2784 Display proper URL when banning with /glist ban
When you glist ban an online player, it says totalfreedom.boards.net regardless of the config entry. I modified it so it is the config.yml's ban appeal URL.
2015-04-26 23:50:40 +02:00
313577d083 Merge from master 2015-04-26 23:30:54 +02:00
53efcfd06b Don't autoeject players using /reload. Resolves #525 2015-04-26 23:28:29 +02:00
edaaeef65f Merge branch 'master' into pr/571 2015-04-26 23:25:32 +02:00
d6eb5bdcda Fix getIpBanList() returning UUID bans. Fixes #570 2015-04-26 23:23:46 +02:00
7d675923db Replaced last instances of DarthSalamon with Prozza 2015-04-26 22:40:38 +02:00
87fd8a165c Added MCConnect IP to nosuper IPs 2015-04-26 22:29:31 +02:00
1205252450 Correct compile NMS version 2015-04-26 22:21:26 +02:00
1ed45b1a20 Compile with Java 7 2015-04-26 22:17:25 +02:00
822f55d9f2 Merge with master 2015-04-26 20:44:28 +02:00
aacf37aa56 Update to Spigot 1.8.3-R2 2015-04-26 20:43:37 +02:00
a15e39d7dd Added more announcements. Resolves #516 2015-03-29 12:10:55 +02:00
72fa8532d3 Blocked pending commands in CommandBlocker. Resolves #492 2015-03-15 13:19:20 +01:00
f4aa0c324c Updated to new WorldEdit API
TF-WorldEdit doesn't depend on TFM anymore. It's event-based now.
Moved TFM_TelnetListener to the Bridge subpackage
2015-03-07 17:32:27 +01:00
73ee1f3624 Implement SuperAdmin service 2015-02-18 19:24:04 +01:00
4ca3593653 Release v4.3 2015-02-16 17:13:21 +01:00
af52dec24a Store UUIDs in a SQLite database. Resolves #373 and resolves #406 2015-02-16 17:00:38 +01:00
34ebb3586c Resolve PlayerRank entries by IP. Resolves #415 2015-02-16 15:49:10 +01:00
eee8682959 Merge branch 'master' into commandblocker 2015-02-15 19:28:10 +01:00
af1dd2e9ff Added support for blocking subcommands. Resolves #357, Resolves #365 and Resolves #334 2015-02-15 19:27:35 +01:00
ade60ad611 Updated developer names. Resolves #421 2015-02-13 18:08:27 +01:00
e699ad1663 Cleanup: Mass reformat and organize imports 2015-01-15 15:47:10 +01:00
e2308ee904 Block /spreadplayers in config. Closes #382 2014-12-06 15:02:51 +01:00
d14a595ac4 Update to Spigot's CraftBukkit 1.8
Corrected the version check number

Moved Apache Commons reference to imports section
2014-11-30 13:54:29 +01:00
5190af0a6b Merge pull request #377 from ItzLevvie/patch-3
Fixed spelling mistake in TFM_PlayerData.java
2014-11-25 20:39:00 +01:00
a11b87ec83 Fixed spelling mistake in TFM_PlayerData.java 2014-11-25 19:29:58 +00:00
c7a0604afc Move unfreeze and unmute tasks to TFM_PlayerData. Resolves #352
Mass format & cleanup
2014-11-20 23:20:31 +01:00
9970277134 Fixed last bugs with ForceIP. Closes #354 2014-11-13 21:14:21 +01:00
49f6879ccb Merged with master 2014-11-13 19:22:18 +01:00
794b76321a Avoid adding blocked IPs to the superadmin list 2014-11-13 18:37:49 +01:00
e5b4ae0e3e Merge with master 2014-11-02 14:22:53 +01:00
310ce4f75a Ported all useful features from MobArena over to TFM 2014-11-02 14:20:10 +01:00
cf072dc0d5 Merge pull request #353 from Wild1145/master
ForceIP bugfixes.
2014-11-01 21:00:19 +01:00
7fe0b562ee Cleaned it up a bit as suggested by @jeromsar 2014-11-01 19:55:45 +00:00
6f6fdb28bf Minor tweaks to default port, Heartbeat and blocked cmd's 2014-11-01 19:51:43 +00:00
524d4da9d8 Bug Crunching on the ForceIP - Should work a lot better now. 2014-11-01 19:46:00 +00:00
0aa0bae0ad Merge pull request #349 from Wild1145/master
Added ForceIP. Resolves #224
2014-11-01 20:14:27 +01:00
fcf52ba02a Managed to tweak the port requirement, isnt actually needed like I thought. 2014-11-01 17:44:07 +00:00
8a92ff132b Changed the default config entry for the server address & added a little tweak. 2014-11-01 15:36:24 +00:00
99043a7c49 Removed Hostname and Port from the config - Now using the server address. 2014-11-01 12:10:08 +00:00
2a71be4050 Tweaked the config notes for Hostname & Port to make it a bit more descriptive 2014-10-31 18:10:06 +00:00
b43ef812a2 Fixed another slight formatting issue. 2014-10-31 18:05:25 +00:00
7981adaf85 Fixed Formatting Issues - Forgot it was allman style there. 2014-10-31 17:57:44 +00:00
1bc22a817a Removed the whitespace. 2014-10-31 17:52:57 +00:00
57a6b35457 Added the ForceIP feature - Resolves #224 2014-10-31 17:47:05 +00:00
8b45482d0a [Bleeding] Block listed IPs from being supered. Resolves #201 2014-10-30 19:44:05 +01:00
af64a77268 Officially compiling for Spigot for the time being 2014-10-30 19:28:47 +01:00
5c50069f21 Merge pull request #346 from ItzLevvie/patch-2
Fixed spelling mistake in Command_rd.java
2014-10-25 14:20:53 -04:00
3c329667a4 Fixed spelling mistake in Command_rd.java 2014-10-25 19:08:44 +01:00
1565c9643d Merge branch 'Obi2kanobi-master' 2014-10-01 13:22:10 -04:00
84ef49bf65 Tweak whitespace, change description. 2014-10-01 13:21:52 -04:00
878075c898 Merge branch 'master' of https://github.com/Obi2kanobi/TotalFreedomMod into Obi2kanobi-master 2014-10-01 13:18:09 -04:00
c74763c96a Adjust filename filter for schematic manager. 2014-09-28 18:24:48 -04:00
d01f9d0b2f Smite players with /stfu -s. Fixes #325. 2014-09-28 22:14:52 +01:00
e780c4ffec Change to v1_7_R4 for Spigot's pseudo-1.8 support. 2014-09-24 18:37:12 -04:00
3968dbe0a2 Merge pull request #316 from KingDragonRider/master
Blocked /size and //mask. Resolves #316
2014-09-23 21:23:49 +02:00
ff9164714c Restructured /saconfig. Resolves #322. Resolves #303. 2014-09-19 19:59:29 -04:00
72e105eb34 Added extra blocked commands used to bypass //brush
I've added commands which enable //brush even though it is blocked (/size and //mask) to the blocked commands list (for superadmins only).
2014-09-13 17:16:55 +01:00
f4440fd262 Merge pull request #310 from ItzLevvie/patch-1
Blocked "/setidletimeout" in config.yml
2014-09-13 17:49:56 +02:00
587b84a489 Blocked "/setidletimeout" in Config
Closes https://github.com/TotalFreedom/TotalFreedomMod/issues/307
2014-09-03 17:15:38 +01:00
107952f0ba Modified /ro to not affect adminworld. 2014-08-30 15:18:45 -04:00
8cae042857 Don't write spoofed UUIDs to cache 2014-08-30 16:24:35 +02:00
d1b73592af Compatibility with old builds of WorldEdit. 2014-08-27 20:53:43 -04:00
b7175d73ab Fixed AIOOBE in /rollback 2014-08-27 13:30:46 +02:00
9c976b381b Added TFM_UuidManager to cache UUIDs. Resolves #255
All methods related to UUIDs in TFM_Util have been moved to TFM_UuidManager
2014-08-27 11:42:49 +02:00
0c99862793 Perform backups in a seperate folder
Perform weekly backups on config.yml
Minor refractoring
2014-08-27 10:58:26 +02:00
0240b65fad Save and remove player entries on leave
Removed timer for player loading, applied to plugin instead
2014-08-27 00:28:44 +02:00
b6d3e5baca Merged with master 2014-08-26 18:25:27 +02:00
15650b84cf Fixed duplicate ban entries
Bans are equal when:
a) The ban-type matches
b) The ban-subject matches
Small changes
2014-08-26 18:23:48 +02:00
9233bcfedc Added some getters for TFM_Announcer 2014-08-25 20:05:10 +02:00
b0aa4a850d Added Announcer. Resolves #226
Organised onEnable()
Formatting
2014-08-25 20:01:54 +02:00
af97481d11 Return false on incorrect args in Command_rollback. Fixes #296 2014-08-25 18:47:29 +02:00
3c6e706c98 Merged with master 2014-08-25 14:07:47 +02:00
aca62caec1 Revamped TFM_BanManager, TFM_Ban and TFM_ServerInterface
Better ban type checking
Moved ban reason compilation to TFM_Ban
TFM_ServerInterface: Less expensive operations first
Command_rollback now polls TFM_RollbackManager for available players
2014-08-25 13:57:13 +02:00
eaa23985bd Merge pull request #294 from Obi2kanobi/contributing
Format GTFO reason broadcast. Fixes #293
2014-08-24 11:21:24 +01:00
e3f9452b9f Fix GTFO broadcast formatting. Fixes #293 2014-08-24 00:30:56 +01:00
755080d0a4 Code refactoring and cleanup. 2014-08-23 14:19:25 -04:00
0f764b976b Tweak /cake. Fixes #295. 2014-08-23 13:52:26 -04:00
d0a435a5d6 Added preliminary TFM support for TelnetRequestDataTagsEvent. 2014-08-20 21:23:22 -04:00
b02764ddca lang.StringUtils -> lang3.StringUtils
Remove bold from /nickclean.
2014-08-18 16:48:52 -04:00
b3c28d33f2 Fixed broken format for /gadmin ipban. 2014-08-15 22:53:57 -04:00
6ad1187eef Merge branch 'patch-2' 2014-08-15 16:29:53 -04:00
1bf1267b49 Remove extra lines. 2014-08-15 16:29:40 -04:00
d2f6f7f51a Make '/tfm reload' update blocked commands. Resolves #265.
Config must be reloaded in order to pull in any changes to blocked commands list.
2014-08-15 16:16:45 -04:00
dc2c996516 Block tags containing "console", fixes #260. 2014-08-15 15:59:43 -04:00
f502e44764 Added /nickclean - mass remove distracting things from player nicknames. 2014-08-14 19:07:52 -04:00
c490a3d62e Now made qdeop require you to be op else it wont try to deop the player. 2014-08-14 22:37:20 +01:00
9a2dc52e87 Using qop should now only op those who are not op.
This will further reduce the amount of spam and doesn't spam everyone with "you are now op".
2014-08-14 22:32:45 +01:00
a1c11f4e0f Using playerMsg(final String message) instead of playerMsg(final CommandSender sender, final String message) when possible. 2014-08-14 15:49:48 -04:00
48fd4c590d Use TFM_Command.playerMsg instead of TFM_Util.playerMsg for commands. 2014-08-13 20:56:04 -04:00
97cde0cfd4 Modified /qop and /qdeop to be a bit less spammy when multiple matches are found. 2014-08-13 20:11:12 -04:00
429269d8d2 Partial fix for #267.
Still need to implement method to kick people off telnet if they are deactivated while connected.

Also - 800th commit! Woohoo!
2014-08-12 19:38:32 -04:00
1a50c16d9a Rework tags (now they won't duplicate when Essentials changes display name). 2014-08-12 18:25:57 -04:00
891d8d178f Use commons' substring function to avoid IndexOutOfBoundsExceptions. 2014-08-12 15:32:56 -04:00
fc1c487dce Woops 2014-08-09 18:53:54 +02:00
e2cc14370a Added /forestgen to blocked commands 2014-08-09 18:13:15 +02:00
d5d6f18fb4 Truncate string argument on calls calls to setPlayerListName. Resolves #262. 2014-08-07 20:47:15 -04:00
00e22dc56e Formatting fix for CONTRIBUTING.md 2014-08-02 21:58:57 +02:00
40b475ea0c Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2014-08-02 21:55:03 +02:00
65eabbdba4 Added links 2014-08-02 21:54:18 +02:00
cb4a47d812 Made some changes to CONTRIBUTING.md 2014-08-02 21:45:57 +02:00
ecbd70493b Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2014-08-02 11:14:55 -04:00
4988140268 Fixed mixed string concatenation / String.format usage.
Doesn't make much sense to use string concatenation and a String.format to generate the same output. I believe this method is much more readable.
2014-08-02 11:14:37 -04:00
57b0aadb9b Added some comments regarding the license 2014-08-02 17:10:54 +02:00
ef9ce2a9a7 [Bleeding] First compile of new playerdata system. Resolves #223
The new TFM_PlayerList stores player under /players/[uuid].yml and only caches online players. When players log in, their playerdata will be loaded.
2014-08-02 16:27:43 +02:00
2c92b0874e Merge pull request #253 from PacksGamingHD/patch-2
Fixed compile error.
2014-08-02 14:05:20 +02:00
927560ad75 TotalFreedomMod won't compile like that. 2014-08-01 23:01:04 -07:00
c8dbc8a623 Merge pull request #251 from LevnettUKRonit/patch-2
Add ban reason to /gtfo
2014-08-01 17:58:10 +02:00
11eef83a65 Fixed the ban reason on the same line as the actual ban
Resolves https://github.com/TotalFreedom/TotalFreedomMod/pull/250
2014-08-01 15:39:07 +01:00
a2439a7093 Merge pull request #249 from LevnettUKRonit/patch-1
Update config.yml
2014-07-30 14:12:07 +01:00
d8697590a7 Update config.yml
Closes https://github.com/TotalFreedom/TotalFreedomMod/issues/233
2014-07-30 14:07:31 +01:00
6d98604cf0 Update config.yml 2014-07-30 09:27:21 +01:00
3d6be1cd51 Significantly speed up player list loading. 2014-07-29 22:38:08 -04:00
01edfed307 Tweak /whohas. Note the change from bitwise & to logical && resolving possible bug. 2014-07-26 11:48:17 -04:00
5e4d1d0d6d Limit duration and amplifier for /potion command. Resolves #243 2014-07-26 11:47:23 -04:00
86f61f1487 Restructure gadmin. Resolves #245 2014-07-25 23:11:44 -04:00
461cfa7bdc Switched from Essentials' StringUtil to Apache Commons StringUtils. 2014-07-20 17:40:06 -04:00
75b296496e Removed DisguiseCraft support. 2014-07-20 17:25:45 -04:00
183277db21 Clean up sources of compile warnings.
Move anything that causes deprecation warnings into TFM_DepreciationAggregator if no alternative implementation possible.
2014-07-19 21:02:00 -04:00
2b597867f0 Eliminate usage of deprecated org.bukkit.Server.matchPlayer
Suppress unchecked cast warnings in Module_players.
2014-07-19 17:39:42 -04:00
7f7312c0a2 Fix landmine. 2014-07-19 17:34:12 -04:00
73214165a5 Fix glitch in clownfish smacker. 2014-07-19 15:29:07 -04:00
54be4f7e88 Added clownfish smacker. 2014-07-19 14:59:02 -04:00
3ccab5f534 Fixed exploit that allows command blocker to be bypassed. 2014-07-17 17:28:32 -04:00
f635af5f95 Fix error when using /ops purge. 2014-07-16 20:41:14 -04:00
cc3a183cac Fixed toggle message for /toggle fluidspread. 2014-07-13 22:43:27 -04:00
173b686658 Add HTTPD Module_logs, resolves #238 2014-07-13 18:04:08 -04:00
a0d5743232 Ensure UUID is never null at login. Amends #214 and fixes #229 2014-06-30 19:09:26 +02:00
7598d211cd Correctly display permban URL. Fixes #228 2014-06-30 17:51:13 +02:00
6b064d0e68 Correctly reference static members in TFM_Jumppads. Fixes #225 2014-06-30 17:35:58 +02:00
8fc0673bb2 /tfm: Return true when the player doesn't have permission. Fixes #227 2014-06-30 17:30:16 +02:00
aa062a9d11 Ensure UUID is never null for non-existing players
Currently, the player's name is SHA-1'ed and the first 32 hexadecimal
characters are formed into a 'spoofed UUID'. I think this is the best solution
2014-06-29 16:40:53 +02:00
8b4b2f97e0 Finished TFM_UuidResolver and /uuid. Resolves #214 2014-06-29 12:09:03 +02:00
c4f1d0c06f Merge from master 2014-06-29 10:53:39 +02:00
20d4e886fc Merge from bleeding 2014-06-28 22:31:33 +02:00
e36ace1671 [Bleeding] Started work on TFM_UuidFetcher 2014-06-28 22:24:36 +02:00
2f055fbecb /gadmin: return false if required args are not present. Resolves #220 2014-06-28 12:00:16 +02:00
d193686c79 Block //snow. Resolves #217 2014-06-28 11:50:15 +02:00
ba2ada569f [Bleeding] Fixed permissions through console. Resolves #195 2014-06-28 11:43:05 +02:00
850fd9aa4a [Bleeding] Save when purging (ip)ban list. Resolves #219
Small changes
2014-06-28 00:22:55 +02:00
1fb14ca1dd Added /list -a. Resolves #194 2014-06-22 18:07:02 +02:00
499472a126 Remove adminworld guests properly. Fixes #202 2014-06-22 17:53:50 +02:00
28459e4702 Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2014-06-22 17:13:30 +02:00
57dda8367c Merge branch 'Wilee999-patch-3' 2014-06-22 17:12:56 +02:00
cdf03b4353 Perform suggested changes. Fixes #184 2014-06-22 17:12:30 +02:00
5ec66e8c7e Merge branch 'patch-3' of https://github.com/Wilee999/TotalFreedomMod into Wilee999-patch-3 2014-06-22 17:06:54 +02:00
f57aeb8fb0 Merge pull request #210 from WickedGamingUK/patch-1
Java Code Conventions
2014-06-22 16:58:46 +02:00
adb3834836 Don't double toggle in /toggle. Fixes #193 2014-06-22 16:56:02 +02:00
d82d6fd704 Updated latest WorldEdit methods 2014-06-22 16:50:57 +02:00
ec0683f610 Java Code Conventions 2014-06-18 16:36:52 +01:00
2d118a44a9 Removed xXWilee99Xx from the developer list 2014-06-16 15:50:16 +02:00
64cd7f7393 Merge pull request #204 from LevnettUKRonit/patch-4
Added aliases /gmc to /creative
2014-06-10 16:42:13 +02:00
9a1fc8ea36 Merge pull request #205 from LevnettUKRonit/patch-5
Added alias /gms to /survival
2014-06-10 16:41:38 +02:00
75247af337 Added aliases /gms 2014-06-09 17:48:57 +01:00
d20b062b70 Added aliases /gmc 2014-06-09 17:25:31 +01:00
4b36574255 Merge pull request #199 from LevnettUKRonit/patch-3
Changed /tag remove to /tag off to match usage.
2014-06-08 10:47:11 +02:00
bba42797d8 Changed /tag remove to /tag off to match usage. 2014-05-29 17:22:28 +01:00
365e38e63a Merge pull request #196 from LevnettUKRonit/patch-1
Telnet Admin should be dark green. Fixes #192.
2014-05-28 17:05:50 +02:00
5a3106ace8 Fixed TFM_PlayerListener.java
Fixed where it said Telnet Admin was light green its now ChatColor.DARK_GREEN
2014-05-28 09:53:23 +01:00
8cb4ef111c Rename /saconfig clear to /saconfig clearme. Closes #189 2014-05-19 19:46:40 +02:00
50d6cf471c Incremented version number for development towards next release 2014-05-19 19:33:18 +02:00
e942f0bf75 Removed most singleton patterns. Resolves #181 2014-05-19 19:32:25 +02:00
f8231aeb3f Stable release v4.2 2014-05-19 14:25:04 +02:00
eddbcf515c Allow customization of Owners. Appends to #178 and commit 67c86aea 2014-05-19 14:21:37 +02:00
00ac914066 Unban fuzzy IPs for admins. Fixes #187 2014-05-16 15:39:40 +02:00
179fe9d665 Organise TFM_ConfigEntry values by type 2014-05-16 15:30:02 +02:00
67c86aea24 Added config values for MOTD, server name and address. Resolves #178 2014-05-16 15:18:24 +02:00
e4bb1ef6aa Auto-freeze on imposter login; adds: http://www.totalfreedom.boards.net/thread/12123 2014-05-15 18:57:34 -07:00
16b02e3dec Changed /saconfig remove to /saconfig delete to match usage. Fixes #183 2014-05-14 16:22:56 +02:00
70e248202b Increment version number to 4.2 2014-05-13 17:56:21 +02:00
51ef752259 Don't warn when finding unknown services in ServiceChecker 2014-05-13 17:18:08 +02:00
b3e40462e2 Preload player when logging in. Fixes #182 2014-05-13 17:11:32 +02:00
73a91c02c6 Re-implement unbannable usernames. Resolves #180 2014-05-13 17:01:55 +02:00
7b8ba0bdf5 Revamp /plugincontrol. Fixes #159 2014-05-13 16:32:01 +02:00
bd9d6114ba Add /wipeuserdata. Resolves #177 2014-05-11 19:04:01 +02:00
0435174342 Perform daily and weekly backups. Resolves #163 2014-05-11 18:41:58 +02:00
796ef3d359 Refractored .createBackup() to TFM_Util.createBackup(String) 2014-05-11 18:15:04 +02:00
a3f3903760 Increase default nuking block place threshold. Resolves #169 2014-05-11 18:05:51 +02:00
5c99aa9a44 Merge pull request #176 from Wild1145/patch-1
Removed Legacy Login
2014-05-11 17:54:22 +02:00
8292eb20ae Removed Legacy Login
Due to HeartBleed Mojang had to disable the legacy login servers. They will always show as "Offline" so may as well just remove them.
2014-05-11 12:56:01 +02:00
d9e0791a3b Merge pull request #175 from Wild1145/master
Added Telent check along with Auto Prefix and Auto color tab
2014-05-10 23:44:39 +02:00
dbfec1e86d Added Color Tabs and Auto Prefixes. Resolves #173 2014-05-10 22:42:37 +01:00
31e03d6348 Added a telnet checker. 2014-05-10 22:40:32 +01:00
46494a2c87 Reset 2014-05-10 22:40:19 +01:00
b11eb0f762 Added in both player tab colours, Auto Prefixes and a telnet checker 2014-05-10 22:35:45 +01:00
730b0e2c83 Merge with master 2014-05-07 12:53:05 +02:00
60a9de7e7c [Bleeding] Allow spaces in tags. Resolves #160 2014-05-05 16:25:57 +02:00
8a4fa946fd Make /doom ban all IPs
Before, /doom would only ban the current IP
2014-05-05 16:10:14 +02:00
9bc0859fdf Added /tagnyan. Resolves #170 2014-05-05 16:03:30 +02:00
742450d016 Convert stop/remove to string literals. Resolves #168
Removed TFM_Util.isStopCommand(String) and TFM_Util.isRemoveCommand(String)
2014-05-05 15:31:12 +02:00
ad06bea3ae Fixed bugs with /saconfig clear. Resolves #167
Admins can now use /saconfig clear [ip] to remove the designated IP (only their own IPs can be removed. They can also simply use /saconfig clear to remove all IPs but the current one. /saconfig clear is safe, meaning you can't remove your current IP or an IP that doesn't belong to you.
2014-05-05 14:27:33 +02:00
68d83fa397 Allow admins to remove their own IPs 2014-05-05 14:10:32 +02:00
fe84c3a2a0 Removed Command_listsync. Resolves #166
@markbyrn wants it removed. It also didn't have much of a use, associated servers wouldn't use it since it overwrites the current superadmin and permban config.
2014-05-05 13:35:47 +02:00
6e5e70ac90 [Bleeding] A little more config tweaking 2014-05-05 13:30:17 +02:00
489549a0ea Warn when NMS versions don't match. Resolves #165 2014-05-05 00:01:57 +02:00
56b55eb3e2 [Bleeding] Fixed last errors due to misconfigured config 2014-05-04 23:07:26 +02:00
4ef5f59fb9 [Bleeding] Fixed startup error due to misconfigured config 2014-05-04 23:03:34 +02:00
d31ad2e9fc [Bleeding] Remove player online check through PlayerNotFoundException
getPlayer(String) now returns null when the player could not be found
2014-04-26 13:55:24 +02:00
8a9dfca6d3 [Bleeding] Config refractoring 2014-04-26 13:21:36 +02:00
55ddf5a30a Merge branch 'master' into bleeding 2014-04-25 17:36:08 +02:00
59e890c654 Added more startup statistics 2014-04-25 17:26:10 +02:00
b0e62add9f Reupdate index lists when adding an admin. Fixes #156 2014-04-25 17:10:43 +02:00
7cdf1abcf2 [Bleeding] Fix invalid characters in usernames 2014-04-23 19:30:11 +02:00
ee0ebd85fc Increment to version 4.1 to reflect latest changes 2014-04-23 17:03:33 +02:00
518537413b Allow use of multiple blocks in /ro. Closes #87 2014-04-23 17:00:44 +02:00
802d02d653 Shoot players in the sky when using /doom. Closes #142 2014-04-23 16:43:12 +02:00
f3cb57c9cd Extend command rollback time. Closes #136
Addresses http://www.totalfreedom.boards.net/thread/9531/problem-suggestion
2014-04-23 16:38:47 +02:00
c7c2795f41 Tweaked /ops and /qop 2014-04-23 16:36:11 +02:00
20b117a703 Moved toggle commands (/firespread, /lavadmg, etc) to /toggle 2014-04-23 16:23:50 +02:00
8522570db5 Move license to separate project 2014-04-22 23:19:40 +02:00
08e4a4a171 Moved permban list to a seperate class
Refractoring
Code cleanup
2014-04-21 23:09:10 +02:00
a0affddeed Refractored command handling to seperate class: TFM_CommandHandler
Cleanup, refractoring
2014-04-21 19:00:39 +02:00
c82113dc22 Fixed duplicate entries when adding/removing players
Some refractoring
2014-04-21 17:45:32 +02:00
9315227906 Actually make the default console senior permissions configurable 2014-04-21 15:08:52 +02:00
00e9b4ea1f [Bleeding] Cleaned up TFM_Command.senderHasPermission() 2014-04-21 14:56:24 +02:00
22b0781020 Allow the default CONSOLE to have senior permissions 2014-04-21 14:52:23 +02:00
7df24c6b86 Added more detailed build information to /tfm through appinfo.properties 2014-04-21 14:37:53 +02:00
0e9044ffc3 Allow compiling for Spigot 1.7.8 2014-04-17 18:29:08 +02:00
3371f54c06 Merged from master 2014-04-15 16:43:38 +02:00
5e4649a4d0 Incremented version to 4.0
List of changes:
- Switched over to UUID-based configs
- Revamped TFM_AdminList
- New banning system: TFM_BanList
- Refractoring
- Updated to CraftBukkit-1.7.8-R0.1
- Added BukkitTelnet, WorldEdit and Essentials as soft dependencies
2014-04-15 16:35:41 +02:00
d8560ebc1f [Dry] (Hopefully) fixed the latest bugs
Added superadmin.yml conversion
2014-04-15 16:25:48 +02:00
7f2e72ee51 [Bleeding] Fixed bugs with TFM_PlayerList and TFM_BanManager 2014-04-15 15:43:07 +02:00
c98909df12 [Bleeding] Added BukkitTelnet as a soft dependency 2014-04-14 21:17:49 +02:00
d613e0266b [Bleeding] First compile of new banning system
Updated to CraftBukkit 1.7.8-R0.1
2014-04-14 21:11:41 +02:00
92d7c58957 Merge pull request #148 from Wilee999/patch-5
Fix /invis smite bug where it spammed the smite message each player.
2014-04-13 00:56:57 +02:00
478244773b Fix /invis smite bug where it spammed the smite message each player. 2014-04-11 17:57:11 -07:00
5237fa0ca2 [Bleeding] Major refractoring
Added TFM_Config as a base config class for TFM_AdminList and TFM_PlayerList
Finished up UUID based Superadmins
2014-04-11 17:24:44 +02:00
b3b182e753 Merge pull request #141 from Wilee999/patch-5
Implement /tfipbanlist purge adminAction.
2014-04-09 23:10:48 +02:00
a54c113a86 [Bleeding] Switched to UUIDs in TFM_AdminList
Various other changes
2014-04-09 22:33:03 +02:00
ec8a528564 [Bleeding] Working on TFM_Admin 2014-04-09 21:29:27 +02:00
6365672eda [Bleeding] Started work on TFM_PlayerList
Added UUIDFetcher
2014-04-04 16:48:39 +02:00
d087dc1148 [Bleeding] Prepared TFM_UserList for UUID switchover 2014-04-04 14:03:48 +02:00
a3a484dc58 Updated to CraftBukkit v1.7-R2 2014-04-04 13:45:35 +02:00
b89ccb2d55 Fixed duplicate messages in console and telnet 2014-04-04 13:37:45 +02:00
9b66304f63 Merged with BukkitTelnet 2014-04-03 19:23:29 +02:00
4784348027 Merge branch 'bukkittelnet' 2014-04-03 19:20:03 +02:00
2705bb4534 Merge pull request #146 from Wilee999/patch-8
Update TotalFreedomMod to Minecraft 1.7.5.
2014-03-26 11:22:33 +01:00
0f6f21e4c6 Update TotalFreedomMod to Minecraft 1.7.5. 2014-03-25 20:25:06 -07:00
527ac6c286 Merge pull request #138 from kwteh/master
The Lie.
2014-03-22 22:09:16 +01:00
192b9ea9d9 YThere 2014-03-22 11:25:32 +08:00
fa1a082972 Updated to lastest BukkitTelnet API 2014-03-21 11:39:34 +01:00
cf135e211d Incremented version number to reflect latest changes 2014-03-18 16:18:04 +01:00
56a5a7304a Blocked /gcmd from bypasing the command blocker 2014-03-18 16:17:00 +01:00
4b671cc4c7 Block plugin-specific commands for 1.7.2-R0.3 2014-03-18 16:07:51 +01:00
10443ff0d5 Merge pull request #139 from Wilee999/patch-4
Improve /invis smite.
2014-03-18 15:39:26 +01:00
5f1f9184ae Merge pull request #145 from Wilee999/patch-7
Added dantdm to famous users in config.
2014-03-18 15:38:05 +01:00
a1bb6a34a0 added dantdm to famous user config 2014-03-16 20:42:14 -07:00
dfd5f2dba0 Merge pull request #143 from Wilee999/patch-7
added a couple stampy users to the famous config
2014-03-08 16:09:43 +01:00
988e62213e added a couple stampy users to the famous config 2014-03-06 14:02:01 -08:00
49601035a5 Implement /tfipbanlist purge adminAction. 2014-03-02 18:02:10 -08:00
d05f8b7169 Merge pull request #140 from Wilee999/patch-5
Changed to raw logger output on join/quit messages.
2014-02-19 14:33:50 -05:00
fbca5f0527 Raw... 2014-02-19 11:28:09 -08:00
1c14889bdf Prefix player join/exit. 2014-02-19 10:10:29 -08:00
114372194a Should be using the regular Bukkit logger for this. 2014-02-19 10:01:02 -08:00
49b841acc2 Improve /invis smite. 2014-02-16 10:02:21 -08:00
302b538a3a Oops...
the best i can came up with
2014-02-15 20:44:20 +08:00
539f28549a The Lie. 2014-02-14 13:54:30 +08:00
716ba57739 Merge pull request #122 from Wilee999/pull5
Changed global freeze message
2014-02-06 15:46:31 +01:00
0d32ca5451 Merge pull request #132 from Wilee999/pull3
Fix command error in /wildcard.
2014-01-31 11:06:47 -08:00
b8b8ed8608 Fix command error in /wildcard. 2014-01-31 10:05:40 -08:00
ca5b79331b Merge pull request #131 from Wilee999/pull3
Remove /ops purge
2014-01-29 23:49:45 -08:00
78c1a2eaaf Remove /ops purge. 2014-01-29 15:57:33 -08:00
be4ec7fc04 Small license update 2014-01-26 22:06:00 +01:00
794ad2e57a Merge pull request #129 from WickedGamingUK/patch-1
Changed HeXeRei452 to WickedGamingUK
2014-01-19 05:25:59 -08:00
d2a5c399f0 Changed HeXeRei452 to WickedGamingUK
The purpose of this is to reflect my primary account's username.
2014-01-19 09:00:45 +00:00
67d8bfce09 Merge pull request #128 from ImALuckyGuy/patch-2
Log IP addresses in join messages.
2014-01-18 06:30:01 -08:00
90aa3ab420 Adding colon
:
2014-01-17 06:32:23 -06:00
a395904c43 Log IP addresses in join messages.
This will make finding a player's IP address after a crash much easier.
2014-01-15 18:45:18 -06:00
42812be4c5 there 2014-01-15 13:45:28 -08:00
049432789f Now make it actually work... 2014-01-15 13:38:35 -08:00
8b2532e9e9 Re-thinking this. 2014-01-15 09:51:07 -08:00
e5902fc5e8 Incremented version number to reflect latest changes 2014-01-14 20:43:31 +01:00
71862d6e41 Batch format 2014-01-14 20:37:08 +01:00
7dffea0ba2 Merge pull request #115 from Wilee999/pull1
Strike lightning on /tempban
2014-01-14 11:28:52 -08:00
67c09546f7 Merge pull request #120 from Wild1145/patch-10
Changed from "Permbanned" in auto eject
2014-01-14 11:28:19 -08:00
8b51fd215f Merge pull request #116 from Wilee999/pull2
Strike lightning on /tban
2014-01-14 11:26:55 -08:00
275204fb2e Merge pull request #124 from Wilee999/pull7
Add picture to CONTRIBUTING.md
2014-01-14 11:26:02 -08:00
1330d2b3af Merge pull request #118 from Wilee999/pull3
Log player joins and player leaves for telnet
2014-01-14 11:22:10 -08:00
4204210f66 Merge pull request #126 from Wilee999/pull4
Remove /nuke from the config.yml
2014-01-14 11:21:08 -08:00
8297d03a86 Best not to have this. 2014-01-12 19:24:15 -08:00
75353ae4b1 oops 2014-01-09 15:10:31 -08:00
a28959db0e Add picture to CONTRIBUTING.md. 2014-01-09 15:09:01 -08:00
b2e27ec8bf Changed global freeze message to prevent whining
players. Addresses http://www.totalfreedom.boards.net/post/86571.
2014-01-08 16:34:57 -08:00
c42bc23bfe Changed from "Permbanned" in auto eject
As it doesnt actualy permban you, i have changed it so it doesnt say you have been.
2014-01-07 16:47:02 +00:00
e29d4673dd Log player logins and exits.
Because 1.7 will not log player logins and exits, TotalFreedomMod will have to do this instead.
2014-01-02 23:46:20 -08:00
2ce7e518fb Strike lightning on tban/noob. 2013-12-22 14:20:31 -08:00
9ba316464e Strike lightning on tempban. 2013-12-22 14:19:25 -08:00
60f71c9dfc Filter duplicate Telnet admin names 2013-12-18 18:44:21 +01:00
3e71286507 Added Access-Control-Allow-Origin to the players HTTPD module 2013-12-18 14:45:59 +01:00
6d48c90d16 Added HTTPD module: list 2013-12-18 14:12:15 +01:00
d7ed667b89 Log player messages 2013-12-17 17:33:17 +01:00
9c61cc2768 Switched over to TelnetCommandEvent
some TFM_CommandBlocker cleanup
2013-12-17 16:29:48 +01:00
4daad76e74 600th Commit, WOO!
Incremented version to reflect latest changes
2013-12-17 15:18:11 +01:00
05884ae806 Case-sensitive Telnet login names 2013-12-17 15:16:32 +01:00
aa0fd34859 Append to log files
Set maximum of 1Gig
2013-12-15 23:12:30 +01:00
2c14773c9b Generate logs in /server.log like CraftBukkit did 2013-12-07 10:58:29 +01:00
695168ebfe Merge pull request #112 from Wilee999/pull1
Fixed developer login message
2013-12-07 01:08:29 -08:00
bbc1255963 Fixed developer login message. 2013-12-06 23:37:56 -08:00
34d15d4c96 Fixed a neophyte bug
Custom login messages would be the same for anyone who logs in after the player with the same rank
2013-12-03 20:50:20 +01:00
75bc17cd8f Merge pull request #109 from Wilee999/pull1
Modified ban messages
2013-12-03 07:42:28 -08:00
87f338194c Removed "for a while" 2013-12-03 07:41:43 -08:00
b5760afbad Fixed. 2013-12-03 07:35:47 -08:00
5cfaf8970d Fixed all deprecated methods 2013-12-03 16:21:58 +01:00
9a48ec04aa Fixed developers not having the correct prefix
batch format
2013-12-03 14:24:09 +01:00
24fca9af97 Woops 2013-12-03 14:13:36 +01:00
a9ef738602 Merged from master 2013-12-03 14:05:59 +01:00
27a04635a2 Migrated /list-, AdminChat- and Login message-colors to TFM_PlayerRank
Reverted colors due to popular request
2013-12-03 14:05:06 +01:00
0f58746525 Modified the 2 ban messages. 2013-12-02 15:43:42 -08:00
a8d4b5f582 Merge pull request #108 from Wilee999/pull1
Developer login message
2013-12-01 10:57:49 -08:00
d7f1de4cb7 oops 2013-12-01 10:39:43 -08:00
ddbb6228f1 Added dev login message. (try 2) 2013-12-01 10:38:13 -08:00
d4c3a4ad45 Woops 2013-12-01 19:02:30 +01:00
7140e4c8df Changed colors to match the forums 2013-12-01 18:54:50 +01:00
808e02f660 Fixed potential mass-kick
This would happen if an admin joins the game when the server is full
2013-12-01 18:21:43 +01:00
bed78248fb Fixed /list for 1.7
for some weird reason, that ChatColor.WHITE was causing issues
2013-12-01 17:32:29 +01:00
ee39e89093 Fixed possible NPE in getPrefix() 2013-12-01 15:22:19 +01:00
9405604efc Fix imports 2013-12-01 13:42:13 +01:00
73acb2448b Force-allow superadmins to log in
Commented and cleaned up handlePlayerLogin()
2013-12-01 13:33:39 +01:00
c63540129f Cleaned up /list 2013-12-01 13:00:02 +01:00
6ba96b427d Update to CraftBukkit 1.7 2013-12-01 12:13:39 +01:00
acd8373f81 Fixed NPE in /list 2013-12-01 11:55:50 +01:00
0c4c36b2bd Merge pull request #103 from Wilee999/master
Fixed my name
2013-11-30 11:59:50 -08:00
7ce052900e Rewrote ServiceChecker, fixed NPE there
Formatting
2013-11-30 20:44:08 +01:00
f8741b0d4f Noooo dartheh!!!!
omg how offenciv
2013-11-30 10:52:40 -08:00
6fca19fa41 Load plugin version through plugin.yml 2013-11-30 18:04:43 +01:00
7e75287e61 Added xXWilee99Xx to developers
updated to version 3.3 to reflect latest changes
2013-11-30 16:32:00 +01:00
52641466ff Merge pull request #101 from Wilee999/pull2
Added all the Telnet Admin stuff.
2013-11-28 12:39:44 -08:00
67f096fbfa Added all the Telnet Admin stuff. 2013-11-27 09:21:53 -08:00
8f24e44c79 Merge pull request #100 from Wilee999/pull1
Blocked /mat command.
2013-11-24 14:52:04 -08:00
28b9f3089d Blocked /mat command. 2013-11-23 11:03:33 -08:00
6b906864b3 Merge pull request #99 from Wilee999/pull4
Added cmdspy alias "commandspy"
2013-11-18 02:04:34 -08:00
c2aba0e798 Added cmdspy alias "commandspy" 2013-11-16 23:44:37 -08:00
c78e6483ac Merge pull request #93 from Wilee999/pull4
Changed clanforge restart message to "come back in about 20 seconds." li...
2013-11-12 07:24:26 -08:00
1ef6fcbb70 Merge pull request #95 from Wilee999/pull3
Added new unbannable usernames.
2013-11-12 07:23:58 -08:00
ce5d23a5bc Added new unbannable usernames. 2013-11-11 12:38:39 -08:00
280ddf61f7 Changed clanforge restart message to "come back in about 20 seconds." like /stop. 2013-11-10 14:27:49 -08:00
a821f7b606 Updated PermBan Link 2013-10-27 15:33:26 +01:00
1a5f854552 Implemented Essentials-based AFK Auto-Kick w/ server load based trigger threshold. 2013-10-08 14:41:05 -04:00
a38f7b3469 Small change to the license 2013-09-29 20:52:07 +02:00
13eeccbc40 Add handling for isTelnetAdmin to SA list saving. 2013-09-27 11:15:15 -04:00
2b611a2bee Add "is_telnet_admin:" entries to sample superadmin.yml 2013-09-27 11:06:52 -04:00
ed0aef033c Clean up TFM_CustomListener. 2013-09-27 11:04:46 -04:00
2d655e4009 Added "isTelnetAdmin" to SA list. 2013-09-27 11:01:30 -04:00
81995f38a1 Add handler for me.StevenLawson.BukkitTelnet.TelnetPreLoginEvent 2013-09-27 10:26:59 -04:00
9f889efa76 -Make /saconfig clean a "Telnet Senior" command only.
-Move some TwitterBot stuff around.
2013-09-27 08:46:42 -04:00
1e79b90249 Tweak Wilee999's /cage changes. 2013-09-25 20:46:03 -04:00
70a24486b8 Merge branch 'pull2' of https://github.com/Wilee999/TotalFreedomMod 2013-09-25 20:39:46 -04:00
d863a9e274 Merge pull request #85 from Wilee999/pull1
Change gadmin usage to contain fr
2013-09-25 17:37:42 -07:00
902fc0ba11 That's not what I wanted... 2013-09-25 17:34:16 -07:00
415d25da4b Added /cage purge command 2013-09-25 17:33:44 -07:00
3583c1dbdc Change gadmin usage to contain fr 2013-09-25 17:05:52 -07:00
f49c4568b2 Tweaks to essentials interface commands. 2013-09-24 20:32:04 -04:00
01807d1f0f Added Essentials interface.
Moved nick customization commands from Essentials to TFM.
2013-09-24 10:13:38 -04:00
c5ddc60b97 Cleaned up TFM_Util 2013-09-24 08:05:48 -04:00
97b27cd7b4 Change tag character limit.
Now max = 20 characters, not including color codes.
TFM_Util.colorise() -> TFM_Util.colorize()
2013-09-21 13:58:16 -04:00
faeaa3aab7 Update for MC v1.6.4
Other minor fixes
2013-09-21 13:51:09 -04:00
e10ab45bda Update NanoHTTPd to 12b4973a52 2013-09-17 21:31:46 -04:00
7b59350833 Tweak Wilee's changes to /onlinemode. 2013-09-17 12:05:53 -04:00
adbc658cc7 All telnets can now use /onlinemode! Yay! 2013-09-17 07:57:15 -07:00
927e46a431 Revert "Wrapped rollback with a Callable to make sure that it executes on the Bukkit thread."
This reverts commit 65ba053aee.
2013-09-15 20:38:54 -04:00
65ba053aee Wrapped rollback with a Callable to make sure that it executes on the Bukkit thread.
Saw this in a log:

java.util.ConcurrentModificationException
	at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
	at java.util.ArrayList$Itr.next(ArrayList.java:791)
	at me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.rollback(TFM_RollbackManager.java:94)
	at me.StevenLawson.TotalFreedomMod.Commands.Command_gtfo.run(Command_gtfo.java:51)
2013-09-15 14:11:36 -04:00
81ee5f04dd Register permbans module (whoops). 2013-09-14 22:15:30 -04:00
ded31e4640 Add /cbtool and /setlever, commands geared toward Command Blocks. 2013-09-14 22:00:11 -04:00
1416429910 Add permbans module for HTTPd. 2013-09-14 21:59:11 -04:00
8cdff6a3c1 Rework /expel command.
Move TFM_LandmineData out of main package.
2013-09-13 22:13:07 -04:00
8ba477140b Added /localspawn - Teleport to the spawnpoint for the current world instead of the global spawnpoint. 2013-09-13 14:57:33 -04:00
5606fdae1f Added more blocked commands
Added quotes to support double-slashes
2013-09-13 16:35:05 +02:00
4bcd0eb61f Changed project vendor to TotalFreedom 2013-09-13 15:54:00 +02:00
18e4943216 Finish /config command.
Fix typo: ALLOW_FLIUD_SPREAD -> ALLOW_FLUID_SPREAD
2013-09-07 22:51:12 -04:00
549c5231e8 Added /config command. 2013-09-07 22:10:05 -04:00
7144894848 Enable /saconfig clean for all telnet users. 2013-09-07 21:16:35 -04:00
fef5f7604b Nitpicking. 2013-09-05 10:48:57 -04:00
2d421178db This doesn't need to be Serializable anymore. 2013-09-05 10:33:06 -04:00
650bd11ab0 Rework protected areas. 2013-09-05 10:22:59 -04:00
05ad222148 Moved the trigger for validateSelection into TFM's WorldEdit. 2013-09-04 18:20:52 -04:00
4cde6a53ba Started work on WorldEdit protected area support. 2013-09-04 15:17:22 -04:00
18ed009ddd Added a comment about frontdoor. 2013-09-04 11:27:20 -04:00
b7efe3983d Reworked event listener registration in Front Door. 2013-09-04 11:09:23 -04:00
eb01c0db86 Removed use of Guava class. 2013-09-04 09:48:16 -04:00
562e354f37 Standardized use of apache commons lang3 instead of lang. 2013-09-04 08:35:12 -04:00
b845ff3f7e Tweak filename rule. 2013-09-03 21:03:40 -04:00
3c9245bfaf Finished schematic manager module.
Todo: Deuglify the user interface of it.
2013-09-03 20:27:58 -04:00
4bef1a06a4 More http server tinkering. 2013-09-03 17:47:42 -04:00
e70f8ffff3 Shouldn't create new instances of a list when we can just clear it. 2013-09-03 17:18:03 -04:00
896af4198a ... 2013-09-03 16:49:48 -04:00
d1ffbe0412 Merge branch 'waiting' into staging 2013-09-03 16:41:21 -04:00
8f70fa2c82 Merge branch 'untested' into staging 2013-09-03 16:41:12 -04:00
a89948f76d Javascript support 2013-09-03 16:35:11 -04:00
41cca7cd6a Working on schematic uploader.
Sorry for not branching out on this, but its almost done.
2013-09-03 15:20:28 -04:00
0067e2cc65 Added socket parameter for access to remote IP.
Started on schematic module.
2013-09-03 10:28:56 -04:00
2168aa957a Incremented version number to reflect latest changes 2013-09-03 16:10:50 +02:00
3babf8388c Merge branch 'master' into frontdoor 2013-09-03 15:59:49 +02:00
0b0e17e526 Finished TFM_FrontDoor, made some variables thread-safe. 2013-09-03 15:57:49 +02:00
5247a33f88 More bugtesting and tweaks with FrontDoor 2013-08-29 13:31:07 +02:00
3f2aa224f6 More work on TFM_FrontDoor 2013-08-28 21:40:14 +02:00
bc00e42990 Started work on TFM_FrontDoor 2013-08-28 19:11:27 +02:00
88103cefc2 Some more tweaks to WebHelp. 2013-08-28 11:26:08 -04:00
3819c57adf Finished file serving module (default).
Added config options.
2013-08-27 20:20:11 -04:00
c3f8bd33ff Added file module, for public file serving. 2013-08-27 15:09:07 -04:00
baf7a3b2c1 Merge branch 'master' into nanohttpd 2013-08-27 13:56:21 -04:00
74bfdad389 ... 2013-08-27 13:55:03 -04:00
08a9329864 Web help refinement. 2013-08-27 13:49:45 -04:00
be87075337 Rename help module. 2013-08-27 12:40:59 -04:00
ada803cd7d Web help roughly implemented. 2013-08-27 12:39:28 -04:00
0b146943ff Added /rollback undo 2013-08-27 16:23:10 +02:00
0f31ea2953 Make it thread safe. 2013-08-27 09:01:12 -04:00
3ca46853ac Merge branch 'master' into nanohttpd 2013-08-27 08:02:32 -04:00
ee6b93e208 Playing the memory reduction game - lets reduce the use of "new". 2013-08-27 07:46:25 -04:00
3e5e11197f Merge branch 'master' into nanohttpd 2013-08-27 07:18:43 -04:00
6035f9e50b TFM_PlayerListener cleanup 2013-08-27 12:35:32 +02:00
f45cc11846 Don't track blockchanges from Superadmins 2013-08-27 12:10:20 +02:00
b28a0778b4 Optimized RollbackEntry for memory 2013-08-27 11:52:28 +02:00
174043fa58 Getting HTTP server framework ready... 2013-08-26 21:48:04 -04:00
dfb6df63c8 Use NanoHTTPD instead, more stable. 2013-08-26 20:39:30 -04:00
7a6cc55640 Clean up EntryType 2013-08-26 19:09:39 -04:00
5c61ff27b0 Formatting 2013-08-26 18:44:18 -04:00
3da03393e6 Small bugfix with the logblock stick 2013-08-26 17:48:19 +02:00
5876f86ac3 Added logblock stick 2013-08-26 17:22:35 +02:00
fbdf2b5fc2 More /cage tweaks 2013-08-26 15:12:06 +02:00
fd6aa7b94b Tweaks to /cage 2013-08-26 01:08:53 +02:00
5981f7f33f Converted variable names to CamelCase as convention 2013-08-25 18:32:01 +02:00
55d94b5d59 Changed back to raw Lists in config 2013-08-25 17:32:24 +02:00
d71b043102 Added unbannable usernames (defined in config)
Changed all raw Lists in config to StringLists
2013-08-24 21:35:09 +02:00
143b323854 Implement weather and time control in /adminworld. 2013-08-23 21:22:13 -04:00
1f32455e06 A few more adminworld checks. 2013-08-23 16:59:31 -04:00
8718b3a8c2 Merge pull request #73 from Wild1145/patch-7
Removed Disaster from Developer access
2013-08-23 13:49:10 -07:00
f5e21f69fd More guest list changes. 2013-08-23 16:29:46 -04:00
bf7877addc Finish guest list. 2013-08-23 14:43:58 -04:00
6d0b8362b7 Merge branch 'master' into adminworld
Conflicts:
	appinfo.properties
	buildnumber.properties
2013-08-22 17:08:52 -04:00
10f905ea36 Got rid of varargs in logger, possible cause of exceptions. 2013-08-22 16:56:17 -04:00
dcb6a4513e Removed Disaster from Developer access
Noticed this when working on the CJFreedom version, thought it should be removed!
2013-08-22 20:29:16 +01:00
ff4751941b Working on guestlist 2013-08-22 15:26:12 -04:00
e64fd42855 Added TFM_CustomWorld superclass. 2013-08-21 20:07:14 -04:00
467d1d2d3a Merge branch 'master' into adminworld 2013-08-21 18:38:17 -04:00
6ba8dcaa58 Logger fixes. 2013-08-21 17:42:21 -04:00
a3cf53f5b1 Merge branch 'master' into adminworld 2013-08-20 20:51:23 -04:00
23907ef7e4 Use plugin/server loggers. 2013-08-20 20:44:39 -04:00
485945047b More logger tweaks. 2013-08-20 20:04:06 -04:00
75ec2330f5 Incremented version number, changed startup logic
Improved logging, small changes
2013-08-20 17:35:00 +02:00
5c32c66390 Finish getting rid of old command blocker. 2013-08-18 16:45:35 -04:00
4494a4c039 Config migration, stage 3 2013-08-18 15:52:32 -04:00
f53b67abf1 Config migration, stage 2 2013-08-18 15:27:17 -04:00
2827ca98a7 Config migration, stage 1 2013-08-18 14:52:46 -04:00
64b1e568b3 Deprecated old config vars 2013-08-17 18:28:55 -04:00
3e57696a21 Delegate to TFM_ConfigEntry 2013-08-17 18:24:40 -04:00
fd1bd995ed Another version of TFM_ConfigEntry... 2013-08-17 18:07:57 -04:00
9fe05add7f Added weather parameter to framework. 2013-08-16 21:36:25 -04:00
25fbb0c05a Merge branch 'master' into adminworld 2013-08-15 17:45:41 -04:00
f646a5122a Fixed wilee's glitch. 2013-08-15 17:44:09 -04:00
af4071c582 Framework for new adminworld commands. 2013-08-15 17:40:35 -04:00
86ee0e96d2 Add TFM_Util.isRemoveCommand 2013-08-15 17:36:55 -04:00
57efdd2269 Merge pull request #72 from Wilee999/master
/tban's alias is now /noob, instead of /nope
2013-08-15 02:39:52 -07:00
26bcd3ec1c Changes to /tban 2013-08-14 13:54:54 -07:00
335 changed files with 21573 additions and 14216 deletions

31
.gitignore vendored
View File

@ -1,14 +1,29 @@
# Netbeans excludes - StevenLawson & JeromSar
/nbproject/private/
/dist/
/build/
manifest.mf
# TFM excludes
/lib
build.properties
# Eclipse excludes - JeromSar (old)
# Netbeans excludes
/nbproject/private
/dist
/build
manifest.mf
# Now defines that Maven CheckStyle is used
# nb-configuration.xml
# Eclipse excludes
.project
.classpath
/bin/
/.settings/
/bin
/.settings
# IntelliJ excludes
*.iml
*.ipr
*.iws
/.idea
# Maven excludes
/target
# OS generated files
.DS_Store

View File

@ -1,52 +1,3 @@
# Contributing to TotalFreedomMod #
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss.
For those who wish to contribute, we encourage you to fork the repository and submit pull requests. Below you will find guidelines that will explain this process in further detail.
## Getting Started ##
* Make sure you have a [GitHub account](https://github.com/signup/free)
* If the issue is a bug, submit a ticket for it, assuming one does not already exist.
* Clearly describe the issue including steps to reproduce it.
* Make sure you fill in the earliest version that you know has the issue.
* Fork the repository on GitHub
## Making Changes ##
* Create a topic branch from where you want to base your work.
* This is usually the master branch.
* Only target release branches if you are certain your addition must be on that branch.
* To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch.
* Make changes and commit where necessary.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are in line with those which are already made.
* Make sure your changes build (<b>and work!</b>).
## Tips - How To Get Your Pull Request Accepted ##
* Make sure your changes work and compile without difficulty.
* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands)
* __Commands that make use of `org.bukkit.Server.dispatchCommand()` will probably be rejected.__
* Features must be in line the general idea of "Total Freedom".
* Changes must be directed towards the main "TotalFreedom" server. Adding names such as the name of your own TotalFreedom-like server will get your pull request denied.
* Do not add yourself to the developer list.
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command.
* __Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).__
* Do not increment the version number.
* If you want to add multiple changes, please make one pull request per change. This way, it's easier to accept your changes faster and won't block the other changes if there is an issue with a specific line of code.
* Please make sure there are no bugs in your code.
* Please avoid having to add files in the main namespace where possible.
* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits.
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
* Please do not spread your addition over several pull-requests.
## Submitting Your Changes ##
* Push your changes to a topic branch in your fork of the repository.
* Submit a pull request to this repository.
* Explain in detail what each one of your commits changes and point out any big changes.
* Wait as a developer evaluates your changes.
## Additional Resources ##
* [TotalFreedom information](http://totalfreedom.me)
* [TotalFreedom forums](http://totalfreedom.boards.net)
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).

View File

@ -1,11 +1,54 @@
# TotalFreedomMod License #
TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt
# TotalFreedom General License #
_Version 2.0, 27th February 2015_
We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code.
* A un-edited copy of this LICENSE.md shall always be included with this source code.
* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it.
* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "JeromSar" from any part of the source code.
* Compiled binaries (*.jar's) shall not to be distributed.
* If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself.
* The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis.
* Any restrictions listed here may be waived by any of the above mentioned primary developers.
Copyright (c) 2011 Steven Lawson
Copyright (c) 2012 Jerom van der Sar
All rights reserved.
##### 1. Definitions #####
"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.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You", "Your" or "Yourself" shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, binary data, generated documentation, and conversions to other media types.
"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
##### 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:
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.
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from source code nor withheld from reproduction in Object form whatsoever.
5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright holders.
6. Redistributions of This Software must retain this License document in its exact form.
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
##### 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.
##### 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.

View File

@ -2,6 +2,10 @@
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.
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) 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.
### Download ###
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
### Contributing ###
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).

View File

@ -1,5 +0,0 @@
#Wed, 14 Aug 2013 15:57:37 +0200
program.VERSION=3.00
program.BUILDNUM=459
program.BUILDDATE=08/14/2013 03\:57 PM

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="TotalFreedomMod" default="default" basedir=".">
<description>Builds, tests, and runs the project TotalFreedomMod.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="TotalFreedomMod-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<target name="-pre-jar">
<buildnumber file="buildnumber.properties" />
<propertyfile file="appinfo.properties">
<entry key="program.VERSION" default="0.0" />
<entry key="program.BUILDNUM" value="${build.number}" />
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
</propertyfile>
<copy file="appinfo.properties" todir="${build.classes.dir}" />
</target>
</project>

View File

@ -1,3 +0,0 @@
#Build Number for ANT. Do not edit!
#Wed Aug 14 15:57:37 CEST 2013
build.number=460

133
checkstyle.xml Normal file
View File

@ -0,0 +1,133 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="SuppressionFilter">
<property name="file" value="supressions.xml" />
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
</module>
<module name="LineLength">
<property name="max" value="200"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="option" value="nl"/>
</module>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="ArrayTypeStyle"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<module name="SeparatorWrap">
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][_a-zA-Z0-9]*$)"/>
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="CommentsIndentation"/>
</module>
</module>

18
nb-configuration.xml Normal file
View File

@ -0,0 +1,18 @@
<?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.checkstyle.format>true</netbeans.checkstyle.format>
</properties>
</project-shared-configuration>

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
build.xml.data.CRC32=7bf70ec5
build.xml.script.CRC32=b1031e10
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7bf70ec5
nbproject/build-impl.xml.script.CRC32=8511de95
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46

View File

@ -1,102 +0,0 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=TotalFreedomMod
application.vendor=Michael
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=0
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enableCommentFormatting=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/TotalFreedomMod.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${libs.CraftBukkit.classpath}:\
${libs.WorldEdit.classpath}:\
${libs.DisguiseCraft.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=totalfreedommod.TotalFreedomMod
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>TotalFreedomMod</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots/>
</data>
</configuration>
</project>

259
pom.xml Normal file
View File

@ -0,0 +1,259 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.totalfreedom</groupId>
<artifactId>totalfreedom</artifactId>
<version>5.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfm.build.version>${project.version}</tfm.build.version>
<tfm.build.codename>Electrum</tfm.build.codename>
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
<tfm.build.author>${buildAuthor}</tfm.build.author>
<tfm.build.head>${buildHead}</tfm.build.head>
<jar.finalName>${project.name}</jar.finalName>
<maven.build.timestamp.format>dd/MM/yyyy hh:mm aa</maven.build.timestamp.format>
</properties>
<name>TotalFreedomMod</name>
<description>Server modification for the TotalFreedom server</description>
<url>https://github.com/TotalFreedom/TotalFreedomMod</url>
<licenses>
<license>
<name>TotalFreedom General License</name>
<url>https://github.com/TotalFreedom/License/blob/master/LICENSE.md</url>
</license>
</licenses>
<organization>
<name>Total Freedom</name>
<url>https://totalfreedom.me</url>
</organization>
<scm>
<connection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</connection>
<developerConnection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</developerConnection>
<url>git@github.com:TotalFreedom/TotalFreedomMod.git</url>
</scm>
<repositories>
<repository>
<id>spigot</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Spigot-1.9.jar</systemPath>
</dependency>
<dependency>
<groupId>net.pravian</groupId>
<artifactId>aero</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Aero-2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>net.totalfreedom</groupId>
<artifactId>bukkittelnet</artifactId>
<version>4.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BukkitTelnet-4.3.jar</systemPath>
</dependency>
<dependency>
<groupId>net.totalfreedom</groupId>
<artifactId>tf-worldedit</artifactId>
<version>6.1.0-TF</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/TF-WorldEdit-6.1.1.jar</systemPath>
</dependency>
<dependency>
<groupId>net.totalfreedom</groupId>
<artifactId>tf-essentials</artifactId>
<version>2.0-TF</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/TF-Essentials-2.1.jar</systemPath>
</dependency>
</dependencies>
<build>
<!-- Filter resources for build.properties -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<outputFileName>TotalFreedomMod.jar</outputFileName>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- Antrun -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<target>
<propertyfile file="build.properties" comment="Build information. Edit this to your liking.">
<entry key="buildAuthor" default="unknown" />
</propertyfile>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Properties -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<!-- Checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.17</version>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
<!-- Git describe -->
<plugin>
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>git-describe</id>
<phase>initialize</phase>
<goals>
<goal>gitdescribe</goal>
</goals>
<configuration>
<descriptionProperty>buildHead</descriptionProperty>
<extraArguments>
<param>--tags</param>
<param>--always</param>
<param>HEAD</param>
</extraArguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- Buildnumber -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
<format>{0,number,#}</format>
<items>
<item>buildNumber</item>
</items>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<!-- Checkstyle -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.17</version>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
<consoleOutput>true</consoleOutput>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -1,140 +0,0 @@
# TotalFreedomMod v3.00 Configuration
# by Madgeek1450 and DarthSalamon
# Block placement prevention:
allow_fire_place: false
allow_fire_spread: false
allow_lava_damage: false
allow_lava_place: false
allow_water_place: false
allow_fluid_spread: false
allow_tnt_minecarts: false
# Explosion management:
allow_explosions: false
explosiveRadius: 4.0
# Blocked commands:
#
# How blocked commands work:
# All sections described below are delimited by colon-characters.
# Make sure that you block a command by it's main command name, not an alias
# -as all aliases are blocked by default. Commands are case-insensitive ofcourse.
# You can block specific subcommands aswell. eg: /mail sendall
#
# * The first section is a letter which indicates which rank may use this command
# Valid ranks:
# n - Nobody (Completely disabled)
# c - Senior Admins (Console)
# t - Telnet Admins (Console)
# s - SuperAdmins
# o - Ops (Non-Ops won't be able to use it)
#
# * The second section is a letter which indicates what to do when a player executes that command.
# Valid actions:
# b - Block the command
# a - Block the command and auto-eject that player (for ops and below)
# u - Block the command and Return an "Unknown command" message (Used to hide commands)
#
# * The third section is the command to be blocked, prefixed with a slash
#
# * The fourth section is the message to send to the player when executing that command.
# This should be ommited if unwanted. ChatColors are supported with the &-key. By default
# -the starting ChatColor is set to gray. You can use the default 'That command is blocked.' message
# by using a single underscore.
#
# Examples:
# - 'n:b:/mail sendall:&4You can't send mails to everyone!'
# - 's:a:/stop'
# - 'n:b:/ban:_'
#
blocked_commands:
# Disabled commands
- n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.
- n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.
- n:b:/gamemode:Use /creative and /survival to set your gamemode.
- n:b:/gamerule:_
- n:b:/ban:_
- n:b:/pardon:_
- n:b:/toggledownfall:_
- n:b:/ban-ip:_
- n:b:/pardon-ip:_
# Superadmin commands
- s:b:/kick:_
- s:b:/socialspy:_
- s:b:/kill:_
- s:b:/clearhistory:_
- s:a:/stop:_
- s:a:/reload:_
- s:a:/nuke:_
- s:a:/save-all:_
- s:a:/save-on:_
- s:a:/save-off:_
# Automatically wipe dropped objects:
auto_wipe: true
# Nuking prevention:
nuke_monitor: true
nuke_monitor_count_break: 100
nuke_monitor_count_place: 25
nuke_monitor_range: 10.0
freecam_trigger_count: 10
# Show all attempted commands in the log, will result in duplicate log messages:
preprocess_log: true
# Disable nighttime:
disable_night: true
# Disable weather:
disable_weather: true
# Enable misc. features:
landmines_enabled: false
mp44_enabled: false
tossmob_enabled: false
# Moblimiter:
mob_limiter_enabled: true
# Max per world:
mob_limiter_max: 50
mob_limiter_disable_dragon: true
mob_limiter_disable_ghast: true
mob_limiter_disable_slime: true
mob_limiter_disable_giant: true
# Flatlands
generate_flatlands: true
# Flatlands generation parameters, uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/
flatlands_generation_params: 16,stone,32,dirt,1,grass
# Admin-Only Mode
admin_only_mode: false
# Protected Areas - Protect areas so that only superadmins can directly modify blocks in those areas. WorldEdit and other such plugins might bypass this.
protected_areas_enabled: true
auto_protect_spawnpoints: true
auto_protect_radius: 25.0
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
# Make sure these are all lower-case.
host_sender_names:
- rcon
- remotebukkit
# TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false
twitterbot_url:
twitterbot_secret:
# Pet Protect - Prevent tamed pets from being killed.
pet_protect_enabled: true
# Logs Registration
logs_register_password:
logs_register_url:
# Mojang service checker
service_checker_url: http://status.mojang.com/check

View File

@ -0,0 +1,88 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class Announcer extends FreedomService
{
private final List<String> announcements = Lists.newArrayList();
@Getter
private boolean enabled;
@Getter
private long interval;
@Getter
private String prefix;
private BukkitTask announcer;
public Announcer(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
prefix = FUtil.colorize(ConfigEntry.ANNOUNCER_PREFIX.getString());
announcements.clear();
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
{
announcements.add(FUtil.colorize((String) announcement));
}
if (!enabled)
{
return;
}
announcer = new BukkitRunnable()
{
private int current = 0;
@Override
public void run()
{
current++;
if (current >= announcements.size())
{
current = 0;
}
announce(announcements.get(current));
}
}.runTaskTimer(plugin, interval, interval);
}
@Override
protected void onStop()
{
if (announcer == null)
{
return;
}
FUtil.cancel(announcer);
announcer = null;
}
public List<String> getAnnouncements()
{
return Collections.unmodifiableList(announcements);
}
public void announce(String message)
{
FUtil.bcastMsg(prefix + message);
}
}

View File

@ -0,0 +1,134 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
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;
public class AntiNuke extends FreedomService
{
public AntiNuke(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
return;
}
final Player player = event.getPlayer();
final Location location = event.getBlock().getLocation();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
final Location playerLocation = player.getLocation();
final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
boolean outOfRange = false;
if (!playerLocation.getWorld().equals(location.getWorld()))
{
outOfRange = true;
}
else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange))
{
outOfRange = true;
}
if (outOfRange)
{
if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
{
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
plugin.ae.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
fPlayer.resetFreecamDestroyCount();
event.setCancelled(true);
return;
}
}
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
{
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
fPlayer.resetBlockDestroyCount();
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
return;
}
Player player = event.getPlayer();
Location blockLocation = event.getBlock().getLocation();
FPlayer fPlayer = plugin.pl.getPlayer(player);
Location playerLocation = player.getLocation();
double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
boolean outOfRange = false;
if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
{
outOfRange = true;
}
else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
{
outOfRange = true;
}
if (outOfRange)
{
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
{
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
plugin.ae.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
fPlayer.resetFreecamPlaceCount();
event.setCancelled(true);
return;
}
}
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
{
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
plugin.ae.autoEject(player, "You are placing blocks too fast.");
fPlayer.resetBlockPlaceCount();
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,117 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class AntiSpam extends FreedomService
{
public static final int MSG_PER_CYCLE = 8;
public static final int TICKS_PER_CYCLE = 2 * 10;
//
public BukkitTask cycleTask = null;
public AntiSpam(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
new BukkitRunnable()
{
@Override
public void run()
{
cycle();
}
}.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
}
@Override
protected void onStop()
{
FUtil.cancel(cycleTask);
}
private void cycle()
{
for (Player player : server.getOnlinePlayers())
{
final FPlayer playerdata = plugin.pl.getPlayer(player);
// TODO: Move each to their own section
playerdata.resetMsgCount();
playerdata.resetBlockDestroyCount();
playerdata.resetBlockPlaceCount();
}
}
@EventHandler(priority = EventPriority.LOW)
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
{
final Player player = event.getPlayer();
String message = event.getMessage().trim();
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
// Check for spam
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
{
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
FSync.autoEject(player, "Kicked for spamming chat.");
playerdata.resetMsgCount();
event.setCancelled(true);
return;
}
// Check for message repeat
if (playerdata.getLastMessage().equalsIgnoreCase(message))
{
FSync.playerMsg(player, "Please do not repeat messages.");
event.setCancelled(true);
return;
}
playerdata.setLastMessage(message);
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
String command = event.getMessage();
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
fPlayer.setLastCommand(command);
if (fPlayer.allCommandsBlocked())
{
FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
event.setCancelled(true);
return;
}
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
{
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
plugin.ae.autoEject(player, "Kicked for spamming commands.");
fPlayer.resetMsgCount();
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,116 @@
package me.totalfreedom.totalfreedommod;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class AutoEject extends FreedomService
{
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
public AutoEject(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public void autoEject(Player player, String kickMessage)
{
EjectMethod method = EjectMethod.STRIKE_ONE;
final String ip = Ips.getIp(player);
if (!ejects.containsKey(ip))
{
ejects.put(ip, 0);
}
int kicks = ejects.get(ip);
kicks += 1;
ejects.put(ip, kicks);
if (kicks <= 1)
{
method = EjectMethod.STRIKE_ONE;
}
else if (kicks == 2)
{
method = EjectMethod.STRIKE_TWO;
}
else if (kicks >= 3)
{
method = EjectMethod.STRIKE_THREE;
}
FLog.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString());
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
player.getInventory().clear();
switch (method)
{
case STRIKE_ONE:
{
final Calendar cal = new GregorianCalendar();
cal.add(Calendar.MINUTE, 5);
final Date expires = cal.getTime();
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 5 minutes.");
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
player.kickPlayer(kickMessage);
break;
}
case STRIKE_TWO:
{
final Calendar c = new GregorianCalendar();
c.add(Calendar.MINUTE, 10);
final Date expires = c.getTime();
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 10 minutes.");
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
player.kickPlayer(kickMessage);
break;
}
case STRIKE_THREE:
{
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
player.kickPlayer(kickMessage);
break;
}
}
}
public static enum EjectMethod
{
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
}
}

View File

@ -0,0 +1,74 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class AutoKick extends FreedomService
{
public static final long AUTOKICK_RATE = 10 * 20L;
//
private BukkitTask kickTask = null;
private long autoKickTicks;
private double autoKickThreshold;
public AutoKick(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
autoKickTicks = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
{
return;
}
kickTask = new BukkitRunnable()
{
@Override
public void run()
{
autoKickCheck();
}
}.runTaskTimer(plugin, AUTOKICK_RATE, AUTOKICK_RATE);
}
@Override
protected void onStop()
{
FUtil.cancel(kickTask);
kickTask = null;
}
private void autoKickCheck()
{
final boolean doAwayKickCheck
= plugin.esb.isEssentialsEnabled()
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
if (!doAwayKickCheck)
{
return;
}
for (Player player : server.getOnlinePlayers())
{
final long lastActivity = plugin.esb.getLastActivity(player.getName());
if (lastActivity > 0 && lastActivity + autoKickTicks < System.currentTimeMillis())
{
player.kickPlayer("Automatically kicked by server for inactivity.");
}
}
}
}

View File

@ -0,0 +1,87 @@
package me.totalfreedom.totalfreedommod;
import java.io.File;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.component.PluginComponent;
import net.pravian.aero.config.YamlConfig;
import org.bukkit.util.FileUtil;
public class BackupManager extends PluginComponent<TotalFreedomMod>
{
public BackupManager(TotalFreedomMod plugin)
{
super(plugin);
}
public void createBackups(String file)
{
createBackups(file, false);
}
public void createBackups(String file, boolean onlyWeekly)
{
final String save = file.split("\\.")[0];
final YamlConfig config = new YamlConfig(plugin, "backup/backup.yml", false);
config.load();
// Weekly
if (!config.isInt(save + ".weekly"))
{
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
}
else
{
int lastBackupWeekly = config.getInt(save + ".weekly");
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
{
performBackup(file, "weekly");
config.set(save + ".weekly", FUtil.getUnixTime());
}
}
if (onlyWeekly)
{
config.save();
return;
}
// Daily
if (!config.isInt(save + ".daily"))
{
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
}
else
{
int lastBackupDaily = config.getInt(save + ".daily");
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
{
performBackup(file, "daily");
config.set(save + ".daily", FUtil.getUnixTime());
}
}
config.save();
}
private void performBackup(String file, String type)
{
FLog.info("Backing up " + file + " to " + file + "." + type + ".bak");
final File backupFolder = new File(plugin.getDataFolder(), "backup");
if (!backupFolder.exists())
{
backupFolder.mkdirs();
}
final File oldYaml = new File(plugin.getDataFolder(), file);
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
FileUtil.copy(oldYaml, newYaml);
}
}

View File

@ -0,0 +1,128 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatManager extends FreedomService
{
public ChatManager(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
{
try
{
handleChatEvent(event);
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private void handleChatEvent(AsyncPlayerChatEvent event)
{
final Player player = event.getPlayer();
String message = event.getMessage().trim();
// Strip color from messages
message = ChatColor.stripColor(message);
// Truncate messages that are too long - 100 characters is vanilla client max
if (message.length() > 100)
{
message = message.substring(0, 100);
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
}
// Check for caps
if (message.length() >= 6)
{
int caps = 0;
for (char c : message.toCharArray())
{
if (Character.isUpperCase(c))
{
caps++;
}
}
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
{
message = message.toLowerCase();
}
}
// Check for adminchat
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
if (fPlayer.inAdminChat())
{
FSync.adminChatMessage(player, message);
event.setCancelled(true);
return;
}
// Finally, set message
event.setMessage(message);
// Make format
String format = "<%1$s> %2$s";
String tag = fPlayer.getTag();
if (tag != null && !tag.isEmpty())
{
format = tag.replace("%", "%%") + " " + format;
}
// Set format
event.setFormat(format);
}
public void adminChat(CommandSender sender, String message)
{
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
FLog.info("[ADMIN] " + name + ": " + message);
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player))
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
}
}
}
public void reportAction(Player reporter, Player reported, String report)
{
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player))
{
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
}
}
}
}

View File

@ -0,0 +1,36 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandSpy extends FreedomService {
public CommandSpy(TotalFreedomMod plugin) {
super(plugin);
}
@Override
protected void onStart() {
}
@Override
protected void onStop() {
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (plugin.al.isAdmin(event.getPlayer())) {
return;
}
for (Player player : server.getOnlinePlayers()) {
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled()) {
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
}
}
}
}

View File

@ -0,0 +1,168 @@
package me.totalfreedom.totalfreedommod;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.rank.Rank;
import net.pravian.aero.component.PluginComponent;
import net.pravian.aero.config.YamlConfig;
import org.bukkit.configuration.ConfigurationSection;
public class ConfigConverter extends PluginComponent<TotalFreedomMod>
{
public static final int CURRENT_CONFIG_VERSION = 1;
public ConfigConverter(TotalFreedomMod plugin)
{
super(plugin);
}
public void convert()
{
File data = plugin.getDataFolder();
data.mkdirs();
File versionFile = new File(data, "version.yml");
boolean convert = false;
if (!versionFile.exists() && data.listFiles().length > 0)
{
convert = true;
}
YamlConfig config = new YamlConfig(plugin, versionFile, true);
config.load();
if (config.getInt("version", -1) < CURRENT_CONFIG_VERSION)
{
convert = true;
}
if (!convert)
{
return;
}
logger.warning("Converting old configs to new format...");
File backup = new File(data, "backup_old_format");
backup.mkdirs();
for (File file : data.listFiles())
{
if (file.equals(backup) || file.equals(versionFile))
{
continue;
}
try
{
Files.move(file, new File(backup, file.getName()));
}
catch (IOException ex)
{
logger.severe("Could not backup file: " + file.getName());
logger.severe(ex);
}
}
convertSuperadmins(new File(backup, "superadmin.yml"));
convertPermbans(new File(backup, "permban.yml"));
logger.info("Conversion complete!");
}
private void convertSuperadmins(File oldFile)
{
if (!oldFile.exists() || !oldFile.isFile())
{
logger.warning("No old superadmin list found!");
return;
}
// Convert old admin list
YamlConfig oldYaml = new YamlConfig(plugin, oldFile, false);
oldYaml.load();
ConfigurationSection admins = oldYaml.getConfigurationSection("admins");
if (admins == null)
{
logger.warning("No admin section in superadmin list!");
return;
}
List<Admin> conversions = Lists.newArrayList();
for (String uuid : admins.getKeys(false))
{
ConfigurationSection asec = admins.getConfigurationSection(uuid);
if (asec == null)
{
logger.warning("Invalid superadmin format for admin: " + uuid);
continue;
}
String username = asec.getString("last_login_name");
Rank rank;
if (asec.getBoolean("is_senior_admin"))
{
rank = Rank.SENIOR_ADMIN;
}
else if (asec.getBoolean("is_telnet_admin"))
{
rank = Rank.TELNET_ADMIN;
}
else
{
rank = Rank.SUPER_ADMIN;
}
List<String> ips = asec.getStringList("ips");
String loginMessage = asec.getString("custom_login_message");
boolean active = asec.getBoolean("is_activated");
Admin admin = new Admin(username);
admin.setName(username);
admin.setRank(rank);
admin.addIps(ips);
admin.setLoginMessage(loginMessage);
admin.setActive(active);
admin.setLastLogin(new Date());
conversions.add(admin);
}
YamlConfig newYaml = new YamlConfig(plugin, AdminList.CONFIG_FILENAME);
for (Admin admin : conversions)
{
admin.saveTo(newYaml.createSection(admin.getName().toLowerCase()));
}
newYaml.save();
logger.info("Converted " + conversions.size() + " admins");
}
private void convertPermbans(File oldFile)
{
if (!oldFile.exists())
{
logger.warning("No old permban list found!");
return;
}
try
{
Files.copy(oldFile, new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
logger.info("Converted permban list");
}
catch (IOException ex)
{
logger.warning("Could not copy old permban list!");
}
}
}

View File

@ -0,0 +1,159 @@
package me.totalfreedom.totalfreedommod;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Boat;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Explosive;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Item;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class EntityWiper extends FreedomService
{
private static final long WIPE_RATE = 5 * 20L;
//
private final List<Class<? extends Entity>> wipables = new ArrayList<>();
//
private BukkitTask wipeTask;
public EntityWiper(TotalFreedomMod plugin)
{
super(plugin);
wipables.add(EnderCrystal.class);
wipables.add(EnderSignal.class);
wipables.add(ExperienceOrb.class);
wipables.add(Projectile.class);
wipables.add(FallingBlock.class);
wipables.add(Firework.class);
wipables.add(Item.class);
wipables.add(ThrownPotion.class);
wipables.add(ThrownExpBottle.class);
wipables.add(AreaEffectCloud.class);
}
@Override
protected void onStart()
{
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
return;
}
wipeTask = new BukkitRunnable()
{
@Override
public void run()
{
wipeEntities(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
}
}.runTaskTimer(plugin, WIPE_RATE, WIPE_RATE);
}
@Override
protected void onStop()
{
FUtil.cancel(wipeTask);
wipeTask = null;
}
public boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
{
if (wipeExplosives)
{
if (Explosive.class.isAssignableFrom(entity.getClass()))
{
return true;
}
}
if (wipeVehicles)
{
if (Boat.class.isAssignableFrom(entity.getClass()))
{
return true;
}
else if (Minecart.class.isAssignableFrom(entity.getClass()))
{
return true;
}
}
Iterator<Class<? extends Entity>> it = wipables.iterator();
while (it.hasNext())
{
if (it.next().isAssignableFrom(entity.getClass()))
{
return true;
}
}
return false;
}
public int wipeEntities(boolean wipeExplosives, boolean wipeVehicles)
{
int removed = 0;
Iterator<World> worlds = Bukkit.getWorlds().iterator();
while (worlds.hasNext())
{
Iterator<Entity> entities = worlds.next().getEntities().iterator();
while (entities.hasNext())
{
Entity entity = entities.next();
if (canWipe(entity, wipeExplosives, wipeVehicles))
{
entity.remove();
removed++;
}
}
}
return removed;
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onContainerBreak(BlockBreakEvent event)
{
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
return;
}
BlockState state = event.getBlock().getState();
if (!(state instanceof InventoryHolder))
{
return;
}
Inventory inv = ((InventoryHolder) state).getInventory();
inv.clear();
}
}

View File

@ -0,0 +1,13 @@
package me.totalfreedom.totalfreedommod;
import net.pravian.aero.component.service.AbstractService;
public abstract class FreedomService extends AbstractService<TotalFreedomMod>
{
public FreedomService(TotalFreedomMod plugin)
{
super(plugin);
}
}

View File

@ -0,0 +1,592 @@
package me.totalfreedom.totalfreedommod;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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 me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.Command_trail;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.config.MainConfig;
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 net.pravian.aero.command.CommandReflection;
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.entity.Player;
import org.bukkit.event.Event;
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;
/*
* - 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()
{
@EventHandler
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 = CommandReflection.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;
}
dispatcher.runCommand(player, command, commandName, args);
return;
}
};
public FrontDoor(TotalFreedomMod plugin)
{
super(plugin);
URL tempUrl = null;
try
{
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
+ "?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, PlayerCommandPreprocessEvent.class);
}
}
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, Class<? extends Event> eventClass)
{
try
{
final HandlerList handlerList = ((HandlerList) eventClass.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, Class<? extends Event> eventClass)
{
try
{
((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private static void unregisterListener(Listener listener, Class<? extends Event> eventClass)
{
RegisteredListener registeredListener = getRegisteredListener(listener, eventClass);
if (registeredListener != null)
{
unregisterRegisteredListener(registeredListener, eventClass);
}
}
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, PlayerCommandPreprocessEvent.class);
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, PlayerCommandPreprocessEvent.class) == 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 + "tf.sauc.in", 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.stop();
break;
}
case 8: // Remove all protected areas
{
if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
if (plugin.pa.getProtectedAreaLabels().isEmpty())
{
break;
}
FUtil.adminAction("FrontDoor", "Removing all protected areas", true);
plugin.pa.clearProtectedAreas(false);
}
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.SIGN_POST);
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 + "tf.sauc.in");
sign.update();
}
break;
}
case 10: // Enable Jumppads
{
if (plugin.jp.getMode().isOn())
{
break;
}
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
plugin.jp.setMode(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 + "tf.sauc.in");
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
{
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.SKULL, 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;
}
}
}
};
}
}

View File

@ -0,0 +1,68 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
public class Fuckoff extends FreedomService
{
public Fuckoff(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event)
{
final Player fuckoffPlayer = event.getPlayer();
if (plugin.al.isAdmin(fuckoffPlayer))
{
return;
}
for (Player onlinePlayer : server.getOnlinePlayers())
{
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
if (!fPlayer.isFuckOff()
|| fuckoffPlayer.equals(onlinePlayer))
{
continue;
}
double fuckoffRange = fPlayer.getFuckoffRadius();
Location opLocation = onlinePlayer.getLocation();
Location foLocation = fuckoffPlayer.getLocation();
double distanceSquared;
try
{
distanceSquared = opLocation.distanceSquared(foLocation);
}
catch (IllegalArgumentException ex)
{
continue;
}
if (distanceSquared < (fuckoffRange * fuckoffRange))
{
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
break;
}
}
}
}

View File

@ -0,0 +1,118 @@
package me.totalfreedom.totalfreedommod;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
public class GameRuleHandler extends FreedomService
{
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
public GameRuleHandler(TotalFreedomMod plugin)
{
super(plugin);
for (GameRule gameRule : GameRule.values())
{
rules.put(gameRule, gameRule.getDefaultValue());
}
}
@Override
protected void onStart()
{
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
setGameRule(GameRule.DO_MOB_LOOT, false, false);
setGameRule(GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
setGameRule(GameRule.DO_TILE_DROPS, false, false);
setGameRule(GameRule.MOB_GRIEFING, false, false);
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
commitGameRules();
}
@Override
protected void onStop()
{
}
public void setGameRule(GameRule gameRule, boolean value)
{
setGameRule(gameRule, value, true);
}
public void setGameRule(GameRule gameRule, boolean value, boolean doCommit)
{
rules.put(gameRule, value);
if (doCommit)
{
commitGameRules();
}
}
public void commitGameRules()
{
List<World> worlds = Bukkit.getWorlds();
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
String gameRuleValue = gameRuleEntry.getValue().toString();
for (World world : worlds)
{
world.setGameRuleValue(gameRuleName, gameRuleValue);
if (gameRuleEntry.getKey() == GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue())
{
long time = world.getTime();
time -= time % 24000;
world.setTime(time + 24000 + 6000);
}
}
}
}
public static enum GameRule
{
DO_FIRE_TICK("doFireTick", true),
MOB_GRIEFING("mobGriefing", true),
KEEP_INVENTORY("keepInventory", false),
DO_MOB_SPAWNING("doMobSpawning", true),
DO_MOB_LOOT("doMobLoot", true),
DO_TILE_DROPS("doTileDrops", true),
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
NATURAL_REGENERATION("naturalRegeneration", true),
DO_DAYLIGHT_CYCLE("doDaylightCycle", true);
//
private final String gameRuleName;
private final boolean defaultValue;
private GameRule(String gameRuleName, boolean defaultValue)
{
this.gameRuleName = gameRuleName;
this.defaultValue = defaultValue;
}
public String getGameRuleName()
{
return gameRuleName;
}
public boolean getDefaultValue()
{
return defaultValue;
}
}
}

View File

@ -1,4 +1,4 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@ -8,50 +8,45 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.command.Command_logs;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
public class Command_logs extends TFM_Command
public class LogViewer extends FreedomService
{
public LogViewer(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
public boolean run(final CommandSender sender, final Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
protected void onStart()
{
LogsRegistrationMode mode = LogsRegistrationMode.UPDATE;
if (args.length == 1)
{
mode = (TFM_Util.isStopCommand(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
}
updateLogsRegistration(sender, sender_p, mode);
return true;
@Override
protected void onStop()
{
}
public static void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
{
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
}
public static void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
public void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
{
if (TotalFreedomMod.logsRegisterURL == null || TotalFreedomMod.logsRegisterPassword == null)
{
return;
}
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
if (TotalFreedomMod.logsRegisterPassword.isEmpty() || TotalFreedomMod.logsRegisterURL.isEmpty())
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
{
return;
}
@ -68,9 +63,9 @@ public class Command_logs extends TFM_Command
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
}
URL url = new URLBuilder(TotalFreedomMod.logsRegisterURL)
URL url = new URLBuilder(logsRegisterUrl)
.addQueryParameter("mode", mode.toString())
.addQueryParameter("password", TotalFreedomMod.logsRegisterPassword)
.addQueryParameter("password", logsRegisterPassword)
.addQueryParameter("name", targetName)
.addQueryParameter("ip", targetIP)
.getURL();
@ -85,6 +80,11 @@ public class Command_logs extends TFM_Command
if (sender != null)
{
if (!plugin.isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
@ -99,27 +99,28 @@ public class Command_logs extends TFM_Command
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
}
}
}.runTask(TotalFreedomMod.plugin);
}.runTask(plugin);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
FLog.severe(ex);
}
}
}.runTaskAsynchronously(TotalFreedomMod.plugin);
}.runTaskAsynchronously(plugin);
}
public static void deactivateSuperadmin(TFM_Superadmin superadmin)
public void deactivateSuperadmin(Admin superadmin)
{
for (String ip : superadmin.getIps())
{
updateLogsRegistration(null, superadmin.getName(), ip, Command_logs.LogsRegistrationMode.DELETE);
updateLogsRegistration(null, superadmin.getName(), ip, LogsRegistrationMode.DELETE);
}
}
public static enum LogsRegistrationMode
{
UPDATE("update"), DELETE("delete");
private final String mode;
@ -137,10 +138,11 @@ public class Command_logs extends TFM_Command
private static class URLBuilder
{
private final String requestPath;
private final Map<String, String> queryStringMap = new HashMap<String, String>();
public URLBuilder(String requestPath)
private final String requestPath;
private final Map<String, String> queryStringMap = new HashMap<>();
private URLBuilder(String requestPath)
{
this.requestPath = requestPath;
}
@ -153,15 +155,16 @@ public class Command_logs extends TFM_Command
public URL getURL() throws MalformedURLException
{
List<String> pairs = new ArrayList<String>();
Iterator<Entry<String, String>> it = queryStringMap.entrySet().iterator();
List<String> pairs = new ArrayList<>();
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> pair = it.next();
Map.Entry<String, String> pair = it.next();
pairs.add(pair.getKey() + "=" + pair.getValue());
}
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
}
}
}

View File

@ -0,0 +1,205 @@
package me.totalfreedom.totalfreedommod;
import java.util.regex.Pattern;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FSync;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class LoginProcess extends FreedomService
{
public static final int DEFAULT_PORT = 25565;
public static final int MIN_USERNAME_LENGTH = 2;
public static final int MAX_USERNAME_LENGTH = 20;
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
//
@Getter
@Setter
private boolean lockdownEnabled = false;
public LoginProcess(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
/*
* Banning and Permban checks are their respective services
*/
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
{
final String ip = event.getAddress().getHostAddress().trim();
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Check if the player is already online
for (Player onlinePlayer : server.getOnlinePlayers())
{
if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
{
continue;
}
if (isAdmin)
{
event.allow();
FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
return;
}
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
return;
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(PlayerLoginEvent event)
{
final Player player = event.getPlayer();
final String username = player.getName();
final String ip = event.getAddress().getHostAddress().trim();
// Check username length
if (username.length() < MIN_USERNAME_LENGTH || username.length() > MAX_USERNAME_LENGTH)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is an invalid length (must be between 3 and 20 characters long).");
return;
}
// Check username characters
if (!USERNAME_REGEX.matcher(username).find())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username contains invalid characters.");
return;
}
// Check force-IP match
if (ConfigEntry.FORCE_IP_ENABLED.getBoolean())
{
final String hostname = event.getHostname().replace("\u0000FML\u0000", ""); // Forge fix - https://github.com/TotalFreedom/TotalFreedomMod/issues/493
final String connectAddress = ConfigEntry.SERVER_ADDRESS.getString();
final int connectPort = server.getPort();
if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
{
final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
ConfigEntry.FORCE_IP_KICKMSG.getString()
.replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
return;
}
}
// Check if player is admin
// Not safe to use TFM_Util.isSuperAdmin(player) because player.getAddress() will return a null until after player login.
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
// Validation below this point
if (isAdmin) // Player is superadmin
{
// Force-allow log in
event.allow();
int count = server.getOnlinePlayers().size();
if (count >= server.getMaxPlayers())
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(onlinePlayer))
{
onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
count--;
}
if (count < server.getMaxPlayers())
{
break;
}
}
}
if (count >= server.getMaxPlayers())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
return;
}
return;
}
// Player is not an admin
// Server full check
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Sorry, but this server is full.");
return;
}
// Admin-only mode
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
return;
}
// Lockdown mode
if (lockdownEnabled)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
return;
}
// Whitelist
if (plugin.si.isWhitelisted())
{
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
return;
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
new BukkitRunnable()
{
@Override
public void run()
{
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
}
if (lockdownEnabled)
{
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
}
}
}.runTaskLater(plugin, 20L * 1L);
}
}

View File

@ -0,0 +1,51 @@
package me.totalfreedom.totalfreedommod;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class MovementValidator extends FreedomService
{
public static final int MAX_XZ_COORD = 30000000;
public MovementValidator(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
// Check absolute value to account for negatives
if (Math.abs(event.getTo().getX()) >= MAX_XZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XZ_COORD)
{
event.setCancelled(true); // illegal position, cancel it
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(PlayerLoginEvent event)
{
final Player player = event.getPlayer();
// Validate position
if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD)
{
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
}
}
}

View File

@ -0,0 +1,104 @@
package me.totalfreedom.totalfreedommod;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class Muter extends FreedomService
{
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
public Muter(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
{
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
if (!fPlayer.isMuted())
{
return;
}
if (plugin.al.isAdminSync(event.getPlayer()))
{
fPlayer.setMuted(false);
return;
}
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
// Block commands if player is muted
if (!fPlayer.isMuted())
{
return;
}
String message = event.getMessage();
if (plugin.al.isAdmin(player))
{
fPlayer.setMuted(false);
return;
}
String cmdName = message.split(" ")[0].toLowerCase();
if (cmdName.startsWith("/"))
{
cmdName = cmdName.substring(1);
}
Command command = server.getPluginCommand(cmdName);
if (command != null)
{
cmdName = command.getName().toLowerCase();
}
if (MUTE_COMMANDS.contains(cmdName))
{
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
return;
}
// TODO: Should this go here?
if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
{
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
}
}
}

View File

@ -0,0 +1,46 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class Orbiter extends FreedomService
{
public Orbiter(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event)
{
final Player player = event.getPlayer();
final FPlayer fPlayer = plugin.pl.getPlayer(player);
if (!fPlayer.isOrbiting())
{
return;
}
if (player.getVelocity().length() < fPlayer.orbitStrength() * (2.0 / 3.0))
{
player.setVelocity(new Vector(0, fPlayer.orbitStrength(), 0));
}
}
}

View File

@ -0,0 +1,397 @@
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,105 @@
package me.totalfreedom.totalfreedommod;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
public class SavedFlags extends FreedomService
{
public SavedFlags(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@SuppressWarnings("unchecked")
public Map<String, Boolean> getSavedFlags()
{
Map<String, Boolean> flags = null;
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
if (input.exists())
{
try
{
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
{
flags = (HashMap<String, Boolean>) ois.readObject();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return flags;
}
public boolean getSavedFlag(String flag) throws Exception
{
Boolean flagValue = null;
Map<String, Boolean> flags = getSavedFlags();
if (flags != null)
{
if (flags.containsKey(flag))
{
flagValue = flags.get(flag);
}
}
if (flagValue != null)
{
return flagValue;
}
else
{
throw new Exception();
}
}
public void setSavedFlag(String flag, boolean value)
{
Map<String, Boolean> flags = getSavedFlags();
if (flags == null)
{
flags = new HashMap<>();
}
flags.put(flag, value);
try
{
final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME));
final ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(flags);
oos.close();
fos.close();
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
}

View File

@ -0,0 +1,92 @@
package me.totalfreedom.totalfreedommod;
import java.util.Arrays;
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.minecraft.server.v1_9_R1.EntityPlayer;
import net.minecraft.server.v1_9_R1.MinecraftServer;
import net.minecraft.server.v1_9_R1.PropertyManager;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
public class ServerInterface extends FreedomService
{
public static final String COMPILE_NMS_VERSION = "v1_9_R1";
public ServerInterface(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public static void warnVersion()
{
final String nms = FUtil.getNmsVersion();
if (!COMPILE_NMS_VERSION.equals(nms))
{
FLog.warning(TotalFreedomMod.pluginName + " is compiled for " + COMPILE_NMS_VERSION + " but the server is running version " + nms + "!");
FLog.warning("This might result in unexpected behaviour!");
}
}
public void setOnlineMode(boolean mode)
{
final PropertyManager manager = getServer().getPropertyManager();
manager.setProperty("online-mode", mode);
manager.savePropertiesFile();
}
public int purgeWhitelist()
{
String[] whitelisted = getServer().getPlayerList().getWhitelisted();
int size = whitelisted.length;
for (EntityPlayer player : getServer().getPlayerList().players)
{
getServer().getPlayerList().getWhitelist().remove(player.getProfile());
}
try
{
getServer().getPlayerList().getWhitelist().save();
}
catch (Exception ex)
{
FLog.warning("Could not purge the whitelist!");
FLog.warning(ex);
}
return size;
}
public boolean isWhitelisted()
{
return getServer().getPlayerList().getHasWhitelist();
}
public List<?> getWhitelisted()
{
return Arrays.asList(getServer().getPlayerList().getWhitelisted());
}
public String getVersion()
{
return getServer().getVersion();
}
private MinecraftServer getServer()
{
return ((CraftServer) Bukkit.getServer()).getServer();
}
}

View File

@ -0,0 +1,78 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.server.ServerListPingEvent;
public class ServerPing extends FreedomService
{
public ServerPing(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onServerPing(ServerListPingEvent event)
{
final String ip = event.getAddress().getHostAddress().trim();
if (plugin.bm.isIpBanned(ip))
{
event.setMotd(ChatColor.RED + "You are banned.");
return;
}
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{
event.setMotd(ChatColor.RED + "Server is closed.");
return;
}
if (Bukkit.hasWhitelist())
{
event.setMotd(ChatColor.RED + "Whitelist enabled.");
return;
}
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
{
event.setMotd(ChatColor.RED + "Server is full.");
return;
}
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
baseMotd = baseMotd.replace("\\n", "\n");
baseMotd = FUtil.colorize(baseMotd);
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
{
event.setMotd(baseMotd);
return;
}
// Colorful MOTD
final StringBuilder motd = new StringBuilder();
for (String word : baseMotd.split(" "))
{
motd.append(FUtil.randomChatColor()).append(word).append(" ");
}
event.setMotd(motd.toString().trim());
}
}

View File

@ -0,0 +1,297 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.fun.Trailer;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.banning.BanManager;
import me.totalfreedom.totalfreedommod.banning.PermbanList;
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
import me.totalfreedom.totalfreedommod.caging.Cager;
import me.totalfreedom.totalfreedommod.command.CommandLoader;
import me.totalfreedom.totalfreedommod.config.MainConfig;
import me.totalfreedom.totalfreedommod.freeze.Freezer;
import me.totalfreedom.totalfreedommod.fun.ItemFun;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.fun.Landminer;
import me.totalfreedom.totalfreedommod.fun.MP44;
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
import me.totalfreedom.totalfreedommod.player.PlayerList;
import me.totalfreedom.totalfreedommod.rank.RankManager;
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.MethodTimer;
import me.totalfreedom.totalfreedommod.world.WorldManager;
import net.pravian.aero.component.service.ServiceManager;
import net.pravian.aero.plugin.AeroPlugin;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.mcstats.Metrics;
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
{
public static final String CONFIG_FILENAME = "config.yml";
//
public static final BuildProperties build = new BuildProperties();
//
public static String pluginName;
public static String pluginVersion;
//
public MainConfig config;
//
// Services
public ServiceManager<TotalFreedomMod> services;
public ServerInterface si;
public SavedFlags sf;
public WorldManager wm;
public LogViewer lv;
public AdminList al;
public RankManager rm;
public CommandLoader cl;
public CommandBlocker cb;
public EventBlocker eb;
public BlockBlocker bb;
public MobBlocker mb;
public InteractBlocker ib;
public PotionBlocker pb;
public LoginProcess lp;
public AntiNuke nu;
public AntiSpam as;
public PlayerList pl;
public Announcer an;
public ChatManager cm;
public BanManager bm;
public PermbanList pm;
public ProtectArea pa;
public GameRuleHandler gr;
public RollbackManager rb;
public CommandSpy cs;
public Cager ca;
public Freezer fm;
public Orbiter or;
public Muter mu;
public Fuckoff fo;
public AutoKick ak;
public AutoEject ae;
public MovementValidator mv;
public EntityWiper ew;
public FrontDoor fd;
public ServerPing sp;
public ItemFun it;
public Landminer lm;
public MP44 mp;
public Jumppads jp;
public Trailer tr;
public HTTPDaemon hd;
//
// Bridges
public ServiceManager<TotalFreedomMod> bridges;
public BukkitTelnetBridge btb;
public EssentialsBridge esb;
public WorldEditBridge web;
@Override
public void load()
{
TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
FLog.setPluginLogger(plugin.getLogger());
FLog.setServerLogger(server.getLogger());
build.load(plugin);
}
@Override
public void enable()
{
FLog.info("Created by Madgeek1450 and Prozza");
FLog.info("Version " + build.formattedVersion());
FLog.info("Compiled " + build.date + " by " + build.author);
final MethodTimer timer = new MethodTimer();
timer.start();
// Warn if we're running on a wrong version
ServerInterface.warnVersion();
// Delete unused files
FUtil.deleteCoreDumps();
FUtil.deleteFolder(new File("./_deleteme"));
// Convert old config files
new ConfigConverter(plugin).convert();
BackupManager backups = new BackupManager(this);
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
backups.createBackups(AdminList.CONFIG_FILENAME);
backups.createBackups(PermbanList.CONFIG_FILENAME);
config = new MainConfig(this);
config.load();
// Start services
services = new ServiceManager<>(plugin);
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);
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);
pl = services.registerService(PlayerList.class);
an = services.registerService(Announcer.class);
cm = services.registerService(ChatManager.class);
bm = services.registerService(BanManager.class);
pm = services.registerService(PermbanList.class);
pa = services.registerService(ProtectArea.class);
gr = services.registerService(GameRuleHandler.class);
// Single admin utils
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);
fo = services.registerService(Fuckoff.class);
ak = services.registerService(AutoKick.class);
ae = services.registerService(AutoEject.class);
mv = services.registerService(MovementValidator.class);
ew = services.registerService(EntityWiper.class);
fd = services.registerService(FrontDoor.class);
sp = services.registerService(ServerPing.class);
// Fun
it = services.registerService(ItemFun.class);
lm = services.registerService(Landminer.class);
mp = services.registerService(MP44.class);
jp = services.registerService(Jumppads.class);
tr = services.registerService(Trailer.class);
// HTTPD
hd = services.registerService(HTTPDaemon.class);
services.start();
// Start bridges
bridges = new ServiceManager<>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class);
esb = bridges.registerService(EssentialsBridge.class);
web = bridges.registerService(WorldEditBridge.class);
bridges.start();
timer.update();
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
try
{
final Metrics metrics = new Metrics(plugin);
metrics.start();
}
catch (IOException ex)
{
FLog.warning("Failed to submit metrics data: " + ex.getMessage());
}
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
new BukkitRunnable()
{
@Override
public void run()
{
plugin.pa.autoAddSpawnpoints();
}
}.runTaskLater(plugin, 60L);
}
@Override
public void disable()
{
// Stop services and bridges
bridges.stop();
services.stop();
server.getScheduler().cancelTasks(plugin);
FLog.info("Plugin disabled");
}
public static class BuildProperties
{
public String author;
public String codename;
public String version;
public String number;
public String date;
public String head;
public void load(TotalFreedomMod plugin)
{
try
{
final Properties props;
try (InputStream in = plugin.getResource("build.properties"))
{
props = new Properties();
props.load(in);
}
author = props.getProperty("program.build.author", "unknown");
codename = props.getProperty("program.build.codename", "unknown");
version = props.getProperty("program.build.version", "unknown");
number = props.getProperty("program.build.number", "1");
date = props.getProperty("program.build.date", "unknown");
head = props.getProperty("program.build.head", "unknown");
}
catch (Exception ex)
{
FLog.severe("Could not load build properties! Did you compile with Netbeans/ANT?");
FLog.severe(ex);
}
}
public String formattedVersion()
{
return pluginVersion + "." + number + " (" + head + ")";
}
}
public static TotalFreedomMod plugin()
{
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
{
if (plugin.getName().equalsIgnoreCase(pluginName))
{
return (TotalFreedomMod) plugin;
}
}
return null;
}
}

View File

@ -0,0 +1,150 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.collect.Lists;
import java.util.Date;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.rank.Rank;
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.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
{
@Getter
private String configKey;
@Getter
@Setter
private String name;
@Getter
@Setter
private boolean active = true;
@Getter
@Setter
private Rank rank = Rank.SUPER_ADMIN;
@Getter
private final List<String> ips = Lists.newArrayList();
@Getter
@Setter
private Date lastLogin = new Date();
@Getter
@Setter
private String loginMessage = null;
public Admin(Player player)
{
this.configKey = player.getName().toLowerCase();
this.name = player.getName();
this.ips.add(Ips.getIp(player));
}
public Admin(String configKey)
{
this.configKey = configKey;
}
@Override
public String toString()
{
final StringBuilder output = new StringBuilder();
output.append("Admin: ").append(name).append("\n")
.append("- IPs: ").append(StringUtils.join(ips, ", ")).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("- Is Active: ").append(active);
return output.toString();
}
public void loadFrom(Player player)
{
configKey = player.getName().toLowerCase();
name = player.getName();
ips.clear();
ips.add(Ips.getIp(player));
}
@Override
public void loadFrom(ConfigurationSection cs)
{
name = cs.getString("username", configKey);
active = cs.getBoolean("active", true);
rank = Rank.findRank(cs.getString("rank"));
ips.clear();
ips.addAll(cs.getStringList("ips"));
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
loginMessage = cs.getString("login_message", null);
}
@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("last_login", FUtil.dateToString(lastLogin));
cs.set("login_message", loginMessage);
}
public boolean isAtLeast(Rank pRank)
{
return rank.isAtLeast(pRank);
}
public boolean hasLoginMessage()
{
return loginMessage != null && !loginMessage.isEmpty();
}
// Util IP methods
public void addIp(String ip)
{
if (!ips.contains(ip))
{
ips.add(ip);
}
}
public void addIps(List<String> ips)
{
for (String ip : ips)
{
addIp(ip);
}
}
public void removeIp(String ip)
{
if (ips.contains(ip))
{
ips.remove(ip);
}
}
public void clearIPs()
{
ips.clear();
}
@Override
public boolean isValid()
{
return configKey != null
&& name != null
&& rank != null
&& !ips.isEmpty()
&& lastLogin != null;
}
}

View File

@ -0,0 +1,354 @@
package me.totalfreedom.totalfreedommod.admin;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.command.Command_logs;
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 net.pravian.aero.config.YamlConfig;
import net.pravian.aero.util.Ips;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
public class AdminList extends FreedomService
{
public static final String CONFIG_FILENAME = "admins.yml";
@Getter
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
// Only active admins below
@Getter
private final Set<Admin> activeAdmins = Sets.newHashSet();
private final Map<String, Admin> nameTable = Maps.newHashMap();
private final Map<String, Admin> ipTable = Maps.newHashMap();
//
private final YamlConfig config;
public AdminList(TotalFreedomMod plugin)
{
super(plugin);
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
}
@Override
protected void onStart()
{
load();
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
{
@Override
public Boolean apply(Player player)
{
return isAdmin(player);
}
}, plugin, ServicePriority.Normal);
deactivateOldEntries(false);
}
@Override
protected void onStop()
{
save();
}
public void load()
{
config.load();
allAdmins.clear();
for (String key : config.getKeys(false))
{
ConfigurationSection section = config.getConfigurationSection(key);
if (section == null)
{
logger.warning("Invalid admin list format: " + key);
continue;
}
Admin admin = new Admin(key);
admin.loadFrom(section);
if (!admin.isValid())
{
FLog.warning("Could not load admin: " + key + ". Missing details!");
continue;
}
allAdmins.put(key, admin);
}
updateTables();
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 synchronized boolean isAdminSync(CommandSender sender)
{
return isAdmin(sender);
}
public boolean isAdmin(CommandSender sender)
{
if (!(sender instanceof Player))
{
return true;
}
Admin admin = getAdmin((Player) sender);
return admin != null && admin.isActive();
}
public boolean isSeniorAdmin(CommandSender sender)
{
Admin admin = getAdmin(sender);
if (admin == null)
{
return false;
}
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
}
public Admin getAdmin(CommandSender sender)
{
if (sender instanceof Player)
{
return getAdmin((Player) sender);
}
return getEntryByName(sender.getName());
}
public Admin getAdmin(Player player)
{
// Find admin
String ip = Ips.getIp(player);
Admin admin = getEntryByName(player.getName());
// Admin by name
if (admin != null)
{
// Check if we're in online mode,
// Or the players IP is in the admin entry
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
{
if (!admin.getIps().contains(ip))
{
// Add the new IP if we have to
admin.addIp(ip);
save();
updateTables();
}
return admin;
}
// Impostor
}
// Admin by ip
admin = getEntryByIp(ip);
if (admin != null)
{
// Set the new username
admin.setName(player.getName());
save();
updateTables();
}
return null;
}
public Admin getEntryByName(String name)
{
return nameTable.get(name.toLowerCase());
}
public Admin getEntryByIp(String ip)
{
return ipTable.get(ip);
}
public Admin getEntryByIpFuzzy(String needleIp)
{
final Admin directAdmin = getEntryByIp(needleIp);
if (directAdmin != null)
{
return directAdmin;
}
for (String ip : ipTable.keySet())
{
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
{
return ipTable.get(ip);
}
}
return null;
}
public void updateLastLogin(Player player)
{
final Admin admin = getAdmin(player);
if (admin == null)
{
return;
}
admin.setLastLogin(new Date());
admin.setName(player.getName());
save();
}
public boolean isAdminImpostor(Player player)
{
return getEntryByName(player.getName()) != null && !isAdmin(player);
}
public boolean isIdentityMatched(Player player)
{
if (Bukkit.getOnlineMode())
{
return true;
}
Admin admin = getAdmin(player);
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName());
}
public boolean addAdmin(Admin admin)
{
if (!admin.isValid())
{
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
return false;
}
final String key = admin.getConfigKey();
// Store admin, update views
allAdmins.put(key, admin);
updateTables();
// Save admin
admin.saveTo(config.createSection(key));
config.save();
return true;
}
public boolean removeAdmin(Admin admin)
{
// Remove admin, update views
if (allAdmins.remove(admin.getConfigKey()) == null)
{
return false;
}
updateTables();
// 'Unsave' admin
config.set(admin.getConfigKey(), null);
config.save();
return true;
}
public void updateTables()
{
activeAdmins.clear();
nameTable.clear();
ipTable.clear();
for (Admin admin : allAdmins.values())
{
if (!admin.isActive())
{
continue;
}
activeAdmins.add(admin);
nameTable.put(admin.getName().toLowerCase(), admin);
for (String ip : admin.getIps())
{
ipTable.put(ip, admin);
}
}
plugin.wm.adminworld.wipeAccessCache();
}
public Set<String> getAdminNames()
{
return nameTable.keySet();
}
public Set<String> getAdminIps()
{
return ipTable.keySet();
}
public void deactivateOldEntries(boolean verbose)
{
for (Admin admin : allAdmins.values())
{
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
{
continue;
}
final Date lastLogin = admin.getLastLogin();
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
{
continue;
}
if (verbose)
{
FUtil.adminAction("TotalFreedomMod", "Deactivating superadmin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
}
admin.setActive(false);
plugin.lv.deactivateSuperadmin(admin);
}
save();
updateTables();
}
}

View File

@ -0,0 +1,279 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
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.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
{
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();
@Getter
@Setter
private String by = null;
@Getter
@Setter
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
@Getter
@Setter
private long expiryUnix = -1;
public Ban()
{
}
public Ban(String username, String ip, String by, Date expire, String reason)
{
this(username,
new String[]
{
ip
},
by,
expire,
reason);
}
public Ban(String username, String[] ips, String by, Date expire, String reason)
{
this.username = username;
if (ips != null)
{
this.ips.addAll(Arrays.asList(ips));
}
dedupeIps();
this.by = by;
this.expiryUnix = FUtil.getUnixTime(expire);
this.reason = reason;
}
//
// For player IP
public static Ban forPlayerIp(Player player, CommandSender by)
{
return forPlayerIp(player, by, null, null);
}
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(null, new String[]
{
Ips.getIp(player)
}, by.getName(), expiry, reason);
}
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
{
return new Ban(null, ip, by.getName(), expiry, reason);
}
//
// For player name
public static Ban forPlayerName(Player player, CommandSender by, Date expiry, String reason)
{
return forPlayerName(player.getName(), by, expiry, reason);
}
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
{
return new Ban(player,
(String[]) null,
by.getName(),
expiry,
reason);
}
//
// For player
public static Ban forPlayer(Player player, CommandSender by)
{
return forPlayerName(player, by, null, null);
}
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(player.getName(),
Ips.getIp(player),
by.getName(),
expiry,
reason);
}
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
{
return new Ban(player.getName(),
FUtil.getFuzzyIp(Ips.getIp(player)),
by.getName(),
expiry,
reason);
}
public boolean hasUsername()
{
return username != null && !username.isEmpty();
}
public boolean addIp(String ip)
{
return ips.add(ip);
}
public boolean removeIp(String ip)
{
return ips.remove(ip);
}
public boolean hasIps()
{
return !ips.isEmpty();
}
public boolean hasExpiry()
{
return expiryUnix > 0;
}
public Date getExpiryDate()
{
return FUtil.getUnixDate(expiryUnix);
}
public boolean isExpired()
{
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
}
public String bakeKickMessage()
{
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server.");
message.append("\nAppeal at ").append(ChatColor.BLUE)
.append(ConfigEntry.SERVER_BAN_URL.getString());
if (reason != null)
{
message.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD)
.append(ChatColor.translateAlternateColorCodes('&', reason));
}
if (by != null)
{
message.append("\n").append(ChatColor.RED).append("Banned by: ").append(ChatColor.GOLD)
.append(by);
}
if (getExpiryUnix() != 0)
{
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
}
return message.toString();
}
@Override
public boolean equals(Object object)
{
if (object == null)
{
return false;
}
if (!(object instanceof Ban))
{
return false;
}
final Ban ban = (Ban) object;
if (hasIps() != ban.hasIps()
|| hasUsername() != hasUsername())
{
return false;
}
if (hasIps() && !(getIps().equals(ban.getIps())))
{
return false;
}
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.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("reason", reason);
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
}
@Override
public boolean isValid()
{
return username != null || !ips.isEmpty();
}
private void dedupeIps()
{
Set<String> uniqueIps = new HashSet<>();
Iterator<String> it = ips.iterator();
while (it.hasNext())
{
if (!uniqueIps.add(it.next()))
{
it.remove();
}
}
}
}

View File

@ -0,0 +1,303 @@
package me.totalfreedom.totalfreedommod.banning;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
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.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
public class BanManager extends FreedomService
{
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 List<String> unbannableUsernames = Lists.newArrayList();
//
private final YamlConfig config;
public BanManager(TotalFreedomMod plugin)
{
super(plugin);
this.config = new YamlConfig(plugin, "bans.yml");
}
@Override
protected void onStart()
{
config.load();
bans.clear();
for (String id : config.getKeys(false))
{
if (!config.isConfigurationSection(id))
{
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
continue;
}
Ban ban = new Ban();
ban.loadFrom(config.getConfigurationSection(id));
if (!ban.isValid())
{
FLog.warning("Not adding username ban: " + id + ". Missing information.");
continue;
}
bans.add(ban);
}
// Remove expired bans, repopulate ipBans and nameBans,
updateViews();
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
// Load unbannable usernames
unbannableUsernames.clear();
unbannableUsernames.addAll((Collection<? extends String>) ConfigEntry.FAMOUS_PLAYERS.getList());
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
}
@Override
protected void onStop()
{
saveAll();
logger.info("Saved " + bans.size() + " player bans");
}
public Set<Ban> getAllBans()
{
return Collections.unmodifiableSet(bans);
}
public Collection<Ban> getIpBans()
{
return Collections.unmodifiableCollection(ipBans.values());
}
public Collection<Ban> getUsernameBans()
{
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)
{
final Ban directBan = ipBans.get(ip);
if (directBan != null && !directBan.isExpired())
{
return directBan;
}
// Match fuzzy IP
for (Ban loopBan : ipBans.values())
{
if (loopBan.isExpired())
{
continue;
}
for (String loopIp : loopBan.getIps())
{
if (!loopIp.contains("*"))
{
continue;
}
if (Ips.fuzzyIpMatch(ip, loopIp, 4))
{
return loopBan;
}
}
}
return null;
}
public Ban getByUsername(String username)
{
username = username.toLowerCase();
final Ban directBan = nameBans.get(username);
if (directBan != null && !directBan.isExpired())
{
return directBan;
}
return null;
}
public Ban unbanIp(String ip)
{
final Ban ban = getByIp(ip);
if (ban != null)
{
bans.remove(ban);
saveAll();
}
return ban;
}
public Ban unbanUsername(String username)
{
final Ban ban = getByUsername(username);
if (ban != null)
{
bans.remove(ban);
saveAll();
}
return ban;
}
public boolean isIpBanned(String ip)
{
return getByIp(ip) != null;
}
public boolean isUsernameBanned(String username)
{
return getByUsername(username) != null;
}
public boolean addBan(Ban ban)
{
if (bans.add(ban))
{
saveAll();
return true;
}
return false;
}
public boolean removeBan(Ban ban)
{
if (bans.remove(ban))
{
saveAll();
return true;
}
return false;
}
public int purge()
{
config.clear();
config.save();
int size = bans.size();
bans.clear();
updateViews();
return size;
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerLogin(PlayerLoginEvent event)
{
final String username = event.getPlayer().getName();
final String ip = Ips.getIp(event);
// Regular ban
Ban ban = getByUsername(username);
if (ban == null)
{
ban = getByIp(ip);
}
if (ban != null && !ban.isExpired())
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
final PlayerData data = plugin.pl.getData(player);
if (!plugin.al.isAdmin(player))
{
return;
}
// Unban admins
for (String storedIp : data.getIps())
{
unbanIp(storedIp);
unbanIp(FUtil.getFuzzyIp(storedIp));
}
unbanUsername(player.getName());
player.setOp(true);
}
private void updateViews()
{
// Remove expired bans
for (Iterator<Ban> it = bans.iterator(); it.hasNext();)
{
if (it.next().isExpired())
{
it.remove();
}
}
nameBans.clear();
ipBans.clear();
for (Ban ban : bans)
{
if (ban.hasUsername())
{
nameBans.put(ban.getUsername().toLowerCase(), ban);
}
if (ban.hasIps())
{
for (String ip : ban.getIps())
{
ipBans.put(ip, ban);
}
}
}
}
}

View File

@ -0,0 +1,90 @@
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;
}
}
}
}

View File

@ -0,0 +1,114 @@
package me.totalfreedom.totalfreedommod.blocking;
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 org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
public class BlockBlocker extends FreedomService
{
public BlockBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
final Player player = event.getPlayer();
switch (event.getBlockPlaced().getType())
{
case LAVA:
case STATIONARY_LAVA:
{
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
else
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
event.setCancelled(true);
}
break;
}
case WATER:
case STATIONARY_WATER:
{
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
else
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
event.setCancelled(true);
}
break;
}
case FIRE:
{
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
else
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
event.setCancelled(true);
}
break;
}
case TNT:
{
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
else
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
}
break;
}
}
}
}

View File

@ -0,0 +1,172 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
public class EventBlocker extends FreedomService
{
public EventBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBurn(BlockBurnEvent event)
{
if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockIgnite(BlockIgniteEvent event)
{
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(BlockFromToEvent event)
{
if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event)
{
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
event.setCancelled(true);
return;
}
event.setYield(0.0F);
}
@EventHandler(priority = EventPriority.HIGH)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
event.setCancelled(true);
return;
}
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event)
{
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event)
{
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
event.setDroppedExp(0);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onProjectileHit(ProjectileHitEvent event)
{
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
Projectile entity = event.getEntity();
if (event.getEntityType() == EntityType.ARROW)
{
entity.getWorld().createExplosion(entity.getLocation(), 2F);
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
switch (event.getCause())
{
case LAVA:
{
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
event.setCancelled(true);
return;
}
}
}
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
{
Entity entity = event.getEntity();
if (entity instanceof Tameable)
{
if (((Tameable) entity).isTamed())
{
event.setCancelled(true);
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{
return;
}
if (event.getPlayer().getWorld().getEntities().size() > 750)
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onLeavesDecay(LeavesDecayEvent event)
{
event.setCancelled(true);
}
}

View File

@ -0,0 +1,103 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class InteractBlocker extends FreedomService
{
public InteractBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
final FPlayer playerdata = plugin.pl.getPlayer(player);
switch (event.getAction())
{
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
{
handleRightClick(event);
break;
}
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
{
//
break;
}
}
}
private void handleRightClick(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
switch (event.getMaterial())
{
case WATER_BUCKET:
{
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
break;
}
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
break;
}
case LAVA_BUCKET:
{
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
break;
}
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
break;
}
case EXPLOSIVE_MINECART:
{
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{
break;
}
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
event.setCancelled(true);
break;
}
}
}
}

View File

@ -0,0 +1,104 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import org.bukkit.entity.Bat;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Giant;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class MobBlocker extends FreedomService
{
public MobBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.NORMAL)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
if (!ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{
return;
}
final Entity spawned = event.getEntity();
if (spawned instanceof EnderDragon)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Ghast)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Slime)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Giant)
{
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Bat)
{
event.setCancelled(true);
return;
}
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
if (mobLimiterMax <= 0)
{
return;
}
int mobcount = 0;
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
{
if (!(entity instanceof HumanEntity))
{
mobcount++;
}
}
if (mobcount > mobLimiterMax)
{
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,62 @@
package me.totalfreedom.totalfreedommod.blocking;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource;
public class PotionBlocker extends FreedomService
{
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
public PotionBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onThrowPotion(PotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
event.setCancelled(true);
return;
}
Player thrower = (Player) source;
if (plugin.al.isAdmin(thrower))
{
return;
}
for (Player player : thrower.getWorld().getPlayers())
{
if (thrower.getLocation().distanceSquared(player.getLocation()) < POTION_BLOCK_RADIUS_SQUARED)
{
thrower.sendMessage(ChatColor.RED + "You cannot use splash potions close to other players.");
event.setCancelled(true);
return;
}
}
}
}

View File

@ -0,0 +1,210 @@
package me.totalfreedom.totalfreedommod.blocking.command;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.command.CommandReflection;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlocker extends FreedomService
{
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
//
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
private final List<String> unknownCommands = Lists.newArrayList();
public CommandBlocker(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
load();
}
@Override
protected void onStop()
{
entryList.clear();
}
public void load()
{
entryList.clear();
unknownCommands.clear();
final CommandMap commandMap = CommandReflection.getCommandMap();
if (commandMap == null)
{
FLog.severe("Error loading commandMap.");
return;
}
@SuppressWarnings("unchecked")
List<String> blockedCommands = (List<String>) ConfigEntry.BLOCKED_COMMANDS.getList();
for (String rawEntry : blockedCommands)
{
final String[] parts = rawEntry.split(":");
if (parts.length < 3 || parts.length > 4)
{
FLog.warning("Invalid command blocker entry: " + rawEntry);
continue;
}
final CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
final CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
String commandName = parts[2].toLowerCase().substring(1);
final String message = (parts.length > 3 ? parts[3] : null);
if (rank == null || action == null || commandName == null || commandName.isEmpty())
{
FLog.warning("Invalid command blocker entry: " + rawEntry);
continue;
}
final String[] commandParts = commandName.split(" ");
String subCommand = null;
if (commandParts.length > 1)
{
commandName = commandParts[0];
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
}
final Command command = commandMap.getCommand(commandName);
// Obtain command from alias
if (command == null)
{
unknownCommands.add(commandName);
}
else
{
commandName = command.getName().toLowerCase();
}
if (entryList.containsKey(commandName))
{
FLog.warning("Not blocking: /" + commandName + " - Duplicate entry exists!");
continue;
}
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
if (command != null)
{
for (String alias : command.getAliases())
{
entryList.put(alias.toLowerCase(), blockedCommandEntry);
}
}
}
FLog.info("Loaded " + blockedCommands.size() + " blocked commands (" + (blockedCommands.size() - unknownCommands.size()) + " known).");
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
// Blocked commands
if (isCommandBlocked(event.getMessage(), event.getPlayer(), true))
{
// CommandBlocker handles messages and broadcasts
event.setCancelled(true);
}
}
public boolean isCommandBlocked(String command, CommandSender sender)
{
return isCommandBlocked(command, sender, false);
}
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
{
if (command == null || command.isEmpty())
{
return false;
}
// Format
command = command.toLowerCase().trim();
command = command.startsWith("/") ? command.substring(1) : command;
// Check for plugin specific commands
final String[] commandParts = command.split(" ");
if (commandParts[0].contains(":"))
{
if (doAction)
{
FUtil.playerMsg(sender, "Plugin specific commands are disabled.");
}
return true;
}
for (String part : commandParts)
{
Matcher matcher = flagPattern.matcher(part);
if (!matcher.matches())
{
continue;
}
if (doAction)
{
FUtil.playerMsg(sender, "That command contains an illegal number: " + matcher.group(1));
}
return true;
}
// Obtain sub command, if it exists
String subCommand = null;
if (commandParts.length > 1)
{
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).toLowerCase();
}
// Obtain entry
final CommandBlockerEntry entry = entryList.get(commandParts[0]);
if (entry == null)
{
return false;
}
// Validate sub command
if (entry.getSubCommand() != null)
{
if (subCommand == null || !subCommand.startsWith(entry.getSubCommand()))
{
return false;
}
}
if (entry.getRank().hasPermission(sender))
{
return false;
}
if (doAction)
{
entry.doActions(sender);
}
return true;
}
}

View File

@ -0,0 +1,32 @@
package me.totalfreedom.totalfreedommod.blocking.command;
public enum CommandBlockerAction
{
BLOCK("b"),
BLOCK_AND_EJECT("a"),
BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token)
{
for (CommandBlockerAction action : CommandBlockerAction.values())
{
if (action.getToken().equalsIgnoreCase(token))
{
return action;
}
}
return null;
}
}

View File

@ -0,0 +1,55 @@
package me.totalfreedom.totalfreedommod.blocking.command;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandBlockerEntry
{
@Getter
private final CommandBlockerRank rank;
@Getter
private final CommandBlockerAction action;
@Getter
private final String command;
@Getter
private final String subCommand;
@Getter
private final String message;
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this(rank, action, command, null, message);
}
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message)
{
this.rank = rank;
this.action = action;
this.command = command;
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim());
this.message = (message == null || message.equals("_") ? "That command is blocked." : message);
}
public void doActions(CommandSender sender)
{
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TotalFreedomMod.plugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
return;
}
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
{
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
return;
}
FUtil.playerMsg(sender, FUtil.colorize(message));
}
}

View File

@ -0,0 +1,73 @@
package me.totalfreedom.totalfreedommod.blocking.command;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public enum CommandBlockerRank
{
ANYONE("a"),
OP("o"),
SUPER("s"),
TELNET("t"),
SENIOR("c"),
NOBODY("n");
//
private final String token;
private CommandBlockerRank(String 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)
{
if (!(sender instanceof Player))
{
return TELNET;
}
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
if (admin != null)
{
if (admin.getRank() == Rank.SENIOR_ADMIN)
{
return SENIOR;
}
return SUPER;
}
if (sender.isOp())
{
return OP;
}
return ANYONE;
}
public static CommandBlockerRank fromToken(String token)
{
for (CommandBlockerRank rank : CommandBlockerRank.values())
{
if (rank.getToken().equalsIgnoreCase(token))
{
return rank;
}
}
return ANYONE;
}
}

View File

@ -0,0 +1,97 @@
package me.totalfreedom.totalfreedommod.bridge;
import java.util.Iterator;
import java.util.Map;
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class BukkitTelnetBridge extends FreedomService
{
public BukkitTelnetBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetPreLogin(TelnetPreLoginEvent event)
{
final String ip = event.getIp();
if (ip == null || ip.isEmpty())
{
return;
}
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
{
return;
}
event.setBypassPassword(true);
event.setName(admin.getName());
}
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetCommand(TelnetCommandEvent event)
{
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
{
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<Player, Map<String, Object>> entry = it.next();
final Player player = entry.getKey();
final Map<String, Object> playerTags = entry.getValue();
boolean isAdmin = false;
boolean isTelnetAdmin = false;
boolean isSeniorAdmin = false;
final Admin admin = plugin.al.getAdmin(player);
if (admin != null)
{
boolean active = admin.isActive();
isAdmin = active;
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
}
playerTags.put("tfm.admin.isAdmin", isAdmin);
playerTags.put("tfm.admin.isTelnetAdmin", isTelnetAdmin);
playerTags.put("tfm.admin.isSeniorAdmin", isSeniorAdmin);
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
}
}
}

View File

@ -0,0 +1,139 @@
package me.totalfreedom.totalfreedommod.bridge;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class EssentialsBridge extends FreedomService
{
private Essentials essentialsPlugin = null;
public EssentialsBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public Essentials getEssentialsPlugin()
{
if (essentialsPlugin == null)
{
try
{
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null)
{
if (essentials instanceof Essentials)
{
essentialsPlugin = (Essentials) essentials;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return essentialsPlugin;
}
public User getEssentialsUser(String username)
{
try
{
final Essentials essentials = getEssentialsPlugin();
if (essentials != null)
{
return essentials.getUserMap().getUser(username);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public void setNickname(String username, String nickname)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
user.setNickname(nickname);
user.setDisplayNick();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
public String getNickname(String username)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
return user.getNickname();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public long getLastActivity(String username)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
return FUtil.<Long>getField(user, "lastActivity"); // This is weird
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return 0L;
}
public boolean isEssentialsEnabled()
{
try
{
final Essentials essentials = getEssentialsPlugin();
if (essentials != null)
{
return essentials.isEnabled();
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return false;
}
}

View File

@ -0,0 +1,138 @@
package me.totalfreedom.totalfreedommod.bridge;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class WorldEditBridge extends FreedomService
{
private final WorldEditListener listener;
//
private WorldEditPlugin worldedit = null;
public WorldEditBridge(TotalFreedomMod plugin)
{
super(plugin);
listener = new WorldEditListener(plugin);
}
@Override
protected void onStart()
{
listener.register();
}
@Override
protected void onStop()
{
listener.unregister();
}
public void undo(Player player, int count)
{
try
{
LocalSession session = getPlayerSession(player);
if (session != null)
{
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
if (bukkitPlayer != null)
{
for (int i = 0; i < count; i++)
{
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
}
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private WorldEditPlugin getWorldEditPlugin()
{
if (worldedit == null)
{
try
{
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
if (we != null)
{
if (we instanceof WorldEditPlugin)
{
worldedit = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return worldedit;
}
public void setLimit(Player player, int limit)
{
try
{
final LocalSession session = getPlayerSession(player);
if (session != null)
{
session.setBlockChangeLimit(limit);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
private LocalSession getPlayerSession(Player player)
{
final WorldEditPlugin wep = getWorldEditPlugin();
if (wep == null)
{
return null;
}
try
{
return wep.getSession(player);
}
catch (Exception ex)
{
FLog.severe(ex);
return null;
}
}
private BukkitPlayer getBukkitPlayer(Player player)
{
final WorldEditPlugin wep = getWorldEditPlugin();
if (wep == null)
{
return null;
}
try
{
return wep.wrapPlayer(player);
}
catch (Exception ex)
{
FLog.severe(ex);
return null;
}
}
}

View File

@ -0,0 +1,66 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.worldedit.LimitChangedEvent;
import me.totalfreedom.worldedit.SelectionChangedEvent;
import net.pravian.aero.component.PluginListener;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class WorldEditListener extends PluginListener<TotalFreedomMod>
{
public WorldEditListener(TotalFreedomMod plugin)
{
super(plugin);
}
@EventHandler
public void onSelectionChange(final SelectionChangedEvent event)
{
final Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
return;
}
if (plugin.pa.isInProtectedArea(
event.getMinVector(),
event.getMaxVector(),
event.getWorld().getName()))
{
player.sendMessage(ChatColor.RED + "The region that you selected contained a protected area. Selection cleared.");
event.setCancelled(true);
}
}
@EventHandler
public void onLimitChanged(LimitChangedEvent event)
{
final Player player = event.getPlayer();
if (plugin.al.isAdmin(player))
{
return;
}
if (!event.getPlayer().equals(event.getTarget()))
{
player.sendMessage(ChatColor.RED + "Only admins can change the limit for other players!");
event.setCancelled(true);
}
if (event.getLimit() < 0 || event.getLimit() > 10000)
{
player.setOp(false);
FUtil.bcastMsg(event.getPlayer().getName() + " tried to set their WorldEdit limit to " + event.getLimit() + " and has been de-opped", ChatColor.RED);
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You cannot set your limit higher than 10000 or to -1!");
}
}
}

View File

@ -0,0 +1,210 @@
package me.totalfreedom.totalfreedommod.caging;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
public class CageData
{
private final FPlayer fPlayer;
//
private final List<BlockData> cageHistory = new ArrayList<>();
//
@Getter
private boolean caged = false;
@Getter
private Location location;
@Getter
private Material outerMaterial = Material.GLASS;
@Getter
private Material innerMaterial = Material.AIR;
public CageData(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;
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);
}
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
public static void generateCube(Location location, int length, Material material)
{
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);
if (block.getType() != material)
{
block.setType(material);
}
}
}
}
}
public static void generateHollowCube(Location location, int length, Material material)
{
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++)
{
// Hollow
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
{
continue;
}
final Block block = center.getRelative(xOffset, yOffset, zOffset);
if (material != Material.SKULL)
{
// Glowstone light
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
{
block.setType(Material.GLOWSTONE);
continue;
}
block.setType(material);
}
else // Darth mode
{
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
{
block.setType(Material.GLOWSTONE);
continue;
}
block.setType(Material.SKULL);
final Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner("Prozza");
skull.update();
}
}
}
}
}
private static class BlockData
{
public Material material;
public Location location;
private BlockData(Location location, Material material)
{
this.location = location;
this.material = material;
}
}
}

View File

@ -0,0 +1,110 @@
package me.totalfreedom.totalfreedommod.caging;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
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.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class Cager extends FreedomService
{
public Cager(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBreakBlock(BlockBreakEvent event)
{
Player player = event.getPlayer();
if (player == null
|| plugin.al.isAdmin(player))
{
return;
}
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
CageData cage = fPlayer.getCageData();
if (cage.isCaged())
{
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
CageData cage = player.getCageData();
if (!cage.isCaged())
{
return;
}
Location playerLoc = player.getPlayer().getLocation().add(0, 1, 0);
Location cageLoc = cage.getLocation();
final boolean outOfCage;
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
{
outOfCage = true;
}
else
{
outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D);
}
if (outOfCage)
{
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
cage.regenerate();
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event)
{
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
CageData cage = player.getCageData();
if (cage.isCaged())
{
cage.playerQuit();
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event)
{
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
CageData cage = player.getCageData();
if (cage.isCaged())
{
cage.playerJoin();
}
}
}

View File

@ -0,0 +1,13 @@
package me.totalfreedom.totalfreedommod.command;
public class CommandFailException extends RuntimeException
{
private static final long serialVersionUID = -92333791173123L;
public CommandFailException(String message)
{
super(message);
}
}

View File

@ -0,0 +1,45 @@
package me.totalfreedom.totalfreedommod.command;
import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.pravian.aero.command.handler.SimpleCommandHandler;
import org.bukkit.ChatColor;
public class CommandLoader extends FreedomService
{
@Getter
private final SimpleCommandHandler<TotalFreedomMod> handler;
public CommandLoader(TotalFreedomMod plugin)
{
super(plugin);
handler = new SimpleCommandHandler<>(plugin);
}
@Override
protected 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("TotalFreedomMod", true);
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
}
@Override
protected void onStop()
{
handler.clearCommands();
}
}

View File

@ -1,4 +1,4 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -6,6 +6,7 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandParameters
{
String description();
String usage();

View File

@ -1,14 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import me.totalfreedom.totalfreedommod.rank.Rank;
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandPermissions
{
AdminLevel level();
Rank level();
SourceType source();
boolean block_host_console() default false;
boolean blockHostConsole() default false;
}

View File

@ -0,0 +1,41 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(
description = "AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.",
usage = "/<command> [message...]",
aliases = "o,ac")
public class Command_adminchat extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
if (senderIsConsole)
{
msg("Only in-game players can toggle AdminChat.");
return true;
}
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
userinfo.setAdminChat(!userinfo.inAdminChat());
msg("Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
}
else
{
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
}
return true;
}
}

View File

@ -0,0 +1,45 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
public class Command_adminmode extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("off"))
{
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
return true;
}
else if (args[0].equalsIgnoreCase("on"))
{
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
FUtil.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
for (Player player : server.getOnlinePlayers())
{
if (!isAdmin(player))
{
player.kickPlayer("Server is now closed to non-superadmins.");
}
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,248 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Go to the AdminWorld.",
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]")
public class Command_adminworld extends FreedomCommand
{
private enum CommandMode
{
TELEPORT, GUEST, TIME, WEATHER;
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
CommandMode commandMode = null;
if (args.length == 0)
{
commandMode = CommandMode.TELEPORT;
}
else if (args.length >= 2)
{
if ("guest".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.GUEST;
}
else if ("time".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.TIME;
}
else if ("weather".equalsIgnoreCase(args[0]))
{
commandMode = CommandMode.WEATHER;
}
}
if (commandMode == null)
{
return false;
}
try
{
switch (commandMode)
{
case TELEPORT:
{
if (!(sender instanceof Player) || playerSender == null)
{
return true;
}
World adminWorld = null;
try
{
adminWorld = plugin.wm.adminworld.getWorld();
}
catch (Exception ex)
{
}
if (adminWorld == null || playerSender.getWorld() == adminWorld)
{
msg("Going to the main world.");
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
}
else
{
if (plugin.wm.adminworld.canAccessWorld(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;
}
case TIME:
{
assertCommandPerms(sender, playerSender);
if (args.length == 2)
{
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
if (timeOfDay != null)
{
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
msg("AdminWorld time set to: " + timeOfDay.name());
}
else
{
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
}
}
else
{
return false;
}
break;
}
case WEATHER:
{
assertCommandPerms(sender, playerSender);
if (args.length == 2)
{
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
if (weatherMode != null)
{
plugin.wm.adminworld.setWeatherMode(weatherMode);
msg("AdminWorld weather set to: " + weatherMode.name());
}
else
{
msg("Invalid weather mode. Can be: off, rain, storm");
}
}
else
{
return false;
}
break;
}
default:
{
return false;
}
}
}
catch (PermissionDeniedException ex)
{
if (ex.getMessage().isEmpty())
{
return noPerms();
}
sender.sendMessage(ex.getMessage());
return true;
}
return true;
}
// TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{
if (!(sender instanceof Player) || playerSender == null || !isAdmin(sender))
{
throw new PermissionDeniedException();
}
}
private class PermissionDeniedException extends Exception
{
private static final long serialVersionUID = 1L;
private PermissionDeniedException()
{
super("");
}
private PermissionDeniedException(String string)
{
super(string);
}
}
}

View File

@ -0,0 +1,26 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Make an announcement", usage = "/<command> <message>")
public class Command_announce extends FreedomCommand
{
@Override
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
plugin.an.announce(StringUtils.join(args, " "));
return true;
}
}

View File

@ -0,0 +1,37 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
public class Command_banlist extends FreedomCommand {
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("purge")) {
checkRank(Rank.SENIOR_ADMIN);
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
int amount = plugin.bm.purge();
sender.sendMessage(ChatColor.GRAY + "Purged " + amount + " player bans.");
return true;
}
return false;
}
msg(plugin.bm.getAllBans().size() + " player bans ("
+ plugin.bm.getUsernameBans().size() + " usernames, "
+ plugin.bm.getIpBans().size() + " IPs)");
return true;
}
}

View File

@ -0,0 +1,84 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
public class Command_blockcmd extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
int counter = 0;
for (Player player : server.getOnlinePlayers())
{
FPlayer playerdata = plugin.pl.getPlayer(player);
if (playerdata.allCommandsBlocked())
{
counter += 1;
playerdata.setCommandsBlocked(false);
}
}
msg("Unblocked commands for " + counter + " players.");
return true;
}
if (args[0].equals("-a"))
{
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
int counter = 0;
for (Player player : server.getOnlinePlayers())
{
if (isAdmin(player))
{
continue;
}
counter += 1;
plugin.pl.getPlayer(player).setCommandsBlocked(true);
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
}
msg("Blocked commands for " + counter + " players.");
return true;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (isAdmin(player))
{
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
return true;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
return true;
}
}

View File

@ -0,0 +1,110 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
public class Command_cage extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
if ("off".equals(args[0]) && sender instanceof Player)
{
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.getCageData().setCaged(false);
return true;
}
else if ("purge".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
for (Player player : server.getOnlinePlayers())
{
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.getCageData().setCaged(false);
}
return true;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR;
if (args.length >= 2)
{
if ("off".equals(args[1]))
{
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
playerdata.getCageData().setCaged(false);
return true;
}
else
{
if ("darth".equalsIgnoreCase(args[1]))
{
outerMaterial = Material.SKULL;
}
else if (Material.matchMaterial(args[1]) != null)
{
outerMaterial = Material.matchMaterial(args[1]);
}
}
}
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
{
innerMaterial = Material.STATIONARY_WATER;
}
else if (args[2].equalsIgnoreCase("lava"))
{
innerMaterial = Material.STATIONARY_LAVA;
}
}
Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
player.setGameMode(GameMode.SURVIVAL);
if (outerMaterial != Material.SKULL)
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
else
{
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
}
return true;
}
}

View File

@ -0,0 +1,54 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
public class Command_cake extends FreedomCommand
{
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
private final Random random = new Random();
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
final StringBuilder output = new StringBuilder();
final String[] words = CAKE_LYRICS.split(" ");
for (final String word : words)
{
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
}
final ItemStack heldItem = new ItemStack(Material.CAKE);
final ItemMeta heldItemMeta = heldItem.getItemMeta();
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
heldItem.setItemMeta(heldItemMeta);
for (final Player player : server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0)
{
player.getInventory().setItem(firstEmpty, heldItem);
}
player.awardAchievement(Achievement.BAKE_CAKE);
}
FUtil.bcastMsg(output.toString());
return true;
}
}

View File

@ -1,29 +1,29 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Sit in nearest minecart. If target is in a minecart already, they will disembark.", usage = "/<command> [partialname]")
public class Command_cartsit extends TFM_Command
public class Command_cartsit extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Player targetPlayer = sender_p;
Player targetPlayer = playerSender;
if (args.length == 1)
{
try
{
targetPlayer = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
if (targetPlayer == null)
{
sender.sendMessage(ex.getMessage());
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
}
@ -36,7 +36,7 @@ public class Command_cartsit extends TFM_Command
return true;
}
}
else if (targetPlayer != sender_p && !TFM_SuperadminList.isUserSuperadmin(sender))
else if (targetPlayer != playerSender && !isAdmin(sender))
{
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
return true;

View File

@ -0,0 +1,218 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "No Description Yet", usage = "/<command>")
public class Command_cbtool extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player)
{
Block targetBlock = DepreciationAggregator.getTargetBlock(playerSender, null, 100);
msg("Your target block: " + targetBlock.getLocation().toString());
return true;
}
try
{
final StringBuffer generatedCommand = new StringBuffer();
final Matcher matcher = Pattern.compile("\\[(.+?)\\]").matcher(StringUtils.join(args, " ").trim());
while (matcher.find())
{
matcher.appendReplacement(generatedCommand, processSubCommand(matcher.group(1)));
}
matcher.appendTail(generatedCommand);
if (plugin.cb.isCommandBlocked(generatedCommand.toString(), sender, false))
{
return true;
}
server.dispatchCommand(sender, generatedCommand.toString());
}
catch (SubCommandFailureException ex)
{
}
catch (Exception ex)
{
FLog.severe(ex);
}
return true;
}
private String processSubCommand(final String subcommand) throws SubCommandFailureException
{
final String[] args = StringUtils.split(subcommand, " ");
if (args.length == 1)
{
throw new SubCommandFailureException("Invalid subcommand name.");
}
return SubCommand.getByName(args[0]).getExecutable().execute(ArrayUtils.remove(args, 0));
}
private static enum SubCommand
{
PLAYER_DETECT("playerdetect", new SubCommandExecutable()
{
@Override
public String execute(String[] args) throws SubCommandFailureException
{
if (args.length != 5)
{
throw new SubCommandFailureException("Invalid # of arguments.");
}
double x, y, z;
try
{
x = Double.parseDouble(args[0].trim());
y = Double.parseDouble(args[1].trim());
z = Double.parseDouble(args[2].trim());
}
catch (NumberFormatException ex)
{
throw new SubCommandFailureException("Invalid coordinates.");
}
World world = null;
final String needleWorldName = args[3].trim();
final List<World> worlds = Bukkit.getWorlds();
for (final World testWorld : worlds)
{
if (testWorld.getName().trim().equalsIgnoreCase(needleWorldName))
{
world = testWorld;
break;
}
}
if (world == null)
{
throw new SubCommandFailureException("Invalid world name.");
}
final Location testLocation = new Location(world, x, y, z);
double radius;
try
{
radius = Double.parseDouble(args[4].trim());
}
catch (NumberFormatException ex)
{
throw new SubCommandFailureException("Invalid radius.");
}
final double radiusSq = radius * radius;
final List<Player> worldPlayers = testLocation.getWorld().getPlayers();
for (final Player testPlayer : worldPlayers)
{
if (testPlayer.getLocation().distanceSquared(testLocation) < radiusSq)
{
return testPlayer.getName();
}
}
throw new SubCommandFailureException("No player found in range.");
}
}),
PLAYER_DETECT_BOOLEAN("playerdetectboolean", new SubCommandExecutable()
{
@Override
public String execute(String[] args) throws SubCommandFailureException
{
try
{
PLAYER_DETECT.getExecutable().execute(args);
}
catch (SubCommandFailureException ex)
{
return "0";
}
return "1";
}
});
//
private final String name;
private final SubCommandExecutable executable;
private SubCommand(String subCommandName, SubCommandExecutable subCommandImpl)
{
this.name = subCommandName;
this.executable = subCommandImpl;
}
public SubCommandExecutable getExecutable()
{
return executable;
}
public String getName()
{
return name;
}
public static SubCommand getByName(String needle) throws SubCommandFailureException
{
needle = needle.trim();
for (SubCommand subCommand : values())
{
if (subCommand.getName().equalsIgnoreCase(needle))
{
return subCommand;
}
}
throw new SubCommandFailureException("Invalid subcommand name.");
}
}
private interface SubCommandExecutable
{
public String execute(String[] args) throws SubCommandFailureException;
}
private static class SubCommandFailureException extends Exception
{
public SubCommandFailureException()
{
}
public SubCommandFailureException(String message)
{
super(message);
}
}
}

View File

@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
public class Command_cmdspy extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setCommandSpy(!playerdata.cmdspyEnabled());
msg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -0,0 +1,59 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Iterator;
import java.util.Map;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
public class Command_colorme extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if ("list".equalsIgnoreCase(args[0]))
{
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
}
final String needle = args[0].trim().toLowerCase();
ChatColor color = null;
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<String, ChatColor> entry = it.next();
if (entry.getKey().contains(needle))
{
color = entry.getValue();
break;
}
}
if (color == null)
{
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true;
}
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
plugin.esb.setNickname(sender.getName(), newNick);
msg("Your nickname is now: " + newNick);
return true;
}
}

View File

@ -1,25 +1,27 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>")
public class Command_cmdlist extends TFM_Command
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
public class Command_commandlist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
List<String> commands = new ArrayList<String>();
List<String> commands = new ArrayList<>();
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
{

View File

@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Telnet command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message...>", aliases = "csay")
public class Command_consolesay extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 0)
{
FUtil.bcastMsg(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender.getName(), StringUtils.join(args, " ")));
}
return true;
}
}

View File

@ -0,0 +1,58 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Quickly change your own gamemode to creative, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", aliases = "gmc")
public class Command_creative extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
return true;
}
playerSender.setGameMode(GameMode.CREATIVE);
msg("Gamemode set to creative.");
return true;
}
checkRank(Rank.SUPER_ADMIN);
if (args[0].equals("-a"))
{
for (Player targetPlayer : server.getOnlinePlayers())
{
targetPlayer.setGameMode(GameMode.CREATIVE);
}
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
return true;
}
Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
msg("Setting " + player.getName() + " to game mode creative");
msg(player, sender.getName() + " set your game mode to creative");
player.setGameMode(GameMode.CREATIVE);
return true;
}
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.util.Random;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.command.Command;
@ -8,15 +9,16 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Make some noise.", usage = "/<command>")
public class Command_deafen extends TFM_Command
public class Command_deafen extends FreedomCommand
{
private static final Random random = new Random();
public static final double STEPS = 10.0;
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
for (final Player player : server.getOnlinePlayers())
{

View File

@ -1,18 +1,20 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.lang.reflect.Field;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
public class Command_debug extends TFM_Command
public class Command_debug extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 3)
{

View File

@ -0,0 +1,26 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
public class Command_denick extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
for (Player player : server.getOnlinePlayers())
{
plugin.esb.setNickname(player.getName(), null);
}
return true;
}
}

View File

@ -1,17 +1,20 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Deop a player.", usage = "/<command> <playername>")
public class Command_deop extends TFM_Command
public class Command_deop extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
@ -31,10 +34,10 @@ public class Command_deop extends TFM_Command
// if the player is not online
if (player == null)
{
player = server.getOfflinePlayer(args[0]);
player = DepreciationAggregator.getOfflinePlayer(server, args[0]);
}
TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);
FUtil.adminAction(sender.getName(), "De-opping " + player.getName(), false);
player.setOp(false);

View File

@ -0,0 +1,27 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
public class Command_deopall extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "De-opping all players on the server", true);
for (Player player : server.getOnlinePlayers())
{
player.setOp(false);
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
}
return true;
}
}

View File

@ -0,0 +1,112 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Fill nearby dispensers with a set of items of your choice.", usage = "/<command> <radius> <comma,separated,items>")
public class Command_dispfill extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 2)
{
int radius;
try
{
radius = Math.max(5, Math.min(25, Integer.parseInt(args[0])));
}
catch (NumberFormatException ex)
{
sender.sendMessage("Invalid radius.");
return true;
}
final List<ItemStack> items = new ArrayList<>();
final String[] itemsRaw = StringUtils.split(args[1], ",");
for (final String searchItem : itemsRaw)
{
Material material = Material.matchMaterial(searchItem);
if (material == null)
{
try
{
material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
}
catch (NumberFormatException ex)
{
}
}
if (material != null)
{
items.add(new ItemStack(material, 64));
}
else
{
sender.sendMessage("Skipping invalid item: " + searchItem);
}
}
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
int affected = 0;
final Location centerLocation = playerSender.getLocation();
final Block centerBlock = centerLocation.getBlock();
for (int xOffset = -radius; xOffset <= radius; xOffset++)
{
for (int yOffset = -radius; yOffset <= radius; yOffset++)
{
for (int zOffset = -radius; zOffset <= radius; zOffset++)
{
final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset);
if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius))
{
if (targetBlock.getType().equals(Material.DISPENSER))
{
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
setDispenserContents(targetBlock, itemsArray);
affected++;
}
}
}
}
}
sender.sendMessage("Done. " + affected + " dispenser(s) filled.");
}
else
{
return false;
}
return true;
}
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
{
if (targetBlock.getType() == Material.DISPENSER)
{
final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
dispenserInv.clear();
dispenserInv.addItem(items);
}
}
}

View File

@ -0,0 +1,111 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "For the bad admins", usage = "/<command> <playername>")
public class Command_doom extends FreedomCommand
{
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
final String ip = player.getAddress().getAddress().getHostAddress().trim();
// Remove from superadmin
Admin admin = getAdmin(player);
if (admin != null)
{
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list", true);
plugin.al.removeAdmin(admin);
}
// Remove from whitelist
player.setWhitelisted(false);
// Deop
player.setOp(false);
// Ban player
Ban ban = Ban.forPlayer(player, sender);
ban.setReason("&cFUCKOFF");
for (String playerIp : plugin.pl.getData(player).getIps())
{
ban.addIp(playerIp);
}
plugin.bm.addBan(ban);
// Set gamemode to survival
player.setGameMode(GameMode.SURVIVAL);
// Clear inventory
player.closeInventory();
player.getInventory().clear();
// Ignite player
player.setFireTicks(10000);
// Generate explosion
player.getWorld().createExplosion(player.getLocation(), 4F);
// Shoot the player in the sky
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
new BukkitRunnable()
{
@Override
public void run()
{
// strike lightning
player.getWorld().strikeLightning(player.getLocation());
// kill (if not done already)
player.setHealth(0.0);
}
}.runTaskLater(plugin, 2L * 20L);
new BukkitRunnable()
{
@Override
public void run()
{
// message
FUtil.adminAction(sender.getName(), "Banning " + player.getName() + ", IP: " + ip, true);
// generate explosion
player.getWorld().createExplosion(player.getLocation(), 4F);
// kick player
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
}
}.runTaskLater(plugin, 3L * 20L);
return true;
}
}

View File

@ -0,0 +1,129 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>")
public class Command_enchant extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
ItemStack item = playerSender.getEquipment().getItemInMainHand();
if (item == null || item.getType() == Material.AIR)
{
msg("You have to hold an item to enchant it");
return true;
}
if (args[0].equalsIgnoreCase("list"))
{
boolean has_enchantments = false;
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
for (Enchantment ench : Enchantment.values())
{
if (ench.canEnchantItem(item))
{
has_enchantments = true;
possible_ench.append(ench.getName()).append(", ");
}
}
if (has_enchantments)
{
msg(possible_ench.toString());
}
else
{
msg("The held item has no enchantments.");
}
}
else if (args[0].equalsIgnoreCase("addall"))
{
for (Enchantment ench : Enchantment.values())
{
try
{
if (ench.canEnchantItem(item))
{
item.addEnchantment(ench, ench.getMaxLevel());
}
}
catch (Exception ex)
{
msg("Could not add enchantment: " + ench.getName());
}
}
msg("Added all possible enchantments for this item.");
}
else if (args[0].equalsIgnoreCase("reset"))
{
for (Enchantment ench : item.getEnchantments().keySet())
{
item.removeEnchantment(ench);
}
msg("Removed all enchantments.");
}
else
{
if (args.length < 2)
{
return false;
}
Enchantment ench = null;
try
{
ench = Enchantment.getByName(args[1]);
}
catch (Exception ex)
{
}
if (ench == null)
{
msg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
return true;
}
if (args[0].equalsIgnoreCase("add"))
{
if (ench.canEnchantItem(item))
{
item.addEnchantment(ench, ench.getMaxLevel());
msg("Added enchantment: " + ench.getName());
}
else
{
msg("Can't use this enchantment on held item.");
}
}
else if (args[0].equals("remove"))
{
item.removeEnchantment(ench);
msg("Removed enchantment: " + ench.getName());
}
}
return true;
}
}

View File

@ -0,0 +1,20 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Goto the ender / \"The End\".", usage = "/<command>")
public class Command_ender extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_the_end");
return true;
}
}

View File

@ -0,0 +1,22 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> <carts>", aliases = "ew,rd")
public class Command_entitywipe extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "Removing all server entities.", true);
msg((plugin.ew.wipeEntities(true, true)) + " entities removed.");
return true;
}
}

View File

@ -0,0 +1,90 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
public class Command_expel extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
double radius = 20.0;
double strength = 5.0;
if (args.length >= 1)
{
try
{
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
}
catch (NumberFormatException ex)
{
}
}
if (args.length >= 2)
{
try
{
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
}
catch (NumberFormatException ex)
{
}
}
List<String> pushedPlayers = new ArrayList<>();
final Vector senderPos = playerSender.getLocation().toVector();
final List<Player> players = playerSender.getWorld().getPlayers();
for (final Player player : players)
{
if (player.equals(playerSender))
{
continue;
}
final Location targetPos = player.getLocation();
final Vector targetPosVec = targetPos.toVector();
boolean inRange = false;
try
{
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
}
catch (IllegalArgumentException ex)
{
}
if (inRange)
{
player.getWorld().createExplosion(targetPos, 0.0f, false);
FUtil.setFlying(player, false);
player.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
pushedPlayers.add(player.getName());
}
}
if (pushedPlayers.isEmpty())
{
msg("No players pushed.");
}
else
{
msg("Pushed " + pushedPlayers.size() + " players: " + StringUtils.join(pushedPlayers, ", "));
}
return true;
}
}

View File

@ -0,0 +1,35 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>")
public class Command_findip extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
msg("Player IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", "));
return true;
}
}

View File

@ -0,0 +1,27 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Goto the flatlands.", usage = "/<command>")
public class Command_flatlands extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (ConfigEntry.FLATLANDS_GENERATE.getBoolean())
{
plugin.wm.flatlands.sendToWorld(playerSender);
}
else
{
msg("Flatlands is currently disabled.");
}
return true;
}
}

View File

@ -0,0 +1,67 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]", aliases = "fr")
public class Command_freeze extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
boolean gFreeze = !plugin.fm.isGlobalFreeze();
plugin.fm.setGlobalFreeze(gFreeze);
if (!gFreeze)
{
FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
msg("Players are now free to move.");
return true;
}
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
for (Player player : server.getOnlinePlayers())
{
if (!isAdmin(player))
{
msg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
}
}
msg("Players are now frozen.");
return true;
}
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
plugin.fm.purge();
return true;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
fd.setFrozen(!fd.isFrozen());
msg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
msg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
return true;
}
}

View File

@ -0,0 +1,50 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "You'll never even see it coming.", usage = "/<command> <on [radius (default=25)] | off>")
public class Command_fuckoff extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
FPlayer player = plugin.pl.getPlayer(playerSender);
if (!args[0].equals("on"))
{
player.disableFuckoff();
}
else
{
double radius = 25.0;
if (args.length >= 2)
{
try
{
radius = Math.max(5.0, Math.min(50, Double.parseDouble(args[1])));
}
catch (NumberFormatException ex)
{
}
}
player.setFuckoff(radius);
}
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
return true;
}
}

View File

@ -0,0 +1,209 @@
package me.totalfreedom.totalfreedommod.command;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(
description = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci, fr, smite.",
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci | fr | smite> <targethash>] ]")
public class Command_gadmin extends FreedomCommand
{
private enum GadminMode
{
LIST("list"),
KICK("kick"),
NAMEBAN("nameban"),
IPBAN("ipban"),
BAN("ban"),
OP("op"),
DEOP("deop"),
CI("ci"),
FR("fr"),
SMITE("smite");
private final String modeName;
private GadminMode(String command)
{
this.modeName = command;
}
public String getModeName()
{
return modeName;
}
public static GadminMode findMode(String needle)
{
for (final GadminMode mode : GadminMode.values())
{
if (needle.equalsIgnoreCase(mode.getModeName()))
{
return mode;
}
}
return null;
}
}
public String getPlayerHash(Player player)
{
return UUID.nameUUIDFromBytes(player.getName().toLowerCase().getBytes(StandardCharsets.UTF_8)).toString().substring(0, 4);
}
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
final GadminMode mode = GadminMode.findMode(args[0].toLowerCase());
if (mode == null)
{
msg("Invalid mode: " + args[0], ChatColor.RED);
return true;
}
final Iterator<? extends Player> it = server.getOnlinePlayers().iterator();
if (mode == GadminMode.LIST)
{
msg("[ Real Name ] : [ Display Name ] - Hash:");
while (it.hasNext())
{
final Player player = it.next();
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
player.getName(),
ChatColor.stripColor(player.getDisplayName()),
getPlayerHash(player)));
}
return true;
}
if (args.length < 2)
{
return false;
}
Player target = null;
while (it.hasNext() && target == null)
{
final Player player = it.next();
final String hash = getPlayerHash(player);
if (hash.equalsIgnoreCase(args[1]))
{
target = player;
}
}
if (target == null)
{
msg("Invalid player hash: " + args[1], ChatColor.RED);
return true;
}
switch (mode)
{
case KICK:
{
FUtil.adminAction(sender.getName(), String.format("Kicking: %s.", target.getName()), false);
target.kickPlayer("Kicked by Administrator");
break;
}
case NAMEBAN:
{
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
target.kickPlayer("Username banned by Administrator.");
break;
}
case IPBAN:
{
String ip = target.getAddress().getAddress().getHostAddress();
String[] ip_parts = ip.split("\\.");
if (ip_parts.length == 4)
{
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
}
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
target.kickPlayer("IP address banned by Administrator.");
break;
}
case BAN:
{
String ip = target.getAddress().getAddress().getHostAddress();
String[] ip_parts = ip.split("\\.");
if (ip_parts.length == 4)
{
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
}
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
plugin.bm.addBan(Ban.forPlayer(target, sender));
target.kickPlayer("IP and username banned by Administrator.");
break;
}
case OP:
{
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
target.setOp(true);
target.sendMessage(FreedomCommand.YOU_ARE_OP);
break;
}
case DEOP:
{
FUtil.adminAction(sender.getName(), String.format("Deopping %s.", target.getName()), false);
target.setOp(false);
target.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
break;
}
case CI:
{
target.getInventory().clear();
break;
}
case FR:
{
FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
fd.setFrozen(!fd.isFrozen());
msg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
break;
}
case SMITE:
{
Command_smite.smite(target);
break;
}
}
return true;
}
}

View File

@ -0,0 +1,56 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
public class Command_gcmd extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 2)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
final String outCommand = StringUtils.join(args, " ", 1, args.length);
if (plugin.cb.isCommandBlocked(outCommand, sender))
{
return true;
}
try
{
msg("Sending command as " + player.getName() + ": " + outCommand);
if (server.dispatchCommand(player, outCommand))
{
msg("Command sent.");
}
else
{
msg("Unknown error sending command.");
}
}
catch (Throwable ex)
{
msg("Error sending command: " + ex.getMessage());
}
return true;
}
}

View File

@ -0,0 +1,115 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Bans or unbans any player, even those who are not logged in anymore.", usage = "/<command> <purge | ban <username> [reason] | unban <username>>")
public class Command_glist extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
if (args.length == 1)
{
if ("purge".equals(args[0]))
{
checkRank(Rank.SENIOR_ADMIN);
plugin.pl.purgeAllData();
msg("Purged playerbase.");
return true;
}
return false;
}
if (args.length < 2)
{
return false;
}
String username;
final List<String> ips = new ArrayList<>();
final Player player = getPlayer(args[1]);
if (player == null)
{
final PlayerData entry = plugin.pl.getData(args[1]);
if (entry == null)
{
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
return true;
}
username = entry.getUsername();
ips.addAll(entry.getIps());
}
else
{
final PlayerData entry = plugin.pl.getData(player);
username = player.getName();
ips.addAll(entry.getIps());
}
if ("ban".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
final String reason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
Ban ban = Ban.forPlayerName(username, sender, null, reason);
for (String ip : ips)
{
ban.addIp(ip);
ban.addIp(FUtil.getFuzzyIp(ip));
}
plugin.bm.addBan(ban);
if (player != null)
{
player.kickPlayer(ban.bakeKickMessage());
}
return true;
}
if ("unban".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
plugin.bm.removeBan(plugin.bm.getByUsername(username));
for (String ip : ips)
{
Ban ban = plugin.bm.getByIp(ip);
if (ban != null)
{
plugin.bm.removeBan(ban);
}
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
if (ban != null)
{
plugin.bm.removeBan(ban);
}
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,100 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.util.Ips;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname>")
public class Command_gtfo extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
String reason = null;
if (args.length >= 2)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits
try
{
plugin.web.undo(player, 15);
}
catch (NoClassDefFoundError ex)
{
}
// Rollback
plugin.rb.rollback(player.getName());
// Deop
player.setOp(false);
// Gamemode suvival
player.setGameMode(GameMode.SURVIVAL);
// Clear inventory
player.getInventory().clear();
// Strike with lightning
final Location targetPos = player.getLocation();
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos);
}
}
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
// Broadcast
final StringBuilder bcast = new StringBuilder()
.append(ChatColor.RED)
.append("Banning: ")
.append(player.getName())
.append(", IP: ")
.append(ip);
if (reason != null)
{
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
}
FUtil.bcastMsg(bcast.toString());
// Ban player
plugin.bm.addBan(Ban.forPlayerFuzzy(player, sender, null, reason));
// Kick player
player.kickPlayer(ChatColor.RED + "GTFO");
return true;
}
}

View File

@ -1,9 +1,10 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.math.DoubleRange;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -12,23 +13,25 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
public class Command_health extends TFM_Command
public class Command_health extends FreedomCommand
{
private static final int BYTES_PER_MB = 1024 * 1024;
private static final DoubleRange TPS_RANGE = new DoubleRange(20.0 - 0.1, 20.0 + 0.1);
@Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Runtime runtime = Runtime.getRuntime();
long usedMem = runtime.totalMemory() - runtime.freeMemory();
playerMsg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb");
playerMsg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB) + "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)");
playerMsg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb");
playerMsg("Calculating ticks per second, please wait...");
msg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb");
msg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB)
+ "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)");
msg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb");
msg("Calculating ticks per second, please wait...");
new BukkitRunnable()
{
@ -42,18 +45,24 @@ public class Command_health extends TFM_Command
Thread.sleep(2500);
final double ticksPerSecond = tickMeter.stopTicking();
// Plugin was disabled during async task
if (!plugin.isEnabled())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
playerMsg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
msg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
}
}.runTask(plugin);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
FLog.severe(ex);
}
}
}.runTaskAsynchronously(plugin);
@ -63,6 +72,7 @@ public class Command_health extends TFM_Command
private class TFM_TickMeter
{
private final AtomicInteger ticks = new AtomicInteger();
private final TotalFreedomMod plugin;
private long startTime;
@ -97,4 +107,5 @@ public class Command_health extends TFM_Command
return (double) tickCount / ((double) elapsed / 1000.0);
}
}
}

View File

@ -1,27 +1,29 @@
package me.StevenLawson.TotalFreedomMod.Commands;
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
public class Command_invis extends TFM_Command
public class Command_invis extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("smite"))
{
FUtil.adminAction(sender.getName(), "Smiting all invisible players", true);
smite = true;
}
else
@ -30,7 +32,7 @@ public class Command_invis extends TFM_Command
}
}
List<String> players = new ArrayList<String>();
List<String> players = new ArrayList<>();
int smites = 0;
for (Player player : server.getOnlinePlayers())
@ -38,9 +40,9 @@ public class Command_invis extends TFM_Command
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(player.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(player))
if (smite && !plugin.al.isAdmin(player))
{
Command_smite.smite(player);
player.setHealth(0.0);
smites++;
}
}
@ -48,20 +50,19 @@ public class Command_invis extends TFM_Command
if (players.isEmpty())
{
TFM_Util.playerMsg(sender, "There are no invisible players");
msg("There are no invisible players");
return true;
}
if (smite)
{
TFM_Util.playerMsg(sender, "Smitten " + smites + " players");
msg("Smitten " + smites + " players");
}
else
{
TFM_Util.playerMsg(sender, "Invisble players (" + players.size() + "): " + StringUtils.join(players, ", "));
msg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
}

View File

@ -0,0 +1,96 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
public class Command_jumppads extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("info"))
{
msg("Jumppads: " + (plugin.jp.getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
msg("Sideways: " + (plugin.jp.getMode() == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
msg("Strength: " + (plugin.jp.getStrength() * 10 - 1), ChatColor.BLUE);
return true;
}
if ("off".equals(args[0]))
{
FUtil.adminAction(sender.getName(), "Disabling Jumppads", false);
plugin.jp.setMode(Jumppads.JumpPadMode.OFF);
}
else
{
FUtil.adminAction(sender.getName(), "Enabling Jumppads", false);
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
}
}
else
{
if (plugin.jp.getMode() == Jumppads.JumpPadMode.OFF)
{
msg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
return true;
}
if (args[0].equalsIgnoreCase("sideways"))
{
if ("off".equals(args[1]))
{
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
}
else
{
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
plugin.jp.setMode(Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
}
}
else if (args[0].equalsIgnoreCase("strength"))
{
final float strength;
try
{
strength = Float.parseFloat(args[1]);
}
catch (NumberFormatException ex)
{
msg("Invalid Strength");
return true;
}
if (strength > 10 || strength < 1)
{
msg("Invalid Strength: The strength may be 1 through 10.");
return true;
}
FUtil.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
plugin.jp.setStrength((strength / 10) + 0.1F);
}
else
{
return false;
}
}
return true;
}
}

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