Compare commits

..

373 Commits
v2.20 ... v4.0

Author SHA1 Message Date
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
fd372066eb Incremented version to 3.00 2013-08-14 17:39:51 +02:00
122bef2d5a DromedaryCase 2013-08-14 16:55:37 +02:00
339518f4f4 Take two: Cleanup 2013-08-14 16:01:42 +02:00
8ce0defb52 Readd Command_premium.java 2013-08-14 09:32:14 -04:00
ec6e8431e3 Revert "Added /premium"
This reverts commit 0964871e8b.
2013-08-14 09:28:19 -04:00
0964871e8b Added /premium
cleanup
2013-08-14 15:12:30 +02:00
422a7716f3 /nf tweaks. 2013-08-13 21:39:12 -04:00
f1ab8296e4 Tweaks to jumppad physics. 2013-08-13 16:54:20 -04:00
f9cbf11abb JumpPads cleanup 2013-08-13 14:53:33 -04:00
b0090a5412 More tweaks to nonuke and spam prevention. 2013-08-13 13:42:43 -04:00
b94efb525f Added timeout check to nonuke, so lag doesn't ban people. 2013-08-13 13:22:29 -04:00
5c8f98089e Merge branch 'master' into mg_untested 2013-08-13 12:29:12 -04:00
7879fa24e4 Minor changes to JumpPads 2013-08-13 18:21:37 +02:00
6fcaed6253 Finished Jumppads 2013-08-13 17:16:33 +02:00
656dbf8867 Started work on Jumppads 2013-08-13 16:08:00 +02:00
23032e6f9a Added NickFilter. 2013-08-13 09:51:20 -04:00
ad5a236bc2 PlayerMoveEvent optimization. 2013-08-13 08:36:33 -04:00
e23db244a5 Add teleport listener to AdminWorld monitor. 2013-08-12 22:01:28 -04:00
eb4622fc28 AdminWorld tweaks. 2013-08-12 21:33:21 -04:00
0f6b053727 Added /findip 2013-08-12 21:35:59 +02:00
259335958a Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2013-08-12 20:54:35 +02:00
31375b82c3 Tweaked /tag some more, I think this will work best. 2013-08-12 20:54:19 +02:00
0a2d5c8258 Reworked /dtoggle. 2013-08-12 14:49:33 -04:00
bac25258b0 Added /lockdown 2013-08-12 20:47:36 +02:00
c69918d725 Create Command_dtoggle
This is a replacement for DisdFreedom dtoggle, something we had to add on CJFreedom shortly after we lost his plugin :)
2013-08-12 19:28:41 +01:00
c1d0c01524 Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2013-08-12 14:19:33 -04:00
a59e6added Tweaks to Command_tag 2013-08-12 14:19:17 -04:00
56493adcae Merge pull request #67 from Wild1145/patch-4
Block Op's from using &k.
2013-08-12 10:59:52 -07:00
4b91de7414 More AdminWorld tweaks. 2013-08-12 12:51:30 -04:00
c636ee043a Merge branch 'mg_incomplete' of https://github.com/TotalFreedom/TotalFreedomMod into mg_incomplete 2013-08-12 12:41:12 -04:00
6a5306dd7a More AdminWorld tweaks. 2013-08-12 12:38:46 -04:00
4603dc5613 Block Op's from using bad codes
This will block a op from using a set of colour codes you to not want them to use, like &k
2013-08-12 17:10:08 +01:00
af7e6c5d41 AdminWorld welcome sign now facing the right direction :)
Added teleporting message to /adminworld
2013-08-12 17:58:28 +02:00
699d366efb Revert accidental change of this file. 2013-08-12 10:11:04 -04:00
41ed416a51 Merge branch 'master' into mg_incomplete 2013-08-12 10:05:01 -04:00
074630f720 Finished adminworld, still needs testing. 2013-08-12 10:03:12 -04:00
4e3c9a6b9e Batch format fix 2013-08-12 14:41:04 +02:00
bea480c1f1 Merge branch 'master' into mg_incomplete
Conflicts:
	appinfo.properties
	buildnumber.properties
2013-08-12 08:14:55 -04:00
69fd3566af Added /tag clearall and /tag clear <name> 2013-08-12 12:50:39 +02:00
f3ac19a616 Added /tag
Minor cleanup
2013-08-12 12:31:30 +02:00
696ec119c6 Made /saconfig clean a senior command 2013-08-12 11:24:23 +02:00
326c3f6a2b Incomplete features:
-Adminworld
-Better entity wiping
2013-08-11 22:02:18 -04:00
38b1035020 Added Command_trail.
+1 points for no external changes.
2013-08-10 15:50:45 -04:00
1ae6eb8a5a Consolidate loggers. 2013-08-10 15:50:07 -04:00
2c4eca8551 Remove deprecated methods and variables. 2013-08-10 13:17:32 -04:00
f23c61d0b3 Rework Command_health 2013-08-10 12:39:50 -04:00
c10e0deb8b Added formatting parameters to project configuration. 2013-08-09 20:17:08 -04:00
d4dfe06ec0 Formatting cleanup.
Added ignore for unchecked cast warning.
2013-08-09 20:11:17 -04:00
bcd9658b3d Added release link to permban kick message 2013-08-09 17:57:45 +02:00
9b62731e94 Merged branch unfinished 2013-08-09 17:11:30 +02:00
03553b6254 Finished TFM_ServiceChecker, added /services 2013-08-09 17:09:13 +02:00
d40c143afc Reworked /health, should be thread-safe now
Updated version number to reflect latest changes
2013-08-09 15:40:08 +02:00
95afb51321 Moved rollback events to listener with MONITOR priority 2013-08-09 15:10:04 +02:00
4813b8ae27 Fix water/lava buckets not working. 2013-08-06 19:12:26 -04:00
e8d36b31f7 Fix typo. 2013-08-05 22:55:59 -04:00
b2eec1ef01 Rework command interface for rollback. 2013-08-05 22:05:01 -04:00
3bcc4fd7a7 Fix compile error. 2013-08-05 19:41:42 -04:00
e0efb63123 Reworked rollback manager. 2013-08-05 15:26:21 -04:00
028d1a07b2 Minor change to CommandBlockSetEvent handler.
Remove import and add fully qualified name to clairify what's happening here.
2013-08-05 13:31:10 -04:00
5b34facdd3 Started work on ServiceChecker 2013-08-04 20:49:43 +02:00
218fd21774 Some cleanup. More to come. 2013-08-03 16:08:16 -04:00
0901c02c7e Merge branch 'mg_dev' 2013-07-30 21:47:50 -04:00
a4e9bc76a3 Add "Reason: " text to kick. 2013-07-30 21:47:29 -04:00
be8314cf63 Added TFM_GameRuleHandler for easy setting of game rule parameters. 2013-07-29 21:09:20 -04:00
f21c7aa5c5 Added reason to GTFO. Untested. 2013-07-29 14:44:18 -04:00
3f61e05609 Make "/fr purge" clear the auto-unfreeze task timer.
With credit to Wild for bringing it up on his fork, but he did it wrong :P
2013-07-29 13:37:31 -04:00
fe93d1ce07 Added /logs [off] for unregistering connection. 2013-07-29 13:20:08 -04:00
5132bb6550 Removed old commented out code. 2013-07-29 08:29:16 -04:00
6b7a5d8d70 Add /debug command. What can possibly go wrong. 2013-07-28 20:50:57 -04:00
6a4a11a2f4 Merge remote-tracking branch 'origin/debug' 2013-07-28 19:50:05 -04:00
cbe7cdc474 Cleanup Command_droptoggle. 2013-07-28 17:49:41 -04:00
07f4bf82ea Incomplete - /debug command 2013-07-28 17:31:41 -04:00
8e7c9dcd8e Added /droptoggle 2013-07-28 12:39:09 -07:00
1ab74dae05 Forgot to set task variable. 2013-07-28 13:15:51 -04:00
8ac91f7097 Reworked all Scheduler usage - now using BukkitRunnables.
Added /logs command.
A few other fixes...
2013-07-27 17:49:25 -04:00
c482349f47 TFM_CommandBlockerNew cleanup. 2013-07-26 19:48:18 -04:00
b24f1d9247 Moved the ServerListPingEvent from TFM_PlayerListener to TFM_ServerListener. 2013-07-24 11:01:43 -04:00
2079e0ea66 Added event handling for command block changes.
Recoded TFM_CommandBlocker as TFM_CommandBlockerNew, will replace after evaulation.
2013-07-21 22:48:34 -04:00
0e477f8437 Merge branch 'master' of https://github.com/StevenLawson/TotalFreedomMod 2013-07-20 19:44:01 -04:00
c3fc085adc Fix for Bukkit NPE in /enchant. 2013-07-20 19:38:27 -04:00
aad8f17455 Give TFM commands priority over other plugins. 2013-07-20 16:06:46 -04:00
d43fa35e52 Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2013-07-14 18:51:40 -04:00
fdfa30b349 How do I allman? 2013-07-14 14:10:29 +02:00
e56c273457 Moved TotalFreedomMod-related information to /tfm 2013-07-13 22:11:13 +02:00
f3087f0dca Capitalism. 2013-07-13 21:39:10 +02:00
dbed7b7f83 We don't want those commands used at all. 2013-07-13 14:56:47 -04:00
4caa984cef oops 2013-07-13 11:45:19 -07:00
ef2e17c33f Blocked /ban-ip and /pardon-ip 2013-07-13 11:43:23 -07:00
53614d174e Dry - Fixed all commands having a default '/' alias. 2013-07-13 12:49:53 +02:00
123884329c Merge branch 'master' of ../TotalFreedomMod_org 2013-07-12 20:48:19 -04:00
37e78dceec Merge branch origin/master 2013-07-12 21:54:43 +02:00
8f6d71fffb Bleeding - Fixed empty commands
Empty commands would always run the first alphabetically sorted TFM command.
2013-07-12 21:51:03 +02:00
3935bcf09f Merge pull request #6 from TotalFreedom/master
Update primary repository
2013-07-12 04:04:17 -07:00
b9bd046105 Changed WorldEdit API access method. 2013-07-11 20:35:09 -04:00
1fcda4a8fc Merge remote-tracking branch 'origin/untested' 2013-07-11 18:40:42 -04:00
f8e62a9893 Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod 2013-07-11 18:22:12 -04:00
aaf96d00a9 Revert to old login logic. Ban messages weren't working right. 2013-07-11 18:21:23 -04:00
4903f009b3 Add Pet Protection.
Cleaned up config file a bit.
2013-07-11 14:51:08 -04:00
3dc51715c5 Update LICENSE.md 2013-07-11 12:50:23 -04:00
f2aaba17de Update README.md 2013-07-11 12:48:25 -04:00
fa1c9a255c Update and rename LICENCE.md to LICENSE.md 2013-07-11 08:43:48 -04:00
3c80aaa7c4 Update CONTRIBUTING.md 2013-07-11 08:18:10 -04:00
279f69e3de Merge pull request #52 from Wild1145/patch-1
Fine by me.
2013-07-11 04:36:13 -07:00
22bf0c2f62 Removed Command_minecraft and TFM_ServiceChecker.
Restored old Mojang status checker in /status.
Owner of xpaw.ru requested that 3rd party applications not use his API.
Batch formatting fix.
2013-07-10 21:46:29 -04:00
f21e50e002 Fixed bug in /halt 2013-07-10 23:47:21 +02:00
6d9e9406ec Moved to more specific User-Agent in the service Checker 2013-07-10 23:32:31 +02:00
cd16c7fb10 Mark wanted /list -a to show how awesome he was.
Or something like that. Don't do this for other people, please.
2013-07-08 20:51:23 -04:00
11c945c504 Update to 1.6.2 API. 2013-07-08 20:37:02 -04:00
c70e3ad8fd Added DisguiseCraft API functionality. 2013-07-07 21:42:03 -04:00
f63805cca2 Removed some ziptool stuff
Well as it was removed from here, it may aswell just be removed from this file too :)
2013-07-07 23:39:02 +01:00
5868540cbb Optionally ends with 'y', who knew? 2013-07-06 19:09:32 +02:00
8ca518528f Whoops, fixed the description of /whohas 2013-07-05 14:02:43 +02:00
4cbbf10871 Blocked command aliases from being executed when that command is blocked, removed debug message 2013-07-05 13:50:10 +02:00
93914370a1 Added /whohas 2013-07-04 23:32:11 +02:00
ee87d1147d Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod
Conflicts:
	appinfo.properties
	buildnumber.properties
	src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java
2013-07-04 22:51:31 +02:00
44f72815e1 Added configurable blocked commands 2013-07-04 22:46:51 +02:00
391e417882 Move server interface where it belongs. 2013-07-04 12:22:02 -04:00
0dca359e4c A few little fixes.
Make /cake give the cake achievement.
Fix /lockup.
Colorful MOTD, more MOTD options.
2013-07-04 12:10:08 -04:00
15fbd0e1f3 Got rid of dispatchCommand usage (where possible).
Added TFM_WorldEditBridge.
2013-07-03 16:11:57 -04:00
1d9e6ae931 Merge pull request #50 from Wilee999/master
Blocked /butcher and //butcher on mark's request
2013-07-02 19:41:16 -07:00
a0cf0e9352 oops 2013-07-02 19:40:18 -07:00
797de66e10 removed 2013-07-02 19:36:59 -07:00
d40d5b461d Cleaned up Command_setl. Don't use server.dispatchCommand for things that can be done with the existing API!
Fixed depreciation warnings on compile.
2013-07-02 19:08:31 -04:00
8751e0454c Cleaned up /purgeall and /halt 2013-07-02 22:31:05 +02:00
3f29f788d5 Bye bye /butcher! 2013-07-02 12:50:59 -07:00
5c2e67ae1d Merge pull request #49 from Wilee999/master
Made /mp an admin command on mark's request
2013-07-02 12:43:53 -07:00
61db5de20d Reverted last commit. 2013-07-02 12:42:06 -07:00
ed9204c735 might as well add this 2013-07-02 11:59:15 -07:00
9fc237390e grr 2013-07-02 11:58:41 -07:00
ba22aedc58 Batch formatting fix. 2013-07-02 14:31:22 -04:00
188 changed files with 14146 additions and 4818 deletions

3
.gitignore vendored
View File

@ -17,3 +17,6 @@ manifest.mf
.Trashes
ehthumbs.db
Thumbs.db
# TFM files
buildcreator.properties

View File

@ -1,63 +1,53 @@
# How to contribute
# 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.
TotalFreedomMod aims to be a fully functional all-op server mod which works in
a large range of configurations. In order to be as flexible as possible on the
server-end, we encourage contributing to TotalFreedomMod by making 'pull-requests'
to this repository.
## Getting Started
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
## 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.
* 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 (*and work!*).
* Make sure your changes build (<b>and work!</b>).
## Tips - How To Get Your Pull Request Accepted ##
* See this picture for help:
![Imgur](http://i.imgur.com/7kogorv.jpg)
## Tips on getting 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)
* 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.
* 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).
* 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.
* 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.
* 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 Changes
## 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
## Additional Resources ##
* [TotalFreedom information](http://totalfreedom.me)
* [TotalFreedom forums](http://totalfreedom.boards.net)
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)

View File

@ -1,16 +0,0 @@
# Legal
TotalFreedomMod by Madgeek1450 and DarthSalamon is an effort to create an opensource plugin to effectively run a "Total Freedom" like all-Op server. 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 server "TotalFreedom" (http://totalfreedom.me) TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feel of openness towards the administrators and the players themselves.
## License
TotalFreedomMod sourcecode is freely available under the GNU GPLv3 License with a few restrictions in place. The license is available here: http://www.gnu.org/licenses/gpl.txt
The few restrictions are in place to make sure that credit is given to the original authors who remain the maintainers of the plugin and it's sourcecode.
These are the restrictions under which the sourcecode is licensed:
* A un-edited copy of this license must always be included with this sourcecode.
* TotalFreedomMod sourcecode and its derrivations are freely distributable between anyone who choses to download it.
* You may not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" and "jeromsar" from any part of the sourcecode.
* However, compiled binaries (*.jar's) are not to be distributed. If you wish to obtain a copy of TotalFreedomMod you must compile the original sourcecode or it's derivations yourself using an IDE like netbeans. Official superadmins and above of the TotalFreedom (totalfreedom.me) server may obtain a compiled libary with the same limitations as described in this document.
* Any conditions on this license may be waived by any of the official developers.

13
LICENSE.md Normal file
View File

@ -0,0 +1,13 @@
# 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
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.
* You shall not edit or remove the file Command_tfm.java
* You may not modify the file TFM_FrontDoor.java. Removing it is fine, however.
* 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.

View File

@ -1,6 +1,7 @@
TotalFreedomMod
===============
# TotalFreedomMod #
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
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.
Information about the TotalFreedom server can be found at http://totalfreedom.me/
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.
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 @@
#Tue, 02 Jul 2013 14:04:59 +0200
program.VERSION=2.20
program.BUILDNUM=238
program.BUILDDATE=07/02/2013 02\:04 PM

View File

@ -1,83 +1,26 @@
<?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"/>
<!--
<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:
<target name="-pre-jar">
<copy file="buildcreator.default.properties" tofile="buildcreator.properties" overwrite="false" />
-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
<property file="buildcreator.properties"/>
<buildnumber file="buildnumber.properties" />
(Targets beginning with '-' are not intended to be called on their own.)
<propertyfile file="appinfo.properties">
<entry key="program.buildnumber" value="${build.number}" />
<entry key="program.builddate" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
<entry key="program.buildcreator" value="${program.buildcreator}" />
</propertyfile>
<copy file="appinfo.properties" todir="${build.classes.dir}" />
<delete file="appinfo.properties" />
</target>
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>
<target name="-post-jar">
<!-- Cleanup -->
<delete file="${dist.dir}/README.TXT" />
<delete dir="${dist.dir}/lib/" />
</target>
</project>

View File

@ -0,0 +1,2 @@
# Build creator configuration
program.buildcreator=Unknown

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Jul 02 14:04:59 CEST 2013
build.number=239
#Mon Apr 21 23:08:17 CEST 2014
build.number=787

View File

@ -18,7 +18,7 @@ is divided into following sections:
- applet
- cleanup
-->
-->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="TotalFreedomMod-impl">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
@ -29,10 +29,10 @@ is divided into following sections:
</fail>
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
<!--
======================
INITIALIZATION SECTION
======================
-->
======================
INITIALIZATION SECTION
======================
-->
<target name="-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
@ -645,8 +645,8 @@ is divided into following sections:
</target>
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
<!--
pre NB7.2 profiling section; consider it deprecated
-->
pre NB7.2 profiling section; consider it deprecated
-->
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
<target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
<!-- Empty placeholder for easier customization. -->
@ -693,8 +693,8 @@ is divided into following sections:
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
</target>
<!--
end of pre NB7.2 profiling section
-->
end of pre NB7.2 profiling section
-->
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="name"/>
@ -854,10 +854,10 @@ is divided into following sections:
</target>
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<!--
===================
COMPILATION SECTION
===================
-->
===================
COMPILATION SECTION
===================
-->
<target name="-deps-jar-init" unless="built-jar.properties">
<property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
<delete file="${built-jar.properties}" quiet="true"/>
@ -928,10 +928,10 @@ is divided into following sections:
</target>
<target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
<!--
====================
JAR BUILDING SECTION
====================
-->
====================
JAR BUILDING SECTION
====================
-->
<target depends="init" name="-pre-pre-jar">
<dirname file="${dist.jar}" property="dist.jar.dir"/>
<mkdir dir="${dist.jar.dir}"/>
@ -1000,10 +1000,10 @@ is divided into following sections:
</target>
<target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
<!--
=================
EXECUTION SECTION
=================
-->
=================
EXECUTION SECTION
=================
-->
<target depends="init,compile" description="Run a main class." name="run">
<j2seproject1:java>
<customize>
@ -1023,10 +1023,10 @@ is divided into following sections:
<j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
</target>
<!--
=================
DEBUGGING SECTION
=================
-->
=================
DEBUGGING SECTION
=================
-->
<target depends="init" if="netbeans.home" name="-debug-start-debugger">
<j2seproject1:nbjpdastart name="${debug.class}"/>
</target>
@ -1064,13 +1064,13 @@ is divided into following sections:
</target>
<target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
<!--
=================
PROFILING SECTION
=================
-->
=================
PROFILING SECTION
=================
-->
<!--
pre NB7.2 profiler integration
-->
pre NB7.2 profiler integration
-->
<target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
@ -1127,8 +1127,8 @@ is divided into following sections:
</junit>
</target>
<!--
end of pre NB72 profiling section
-->
end of pre NB72 profiling section
-->
<target if="netbeans.home" name="-profile-check">
<condition property="profiler.configured">
<or>
@ -1163,10 +1163,10 @@ is divided into following sections:
<antcall target="run-applet"/>
</target>
<!--
===============
JAVADOC SECTION
===============
-->
===============
JAVADOC SECTION
===============
-->
<target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
@ -1204,10 +1204,10 @@ is divided into following sections:
</target>
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
<!--
=========================
TEST COMPILATION SECTION
=========================
-->
=========================
TEST COMPILATION SECTION
=========================
-->
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
<mkdir dir="${build.test.classes.dir}"/>
</target>
@ -1243,10 +1243,10 @@ is divided into following sections:
</target>
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
<!--
=======================
TEST EXECUTION SECTION
=======================
-->
=======================
TEST EXECUTION SECTION
=======================
-->
<target depends="init" if="have.tests" name="-pre-test-run">
<mkdir dir="${build.test.results.dir}"/>
</target>
@ -1280,10 +1280,10 @@ is divided into following sections:
</target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
<!--
=======================
TEST DEBUGGING SECTION
=======================
-->
=======================
TEST DEBUGGING SECTION
=======================
-->
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
@ -1303,10 +1303,10 @@ is divided into following sections:
</target>
<target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
<!--
=========================
APPLET EXECUTION SECTION
=========================
-->
=========================
APPLET EXECUTION SECTION
=========================
-->
<target depends="init,compile-single" name="run-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer">
@ -1316,10 +1316,10 @@ is divided into following sections:
</j2seproject1:java>
</target>
<!--
=========================
APPLET DEBUGGING SECTION
=========================
-->
=========================
APPLET DEBUGGING SECTION
=========================
-->
<target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer">
@ -1330,10 +1330,10 @@ is divided into following sections:
</target>
<target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
<!--
===============
CLEANUP SECTION
===============
-->
===============
CLEANUP SECTION
===============
-->
<target name="-deps-clean-init" unless="built-clean.properties">
<property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
<delete file="${built-clean.properties}" quiet="true"/>

View File

@ -4,7 +4,23 @@ 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
application.vendor=TotalFreedom
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:
@ -32,6 +48,10 @@ jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${libs.WorldEdit.classpath}:\
${libs.DisguiseCraft.classpath}:\
${libs.Essentials.classpath}:\
${libs.BukkitTelnet.classpath}:\
${libs.CraftBukkit.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
@ -65,10 +85,9 @@ 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
mkdist.disabled=true
platform.active=default_platform
run.classpath=\
${javac.classpath}:\

13
src/bans.yml Normal file
View File

@ -0,0 +1,13 @@
#
# TotalFreedomMod banning config
# Warning: modification of this file is not reccomended
#
# Format:
# Ip: [IP-address / UUID]:[Last login name]:[Expiry unix timestamp (0 = never)][Banned by]:[Reason]
#
ips:
- '192.168.1.254:Notch:DarthSalamon:0:IP ban example'
uuids:
- '245d2f30-61fb-4840-9cd3-298b3920f4a4:Cobrex:DarthSalamon:0:UUID ban example'

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v2.20 Configuration
# TotalFreedomMod v4.0 Configuration
# by Madgeek1450 and DarthSalamon
# Block placement prevention:
@ -12,9 +12,78 @@ allow_tnt_minecarts: false
# Explosion management:
allow_explosions: false
explosiveRadius: 4.0
explosive_radius: 4.0
#Automatically wipe dropped objects:
# 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:/ban-ip:_'
- 'n:b:/pardon-ip:_'
- 'n:b:/toggledownfall:_'
- 'n:b:/effect:Please use /potion to set effects.'
- 'n:b:/enderchest:_'
# Superadmin commands
- 's:b:/kick:_'
- 's:b:/socialspy:_'
- 's:b:/kill:_'
- 's:b://generate:_'
- 's:b://:_'
- 's:b:/superpickaxe:_'
- 's:b:/brush:_'
- 's:b:/mat:_'
- 's:b:/tool:_'
- 's:b://butcher:_'
- 's:b:/scoreboard:_'
# Superadmin commands - Auto-eject
- 's:a:/stop'
- 's:a:/reload'
- 's:a:/save-all'
- 's:a:/save-on'
- 's:a:/save-off'
- 's:a:/clearhistory'
# Automatically wipe dropped objects:
auto_wipe: true
# Nuking prevention:
@ -60,13 +129,78 @@ protected_areas_enabled: true
auto_protect_spawnpoints: true
auto_protect_radius: 25.0
# Give the default CONSOLE senior admin privileges.
# Handy in development environments.
console_is_senior: true
# 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
# Players who cannot be banned by username
unbannable_usernames:
- honeydew
- xephos
- captainsparklez
- truemu
- kiershar
- fvdisco
- sethbling
- notch
- jeb_
- gamechap
- bertiechap
- vechs
- antvenom
- chimneyswift
- deadmau5
- etho
- ethoslab
- skydoesminecraft
- skythekidrs
- tobyturner
- xxslyfoxhoundxx
- paulsoaresjr
- sips_
- deadlox
- xxslyxx
- jeromeasf
- dinnerbone
- grumm
- grum
- evilseph
- cavemanfilms
- herobrine
- whiteboy7thst
- stampylonghead
- stampylongnose
- dantdm
# TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false
twitterbot_url: 'http://tftwitter.darthcraft.net/'
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
# HTTPD
httpd_enabled: true
httpd_public_folder: ./public_html
httpd_port: 28966
# Inactivity Auto-Kick (Requires Essentials)
autokick_enabled: true
# autokick_threshold - Percentage of server player capacity used at which players will be automatically kicked for being inactive. Range: 0.0 - 1.0
autokick_threshold: 0.9
# autokick_time - Time, in seconds, after which a player should be kicked when inactive
autokick_time: 120

View File

@ -0,0 +1,75 @@
package me.StevenLawson.TotalFreedomMod.Bridge;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import pgDev.bukkit.DisguiseCraft.DisguiseCraft;
import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI;
public class TFM_DisguiseCraftBridge
{
private TFM_DisguiseCraftBridge()
{
}
public static boolean undisguisePlayer(Player player)
{
if (!disguiseCraftEnabled())
{
return false;
}
try
{
DisguiseCraftAPI api = DisguiseCraft.getAPI();
if (api != null)
{
return api.undisguisePlayer(player);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return false;
}
public static void undisguiseAllPlayers()
{
if (!disguiseCraftEnabled())
{
return;
}
try
{
DisguiseCraftAPI api = DisguiseCraft.getAPI();
if (api != null)
{
Player[] players = Bukkit.getOnlinePlayers();
for (Player player : players)
{
api.undisguisePlayer(player);
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public static boolean disguiseCraftEnabled()
{
boolean pluginEnabled = false;
try
{
pluginEnabled = Bukkit.getPluginManager().isPluginEnabled("DisguiseCraft");
}
catch (Exception ex)
{
}
return pluginEnabled;
}
}

View File

@ -0,0 +1,118 @@
package me.StevenLawson.TotalFreedomMod.Bridge;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class TFM_EssentialsBridge
{
private Essentials essentialsPlugin = null;
private TFM_EssentialsBridge()
{
}
public Essentials getEssentialsPlugin()
{
if (this.essentialsPlugin == null)
{
try
{
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null)
{
if (essentials instanceof Essentials)
{
this.essentialsPlugin = (Essentials) essentials;
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
return this.essentialsPlugin;
}
public User getEssentialsUser(String username)
{
try
{
final Essentials essentials = getEssentialsPlugin();
if (essentials != null)
{
return essentials.getUserMap().getUser(username);
}
}
catch (Exception ex)
{
TFM_Log.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)
{
TFM_Log.severe(ex);
}
}
public long getLastActivity(String username)
{
try
{
final User user = getEssentialsUser(username);
if (user != null)
{
return TFM_Util.<Long>getField(user, "lastActivity"); // This is weird
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return 0L;
}
public boolean isEssentialsEnabled()
{
try
{
final Essentials essentials = getEssentialsPlugin();
if (essentials != null)
{
return essentials.isEnabled();
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return false;
}
public static TFM_EssentialsBridge getInstance()
{
return TFM_EssentialsBridgeHolder.INSTANCE;
}
private static class TFM_EssentialsBridgeHolder
{
private static final TFM_EssentialsBridge INSTANCE = new TFM_EssentialsBridge();
}
}

View File

@ -0,0 +1,177 @@
package me.StevenLawson.TotalFreedomMod.Bridge;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
public class TFM_WorldEditBridge
{
private WorldEditPlugin worldEditPlugin = null;
private TFM_WorldEditBridge()
{
}
public WorldEditPlugin getWorldEditPlugin()
{
if (this.worldEditPlugin == null)
{
try
{
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (we != null)
{
if (we instanceof WorldEditPlugin)
{
this.worldEditPlugin = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
return this.worldEditPlugin;
}
public BukkitPlayer getBukkitPlayer(Player player)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.wrapPlayer(player);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public LocalSession getPlayerSession(Player player)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.getSession(player);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void undo(Player player, int count)
{
try
{
LocalSession session = getPlayerSession(player);
if (session != null)
{
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(player);
if (bukkitPlayer != null)
{
for (int i = 0; i < count; i++)
{
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
}
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public void setLimit(Player player, int limit)
{
try
{
LocalSession session = getPlayerSession(player);
if (session != null)
{
session.setBlockChangeLimit(limit);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public void validateSelection(final Player player)
{
if (TFM_AdminList.isSuperAdmin(player))
{
return;
}
try
{
final LocalSession session = getPlayerSession(player);
if (session != null)
{
final LocalWorld selectionWorld = session.getSelectionWorld();
final Region selection = session.getSelection(selectionWorld);
if (TFM_ProtectedArea.isInProtectedArea(
getBukkitVector(selection.getMinimumPoint()),
getBukkitVector(selection.getMaximumPoint()),
selectionWorld.getName()))
{
new BukkitRunnable()
{
@Override
public void run()
{
player.sendMessage(ChatColor.RED + "The region that you selected contained a protected area. Selection cleared.");
session.getRegionSelector(selectionWorld).clear();
}
}.runTaskLater(TotalFreedomMod.plugin, 1L);
}
}
}
catch (IncompleteRegionException ex)
{
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
private static org.bukkit.util.Vector getBukkitVector(com.sk89q.worldedit.Vector worldEditVector)
{
return new org.bukkit.util.Vector(worldEditVector.getX(), worldEditVector.getY(), worldEditVector.getZ());
}
public static TFM_WorldEditBridge getInstance()
{
return TFM_WorldEditBridgeHolder.INSTANCE;
}
private static class TFM_WorldEditBridgeHolder
{
private static final TFM_WorldEditBridge INSTANCE = new TFM_WorldEditBridge();
}
}

View File

@ -2,5 +2,17 @@ package me.StevenLawson.TotalFreedomMod.Commands;
public enum AdminLevel
{
ALL, OP, SUPER, SENIOR
ALL("All Player Commands"), OP("OP Commands"), SUPER("SuperAdmin Commands"), SENIOR("Senior Admin Commands");
//
private final String friendlyName;
private AdminLevel(String friendlyName)
{
this.friendlyName = friendlyName;
}
public String getFriendlyName()
{
return friendlyName;
}
}

View File

@ -10,5 +10,5 @@ public @interface CommandPermissions
SourceType source();
boolean block_host_console() default false;
boolean blockHostConsole() default false;
}

View File

@ -1,34 +1,39 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
public class Command_adminmode extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("off"))
{
TotalFreedomMod.adminOnlyMode = false;
TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
return true;
}
else if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.adminOnlyMode = true;
TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
if (!TFM_AdminList.isSuperAdmin(player))
{
p.kickPlayer("Server is now closed to non-superadmins.");
player.kickPlayer("Server is now closed to non-superadmins.");
}
}
return true;

View File

@ -0,0 +1,233 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.World.TFM_AdminWorld;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.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 TFM_Command
{
private enum CommandMode
{
TELEPORT, GUEST, TIME, WEATHER
}
@Override
public boolean run(CommandSender sender, Player sender_p, 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) || sender_p == null)
{
return true;
}
World adminWorld = null;
try
{
adminWorld = TFM_AdminWorld.getInstance().getWorld();
}
catch (Exception ex)
{
}
if (adminWorld == null || sender_p.getWorld() == adminWorld)
{
playerMsg("Going to the main world.");
sender_p.teleport(server.getWorlds().get(0).getSpawnLocation());
}
else
{
if (TFM_AdminWorld.getInstance().canAccessWorld(sender_p))
{
playerMsg("Going to the AdminWorld.");
TFM_AdminWorld.getInstance().sendToWorld(sender_p);
}
else
{
playerMsg("You don't have permission to access the AdminWorld.");
}
}
break;
}
case GUEST:
{
if (args.length == 2)
{
if ("list".equalsIgnoreCase(args[1]))
{
playerMsg("AdminWorld guest list: " + TFM_AdminWorld.getInstance().guestListToString());
}
else if ("purge".equalsIgnoreCase(args[1]))
{
assertCommandPerms(sender, sender_p);
TFM_AdminWorld.getInstance().purgeGuestList();
TFM_Util.adminAction(sender.getName(), "AdminWorld guest list purged.", false);
}
else
{
return false;
}
}
else if (args.length == 3)
{
assertCommandPerms(sender, sender_p);
if ("add".equalsIgnoreCase(args[1]))
{
Player player;
try
{
player = getPlayer(args[2]);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
if (player != null && TFM_AdminWorld.getInstance().addGuest(player, sender_p))
{
TFM_Util.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
}
else
{
playerMsg("Could not add player to guest list.");
}
}
else if (TFM_Util.isRemoveCommand(args[1]))
{
Player player = TFM_AdminWorld.getInstance().removeGuest(args[2]);
if (player != null)
{
TFM_Util.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);
}
else
{
playerMsg("Can't find guest entry for: " + args[2]);
}
}
else
{
return false;
}
}
break;
}
case TIME:
{
assertCommandPerms(sender, sender_p);
if (args.length == 2)
{
TFM_AdminWorld.TimeOfDay timeOfDay = TFM_AdminWorld.TimeOfDay.getByAlias(args[1]);
if (timeOfDay != null)
{
TFM_AdminWorld.getInstance().setTimeOfDay(timeOfDay);
playerMsg("AdminWorld time set to: " + timeOfDay.name());
}
else
{
playerMsg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
}
}
else
{
return false;
}
break;
}
case WEATHER:
{
assertCommandPerms(sender, sender_p);
if (args.length == 2)
{
TFM_AdminWorld.WeatherMode weatherMode = TFM_AdminWorld.WeatherMode.getByAlias(args[1]);
if (weatherMode != null)
{
TFM_AdminWorld.getInstance().setWeatherMode(weatherMode);
playerMsg("AdminWorld weather set to: " + weatherMode.name());
}
else
{
playerMsg("Invalid weather mode. Can be: off, rain, storm");
}
}
else
{
return false;
}
break;
}
default:
{
return false;
}
}
}
catch (PermissionDeniedException ex)
{
sender.sendMessage(ex.getMessage());
}
return true;
}
private void assertCommandPerms(CommandSender sender, Player sender_p) throws PermissionDeniedException
{
if (!(sender instanceof Player) || sender_p == null || !TFM_AdminList.isSuperAdmin(sender))
{
throw new PermissionDeniedException(TotalFreedomMod.MSG_NO_PERMS);
}
}
private class PermissionDeniedException extends Exception
{
public PermissionDeniedException(String string)
{
super(string);
}
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
@ -23,9 +23,9 @@ public class Command_blockcmd extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Unblocking commands for all players", true);
int counter = 0;
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (playerdata.allCommandsBlocked())
{
counter += 1;
@ -36,28 +36,28 @@ public class Command_blockcmd extends TFM_Command
return true;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage());
return true;
}
if (TFM_SuperadminList.isUserSuperadmin(p))
if (TFM_AdminList.isSuperAdmin(player))
{
playerMsg(p.getName() + " is a Superadmin, and cannot have their commands blocked.");
playerMsg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + p.getName(), true);
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
playerMsg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
return true;

View File

@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <partialname> <off | [[outermaterial] [innermaterial]]>")
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
public class Command_cage extends TFM_Command
{
@Override
@ -21,26 +21,53 @@ public class Command_cage extends TFM_Command
return false;
}
Player p;
if (TFM_Util.isStopCommand(args[0]) && sender instanceof Player)
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
return true;
}
else if ("purge".equalsIgnoreCase(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Uncaging all players.", true);
for (Player player : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
}
return true;
}
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
Material outerMaterial = Material.GLASS;
Material innerMaterial = Material.AIR;
Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR;
if (args.length >= 2)
{
if (TFM_Util.isStopCommand(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName() + ".", true);
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
playerdata.setCaged(false);
playerdata.regenerateHistory();
@ -50,10 +77,13 @@ public class Command_cage extends TFM_Command
}
else
{
cage_material_outer = Material.matchMaterial(args[1]);
if (cage_material_outer == null)
if ("darth".equalsIgnoreCase(args[1]))
{
cage_material_outer = Material.GLASS;
outerMaterial = Material.SKULL;
}
else if (Material.matchMaterial(args[1]) != null)
{
outerMaterial = Material.matchMaterial(args[1]);
}
}
}
@ -62,25 +92,32 @@ public class Command_cage extends TFM_Command
{
if (args[2].equalsIgnoreCase("water"))
{
cage_material_inner = Material.STATIONARY_WATER;
innerMaterial = Material.STATIONARY_WATER;
}
else if (args[2].equalsIgnoreCase("lava"))
{
cage_material_inner = Material.STATIONARY_LAVA;
innerMaterial = Material.STATIONARY_LAVA;
}
}
Location target_pos = p.getLocation().add(0, 1, 0);
playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner);
Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial);
playerdata.regenerateHistory();
playerdata.clearHistory();
TFM_Util.buildHistory(target_pos, 2, playerdata);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
TFM_Util.buildHistory(targetPos, 2, playerdata);
TFM_Util.generateHollowCube(targetPos, 2, outerMaterial);
TFM_Util.generateCube(targetPos, 1, innerMaterial);
p.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL);
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName() + ".", true);
if (outerMaterial != Material.SKULL)
{
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName(), true);
}
else
{
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
}
return true;
}

View File

@ -3,12 +3,14 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
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 = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
@ -17,6 +19,7 @@ public class Command_cake extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
StringBuilder output = new StringBuilder();
Random randomGenerator = new Random();
@ -27,10 +30,18 @@ public class Command_cake extends TFM_Command
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
}
for (Player p : server.getOnlinePlayers())
ItemStack heldItem = new ItemStack(Material.CAKE);
ItemMeta heldItemMeta = heldItem.getItemMeta();
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.BLACK).append("Lie").toString());
heldItem.setItemMeta(heldItemMeta);
for (Player player : server.getOnlinePlayers())
{
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
player.getInventory().setItem(player.getInventory().firstEmpty(), heldItem);
player.awardAchievement(Achievement.MINE_WOOD);
player.awardAchievement(Achievement.BUILD_WORKBENCH);
player.awardAchievement(Achievement.BUILD_HOE);
player.awardAchievement(Achievement.BAKE_CAKE);
}
TFM_Util.bcastMsg(output.toString());

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
@ -13,15 +13,15 @@ public class Command_cartsit extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Player target_player = sender_p;
Player targetPlayer = sender_p;
if (args.length == 1)
{
try
{
target_player = getPlayer(args[0]);
targetPlayer = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
@ -30,26 +30,26 @@ public class Command_cartsit extends TFM_Command
if (senderIsConsole)
{
if (target_player == null)
if (targetPlayer == null)
{
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
return true;
}
}
else if (target_player != sender_p && !TFM_SuperadminList.isUserSuperadmin(sender))
else if (targetPlayer != sender_p && !TFM_AdminList.isSuperAdmin(sender))
{
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
return true;
}
if (target_player.isInsideVehicle())
if (targetPlayer.isInsideVehicle())
{
target_player.getVehicle().eject();
targetPlayer.getVehicle().eject();
}
else
{
Minecart nearest_cart = null;
for (Minecart cart : target_player.getWorld().getEntitiesByClass(Minecart.class))
for (Minecart cart : targetPlayer.getWorld().getEntitiesByClass(Minecart.class))
{
if (cart.isEmpty())
{
@ -59,7 +59,7 @@ public class Command_cartsit extends TFM_Command
}
else
{
if (cart.getLocation().distanceSquared(target_player.getLocation()) < nearest_cart.getLocation().distanceSquared(target_player.getLocation()))
if (cart.getLocation().distanceSquared(targetPlayer.getLocation()) < nearest_cart.getLocation().distanceSquared(targetPlayer.getLocation()))
{
nearest_cart = cart;
}
@ -69,7 +69,7 @@ public class Command_cartsit extends TFM_Command
if (nearest_cart != null)
{
nearest_cart.setPassenger(target_player);
nearest_cart.setPassenger(targetPlayer);
}
else
{

View File

@ -0,0 +1,206 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.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 = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "No Description Yet", usage = "/<command>")
public class Command_cbtool extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player)
{
Block targetBlock = sender_p.getTargetBlock(null, 100);
playerMsg("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);
server.dispatchCommand(sender, generatedCommand.toString());
}
catch (SubCommandFailureException ex)
{
}
catch (Exception ex)
{
TFM_Log.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

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -21,11 +21,11 @@ public class Command_cmdlist extends TFM_Command
{
List<String> commands = new ArrayList<String>();
for (Plugin p : server.getPluginManager().getPlugins())
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
{
try
{
PluginDescriptionFile desc = p.getDescription();
PluginDescriptionFile desc = targetPlugin.getDescription();
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) desc.getCommands();
if (map != null)

View File

@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Spy on commands", usage = "/<command>")
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
public class Command_cmdspy extends TFM_Command
{
@Override

View File

@ -0,0 +1,58 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Iterator;
import java.util.Map;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.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 = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
public class Command_colorme extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if ("list".equalsIgnoreCase(args[0]))
{
playerMsg("Colors: " + StringUtils.join(TFM_Util.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
}
final String needle = args[0].trim().toLowerCase();
ChatColor color = null;
final Iterator<Map.Entry<String, ChatColor>> it = TFM_Util.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)
{
playerMsg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true;
}
final String newNick = color + ChatColor.stripColor(sender_p.getDisplayName()).trim() + ChatColor.WHITE;
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), newNick);
playerMsg("Your nickname is now: " + newNick);
return true;
}
}

View File

@ -0,0 +1,70 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Temporarily change config parameters.", usage = "/<command> <entry> <value>")
public class Command_config extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 2)
{
return false;
}
TFM_ConfigEntry entry = TFM_ConfigEntry.findConfigEntry(args[0]);
if (entry == null)
{
sender.sendMessage("Can't find configuration option: " + args[0]);
return true;
}
Object newValue = null;
final String newValueString = args[1].trim();
final Class<?> type = entry.getType();
try
{
if (type.isAssignableFrom(Integer.class))
{
newValue = new Integer(newValueString);
entry.setInteger((Integer) newValue);
}
else if (type.isAssignableFrom(Double.class))
{
newValue = new Double(newValueString);
entry.setDouble((Double) newValue);
}
else if (type.isAssignableFrom(Boolean.class))
{
newValue = Boolean.valueOf(newValueString);
entry.setBoolean((Boolean) newValue);
}
else if (type.isAssignableFrom(String.class))
{
newValue = newValueString;
entry.setString((String) newValue);
}
}
catch (Exception ex)
{
}
if (newValue != null)
{
sender.sendMessage(String.format("Set configuration entry \"%s\" to \"%s\" value \"%s\".",
entry.toString(), type.getName(), newValue.toString()));
}
else
{
sender.sendMessage("Could not parse value \"" + newValueString + "\" as type \"" + type.getName() + "\".");
}
return true;
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.GameMode;
@ -24,31 +24,31 @@ public class Command_creative extends TFM_Command
}
}
Player p;
Player player;
if (args.length == 0)
{
p = sender_p;
player = sender_p;
}
else
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player player : server.getOnlinePlayers())
if (!TFM_AdminList.isSuperAdmin(sender))
{
player.setGameMode(GameMode.CREATIVE);
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player targetPlayer : server.getOnlinePlayers())
{
targetPlayer.setGameMode(GameMode.CREATIVE);
}
TFM_Util.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
return true;
}
if (!(senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender)))
if (!(senderIsConsole || TFM_AdminList.isSuperAdmin(sender)))
{
playerMsg("Only superadmins can change other user's gamemode.");
return true;
@ -56,19 +56,19 @@ public class Command_creative extends TFM_Command
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
}
playerMsg("Setting " + p.getName() + " to game mode 'Creative'.");
playerMsg(p, sender.getName() + " set your game mode to 'Creative'.");
p.setGameMode(GameMode.CREATIVE);
playerMsg("Setting " + player.getName() + " to game mode 'Creative'.");
playerMsg(player, sender.getName() + " set your game mode to 'Creative'.");
player.setGameMode(GameMode.CREATIVE);
return true;
}

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -6,8 +6,9 @@ import org.bukkit.Sound;
import org.bukkit.command.Command;
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 = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Make some noise.", usage = "/<command>")
public class Command_deafen extends TFM_Command
{
@ -17,20 +18,20 @@ public class Command_deafen extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
for (final Player p : server.getOnlinePlayers())
for (final Player player : server.getOnlinePlayers())
{
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
{
final float pitch = (float) (percent * 2.0);
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
{
p.playSound(randomOffset(p.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
player.playSound(randomOffset(player.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
}
}, Math.round(20.0 * percent * 2.0));
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
}
}

View File

@ -0,0 +1,111 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.lang.reflect.Field;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.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)
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
public class Command_debug extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 3)
{
return false;
}
try
{
String className = args[0];
String fieldName = args[1];
String newValue = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
if (className.equalsIgnoreCase("_"))
{
className = "me.StevenLawson.TotalFreedomMod.TotalFreedomMod";
}
setStaticValue(className, fieldName, newValue);
sender.sendMessage("Debug: OK");
}
catch (Exception ex)
{
sender.sendMessage(ex.getMessage());
}
return true;
}
public static void setStaticValue(final String className, final String fieldName, final String newValueString) throws Exception
{
Class<?> forName = Class.forName(className);
if (forName != null)
{
final Field field = forName.getDeclaredField(fieldName);
if (field != null)
{
Object newValue;
Class<?> type = field.getType();
if (type.isPrimitive())
{
if (type.getName().equals("int"))
{
newValue = Integer.parseInt(newValueString);
}
else if (type.getName().equals("double"))
{
newValue = Double.parseDouble(newValueString);
}
else if (type.getName().equals("boolean"))
{
newValue = Boolean.parseBoolean(newValueString);
}
else
{
throw new Exception("Unknown primitive field type.");
}
}
else
{
if (type.isAssignableFrom(Integer.class))
{
newValue = new Integer(newValueString);
}
else if (type.isAssignableFrom(Double.class))
{
newValue = new Double(newValueString);
}
else if (type.isAssignableFrom(Boolean.class))
{
newValue = Boolean.valueOf(newValueString);
}
else if (type.isAssignableFrom(String.class))
{
newValue = newValueString;
}
else
{
throw new Exception("Unknown complex field type.");
}
}
field.setAccessible(true);
final Object oldValue = field.get(Class.forName(className));
if (oldValue != null)
{
field.set(oldValue, newValue);
}
field.setAccessible(false);
}
}
}
}

View File

@ -0,0 +1,26 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
public class Command_denick extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Removing all nicknames.", false);
Player[] onlinePlayers = server.getOnlinePlayers();
for (Player player : onlinePlayers)
{
TFM_EssentialsBridge.getInstance().setNickname(player.getName(), null);
}
return true;
}
}

View File

@ -18,25 +18,25 @@ public class Command_deop extends TFM_Command
return false;
}
OfflinePlayer p = null;
OfflinePlayer player = null;
for (Player onlinePlayer : server.getOnlinePlayers())
{
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
{
p = onlinePlayer;
player = onlinePlayer;
}
}
// if the player is not online
if (p == null)
if (player == null)
{
p = server.getOfflinePlayer(args[0]);
player = server.getOfflinePlayer(args[0]);
}
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);
p.setOp(false);
player.setOp(false);
return true;
}

View File

@ -15,10 +15,10 @@ public class Command_deopall extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "De-opping all players on the server", true);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
p.setOp(false);
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
player.setOp(false);
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
}
return true;

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -74,13 +74,13 @@ public class Command_dispfill extends TFM_Command
{
for (int z_offset = -radius; z_offset <= radius; z_offset++)
{
Block target_block = center_block.getRelative(x_offset, y_offset, z_offset);
if (target_block.getLocation().distanceSquared(center_location) < (radius * radius))
Block targetBlock = center_block.getRelative(x_offset, y_offset, z_offset);
if (targetBlock.getLocation().distanceSquared(center_location) < (radius * radius))
{
if (target_block.getType().equals(Material.DISPENSER))
if (targetBlock.getType().equals(Material.DISPENSER))
{
sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(target_block.getLocation()));
setDispenserContents(target_block, items_array);
sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(targetBlock.getLocation()));
setDispenserContents(targetBlock, items_array);
affected++;
}
}
@ -98,9 +98,9 @@ public class Command_dispfill extends TFM_Command
return true;
}
private static void setDispenserContents(Block target_block, ItemStack[] items)
private static void setDispenserContents(Block targetBlock, ItemStack[] items)
{
Dispenser dispenser = (Dispenser) target_block.getState();
Dispenser dispenser = (Dispenser) targetBlock.getState();
Inventory disp_inv = dispenser.getInventory();
disp_inv.clear();
disp_inv.addItem(items);

View File

@ -1,16 +1,19 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
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;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "For the bad Superadmins.", usage = "/<command> <playername>")
@CommandParameters(description = "For the bad Superadmins", usage = "/<command> <playername>")
public class Command_doom extends TFM_Command
{
@Override
@ -21,82 +24,82 @@ public class Command_doom extends TFM_Command
return false;
}
final Player p;
final Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
TFM_Util.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
final String IP = p.getAddress().getAddress().getHostAddress().trim();
final String ip = player.getAddress().getAddress().getHostAddress().trim();
// remove from superadmin
if (TFM_SuperadminList.isUserSuperadmin(p))
if (TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + " from the superadmin list.", true);
TFM_SuperadminList.removeSuperadmin(p);
TFM_Util.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list.", true);
TFM_AdminList.removeSuperadmin(player);
}
// remove from whitelist
p.setWhitelisted(false);
player.setWhitelisted(false);
// deop
p.setOp(false);
player.setOp(false);
// ban IP
TFM_ServerInterface.banIP(IP, null, null, null);
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName()));
// ban name
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
// set gamemode to survival
p.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL);
// clear inventory
p.closeInventory();
p.getInventory().clear();
player.closeInventory();
player.getInventory().clear();
// ignite player
p.setFireTicks(10000);
player.setFireTicks(10000);
// generate explosion
p.getWorld().createExplosion(p.getLocation(), 4F);
player.getWorld().createExplosion(player.getLocation(), 4F);
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
{
// strike lightning
p.getWorld().strikeLightning(p.getLocation());
player.getWorld().strikeLightning(player.getLocation());
// kill (if not done already)
p.setHealth(0);
player.setHealth(0.0);
}
}, 40L); // 2 seconds
}.runTaskLater(plugin, 20L * 2L);
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
{
// message
TFM_Util.adminAction(sender.getName(), "Banning " + p.getName() + ", IP: " + IP, true);
TFM_Util.adminAction(sender.getName(), "Banning " + player.getName() + ", IP: " + ip, true);
// generate explosion
p.getWorld().createExplosion(p.getLocation(), 4F);
player.getWorld().createExplosion(player.getLocation(), 4F);
// kick player
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
}
}, 60L); // 3 seconds
}.runTaskLater(plugin, 20L * 3L);
return true;
}

View File

@ -0,0 +1,25 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable auto entity wiper.", usage = "/<command> <on | off>")
public class Command_droptoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(sender.getName(),
(TFM_ConfigEntry.AUTO_ENTITY_WIPE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
+ " automatic entity wiping.", false);
return true;
}
}

View File

@ -0,0 +1,42 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shortcut to enable/disable DisguiseCraft.", usage = "/<command>")
public class Command_dtoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft != null)
{
PluginManager pluginManager = plugin.getServer().getPluginManager();
boolean enabled = disguiseCraft.isEnabled();
if (enabled)
{
pluginManager.disablePlugin(disguiseCraft);
}
else
{
pluginManager.enablePlugin(disguiseCraft);
}
TFM_Util.adminAction(sender.getName(), (!enabled ? "Enabled" : "Disabled") + " DisguiseCraft.", true);
}
else
{
sender.sendMessage("DisguiseCraft is not installed on this server.");
}
return true;
}
}

View File

@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
@ -53,9 +55,23 @@ public class Command_enchant extends TFM_Command
{
for (Enchantment ench : Enchantment.values())
{
if (ench.canEnchantItem(itemInHand))
/*
2013-07-20 23:17:13 [INFO] [TotalFreedomMod]: Command Error: enchant
java.lang.NullPointerException
at net.minecraft.server.v1_6_R2.EnchantmentDurability.canEnchant(SourceFile:33)
at org.bukkit.craftbukkit.v1_6_R2.enchantments.CraftEnchantment.canEnchantItem(CraftEnchantment.java:55)
at me.StevenLawson.TotalFreedomMod.Commands.Command_enchant.run(Command_enchant.java:56)
*/
try
{
itemInHand.addEnchantment(ench, ench.getMaxLevel());
if (ench.canEnchantItem(itemInHand))
{
itemInHand.addEnchantment(ench, ench.getMaxLevel());
}
}
catch (Exception ex)
{
TFM_Log.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + sender_p.getName() + ".");
}
}
@ -106,7 +122,7 @@ public class Command_enchant extends TFM_Command
playerMsg("Can't use this enchantment on held item.");
}
}
else if (args[0].equalsIgnoreCase("remove"))
else if (TFM_Util.isRemoveCommand(args[0]))
{
itemInHand.removeEnchantment(ench);

View File

@ -1,9 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.util.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 = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
@ -12,8 +16,8 @@ public class Command_expel extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
double radius = 15.0;
double strength = 20.0;
double radius = 20.0;
double strength = 5.0;
if (args.length >= 1)
{
@ -21,7 +25,7 @@ public class Command_expel extends TFM_Command
{
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
}
catch (NumberFormatException nfex)
catch (NumberFormatException ex)
{
}
}
@ -32,33 +36,50 @@ public class Command_expel extends TFM_Command
{
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
}
catch (NumberFormatException nfex)
catch (NumberFormatException ex)
{
}
}
Location sender_pos = sender_p.getLocation();
for (Player p : sender_pos.getWorld().getPlayers())
List<String> pushedPlayers = new ArrayList<String>();
final Vector senderPos = sender_p.getLocation().toVector();
final List<Player> players = sender_p.getWorld().getPlayers();
for (final Player player : players)
{
if (!p.equals(sender_p))
if (player.equals(sender_p))
{
Location target_pos = p.getLocation();
boolean in_range = false;
try
{
in_range = target_pos.distanceSquared(sender_pos) < (radius * radius);
}
catch (IllegalArgumentException ex)
{
}
if (in_range)
{
p.setVelocity(target_pos.clone().subtract(sender_pos).toVector().normalize().multiply(strength));
playerMsg("Pushing " + p.getName() + ".");
}
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);
player.setFlying(false);
player.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
pushedPlayers.add(player.getName());
}
}
if (pushedPlayers.isEmpty())
{
playerMsg("No players pushed.");
}
else
{
playerMsg("Pushed " + pushedPlayers.size() + " players: " + StringUtils.join(pushedPlayers, ", "));
}
return true;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
{
try
{
TotalFreedomMod.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])));
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
@ -33,12 +33,12 @@ public class Command_explosives extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowExplosions = true;
playerMsg("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
playerMsg("Explosives are now enabled, radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble() + " blocks.");
}
else
{
TotalFreedomMod.allowExplosions = false;
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(false);
playerMsg("Explosives are now disabled.");
}

View File

@ -0,0 +1,37 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>")
public class Command_findip extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player;
try
{
player = getPlayer(args[0]);
}
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage());
return true;
}
playerMsg("Player IPs: " + StringUtils.join(TFM_PlayerList.getInstance().getEntry(player).getIps(), ", "));
return true;
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -19,12 +19,12 @@ public class Command_fireplace extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFirePlace = true;
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
playerMsg("Fire placement is now enabled.");
}
else
{
TotalFreedomMod.allowFirePlace = false;
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(false);
playerMsg("Fire placement is now disabled.");
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -17,16 +18,13 @@ public class Command_firespread extends TFM_Command
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFireSpread = true;
playerMsg("Fire spread is now enabled.");
}
else
{
TotalFreedomMod.allowFireSpread = false;
playerMsg("Fire spread is now disabled.");
}
boolean fireSpread = !args[0].equalsIgnoreCase("off");
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(fireSpread);
playerMsg("Fire spread is now " + (fireSpread ? "enabled" : "disabled") + ".");
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, fireSpread);
return true;
}

View File

@ -1,21 +1,21 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.World.TFM_Flatlands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Goto the flatlands.", usage = "/<command>")
public class Command_flatlands extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (TotalFreedomMod.generateFlatlands)
if (TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean())
{
TFM_Util.gotoWorld(sender, "flatlands");
TFM_Flatlands.getInstance().sendToWorld(sender_p);
}
else
{

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_fluidspread extends TFM_Command
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowFliudSpread = true;
playerMsg("Lava and water spread is now enabled.");
}
else
{
TotalFreedomMod.allowFliudSpread = false;
playerMsg("Lava and water spread is now disabled.");
}
playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}

View File

@ -1,13 +1,15 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.Bukkit;
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.BOTH)
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
@ -24,33 +26,37 @@ public class Command_fr extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
TotalFreedomMod.allPlayersFrozen = true;
TotalFreedomMod.freezePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
if (TotalFreedomMod.freezePurgeTask != null)
{
TotalFreedomMod.freezePurgeTask.cancel();
}
TotalFreedomMod.freezePurgeTask = new BukkitRunnable()
{
@Override
public void run()
{
if (TotalFreedomMod.freezePurgeEventId == 0)
{
TFM_Log.warning("Freeze autopurge task was improperly cancelled!");
return;
}
TFM_Util.adminAction("FreezeTimer", "Unfreezing all players", false);
TotalFreedomMod.allPlayersFrozen = false;
TotalFreedomMod.freezePurgeEventId = 0;
}
}, 6000L); // five minutes in ticks: 20*60*5
}.runTaskLater(plugin, 20L * 60L * 5L);
playerMsg("Players are now frozen.");
for (Player player : Bukkit.getOnlinePlayers())
{
if (!TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.playerMsg(player, "You have been frozen due to rule breaker(s), you will be unfrozen very soon.", ChatColor.RED);
}
}
}
else
{
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
TotalFreedomMod.allPlayersFrozen = false;
if (TotalFreedomMod.freezePurgeEventId != 0)
if (TotalFreedomMod.freezePurgeTask != null)
{
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
TotalFreedomMod.freezePurgeEventId = 0;
TotalFreedomMod.freezePurgeTask.cancel();
}
playerMsg("Players are now free to move.");
}
@ -60,10 +66,14 @@ public class Command_fr extends TFM_Command
if (args[0].toLowerCase().equals("purge"))
{
TotalFreedomMod.allPlayersFrozen = false;
for (Player p : server.getOnlinePlayers())
if (TotalFreedomMod.freezePurgeTask != null)
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TotalFreedomMod.freezePurgeTask.cancel();
}
for (Player player : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setFrozen(false);
}
@ -71,22 +81,22 @@ public class Command_fr extends TFM_Command
}
else
{
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setFrozen(!playerdata.isFrozen());
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(p, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
}
}

View File

@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
@ -12,7 +14,7 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@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",
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci> <targethash>] ]")
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci | fr> <targethash>] ]")
public class Command_gadmin extends TFM_Command
{
@Override
@ -30,77 +32,77 @@ public class Command_gadmin extends TFM_Command
playerMsg("[ Real Name ] : [ Display Name ] - Hash:");
}
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
String hash = p.getUniqueId().toString().substring(0, 4);
String hash = player.getUniqueId().toString().substring(0, 4);
if (mode.equals("list"))
{
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
p.getName(),
ChatColor.stripColor(p.getDisplayName()),
player.getName(),
ChatColor.stripColor(player.getDisplayName()),
hash));
}
else if (hash.equalsIgnoreCase(args[1]))
{
if (mode.equals("kick"))
{
TFM_Util.adminAction(sender.getName(), String.format("Kicking: %s.", p.getName()), false);
p.kickPlayer("Kicked by Administrator");
TFM_Util.adminAction(sender.getName(), String.format("Kicking: %s.", player.getName()), false);
player.kickPlayer("Kicked by Administrator");
}
else if (mode.equals("nameban"))
{
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s.", p.getName()), true);
p.kickPlayer("Username banned by Administrator.");
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s.", player.getName()), true);
player.kickPlayer("Username banned by Administrator.");
}
else if (mode.equals("ipban"))
{
String user_ip = p.getAddress().getAddress().getHostAddress();
String[] ip_parts = user_ip.split("\\.");
String ip = player.getAddress().getAddress().getHostAddress();
String[] ip_parts = ip.split("\\.");
if (ip_parts.length == 4)
{
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
}
TFM_Util.adminAction(sender.getName(), String.format("Banning IP: %s.", p.getName(), user_ip), true);
TFM_ServerInterface.banIP(user_ip, null, null, null);
p.kickPlayer("IP address banned by Administrator.");
TFM_Util.adminAction(sender.getName(), String.format("Banning IP: %s.", player.getName(), ip), true);
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName()));
player.kickPlayer("IP address banned by Administrator.");
}
else if (mode.equals("ban"))
{
String user_ip = p.getAddress().getAddress().getHostAddress();
String[] ip_parts = user_ip.split("\\.");
String ip = player.getAddress().getAddress().getHostAddress();
String[] ip_parts = ip.split("\\.");
if (ip_parts.length == 4)
{
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
}
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), true);
TFM_ServerInterface.banIP(user_ip, null, null, null);
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
p.kickPlayer("IP and username banned by Administrator.");
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", player.getName(), ip), true);
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName()));
player.kickPlayer("IP and username banned by Administrator.");
}
else if (mode.equals("op"))
{
TFM_Util.adminAction(sender.getName(), String.format("Opping %s.", p.getName()), false);
p.setOp(false);
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
TFM_Util.adminAction(sender.getName(), String.format("Opping %s.", player.getName()), false);
player.setOp(false);
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
}
else if (mode.equals("deop"))
{
TFM_Util.adminAction(sender.getName(), String.format("Deopping %s.", p.getName()), false);
p.setOp(false);
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
TFM_Util.adminAction(sender.getName(), String.format("Deopping %s.", player.getName()), false);
player.setOp(false);
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
}
else if (mode.equals("ci"))
{
p.getInventory().clear();
player.getInventory().clear();
}
else if (mode.equals("fr"))
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setFrozen(!playerdata.isFrozen());
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
player.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
}
return true;

View File

@ -1,5 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -17,37 +19,28 @@ public class Command_gcmd extends TFM_Command
return false;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
String outcommand = "";
try
final String outCommand = StringUtils.join(args, " ", 1, args.length);
if (TFM_CommandBlocker.getInstance().isCommandBlocked(outCommand, sender))
{
StringBuilder outcommand_bldr = new StringBuilder();
for (int i = 1; i < args.length; i++)
{
outcommand_bldr.append(args[i]).append(" ");
}
outcommand = outcommand_bldr.toString().trim();
}
catch (Throwable ex)
{
sender.sendMessage(ChatColor.GRAY + "Error building command: " + ex.getMessage());
return true;
}
try
{
playerMsg("Sending command as " + p.getName() + ": " + outcommand);
if (server.dispatchCommand(p, outcommand))
playerMsg("Sending command as " + player.getName() + ": " + outCommand);
if (server.dispatchCommand(player, outCommand))
{
playerMsg("Command sent.");
}

View File

@ -3,11 +3,14 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList.TFM_UserListEntry;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -29,9 +32,9 @@ public class Command_glist extends TFM_Command
if (args[0].equalsIgnoreCase("purge"))
{
//Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database!
if (TFM_SuperadminList.isSeniorAdmin(sender))
if (TFM_AdminList.isSeniorAdmin(sender))
{
TFM_UserList.getInstance(plugin).purge();
TFM_PlayerList.getInstance().purgeAll();
}
else
{
@ -47,18 +50,18 @@ public class Command_glist extends TFM_Command
else if (args.length == 2)
{
String username;
List<String> ip_addresses = new ArrayList<String>();
List<String> ips = new ArrayList<String>();
try
{
Player p = getPlayer(args[1]);
Player player = getPlayer(args[1]);
username = p.getName();
ip_addresses.add(p.getAddress().getAddress().getHostAddress());
username = player.getName();
ips.add(player.getAddress().getAddress().getHostAddress());
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
TFM_UserListEntry entry = TFM_UserList.getInstance(plugin).getEntry(args[1]);
final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(args[1]);
if (entry == null)
{
@ -66,44 +69,44 @@ public class Command_glist extends TFM_Command
return true;
}
username = entry.getUsername();
ip_addresses = entry.getIpAddresses();
username = entry.getLastJoinName();
ips = entry.getIps();
}
String mode = args[0].toLowerCase();
if (mode.equalsIgnoreCase("ban"))
{
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ip_addresses, ","), true);
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
Player p = server.getPlayerExact(username);
if (p != null)
Player player = server.getPlayerExact(username);
if (player != null)
{
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
p.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName()));
player.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
}
else
{
TFM_ServerInterface.banUsername(username, null, null, null);
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(Bukkit.getOfflinePlayer(username).getUniqueId(), username));
}
for (String ip_address : ip_addresses)
for (String ip : ips)
{
TFM_ServerInterface.banIP(ip_address, null, null, null);
String[] ip_address_parts = ip_address.split("\\.");
TFM_ServerInterface.banIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", null, null, null);
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, username));
String[] ip_address_parts = ip.split("\\.");
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", username));
}
}
else if (mode.equalsIgnoreCase("unban") || mode.equalsIgnoreCase("pardon"))
{
TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ip_addresses, ","), true);
TFM_Util.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ","), true);
TFM_ServerInterface.unbanUsername(username);
TFM_BanManager.getInstance().unbanUuid(Bukkit.getOfflinePlayer(username).getUniqueId());
for (String ip_address : ip_addresses)
for (String ip : ips)
{
TFM_ServerInterface.unbanIP(ip_address);
String[] ip_address_parts = ip_address.split("\\.");
TFM_ServerInterface.unbanIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*");
TFM_BanManager.getInstance().unbanIp(ip);
String[] ipParts = ip.split("\\.");
TFM_BanManager.getInstance().unbanIp(ipParts[0] + "." + ipParts[1] + ".*.*");
}
}
else

View File

@ -1,7 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_WorldEditBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Ban;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.ArrayUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -16,71 +22,78 @@ public class Command_gtfo extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
if (args.length == 0)
{
return false;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
String reason = null;
if (args.length >= 2)
{
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
// Op Player
p.setOp(true);
//Undo WorldEdits:
server.dispatchCommand(p, "/undo 15");
//rollback
server.dispatchCommand(sender, "rollback " + p.getName());
TFM_Util.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits:
try
{
TFM_WorldEditBridge.getInstance().undo(player, 15);
}
catch (NoClassDefFoundError ex)
{
}
// rollback
TFM_RollbackManager.rollback(player.getName());
// deop
p.setOp(false);
player.setOp(false);
// set gamemode to survival:
p.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL);
// clear inventory:
p.getInventory().clear();
player.getInventory().clear();
// strike with lightning effect:
final Location target_pos = p.getLocation();
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(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
target_pos.getWorld().strikeLightning(strike_pos);
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
targetPos.getWorld().strikeLightning(strike_pos);
}
}
// ban IP address:
String user_ip = p.getAddress().getAddress().getHostAddress();
String[] ip_parts = user_ip.split("\\.");
if (ip_parts.length == 4)
String ip = player.getAddress().getAddress().getHostAddress();
String[] ipParts = ip.split("\\.");
if (ipParts.length == 4)
{
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
ip = String.format("%s.%s.*.*", ipParts[0], ipParts[1]);
}
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
TFM_ServerInterface.banIP(user_ip, null, null, null);
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", player.getName(), ip), ChatColor.RED);
TFM_BanManager.getInstance().addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason));
// ban username:
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
TFM_BanManager.getInstance().addUuidBan(new TFM_Ban(player.getUniqueId(), player.getName(), sender.getName(), null, reason));
// kick Player:
p.kickPlayer("GTFO");
player.kickPlayer(ChatColor.RED + "GTFO" + (reason != null ? ("\nReason: " + ChatColor.YELLOW + reason) : ""));
return true;
}

View File

@ -1,10 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -25,11 +23,11 @@ public class Command_halt extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Halting all non-superadmins.", true);
int counter = 0;
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
if (!TFM_AdminList.isSuperAdmin(player))
{
setHalted(p, true);
TFM_PlayerData.getPlayerData(player).setHalted(true);
counter++;
}
}
@ -41,11 +39,12 @@ public class Command_halt extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Unhalting all players.", true);
int counter = 0;
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (TFM_PlayerData.getPlayerData(p).isHalted())
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (TFM_PlayerData.getPlayerData(player).isHalted())
{
setHalted(p, false);
playerdata.setHalted(false);
counter++;
}
}
@ -77,60 +76,30 @@ public class Command_halt extends TFM_Command
return true;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
if (!TFM_PlayerData.getPlayerData(p).isHalted())
{
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
setHalted(p, true);
return true;
}
else
{
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
setHalted(p, false);
return true;
}
}
private static void setHalted(Player p, boolean is_halted)
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (is_halted)
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (!playerdata.isHalted())
{
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.setFlying(false);
p.setDisplayName(p.getName());
p.closeInventory();
p.setTotalExperience(0);
playerdata.stopOrbiting();
playerdata.setFrozen(true);
playerdata.setMuted(true);
TFM_Util.adminAction(sender.getName(), "Halting " + player.getName(), true);
playerdata.setHalted(true);
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
return true;
}
else
{
p.setOp(true);
p.setGameMode(GameMode.CREATIVE);
playerdata.setFrozen(false);
playerdata.setMuted(false);
TFM_Util.adminAction(sender.getName(), "Unhalting " + player.getName(), true);
playerdata.setHalted(false);
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
return true;
}
}
}

View File

@ -1,53 +1,100 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.text.DecimalFormat;
import java.util.concurrent.atomic.AtomicInteger;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_TickMeter;
import org.apache.commons.lang.exception.ExceptionUtils;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.math.DoubleRange;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
public class Command_health extends TFM_Command
{
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)
{
Runtime runtime = Runtime.getRuntime();
long usedMem = runtime.totalMemory() - runtime.freeMemory();
Runnable task;
task = new Runnable() // async
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...");
new BukkitRunnable()
{
@Override
public void run()
{
try
{
TFM_TickMeter meter = new TFM_TickMeter(plugin);
meter.startTicking();
Thread.sleep(1000); // per second
meter.stopTicking();
TFM_TickMeter tickMeter = new TFM_TickMeter(plugin);
tickMeter.startTicking();
Thread.sleep(2500);
final double ticksPerSecond = tickMeter.stopTicking();
Runtime runtime = Runtime.getRuntime();
int mb = 1048576; // 1024 * 1024
float usedMem = runtime.totalMemory() - runtime.freeMemory();
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem / runtime.totalMemory() * 100) + "%)");
playerMsg("Max Memory: " + runtime.maxMemory() / mb + "mb");
playerMsg("Ticks per second: " + (meter.getTicks() == 20 ? ChatColor.GREEN : ChatColor.RED) + meter.getTicks());
new BukkitRunnable()
{
@Override
public void run()
{
playerMsg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
}
}.runTask(plugin);
}
catch (Exception iex)
catch (Exception ex)
{
TFM_Log.warning("Exception in TFM_TickMeter: Thread was interupted in sleeping process.");
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
TFM_Log.severe(ex);
}
}
};
new Thread(task, "TickMeter").start();
}.runTaskAsynchronously(plugin);
return true;
}
private class TFM_TickMeter
{
private final AtomicInteger ticks = new AtomicInteger();
private final TotalFreedomMod plugin;
private long startTime;
private BukkitTask task;
public TFM_TickMeter(TotalFreedomMod plugin)
{
this.plugin = plugin;
}
public void startTicking()
{
startTime = System.currentTimeMillis();
ticks.set(0);
task = new BukkitRunnable()
{
@Override
public void run()
{
ticks.incrementAndGet();
}
}.runTaskTimer(plugin, 0L, 1L);
}
public double stopTicking()
{
task.cancel();
long elapsed = System.currentTimeMillis() - startTime;
int tickCount = ticks.get();
return (double) tickCount / ((double) elapsed / 1000.0);
}
}
}

View File

@ -2,18 +2,18 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.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)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
public class Command_invis extends TFM_Command {
public class Command_invis extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -22,6 +22,7 @@ public class Command_invis extends TFM_Command {
{
if (args[0].equalsIgnoreCase("smite"))
{
TFM_Util.adminAction(sender.getName(), "Smiting all invisible players", true);
smite = true;
}
else
@ -33,19 +34,21 @@ public class Command_invis extends TFM_Command {
List<String> players = new ArrayList<String>();
int smites = 0;
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
players.add(p.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(player.getName());
if (smite && !TFM_AdminList.isSuperAdmin(player))
{
server.dispatchCommand(sender, "smite " + p.getName());
player.setHealth(0.0);
smites++;
}
}
}
if (players.isEmpty()) {
if (players.isEmpty())
{
TFM_Util.playerMsg(sender, "There are no invisible players");
return true;
}

View File

@ -0,0 +1,94 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Jumppads;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, 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 TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, 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"))
{
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Strength: " + (TFM_Jumppads.getInstance().getStrength() * 10 - 1), ChatColor.BLUE);
return true;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
}
else
{
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
}
}
else
{
if (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.OFF)
{
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
return true;
}
if (args[0].equalsIgnoreCase("sideways"))
{
if (TFM_Util.isStopCommand(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
}
else
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
}
}
else if (args[0].equalsIgnoreCase("strength"))
{
final float strength;
try
{
strength = Float.parseFloat(args[1]);
}
catch (NumberFormatException ex)
{
playerMsg("Invalid Strength");
return true;
}
if (strength > 10 || strength < 1)
{
playerMsg("Invalid Strength: The strength may be 1 through 10.");
return true;
}
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
TFM_Jumppads.getInstance().setStrength((strength / 10) + 0.1F);
}
else
{
return false;
}
}
return true;
}
}

View File

@ -1,13 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Kick all non-superadmins on server.", usage = "/<command>")
public class Command_kicknoob extends TFM_Command
{
@ -16,11 +16,11 @@ public class Command_kicknoob extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Disconnecting all non-superadmins.", true);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
if (!TFM_AdminList.isSuperAdmin(player))
{
p.kickPlayer(ChatColor.RED + "Disconnected by admin.");
player.kickPlayer(ChatColor.RED + "Disconnected by admin.");
}
}

View File

@ -1,8 +1,10 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -17,11 +19,11 @@ public class Command_landmine extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!TotalFreedomMod.landminesEnabled)
if (!TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean())
{
playerMsg("The landmine is currently disabled.", ChatColor.GREEN);
}
else if (!TotalFreedomMod.allowExplosions)
else if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
playerMsg("Explosions are currently disabled.", ChatColor.GREEN);
}
@ -48,4 +50,20 @@ public class Command_landmine extends TFM_Command
return true;
}
public static class TFM_LandmineData
{
public static List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
public Location location;
public Player player;
public double radius;
public TFM_LandmineData(Location landmine_pos, Player player, double radius)
{
super();
this.location = landmine_pos;
this.player = player;
this.radius = radius;
}
}
}

View File

@ -18,18 +18,18 @@ public class Command_lastcmd extends TFM_Command
return false;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
if (playerdata != null)
{
@ -38,7 +38,7 @@ public class Command_lastcmd extends TFM_Command
{
last_command = "(none)";
}
playerMsg(p.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
playerMsg(player.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
}
return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_lavadmg extends TFM_Command
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowLavaDamage = true;
playerMsg("Lava damage is now enabled.");
}
else
{
TotalFreedomMod.allowLavaDamage = false;
playerMsg("Lava damage is now disabled.");
}
playerMsg("Lava damage is now " + (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_lavaplace extends TFM_Command
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.allowLavaPlace = true;
playerMsg("Lava placement is now enabled.");
}
else
{
TotalFreedomMod.allowLavaPlace = false;
playerMsg("Lava placement is now disabled.");
}
playerMsg("Lava placement is now " + (TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}

View File

@ -2,93 +2,72 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command>", aliases = "who")
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a]", aliases = "who")
public class Command_list extends TFM_Command
{
private static enum ListFilter
{
SHOW_ALL, SHOW_ADMINS
ALL,
ADMINS;
}
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 1)
{
return false;
}
if (TFM_Util.isFromHostConsole(sender.getName()))
{
List<String> player_names = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())
final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers())
{
player_names.add(p.getName());
names.add(player.getName());
}
playerMsg("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "), ChatColor.WHITE);
playerMsg("There are " + names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(names, ", "), ChatColor.WHITE);
return true;
}
ListFilter listFilter = ListFilter.SHOW_ALL;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("-a"))
{
listFilter = ListFilter.SHOW_ADMINS;
}
}
final Command_list.ListFilter listFilter = (args.length == 1 && args[0].equals("-a") ? Command_list.ListFilter.ADMINS : Command_list.ListFilter.ALL);
StringBuilder onlineStats = new StringBuilder();
StringBuilder onlineUsers = new StringBuilder();
final StringBuilder onlineStats = new StringBuilder();
final StringBuilder onlineUsers = new StringBuilder();
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" players online.");
List<String> player_names = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())
final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers())
{
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(p);
final boolean userSuperadmin = TFM_AdminList.isSuperAdmin(player);
if (listFilter == ListFilter.SHOW_ADMINS && !userSuperadmin)
if (listFilter == Command_list.ListFilter.ADMINS && !userSuperadmin)
{
continue;
}
String prefix = "";
if (userSuperadmin)
{
if (TFM_SuperadminList.isSeniorAdmin(p))
{
prefix = (ChatColor.LIGHT_PURPLE + "[SrA]");
}
else
{
prefix = (ChatColor.GOLD + "[SA]");
}
if (TFM_Util.DEVELOPERS.contains(p.getName()))
{
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
}
}
else
{
if (p.isOp())
{
prefix = (ChatColor.RED + "[OP]");
}
}
player_names.add(prefix + p.getName() + ChatColor.WHITE);
names.add(TFM_PlayerRank.fromSender(player).getPrefix() + player.getName());
}
onlineUsers.append("Connected ").append(listFilter == ListFilter.SHOW_ADMINS ? "admins" : "players").append(": ").append(StringUtils.join(player_names, ", "));
onlineUsers.append("Connected ");
onlineUsers.append(listFilter == Command_list.ListFilter.ADMINS ? "admins: " : "players: ");
onlineUsers.append(StringUtils.join(names, ChatColor.WHITE + ", "));
if (senderIsConsole)
{

View File

@ -1,14 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.io.File;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Download the superadmin and permban lists from the main TotalFreedom server.", usage = "/<command>")
public class Command_listsync extends TFM_Command
{
@ -19,8 +21,10 @@ public class Command_listsync extends TFM_Command
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_superadmins_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
TotalFreedomMod.loadSuperadminConfig();
TFM_AdminList.createBackup();
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_superadmins_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(),
TotalFreedomMod.SUPERADMIN_FILE));
TFM_AdminList.load();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.SUPERADMIN_FILE + " downloaded.", false);
}
catch (Exception ex)
@ -30,8 +34,10 @@ public class Command_listsync extends TFM_Command
try
{
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_permbans_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PERMBAN_FILE));
TotalFreedomMod.loadPermbanConfig();
TFM_PermbanList.createBackup();
TFM_Util.downloadFile("http://madgeekonline.com/apps/get_permbans_raw.php", new File(TotalFreedomMod.plugin.getDataFolder(),
TotalFreedomMod.PERMBAN_FILE));
TFM_PermbanList.load();
TFM_Util.adminAction(sender.getName(), TotalFreedomMod.PERMBAN_FILE + " downloaded.", false);
}
catch (Exception ex)

View File

@ -0,0 +1,18 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Teleport to the spawn point for the current world.", usage = "/<command>", aliases = "worldspawn,gotospawn")
public class Command_localspawn extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
sender_p.teleport(sender_p.getWorld().getSpawnLocation());
playerMsg("Teleported to spawnpoint for world \"" + sender_p.getWorld().getName() + "\".");
return true;
}
}

View File

@ -0,0 +1,34 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Prevents new players from joining the server", usage = "/<command> <on | off>")
public class Command_lockdown extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "De-activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = false;
}
else
{
TFM_Util.adminAction(sender.getName(), "Activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = true;
}
return true;
}
}

View File

@ -1,15 +1,14 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Block target's minecraft input. This is evil, and I never should have wrote it.", usage = "/<command> <all | purge | <<partialname> on | off>>")
public class Command_lockup extends TFM_Command
{
@ -22,18 +21,18 @@ public class Command_lockup extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Locking up all players", true);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
startLockup(p);
startLockup(player);
}
playerMsg("Locked up all players.");
}
else if (args[0].equalsIgnoreCase("purge"))
{
TFM_Util.adminAction(sender.getName(), "Unlocking all players", true);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
cancelLockup(p);
cancelLockup(player);
}
playerMsg("Unlocked all players.");
@ -47,37 +46,37 @@ public class Command_lockup extends TFM_Command
{
if (args[1].equalsIgnoreCase("on"))
{
final Player p;
final Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_Util.adminAction(sender.getName(), "Locking up " + p.getName(), true);
startLockup(p);
playerMsg("Locked up " + p.getName() + ".");
TFM_Util.adminAction(sender.getName(), "Locking up " + player.getName(), true);
startLockup(player);
playerMsg("Locked up " + player.getName() + ".");
}
else if (TFM_Util.isStopCommand(args[1]))
{
final Player p;
final Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_Util.adminAction(sender.getName(), "Unlocking " + p.getName(), true);
cancelLockup(p);
playerMsg("Unlocked " + p.getName() + ".");
TFM_Util.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
cancelLockup(player);
playerMsg("Unlocked " + player.getName() + ".");
}
else
{
@ -102,38 +101,31 @@ public class Command_lockup extends TFM_Command
}
}
private void cancelLockup(final Player p)
private void cancelLockup(final Player player)
{
cancelLockup(TFM_PlayerData.getPlayerData(p));
cancelLockup(TFM_PlayerData.getPlayerData(player));
}
private void startLockup(final Player p)
private void startLockup(final Player player)
{
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
cancelLockup(playerdata);
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
playerdata.setLockupScheduleID(new BukkitRunnable()
{
private Random random = new Random();
@Override
public void run()
{
if (p.isOnline())
if (player.isOnline())
{
p.openWorkbench(null, true);
Location l = p.getLocation().clone();
l.setPitch(random.nextFloat() * 360.0f);
l.setYaw(random.nextFloat() * 360.0f);
p.teleport(l);
player.openInventory(player.getInventory());
}
else
{
cancelLockup(playerdata);
}
}
}, 0L, 5L));
}.runTaskTimer(plugin, 0L, 5L));
}
}

View File

@ -0,0 +1,166 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
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.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.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
{
@Override
public boolean run(final CommandSender sender, final Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
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;
}
public static 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)
{
final String logsRegisterURL = TFM_ConfigEntry.LOGS_REGISTER_URL.getString();
final String logsRegisterPassword = TFM_ConfigEntry.LOGS_REGISTER_PASSWORD.getString();
if (logsRegisterURL == null || logsRegisterPassword == null || logsRegisterURL.isEmpty() || logsRegisterPassword.isEmpty())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
if (sender != null)
{
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
}
URL url = new URLBuilder(logsRegisterURL)
.addQueryParameter("mode", mode.toString())
.addQueryParameter("password", logsRegisterPassword)
.addQueryParameter("name", targetName)
.addQueryParameter("ip", targetIP)
.getURL();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(1000 * 5);
connection.setReadTimeout(1000 * 5);
connection.setUseCaches(false);
connection.setRequestMethod("HEAD");
final int responseCode = connection.getResponseCode();
if (sender != null)
{
new BukkitRunnable()
{
@Override
public void run()
{
if (responseCode == 200)
{
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
}
else
{
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
}
}
}.runTask(TotalFreedomMod.plugin);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
}.runTaskAsynchronously(TotalFreedomMod.plugin);
}
public static void deactivateSuperadmin(TFM_Admin superadmin)
{
for (String ip : superadmin.getIps())
{
updateLogsRegistration(null, superadmin.getLastLoginName(), ip, Command_logs.LogsRegistrationMode.DELETE);
}
}
public static enum LogsRegistrationMode
{
UPDATE("update"), DELETE("delete");
private final String mode;
private LogsRegistrationMode(String mode)
{
this.mode = mode;
}
@Override
public String toString()
{
return mode;
}
}
private static class URLBuilder
{
private final String requestPath;
private final Map<String, String> queryStringMap = new HashMap<String, String>();
public URLBuilder(String requestPath)
{
this.requestPath = requestPath;
}
public URLBuilder addQueryParameter(String key, String value)
{
queryStringMap.put(key, value);
return this;
}
public URL getURL() throws MalformedURLException
{
List<String> pairs = new ArrayList<String>();
Iterator<Entry<String, String>> it = queryStringMap.entrySet().iterator();
while (it.hasNext())
{
Entry<String, String> pair = it.next();
pairs.add(pair.getKey() + "=" + pair.getValue());
}
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
}
}
}

View File

@ -1,25 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/<command>")
public class Command_minecraft extends TFM_Command {
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
playerMsg("Status of Mojang services:", ChatColor.BLUE);
for (String service : TFM_ServiceChecker.getAllStatuses())
{
playerMsg(service);
}
playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE);
return true;
}
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -19,27 +20,27 @@ public class Command_moblimiter extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.mobLimiterEnabled = true;
TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
}
else if (args[0].equalsIgnoreCase("off"))
{
TotalFreedomMod.mobLimiterEnabled = false;
TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
}
else if (args[0].equalsIgnoreCase("dragon"))
{
TotalFreedomMod.mobLimiterDisableDragon = !TotalFreedomMod.mobLimiterDisableDragon;
TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
}
else if (args[0].equalsIgnoreCase("giant"))
{
TotalFreedomMod.mobLimiterDisableGiant = !TotalFreedomMod.mobLimiterDisableGiant;
TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
}
else if (args[0].equalsIgnoreCase("slime"))
{
TotalFreedomMod.mobLimiterDisableSlime = !TotalFreedomMod.mobLimiterDisableSlime;
TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
}
else if (args[0].equalsIgnoreCase("ghast"))
{
TotalFreedomMod.mobLimiterDisableGhast = !TotalFreedomMod.mobLimiterDisableGhast;
TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
}
else
{
@ -52,7 +53,7 @@ public class Command_moblimiter extends TFM_Command
{
try
{
TotalFreedomMod.mobLimiterMax = Math.max(0, Math.min(2000, Integer.parseInt(args[1])));
TFM_ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
}
catch (NumberFormatException nfex)
{
@ -60,20 +61,22 @@ public class Command_moblimiter extends TFM_Command
}
}
if (TotalFreedomMod.mobLimiterEnabled)
if (TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TotalFreedomMod.mobLimiterMax + ".");
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TFM_ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
playerMsg("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + ".");
playerMsg("Dragon: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean() ? "disabled" : "enabled") + ".");
}
else
{
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
}
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean());
return true;
}
}

View File

@ -1,22 +1,27 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>")
public class Command_mp extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
sender.sendMessage(ChatColor.GRAY + "Purging all mobs...");
playerMsg("Purging all mobs...");
playerMsg(purgeMobs() + " mobs removed.");
return true;
}
public static int purgeMobs()
{
int removed = 0;
for (World world : server.getWorlds())
for (World world : Bukkit.getWorlds())
{
for (Entity ent : world.getLivingEntities())
{
@ -28,8 +33,6 @@ public class Command_mp extends TFM_Command
}
}
playerMsg(removed + " mobs removed.");
return true;
return removed;
}
}

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
@ -16,7 +16,7 @@ public class Command_mp44 extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!TotalFreedomMod.mp44Enabled)
if (!TFM_ConfigEntry.MP44_ENABLED.getBoolean())
{
playerMsg("The mp44 is currently disabled.", ChatColor.GREEN);
return true;

View File

@ -0,0 +1,125 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.", usage = "/<command> <other_command> !<playernick>")
public class Command_nf extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean nickMatched = false;
final List<String> outputCommand = new ArrayList<String>();
if (args.length >= 1)
{
final List<String> argsList = Arrays.asList(args);
for (String arg : argsList)
{
Player player = null;
Matcher matcher = Pattern.compile("^!(.+)$").matcher(arg);
if (matcher.find())
{
String displayName = matcher.group(1);
try
{
player = getPlayerByDisplayName(displayName);
}
catch (PlayerNotFoundException ex)
{
}
if (player == null)
{
try
{
player = getPlayerByDisplayNameAlt(displayName);
}
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
return true;
}
}
}
if (player == null)
{
outputCommand.add(arg);
}
else
{
nickMatched = true;
outputCommand.add(player.getName());
}
}
}
if (!nickMatched)
{
sender.sendMessage("No nicknames replaced in command.");
return true;
}
String newCommand = StringUtils.join(outputCommand, " ");
sender.sendMessage("Sending command: \"" + newCommand + "\".");
server.dispatchCommand(sender, newCommand);
return true;
}
private static Player getPlayerByDisplayName(String needle) throws PlayerNotFoundException
{
needle = needle.toLowerCase().trim();
Player[] onlinePlayers = Bukkit.getOnlinePlayers();
for (Player player : onlinePlayers)
{
if (player.getDisplayName().toLowerCase().trim().contains(needle))
{
return player;
}
}
throw new PlayerNotFoundException();
}
private static Player getPlayerByDisplayNameAlt(String needle) throws PlayerNotFoundException
{
needle = needle.toLowerCase().trim();
Integer minEditDistance = null;
Player minEditMatch = null;
Player[] onlinePlayers = Bukkit.getOnlinePlayers();
for (Player player : onlinePlayers)
{
String haystack = player.getDisplayName().toLowerCase().trim();
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
if (minEditDistance == null || minEditDistance.intValue() > editDistance)
{
minEditDistance = editDistance;
minEditMatch = player;
}
}
if (minEditMatch == null)
{
throw new PlayerNotFoundException();
}
return minEditMatch;
}
}

View File

@ -0,0 +1,72 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_EssentialsBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Nyanify your nickname.", usage = "/<command> <<nick> | off>")
public class Command_nicknyan extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), null);
playerMsg("Nickname cleared.");
return true;
}
final String nickPlain = ChatColor.stripColor(TFM_Util.colorize(args[0].trim()));
if (!nickPlain.matches("^[a-zA-Z_0-9\u00a7]+$"))
{
playerMsg("That nickname contains invalid characters.");
return true;
}
else if (nickPlain.length() < 4 || nickPlain.length() > 30)
{
playerMsg("Your nickname must be between 4 and 30 characters long.");
return true;
}
final Player[] onlinePlayers = server.getOnlinePlayers();
for (final Player player : onlinePlayers)
{
if (player == sender_p)
{
continue;
}
if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain))
{
playerMsg("That nickname is already in use.");
return true;
}
}
final StringBuilder newNick = new StringBuilder();
final char[] chars = nickPlain.toCharArray();
for (char c : chars)
{
newNick.append(TFM_Util.randomChatColor()).append(c);
}
newNick.append(ChatColor.WHITE);
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), newNick.toString());
playerMsg("Your nickname is now: " + newNick.toString());
return true;
}
}

View File

@ -1,11 +1,11 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
public class Command_nonuke extends TFM_Command
{
@ -21,7 +21,7 @@ public class Command_nonuke extends TFM_Command
{
try
{
TotalFreedomMod.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])));
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
@ -32,7 +32,7 @@ public class Command_nonuke extends TFM_Command
{
try
{
TotalFreedomMod.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2])));
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException nfex)
{
@ -41,14 +41,14 @@ public class Command_nonuke extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.nukeMonitor = true;
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(true);
playerMsg("Nuke monitor is enabled.");
playerMsg("Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
playerMsg("Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
}
else
{
TotalFreedomMod.nukeMonitor = false;
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
playerMsg("Nuke monitor is disabled.");
}

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -2,13 +2,15 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Switch server online-mode on and off.", usage = "/<command> <on | off>")
public class Command_onlinemode extends TFM_Command
{
@ -18,12 +20,18 @@ public class Command_onlinemode extends TFM_Command
if (args.length < 1)
{
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.WHITE);
playerMsg("Use \"/onlinemode on\" and \"/onlinemode off\" to change online mode.", ChatColor.WHITE);
playerMsg("\"/onlinemode on\" and \"/onlinemode off\" can be used to change online mode from the console.", ChatColor.WHITE);
}
else
{
boolean online_mode;
if (sender instanceof Player && !TFM_AdminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (args[0].equalsIgnoreCase("on"))
{
online_mode = true;
@ -43,9 +51,9 @@ public class Command_onlinemode extends TFM_Command
if (online_mode)
{
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
p.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@ -26,21 +26,21 @@ public class Command_op extends TFM_Command
return true;
}
OfflinePlayer p = null;
OfflinePlayer player = null;
for (Player onlinePlayer : server.getOnlinePlayers())
{
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
{
p = onlinePlayer;
player = onlinePlayer;
}
}
// if the player is not online
if (p == null)
if (player == null)
{
if (TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole)
{
p = server.getOfflinePlayer(args[0]);
player = server.getOfflinePlayer(args[0]);
}
else
{
@ -50,8 +50,8 @@ public class Command_op extends TFM_Command
}
}
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
p.setOp(true);
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
player.setOp(true);
return true;
}

View File

@ -32,14 +32,14 @@ public class Command_opall extends TFM_Command
}
}
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
p.setOp(true);
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
player.setOp(true);
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
if (doSetGamemode)
{
p.setGameMode(targetGamemode);
player.setGameMode(targetGamemode);
}
}

View File

@ -1,14 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage operators", usage = "/<command> <count | list | purge>")
@CommandParameters(description = "Manage operators", usage = "/<command> <count | list>")
public class Command_ops extends TFM_Command
{
@Override
@ -31,9 +30,9 @@ public class Command_ops extends TFM_Command
int offlineOPs = 0;
int totalOPs = 0;
for (OfflinePlayer p : server.getOperators())
for (OfflinePlayer player : server.getOperators())
{
if (p.isOnline())
if (player.isOnline())
{
onlineOPs++;
}
@ -51,29 +50,6 @@ public class Command_ops extends TFM_Command
return true;
}
if (args[0].equalsIgnoreCase("purge"))
{
if (!senderIsConsole)
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Util.adminAction(sender.getName(), "Removing all operators", true);
for (OfflinePlayer p : server.getOperators())
{
p.setOp(false);
if (p.isOnline())
{
p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
}
}
return true;
}
return true;
}
}

View File

@ -21,18 +21,18 @@ public class Command_orbit extends TFM_Command
return false;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
double strength = 10.0;
@ -40,7 +40,7 @@ public class Command_orbit extends TFM_Command
{
if (TFM_Util.isStopCommand(args[1]))
{
playerMsg("Stopped orbiting " + p.getName());
playerMsg("Stopped orbiting " + player.getName());
playerdata.stopOrbiting();
return true;
}
@ -56,11 +56,11 @@ public class Command_orbit extends TFM_Command
}
}
p.setGameMode(GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL);
playerdata.startOrbiting(strength);
p.setVelocity(new Vector(0, strength, 0));
TFM_Util.adminAction(sender.getName(), "Orbiting " + p.getName() + ".", false);
player.setVelocity(new Vector(0, strength, 0));
TFM_Util.adminAction(sender.getName(), "Orbiting " + player.getName() + ".", false);
return true;
}

View File

@ -1,13 +1,14 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.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 = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
public class Command_permban extends TFM_Command
{
@ -31,7 +32,8 @@ public class Command_permban extends TFM_Command
return true;
}
playerMsg("Reloading permban list...", ChatColor.RED);
TotalFreedomMod.loadPermbanConfig();
TFM_PermbanList.createBackup();
TFM_PermbanList.load();
dumplist(sender);
}
else
@ -44,24 +46,24 @@ public class Command_permban extends TFM_Command
private void dumplist(CommandSender sender)
{
if (TotalFreedomMod.permbanned_players.isEmpty())
if (TFM_PermbanList.getPermbannedPlayers().isEmpty())
{
playerMsg(sender, "No permanently banned player names.");
}
else
{
playerMsg(sender, TotalFreedomMod.permbanned_players.size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_players, ", "));
playerMsg(sender, TFM_PermbanList.getPermbannedPlayers().size() + " permanently banned players:");
playerMsg(sender, StringUtils.join(TFM_PermbanList.getPermbannedPlayers(), ", "));
}
if (TotalFreedomMod.permbanned_ips.isEmpty())
if (TFM_PermbanList.getPermbannedIps().isEmpty())
{
playerMsg(sender, "No permanently banned IPs.");
}
else
{
playerMsg(sender, TotalFreedomMod.permbanned_ips.size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TotalFreedomMod.permbanned_ips, ", "));
playerMsg(sender, TFM_PermbanList.getPermbannedIps().size() + " permanently banned IPs:");
playerMsg(sender, StringUtils.join(TFM_PermbanList.getPermbannedIps(), ", "));
}
}
}

View File

@ -0,0 +1,28 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable tamed pet protection.", usage = "/<command> <on | off>")
public class Command_petprotect extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(
sender.getName(),
"Tamed pet protection is now " + (TFM_ConfigEntry.PET_PROTECT_ENABLED.setBoolean(!TFM_Util.isStopCommand(args[0])) ? "enabled" : "disabled") + ".",
false);
return true;
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -58,20 +58,20 @@ public class Command_plugincontrol extends TFM_Command
else if (commandMode == CommandMode.RELOAD)
{
playerMsg("Disabling all plugins.");
for (Plugin p : pluginManager.getPlugins())
for (Plugin targetPlugin : pluginManager.getPlugins())
{
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
if (!targetPlugin.getName().toLowerCase().startsWith("totalfreedommod"))
{
pluginManager.disablePlugin(p);
pluginManager.disablePlugin(targetPlugin);
}
}
playerMsg("Enabling all plugins.");
for (Plugin p : pluginManager.getPlugins())
for (Plugin targetPlugin : pluginManager.getPlugins())
{
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
if (!targetPlugin.getName().toLowerCase().startsWith("totalfreedommod"))
{
pluginManager.enablePlugin(p);
pluginManager.enablePlugin(targetPlugin);
}
}
}
@ -81,11 +81,11 @@ public class Command_plugincontrol extends TFM_Command
Plugin targetPlugin = null;
for (Plugin p : pluginManager.getPlugins())
for (Plugin serverPlugin : pluginManager.getPlugins())
{
if (searchPluginName.equalsIgnoreCase(p.getName().toLowerCase().trim()))
if (searchPluginName.equalsIgnoreCase(serverPlugin.getName().toLowerCase().trim()))
{
targetPlugin = p;
targetPlugin = serverPlugin;
break;
}
}

View File

@ -2,10 +2,10 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -16,7 +16,7 @@ import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(
description = "Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).",
usage = "/<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>")
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>")
public class Command_potion extends TFM_Command
{
@Override
@ -38,7 +38,7 @@ public class Command_potion extends TFM_Command
}
else if (args[0].equalsIgnoreCase("clearall"))
{
if (!(TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole))
if (!(TFM_AdminList.isSuperAdmin(sender) || senderIsConsole))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -62,7 +62,7 @@ public class Command_potion extends TFM_Command
{
target = getPlayer(args[1]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
@ -71,7 +71,7 @@ public class Command_potion extends TFM_Command
if (!target.equals(sender_p))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg("Only superadmins can clear potion effects from other players.");
return true;
@ -107,7 +107,7 @@ public class Command_potion extends TFM_Command
{
target = getPlayer(args[4]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
@ -116,7 +116,7 @@ public class Command_potion extends TFM_Command
if (!target.equals(sender_p))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
sender.sendMessage("Only superadmins can apply potion effects to other players.");
return true;

View File

@ -1,11 +1,11 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(
description = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
usage = "/<command> <on | off>")
@ -21,12 +21,12 @@ public class Command_prelog extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.preprocessLogEnabled = true;
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(true);
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
}
else
{
TotalFreedomMod.preprocessLogEnabled = false;
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(false);
playerMsg("Command preprocess logging is now disabled.");
}

View File

@ -0,0 +1,71 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
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.BOTH)
@CommandParameters(description = "Validates if a given account is premium.", usage = "/<command> <player>", aliases = "prem")
public class Command_premium extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
String name;
try
{
name = getPlayer(args[0]).getName();
}
catch (PlayerNotFoundException ex)
{
name = args[0];
}
final String playername = name;
new BukkitRunnable()
{
@Override
public void run()
{
try
{
final URL getUrl = new URL("https://minecraft.net/haspaid.jsp?user=" + playername);
final URLConnection urlConnection = getUrl.openConnection();
// Read the response
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
final String message = ("false".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
in.close();
new BukkitRunnable()
{
@Override
public void run()
{
playerMsg("Player " + playername + " is premium: " + message);
}
}.runTask(plugin);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
playerMsg("There was an error querying the mojang server.", ChatColor.RED);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -1,8 +1,9 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -16,7 +17,7 @@ public class Command_protectarea extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!TotalFreedomMod.protectedAreasEnabled)
if (!TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{
playerMsg("Protected areas are currently disabled in the TotalFreedomMod configuration.");
return true;
@ -43,7 +44,7 @@ public class Command_protectarea extends TFM_Command
}
else if (args.length == 2)
{
if (args[0].equalsIgnoreCase("remove"))
if (TFM_Util.isRemoveCommand(args[0]))
{
TFM_ProtectedArea.removeProtectedArea(args[1]);

View File

@ -1,8 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Bridge.TFM_DisguiseCraftBridge;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
@ -11,16 +16,77 @@ public class Command_purgeall extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
server.dispatchCommand(sender, "rd");
server.dispatchCommand(sender, "potion clearall");
server.dispatchCommand(sender, "uall");
server.dispatchCommand(sender, "mute purge");
server.dispatchCommand(sender, "fr purge");
server.dispatchCommand(sender, "mp");
server.dispatchCommand(sender, "blockcmd purge");
server.dispatchCommand(sender, "halt purge");
//If I'm missing any, lemme know. Or just add it yourself.
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
// Purge entities
TFM_Util.TFM_EntityWiper.wipeEntities(true, true);
// Undisguise all players
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
for (Player player : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
// Unmute all players
if (playerdata.isMuted())
{
playerdata.setMuted(false);
}
// Unblock all commands
if (playerdata.allCommandsBlocked())
{
playerdata.setCommandsBlocked(false);
}
// Unhalt all players
if (playerdata.isHalted())
{
playerdata.setHalted(false);
}
// Stop orbiting
if (playerdata.isOrbiting())
{
playerdata.stopOrbiting();
}
// Unfreeze
if (playerdata.isFrozen())
{
playerdata.setFrozen(false);
}
// Purge potion effects
for (PotionEffect potion_effect : player.getActivePotionEffects())
{
player.removePotionEffect(potion_effect.getType());
}
// Uncage
if (playerdata.isCaged())
{
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
}
}
// Clear auto-unmute and auto-unfreeze tasks
if (TotalFreedomMod.mutePurgeTask != null)
{
TotalFreedomMod.mutePurgeTask.cancel();
}
TotalFreedomMod.allPlayersFrozen = false;
if (TotalFreedomMod.freezePurgeTask != null)
{
TotalFreedomMod.freezePurgeTask.cancel();
}
// Remove all mobs
Command_mp.purgeMobs();
return true;
}

View File

@ -26,20 +26,20 @@ public class Command_qdeop extends TFM_Command
boolean matched_player = false;
String target_name = args[0].toLowerCase();
String targetName = args[0].toLowerCase();
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (p.getName().toLowerCase().indexOf(target_name) != -1 || p.getDisplayName().toLowerCase().indexOf(target_name) != -1)
if (player.getName().toLowerCase().indexOf(targetName) != -1 || player.getDisplayName().toLowerCase().indexOf(targetName) != -1)
{
matched_player = true;
if (!silent)
{
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);
}
p.setOp(false);
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
player.setOp(false);
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
}
}

View File

@ -26,20 +26,20 @@ public class Command_qop extends TFM_Command
boolean matched_player = false;
String target_name = args[0].toLowerCase();
String targetName = args[0].toLowerCase();
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
if (p.getName().toLowerCase().indexOf(target_name) != -1 || p.getDisplayName().toLowerCase().indexOf(target_name) != -1)
if (player.getName().toLowerCase().indexOf(targetName) != -1 || player.getDisplayName().toLowerCase().indexOf(targetName) != -1)
{
matched_player = true;
if (!silent)
{
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
}
p.setOp(true);
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
player.setOp(true);
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
}
}

View File

@ -2,8 +2,8 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_RadarData;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
@ -21,13 +21,13 @@ public class Command_radar extends TFM_Command
List<TFM_RadarData> radar_data = new ArrayList<TFM_RadarData>();
for (Player p : sender_pos.getWorld().getPlayers())
for (Player player : sender_pos.getWorld().getPlayers())
{
if (!p.equals(sender_p))
if (!player.equals(sender_p))
{
try
{
radar_data.add(new TFM_RadarData(p, sender_pos.distance(p.getLocation()), p.getLocation()));
radar_data.add(new TFM_RadarData(player, sender_pos.distance(player.getLocation()), player.getLocation()));
}
catch (IllegalArgumentException ex)
{
@ -71,4 +71,39 @@ public class Command_radar extends TFM_Command
return true;
}
private class TFM_RadarData implements Comparator<TFM_RadarData>
{
public Player player;
public double distance;
public Location location;
public TFM_RadarData(Player player, double distance, Location location)
{
this.player = player;
this.distance = distance;
this.location = location;
}
public TFM_RadarData()
{
}
@Override
public int compare(TFM_RadarData t1, TFM_RadarData t2)
{
if (t1.distance > t2.distance)
{
return 1;
}
else if (t1.distance < t2.distance)
{
return -1;
}
else
{
return 0;
}
}
}
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -15,9 +15,9 @@ public class Command_rank extends TFM_Command
{
if (senderIsConsole && args.length < 1)
{
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
playerMsg(p.getName() + " is " + TFM_Util.getRank(p));
playerMsg(player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage());
}
return true;
}
@ -29,22 +29,22 @@ public class Command_rank extends TFM_Command
if (args.length == 0)
{
playerMsg(sender.getName() + " is " + TFM_Util.getRank(sender), ChatColor.AQUA);
playerMsg(sender.getName() + " is " + TFM_PlayerRank.fromSender(sender).getLoginMessage(), ChatColor.AQUA);
return true;
}
Player p;
Player player;
try
{
p = getPlayer(args[0]);
player = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
playerMsg(p.getName() + " is " + TFM_Util.getRank(p), ChatColor.AQUA);
playerMsg(player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage(), ChatColor.AQUA);
return true;
}

View File

@ -1,13 +1,12 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import net.minecraft.util.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, block_host_console = true)
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
public class Command_rawsay extends TFM_Command
{
@ -16,7 +15,7 @@ public class Command_rawsay extends TFM_Command
{
if (args.length > 0)
{
TFM_Util.bcastMsg(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, " ")));
TFM_Util.bcastMsg(TFM_Util.colorize(StringUtils.join(args, " ")));
}
return true;

View File

@ -13,7 +13,7 @@ public class Command_rd extends TFM_Command
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Removing all server entities.", true);
playerMsg((TFM_Util.wipeEntities(true, true)) + " enties removed.");
playerMsg((TFM_Util.TFM_EntityWiper.wipeEntities(true, true)) + " enties removed.");
return true;
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = false)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = false)
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
public class Command_ro extends TFM_Command
{
@ -51,14 +51,14 @@ public class Command_ro extends TFM_Command
}
}
Player target_player = null;
Player targetPlayer = null;
if (args.length == 3)
{
try
{
target_player = getPlayer(args[2]);
targetPlayer = getPlayer(args[2]);
}
catch (CantFindPlayerException ex)
catch (PlayerNotFoundException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
@ -67,18 +67,18 @@ public class Command_ro extends TFM_Command
int affected = 0;
if (target_player == null)
if (targetPlayer == null)
{
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of all players. Brace for lag...", senderIsConsole);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
affected += TFM_Util.replaceBlocks(p.getLocation(), from_material, Material.AIR, radius);
affected += TFM_Util.replaceBlocks(player.getLocation(), from_material, Material.AIR, radius);
}
}
else
{
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of " + target_player.getName() + ".", senderIsConsole);
affected += TFM_Util.replaceBlocks(target_player.getLocation(), from_material, Material.AIR, radius);
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of " + targetPlayer.getName() + ".", senderIsConsole);
affected += TFM_Util.replaceBlocks(targetPlayer.getLocation(), from_material, Material.AIR, radius);
}
TFM_Util.adminAction(sender.getName(), "Remove complete. " + affected + " blocks removed.", senderIsConsole);

View File

@ -1,88 +1,107 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
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, block_host_console = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends TFM_Command {
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 2)
if (args.length == 1)
{
return false;
}
if (args.length == 1 && args[0].equalsIgnoreCase("purgeall"))
{
TFM_Util.adminAction(sender.getName(), "Puring all rollback data", false);
playerMsg("Purged entries for " + TFM_RollbackManager.purgeEntries() + " players.");
return true;
}
if (args.length == 2 && args[0].equalsIgnoreCase("purge"))
{
OfflinePlayer p;
try
if ("purgeall".equalsIgnoreCase(args[0]))
{
p = getPlayer(args[1]);
TFM_Util.adminAction(sender.getName(), "Purging all rollback history", false);
playerMsg("Purged all rollback history for " + TFM_RollbackManager.purgeEntries() + " players.");
}
catch (CantFindPlayerException ex)
else
{
p = server.getOfflinePlayer(args[1]);
if (!p.hasPlayedBefore())
String playerName = getPlayerName(args[0]);
if (!TFM_RollbackManager.canRollback(playerName))
{
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
playerMsg("That player has no entries stored.");
return true;
}
}
if (!TFM_RollbackManager.canRollback(p.getName()))
{
playerMsg("No rollback data found for that player", ChatColor.RED);
} else {
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries.");
return true;
if (TFM_RollbackManager.canUndoRollback(playerName))
{
playerMsg("That player has just been rolled back.");
}
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 20 seconds to reverse the rollback.");
}
}
else if (args.length == 2)
{
if ("purge".equalsIgnoreCase(args[0]))
{
String playerName = getPlayerName(args[1]);
if (args.length != 1)
if (!TFM_RollbackManager.canRollback(playerName))
{
playerMsg("That player has no entries stored.");
return true;
}
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
}
else if ("undo".equalsIgnoreCase(args[0]))
{
String playerName = getPlayerName(args[1]);
if (!TFM_RollbackManager.canUndoRollback(playerName))
{
playerMsg("That player hasn't been rolled back recently.");
return true;
}
TFM_Util.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
playerMsg("Reverted " + TFM_RollbackManager.undoRollback(playerName) + " edits for " + playerName + ".");
}
else
{
return false;
}
}
else
{
return false;
}
OfflinePlayer p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
p = server.getOfflinePlayer(args[0]);
if (!p.hasPlayedBefore())
{
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
return true;
}
}
if (!TFM_RollbackManager.canRollback(p.getName()))
{
playerMsg("Player has no rollback data set.", ChatColor.RED);
return true;
}
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + p.getName(), false);
playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks");
return true;
}
private String getPlayerName(String playerNameInput)
{
String playerName = null;
try
{
Player player = getPlayer(playerNameInput);
if (player != null)
{
playerName = player.getName();
}
}
catch (PlayerNotFoundException ex)
{
}
if (playerName == null)
{
playerName = TFM_PlayerList.getInstance().getEntry(playerNameInput).getLastJoinName();
}
return playerName;
}
}

View File

@ -1,12 +1,15 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -18,186 +21,138 @@ public class Command_saconfig extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 1)
{
if (args[0].equals("list"))
{
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "), ChatColor.GOLD);
}
else
{
if (!senderIsConsole)
{
playerMsg("This command may only be used from the console.");
return true;
}
if (args[0].equals("clean"))
{
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list.", true);
TFM_SuperadminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "), ChatColor.YELLOW);
}
else
{
return false;
}
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperNames(), ", "), ChatColor.GOLD);
return true;
}
return true;
}
else if (args.length == 2)
{
if (args[0].equalsIgnoreCase("info"))
if (args[0].equals("clean"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
if (!TFM_AdminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Superadmin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
if (superadmin == null)
{
try
{
superadmin = TFM_SuperadminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
}
catch (CantFindPlayerException ex)
{
}
}
if (superadmin == null)
{
playerMsg("Superadmin not found: " + args[1]);
}
else
{
playerMsg(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', superadmin.toString())));
}
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
TFM_AdminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperUUIDs(), ", "), ChatColor.YELLOW);
return true;
}
if (!senderIsConsole)
{
playerMsg("This command may only be used from the console.");
return true;
}
if (args[0].equalsIgnoreCase("add"))
{
Player p = null;
String admin_name = null;
try
{
p = getPlayer(args[1]);
}
catch (CantFindPlayerException ex)
{
TFM_Superadmin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
if (superadmin != null)
{
admin_name = superadmin.getName();
}
else
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
}
if (p != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the superadmin list.", true);
TFM_SuperadminList.addSuperadmin(p);
}
else if (admin_name != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + admin_name + " to the superadmin list.", true);
TFM_SuperadminList.addSuperadmin(admin_name);
}
}
else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("del") || args[0].equalsIgnoreCase("remove"))
{
if (!TFM_SuperadminList.isSeniorAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
String target_name = args[1];
try
{
target_name = getPlayer(target_name).getName();
}
catch (CantFindPlayerException ex)
{
}
if (!TFM_SuperadminList.getSuperadminNames().contains(target_name.toLowerCase()))
{
playerMsg("Superadmin not found: " + target_name);
return true;
}
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(target_name);
if (!TotalFreedomMod.twitterbotEnabled)
{
return true;
}
// Twitterbot
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
String reply = twitterbot.delTwitter(target_name);
if ("ok".equals(reply))
{
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from TwitterBot", true);
}
else if ("disabled".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "TwitterBot has been temporarily disabled,, please wait until it get re-enabled", ChatColor.RED);
}
else if ("failed".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem querying the database, please let a developer know.", ChatColor.RED);
}
else if ("false".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "There was a problem with the database, please let a developer know.", ChatColor.RED);
}
else if ("cannotauth".equals(reply))
{
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
TFM_Util.playerMsg(sender, "The database password is incorrect, please let a developer know.", ChatColor.RED);
}
else if ("notfound".equals(reply))
{
TFM_Util.playerMsg(sender, target_name + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
}
}
else
{
return false;
}
return true;
}
else
{
return false;
}
if (args[0].equalsIgnoreCase("info"))
{
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Admin superadmin = TFM_AdminList.getEntry(args[1].toLowerCase());
if (superadmin == null)
{
try
{
superadmin = TFM_AdminList.getEntry(getPlayer(args[1]).getName().toLowerCase());
}
catch (PlayerNotFoundException ex)
{
}
}
if (superadmin == null)
{
playerMsg("Superadmin not found: " + args[1]);
}
else
{
playerMsg(superadmin.toString());
}
return true;
}
if (!senderIsConsole)
{
playerMsg("This command may only be used from the console.");
return true;
}
if (args[0].equalsIgnoreCase("add"))
{
OfflinePlayer player;
try
{
player = getPlayer(args[1]);
}
catch (PlayerNotFoundException ex)
{
final TFM_Admin superadmin = TFM_AdminList.getEntry(args[1]);
if (superadmin == null)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
player = Bukkit.getOfflinePlayer(superadmin.getLastLoginName());
}
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list", true);
TFM_AdminList.addSuperadmin(player);
return true;
}
if (TFM_Util.isRemoveCommand(args[0]))
{
if (!TFM_AdminList.isSeniorAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
String targetName = args[1];
try
{
targetName = getPlayer(targetName).getName();
}
catch (PlayerNotFoundException ex)
{
}
if (!TFM_AdminList.getLowerSuperNames().contains(targetName.toLowerCase()))
{
playerMsg("Superadmin not found: " + targetName);
return true;
}
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
TFM_AdminList.removeSuperadmin(Bukkit.getOfflinePlayer(targetName));
// Twitterbot
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
{
TFM_TwitterHandler.getInstance().delTwitterVerbose(targetName, sender);
}
return true;
}
return false;
}
}

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -27,9 +27,9 @@ public class Command_say extends TFM_Command
{
TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY);
for (Player p : server.getOnlinePlayers())
for (Player player : server.getOnlinePlayers())
{
p.kickPlayer("Server is going offline, come back in a few minutes.");
player.kickPlayer("Server is going offline, come back in about 20 seconds.");
}
server.shutdown();

View File

@ -0,0 +1,28 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker.ServiceStatus;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows the status of all Mojang services", usage = "/<command>")
public class Command_services extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
for (ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses())
{
playerMsg(service.getFormattedStatus());
}
playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getVersion(), ChatColor.DARK_PURPLE);
playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().getLastCheck(), ChatColor.DARK_PURPLE);
return true;
}
}

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