Compare commits

...

134 Commits
v2.14 ... v2.22

Author SHA1 Message Date
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
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
44fb26b27f Updated to Bukkit 1.6 2013-07-02 14:05:29 +02:00
fab341608b Improved mojang service checker, now using xpaw.ru, migrated to /minecraft 2013-07-01 10:04:43 +02:00
4f6a0ca5d3 Blocked TNT Minecarts from being placed 2013-06-23 15:17:12 +02:00
f3684cc2ce Whoops! 2013-06-22 20:12:58 +02:00
772b7e43f7 Added license 2013-06-22 19:59:52 +02:00
c308c9a268 Oopsies. 2013-06-18 19:52:41 +03:00
fcb424a793 Minor changes to CONTRIBUTING.md 2013-06-18 16:34:35 +02:00
be1acb4e03 Disaster839 is without a capital, who knew? 2013-06-11 22:48:38 +03:00
386989fa69 Added contribution info 2013-06-11 17:59:04 +02:00
4c7cd9cb23 Merge pull request #40 from WickedGamingUK/patch-6
Changed madgeek1540 to madgeek1450
2013-06-10 06:46:51 -07:00
1f87c05547 Changed madgeek1540 to madgeek1450
Just noticed a little typing error in the developer's StringList, so I decided to fix it :)
2013-06-10 11:51:55 +02:00
a2a6e39db9 Minor changes, added /creative -a, formatting fixes, updated version number 2013-06-10 08:24:53 +02:00
c6ca262472 Merge pull request #39 from WickedGamingUK/patch-5
Fixed survival -a
2013-06-09 13:29:41 -07:00
c96bdea066 Fixed survival -a
I was a numpty and forgot to change the gamemode it changed people to.
2013-06-09 22:26:06 +02:00
893c7c2991 Merge pull request #38 from WickedGamingUK/patch-4
Added survival -a
2013-06-09 12:59:56 -07:00
201d27e070 Added survival -a (Allman Style) 2013-06-09 21:52:13 +02:00
36ceb7007a Added Disaster839 as a developer. 2013-06-09 14:11:22 +03:00
6519ead121 Added Acidic, Wild and Hex to the developer list 2013-06-03 23:08:31 +02:00
95805dd9c1 Merge pull request #30 from Wild1145/patch-7
Added blocks to /wildcard
2013-06-02 13:03:27 -07:00
6768854eda Added new blocked wildcards
This is to stop people from being able to abuse admin or going rogue as easily
2013-06-02 18:17:33 +02:00
83176ba0b9 Merge pull request #26 from Wilee999/pull2
Added /rb (/rollback alias)
2013-06-01 14:39:30 -07:00
4a2b58bf97 Merge pull request #28 from Wilee999/pull4
/nuke will now tempban you.
2013-06-01 14:38:12 -07:00
79fc01eae7 /nuke will now tempban you. 2013-05-31 19:54:36 -06:00
d1d220f618 Added /rb (/rollback alias) 2013-05-30 16:38:27 -06:00
f6943b9754 This /stop message works better. 2013-05-29 20:57:01 -06:00
2977167bd3 Merge pull request #24 from Wilee999/master
Fixed /blockcmd in /purgeall
2013-05-28 23:03:29 -07:00
ad9e901aa0 Fixed /blockcmd in /purgeall 2013-05-27 19:57:53 -07:00
4f6e4e2e87 Merge pull request #23 from Wild1145/patch-6
Blocked /clearhistory
2013-05-26 11:32:53 -07:00
d8ae364300 Patched exploit found in commands
This will fix the issue with world edit history erasing, please push and compile ASAP as Mark would like this patched :)
2013-05-26 14:18:16 +02:00
7f9661ec11 Merge pull request #14 from Wild1145/patch-1
Blocked /rl
2013-05-22 07:40:51 -07:00
8d59ba59f4 Prepend Rollback entries, this ensures the last entries get restored first, instead of last 2013-05-20 15:40:04 +02:00
6a7e866a53 Merge pull request #19 from Wild1145/patch-5
Fixed /gtfo
2013-05-19 14:30:56 -07:00
63508addf4 /Gtfo bug fix 2013-05-19 23:28:57 +02:00
b8ab56bed5 Incremented version number 2013-05-17 23:00:27 +02:00
4853cc439b Added /rollback 2013-05-17 22:58:03 +02:00
3b7a8d4d88 Incremented version number 2013-05-17 20:05:52 +02:00
d016e1ff08 Fixed stuff with Wilee's and Wild's changes 2013-05-17 20:03:16 +02:00
ab9650dc54 Merge pull request #13 from Wilee999/master
xxWileexx: Add /purgeall, minor changes.
2013-05-16 11:54:12 -07:00
d3139dd39f hopefully this works 2013-05-16 11:49:41 -07:00
ba834b6b92 g 2013-05-16 11:45:21 -07:00
ccd4237491 Merge pull request #15 from Wild1145/patch-3
Added /setl to set the amount of world edit blocks that can be used
2013-05-16 11:35:43 -07:00
ff51bb1980 Merge pull request #16 from Wild1145/patch-4
Added warning in MOTD if in adminmode=true
2013-05-16 11:31:52 -07:00
d2457adf68 Create Command_cmdlist.java 2013-05-16 12:31:22 -06:00
aea65815a8 removed /denick from /purgeall 2013-05-16 12:29:06 -06:00
6abd2491f1 Removed /denick from /spurgeall 2013-05-16 12:28:28 -06:00
31b5c99007 Added broadcast to /spurgeall 2013-05-16 12:19:47 -06:00
4aebf33006 Added a broadcast to /purgeall 2013-05-16 12:18:39 -06:00
e29a820398 Added /spurgeall 2013-05-16 00:57:26 -07:00
fabbc78d22 Replaced /clearall with /purgeall, this cleans more! 2013-05-15 23:59:08 -07:00
a8b4f1d950 Removed /cmdlist (useless) 2013-05-15 20:56:18 -07:00
b7c9f4e02d Added warning in MOTD if in adminmode=true
I think this would save people connecting and spamming logs if in adminmode!
2013-05-15 23:12:46 +02:00
ba9289e1a3 Added /setl to set the amount of world edit blocks that can be used 2013-05-15 23:05:20 +02:00
47dec49381 added /rl as a blocked command
Just because it buggs me ALOT!
2013-05-15 21:13:36 +02:00
b1202c7871 hopefully this fixed /invis 2013-05-15 12:03:45 -06:00
e82e88f48f Added /invis, incremented version number to reflect latest changes 2013-05-15 15:23:35 +02:00
36747cb986 Added /tban, colors for /rawsay, minor changes 2013-05-15 14:56:23 +02:00
76 changed files with 2924 additions and 829 deletions

52
CONTRIBUTING.md Normal file
View File

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

11
LICENSE.md Normal file
View File

@ -0,0 +1,11 @@
# 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.
* 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 +0,0 @@
TotalFreedomMod
===============
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
Information about the TotalFreedom server can be found at http://totalfreedom.me/

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# TotalFreedomMod #
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
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 +1,6 @@
#Thu, 09 May 2013 15:32:18 +0200
#Fri, 09 Aug 2013 15:38:23 +0200
program.VERSION=2.22
program.BUILDNUM=378
program.BUILDDATE=08/09/2013 03\:38 PM
program.VERSION=2.14
program.BUILDNUM=182
program.BUILDDATE=05/09/2013 03\:32 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Thu May 09 15:32:18 CEST 2013
build.number=183
#Fri Aug 09 15:38:23 CEST 2013
build.number=379

View File

@ -32,7 +32,9 @@ jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${libs.CraftBukkit.classpath}
${libs.CraftBukkit.classpath}:\
${libs.WorldEdit.classpath}:\
${libs.DisguiseCraft.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
javac.deprecation=false

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v2.13 Configuration
# TotalFreedomMod v2.22 Configuration
# by Madgeek1450 and DarthSalamon
# Block placement prevention:
@ -8,11 +8,70 @@ allow_lava_damage: false
allow_lava_place: false
allow_water_place: false
allow_fluid_spread: false
allow_tnt_minecarts: false
# Explosion management:
allow_explosions: false
explosiveRadius: 4.0
# Blocked commands:
#
# How blocked commands work:
# All sections described below are delimited by colon-characters.
# Make sure that you block a command by it's main command name, not an alias
# -as all aliases are blocked by default. Commands are case-insensitive ofcourse.
# You can block specific subcommands aswell. eg: /mail sendall
#
# * The first section is a letter which indicates which rank may use this command
# Valid ranks:
# n - Nobody (Completely disabled)
# c - Senior Admins (Console)
# t - Telnet Admins (Console)
# s - SuperAdmins
# o - Ops (Non-Ops won't be able to use it)
#
# * The second section is a letter which indicates what to do when a player executes that command.
# Valid actions:
# b - Block the command
# a - Block the command and auto-eject that player (for ops and below)
# u - Block the command and Return an "Unknown command" message (Used to hide commands)
#
# * The third section is the command to be blocked, prefixed with a slash
#
# * The fourth section is the message to send to the player when executing that command.
# This should be ommited if unwanted. ChatColors are supported with the &-key. By default
# -the starting ChatColor is set to gray. You can use the default 'That command is blocked.' message
# by using a single underscore.
#
# Examples:
# - 'n:b:/mail sendall:&4You can't send mails to everyone!'
# - 's:a:/stop'
# - 'n:b:/ban:_'
#
blocked_commands:
# Disabled commands
- n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.
- n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.
- n:b:/gamemode:Use /creative and /survival to set your gamemode.
- n:b:/gamerule:_
- n:b:/ban:_
- n:b:/pardon:_
- n:b:/toggledownfall:_
- n:b:/ban-ip:_
- n:b:/pardon-ip:_
# Superadmin commands
- s:b:/kick:_
- s:b:/socialspy:_
- s:b:/kill:_
- s:b:/clearhistory:_
- s:a:/stop:_
- s:a:/reload:_
- s:a:/nuke:_
- s:a:/save-all:_
- s:a:/save-on:_
- s:a:/save-off:_
# Automatically wipe dropped objects:
auto_wipe: true
@ -67,5 +126,12 @@ host_sender_names:
# TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false
twitterbot_url: 'http://tftwitter.darthcraft.net/'
twitterbot_secret: ''
twitterbot_url:
twitterbot_secret:
# Pet Protect - Prevent tamed pets from being killed.
pet_protect_enabled: true
# Logs Registration
logs_register_password:
logs_register_url:

View File

@ -15,7 +15,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.StevenLawson.TotalFreedomMod;
import java.util.Random;
@ -26,6 +25,7 @@ import org.bukkit.generator.BlockPopulator;
public class CleanroomBlockPopulator extends BlockPopulator
{
byte[] layerDataValues;
protected CleanroomBlockPopulator(byte[] layerDataValues)
{
this.layerDataValues = layerDataValues;
@ -41,7 +41,10 @@ public class CleanroomBlockPopulator extends BlockPopulator
for (int y = 0; y < layerDataValues.length; y++)
{
byte dataValue = layerDataValues[y];
if (dataValue == 0) continue;
if (dataValue == 0)
{
continue;
}
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)

View File

@ -15,7 +15,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.StevenLawson.TotalFreedomMod;
import static java.lang.System.arraycopy;
@ -55,7 +54,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
if ((id.length() > 0) && (id.charAt(0) == '.')) // Is the first character a '.'? If so, skip bedrock generation.
{
id = id.substring(1); // Skip bedrock then and remove the .
} else // Guess not, bedrock at layer0 it is then.
}
else // Guess not, bedrock at layer0 it is then.
{
layer[y++] = (short) Material.BEDROCK.getId();
}
@ -64,7 +64,10 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
String tokens[] = id.split("[,]");
if ((tokens.length % 2) != 0) throw new Exception();
if ((tokens.length % 2) != 0)
{
throw new Exception();
}
for (int i = 0; i < tokens.length; i += 2)
{
@ -83,7 +86,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
// Lets try to read the data value
dataValue = Byte.parseByte(materialTokens[1]);
} catch (Exception e)
}
catch (Exception e)
{
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
dataValue = 0;
@ -96,7 +100,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
// Mabe it's an integer?
mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
} catch (Exception e)
}
catch (Exception e)
{
// Well, I guess it wasn't an integer after all... Awkward...
}
@ -153,7 +158,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
layerDataValues = newLayerDataValues;
}
} catch (Exception e)
}
catch (Exception e)
{
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
e.printStackTrace();
@ -162,7 +168,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
}
} else
}
else
{
layerDataValues = null;
layer = new short[65];
@ -201,7 +208,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
if (layerDataValues != null)
{
return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues));
} else
}
else
{
// This is the default, but just in case default populators change to stock minecraft populators by default...
return new ArrayList<BlockPopulator>();

View File

@ -14,6 +14,11 @@ 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;

View File

@ -3,6 +3,7 @@ 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;
@ -31,6 +32,10 @@ public class Command_cake extends TFM_Command
{
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
p.awardAchievement(Achievement.MINE_WOOD);
p.awardAchievement(Achievement.BUILD_WORKBENCH);
p.awardAchievement(Achievement.BUILD_HOE);
p.awardAchievement(Achievement.BAKE_CAKE);
}
TFM_Util.bcastMsg(output.toString());

View File

@ -1,20 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Removes all entities, nicks and disguises.", usage = "/<command>")
public class Command_clearall 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");
return true;
}
}

View File

@ -1,6 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -29,8 +31,29 @@ public class Command_creative extends TFM_Command
}
else
{
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player player : server.getOnlinePlayers())
{
player.setGameMode(GameMode.CREATIVE);
}
TFM_Util.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
return true;
}
if (!(senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender)))
{
playerMsg("Only superadmins can change other user's gamemode.");
return true;
}
try
{
p = getPlayer(args[0]);
@ -40,12 +63,7 @@ public class Command_creative extends TFM_Command
sender.sendMessage(ex.getMessage());
return true;
}
}
else
{
playerMsg("Only superadmins can change other user's gamemode.");
return true;
}
}
playerMsg("Setting " + p.getName() + " to game mode 'Creative'.");

View File

@ -6,6 +6,7 @@ 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)
@CommandParameters(description = "Make some noise.", usage = "/<command>")
@ -23,14 +24,14 @@ public class Command_deafen extends TFM_Command
{
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);
}
}, 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 org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.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

@ -8,6 +8,7 @@ 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>")
@ -69,7 +70,7 @@ public class Command_doom extends TFM_Command
// generate explosion
p.getWorld().createExplosion(p.getLocation(), 4F);
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
@ -78,11 +79,11 @@ public class Command_doom extends TFM_Command
p.getWorld().strikeLightning(p.getLocation());
// kill (if not done already)
p.setHealth(0);
p.setHealth(0.0);
}
}, 40L); // 2 seconds
}.runTaskLater(plugin, 20L * 2L);
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
@ -96,7 +97,7 @@ public class Command_doom extends TFM_Command
// kick player
p.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.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 = "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(),
((TotalFreedomMod.autoEntityWipe = !args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
+ " automatic entity wiping.", false);
return true;
}
}

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
@ -52,12 +53,26 @@ public class Command_enchant extends TFM_Command
else if (args[0].equalsIgnoreCase("addall"))
{
for (Enchantment ench : Enchantment.values())
{
/*
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
{
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() + ".");
}
}
playerMsg("Added all possible enchantments for this item.");
}

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -17,16 +18,9 @@ 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.");
}
playerMsg("Fire spread is now " + ((TotalFreedomMod.allowFireSpread = !args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TotalFreedomMod.allowFireSpread);
return true;
}

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -8,6 +7,7 @@ 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 = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
@ -24,33 +24,30 @@ 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.");
}
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,6 +57,10 @@ public class Command_fr extends TFM_Command
if (args[0].toLowerCase().equals("purge"))
{
TotalFreedomMod.allPlayersFrozen = false;
if (TotalFreedomMod.freezePurgeTask != null)
{
TotalFreedomMod.freezePurgeTask.cancel();
}
for (Player p : server.getOnlinePlayers())
{

View File

@ -1,7 +1,11 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -16,7 +20,7 @@ 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;
}
@ -32,19 +36,19 @@ public class Command_gtfo extends TFM_Command
return true;
}
String ban_reason = null;
if (args.length >= 2)
{
ban_reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
}
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Op Player
p.setOp(true);
// Undo WorldEdits:
server.dispatchCommand(p, "/undo 15");
TFM_WorldEditBridge.getInstance().undo(p, 15);
// rollback
server.dispatchCommand(sender, "rollback " + p.getName() + " all");
TFM_RollbackManager.rollback(p.getName());
// deop
p.setOp(false);
@ -74,13 +78,13 @@ public class Command_gtfo extends TFM_Command
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[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_ServerInterface.banIP(user_ip, ban_reason, null, null);
// ban username:
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
TFM_ServerInterface.banUsername(p.getName(), ban_reason, null, null);
// kick Player:
p.kickPlayer("GTFO");
p.kickPlayer(ChatColor.RED + "GTFO" + (ban_reason != null ? ("\nReason: " + ChatColor.YELLOW + ban_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_SuperadminList;
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;
@ -29,7 +27,7 @@ public class Command_halt extends TFM_Command
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
setHalted(p, true);
TFM_PlayerData.getPlayerData(p).setHalted(true);
counter++;
}
}
@ -43,9 +41,10 @@ public class Command_halt extends TFM_Command
int counter = 0;
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (TFM_PlayerData.getPlayerData(p).isHalted())
{
setHalted(p, false);
playerdata.setHalted(false);
counter++;
}
}
@ -86,51 +85,21 @@ public class Command_halt extends TFM_Command
{
sender.sendMessage(ex.getMessage());
return true;
}
if (!TFM_PlayerData.getPlayerData(p).isHalted())
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (!playerdata.isHalted())
{
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
setHalted(p, true);
playerdata.setHalted(true);
return true;
}
else
{
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
setHalted(p, false);
playerdata.setHalted(false);
return true;
}
}
private static void setHalted(Player p, boolean is_halted)
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (is_halted)
{
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);
playerdata.setHalted(true);
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
}
else
{
p.setOp(true);
p.setGameMode(GameMode.CREATIVE);
playerdata.setFrozen(false);
playerdata.setMuted(false);
playerdata.setHalted(false);
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
}

View File

@ -3,11 +3,13 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.text.DecimalFormat;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_TickMeter;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.exception.ExceptionUtils;
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 = "View ticks-per-second", usage = "/<command>")
@ -17,37 +19,44 @@ public class Command_health extends TFM_Command
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Runnable task;
task = new Runnable() // async
new BukkitRunnable()
{
@Override
public void run()
{
try
{
TFM_TickMeter meter = new TFM_TickMeter(plugin);
final TFM_TickMeter meter = new TFM_TickMeter(plugin);
meter.startTicking();
Thread.sleep(1000); // per second
meter.stopTicking();
Runtime runtime = Runtime.getRuntime();
int mb = 1048576; // 1024 * 1024
final Runtime runtime = Runtime.getRuntime();
final int mb = 1048576; // 1024 * 1024
float usedMem = runtime.totalMemory() - runtime.freeMemory();
final float usedMem = runtime.totalMemory() - runtime.freeMemory();
new BukkitRunnable()
{
@Override
public void run() {
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem / runtime.totalMemory() * 100) + "%)");
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());
}
}.runTask(TotalFreedomMod.plugin);
}
catch (Exception iex)
{
TFM_Log.warning("Exception in TFM_TickMeter: Thread was interupted in sleeping process.");
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
}
}
};
new Thread(task, "TickMeter").start();
}.runTaskAsynchronously(TotalFreedomMod.plugin);
return true;
}
}

View File

@ -0,0 +1,67 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import 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
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("smite"))
{
smite = true;
}
else
{
return false;
}
}
List<String> players = new ArrayList<String>();
int smites = 0;
for (Player p : server.getOnlinePlayers())
{
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(p.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
{
Command_smite.smite(p);
smites++;
}
}
}
if (players.isEmpty())
{
TFM_Util.playerMsg(sender, "There are no invisible players");
return true;
}
if (smite)
{
TFM_Util.playerMsg(sender, "Smitten " + smites + " players");
}
else
{
TFM_Util.playerMsg(sender, "Invisble players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
}

View File

@ -72,10 +72,15 @@ public class Command_list extends TFM_Command
prefix = (ChatColor.GOLD + "[SA]");
}
if (p.getName().equalsIgnoreCase("madgeek1450") || p.getName().equalsIgnoreCase("darthsalamon"))
if (TFM_Util.DEVELOPERS.contains(p.getName()))
{
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
}
if (p.getName().equals("markbyron"))
{
prefix = (ChatColor.BLUE + "[Owner]");
}
}
else
{

View File

@ -1,12 +1,11 @@
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)
@ -113,27 +112,20 @@ public class Command_lockup extends TFM_Command
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())
{
p.openWorkbench(null, true);
Location l = p.getLocation().clone();
l.setPitch(random.nextFloat() * 360.0f);
l.setYaw(random.nextFloat() * 360.0f);
p.teleport(l);
p.openInventory(p.getInventory());
}
else
{
cancelLockup(playerdata);
}
}
}, 0L, 5L));
}.runTaskTimer(plugin, 0L, 5L));
}
}

View File

@ -0,0 +1,167 @@
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.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Register your connection with the TFM logviewer.", usage = "/<command> [off]")
public class Command_logs extends TFM_Command
{
@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)
{
if (TotalFreedomMod.logsRegisterURL == null || TotalFreedomMod.logsRegisterPassword == null)
{
return;
}
if (TotalFreedomMod.logsRegisterPassword.isEmpty() || TotalFreedomMod.logsRegisterURL.isEmpty())
{
return;
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
if (sender != null)
{
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
}
URL url = new URLBuilder(TotalFreedomMod.logsRegisterURL)
.addQueryParameter("mode", mode.toString())
.addQueryParameter("password", TotalFreedomMod.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_Superadmin superadmin)
{
for (String ip : superadmin.getIps())
{
updateLogsRegistration(null, superadmin.getName(), 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,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -74,6 +75,8 @@ public class Command_moblimiter extends TFM_Command
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
}
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TotalFreedomMod.mobLimiterEnabled);
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

@ -7,7 +7,7 @@ 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.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
public class Command_permban extends TFM_Command
{

View File

@ -0,0 +1,30 @@
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 = "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;
}
TotalFreedomMod.petProtectEnabled = !TFM_Util.isStopCommand(args[0]);
TFM_Util.adminAction(
sender.getName(),
"Tamed pet protection is now " + (TotalFreedomMod.petProtectEnabled ? "enabled" : "disabled") + ".",
false);
return true;
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH)
@CommandParameters(description = "Enable / disable plugins.", usage = "/<command> < <enable | disable> <pluginname> | list >")
@CommandParameters(description = "Enable / disable plugins.", usage = "/<command> < <enable | disable> <pluginname> | list >", aliases = "plc")
public class Command_plugincontrol extends TFM_Command
{
private enum CommandMode

View File

@ -0,0 +1,93 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.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>")
public class Command_purgeall 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(), "Purging all player data", true);
// Purge entities
TFM_Util.wipeEntities(true, true);
// Undisguise all players
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
// 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 : p.getActivePotionEffects())
{
p.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

@ -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;
@ -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

@ -2,12 +2,13 @@ package me.StevenLawson.TotalFreedomMod.Commands;
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.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandParameters(description = "Broadcasts the given message with no extra formatting.", usage = "/<command> <message>")
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
public class Command_rawsay extends TFM_Command
{
@Override
@ -15,7 +16,7 @@ public class Command_rawsay extends TFM_Command
{
if (args.length > 0)
{
TFM_Util.bcastMsg(StringUtils.join(args, " "));
TFM_Util.bcastMsg(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, " ")));
}
return true;

View File

@ -0,0 +1,74 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
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, 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
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("purgeall"))
{
TFM_Util.adminAction(sender.getName(), "Purging all rollback history.", false);
playerMsg("Purged all rollback history for " + TFM_RollbackManager.purgeEntries() + " players.");
}
else
{
String playerName = getPlayerName(args[0]);
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
}
}
else if (args.length == 2)
{
if (args[0].equalsIgnoreCase("purge"))
{
String playerName = getPlayerName(args[1]);
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
}
else
{
return false;
}
}
else
{
return false;
}
return true;
}
private String getPlayerName(String playerNameInput)
{
String playerName = null;
try
{
Player player = getPlayer(playerNameInput);
if (player != null)
{
playerName = player.getName();
}
}
catch (CantFindPlayerException ex)
{
}
if (playerName == null)
{
playerName = TFM_UserList.getInstance(plugin).searchByPartialName(playerNameInput);
}
return playerName;
}
}

View File

@ -0,0 +1,24 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to 500.", usage = "/<command>")
public class Command_setl 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(), "Setting everyone's Worldedit block modification limit to 500.", true);
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
for (final Player p : server.getOnlinePlayers())
{
web.setLimit(p, 500);
}
return true;
}
}

View File

@ -32,6 +32,13 @@ public class Command_smite extends TFM_Command
return true;
}
smite(p);
return true;
}
public static void smite(final Player p)
{
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
//Deop
@ -56,8 +63,6 @@ public class Command_smite extends TFM_Command
}
//Kill:
p.setHealth(0);
return true;
p.setHealth(0.0);
}
}

View File

@ -10,13 +10,13 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
@ -40,11 +40,9 @@ public class Command_status extends TFM_Command
@Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
playerMsg(String.format("Total Freedom Mod v%s.%s, built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
playerMsg("TotalFreedomMod was created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
playerMsg("For information about TotalFreedomMod, try /tfm", ChatColor.GREEN); // Temporary
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
playerMsg("Loaded worlds:", ChatColor.BLUE);
int i = 0;
for (World world : server.getWorlds())
@ -52,7 +50,7 @@ public class Command_status extends TFM_Command
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
}
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
new BukkitRunnable()
{
@SuppressWarnings("unchecked")
@Override
@ -79,7 +77,7 @@ public class Command_status extends TFM_Command
}
}
List<String> status_output = new ArrayList<String>();
final List<String> status_output = new ArrayList<String>();
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
while (output_it.hasNext())
@ -96,14 +94,21 @@ public class Command_status extends TFM_Command
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
}
new BukkitRunnable()
{
@Override
public void run()
{
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
}
}.runTask(plugin);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
});
}.runTaskAsynchronously(plugin);
return true;
}

View File

@ -1,13 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
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.scheduler.BukkitRunnable;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [<player> | list | purge | all]", aliases = "mute")
@ -54,10 +54,9 @@ public class Command_stfu extends TFM_Command
count++;
}
}
if (TotalFreedomMod.mutePurgeEventId != 0)
if (TotalFreedomMod.mutePurgeTask != null)
{
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
TotalFreedomMod.mutePurgeEventId = 0;
TotalFreedomMod.mutePurgeTask.cancel();
}
playerMsg("Unmuted " + count + " players.");
}
@ -77,26 +76,24 @@ public class Command_stfu extends TFM_Command
}
}
TotalFreedomMod.mutePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
if (TotalFreedomMod.mutePurgeTask != null)
{
TotalFreedomMod.mutePurgeTask.cancel();
}
TotalFreedomMod.mutePurgeTask = new BukkitRunnable()
{
@Override
public void run()
{
if (TotalFreedomMod.mutePurgeEventId == 0)
{
TFM_Log.warning("Mute autopurge task was improperly cancelled!");
return;
}
TFM_Util.adminAction("MuteTimer", "Unmuting all players", false);
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData.getPlayerData(p).setMuted(false);
}
TotalFreedomMod.mutePurgeEventId = 0;
}
}, 6000L); // five minutes in ticks: 20*60*5
}.runTaskLater(plugin, 20L * 60L * 5L);
playerMsg("Muted " + counter + " players.");
}
else

View File

@ -17,7 +17,7 @@ public class Command_stop extends TFM_Command
for (Player p : server.getOnlinePlayers())
{
p.kickPlayer("Server is going offline, come back in a few minutes.");
p.kickPlayer("Server is going offline, come back in about 20 seconds.");
}
server.shutdown();

View File

@ -1,6 +1,9 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
@ -8,7 +11,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> [partialname]")
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> <[partialname] | -a>")
public class Command_survival extends TFM_Command
{
@Override
@ -24,12 +27,30 @@ public class Command_survival extends TFM_Command
}
Player p;
if (args.length == 0)
{
p = sender_p;
}
else
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player player : server.getOnlinePlayers())
{
player.setGameMode(GameMode.SURVIVAL);
}
TFM_Util.adminAction(sender.getName(), "Changing everyone's gamemode to survival", false);
return true;
}
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
{
try

View File

@ -0,0 +1,40 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
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 = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope")
public class Command_tban 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;
}
Player p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_Util.adminAction(sender.getName(), "NOPE: " + p.getName(), true);
TFM_ServerInterface.banUsername(p.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes",
sender.getName(), TFM_Util.parseDateOffset("5m"));
p.kickPlayer(ChatColor.RED + "NOPE!\nYou have been temporarily banned for five minutes.");
return true;
}
}

View File

@ -0,0 +1,24 @@
package me.StevenLawson.TotalFreedomMod.Commands;
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.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows information about TotalFreedomMod", usage = "/<command>")
public class Command_tfm extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
playerMsg("TotalFreedomMod for 'TotalFreedom', the original all-op server.", ChatColor.GOLD);
playerMsg(String.format("Version " + ChatColor.BLUE + "%s.%s" + ChatColor.BLUE + ", built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
playerMsg("Created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
playerMsg("Visit " + ChatColor.AQUA + "http://totalfreedom.me/" + ChatColor.GREEN + " for more information.", ChatColor.DARK_GREEN);
return true;
}
}

View File

@ -7,6 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
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, block_host_console = true)
@CommandParameters(description = "Update server files.", usage = "/<command>")
@ -16,6 +17,7 @@ public class Command_tfupdate extends TFM_Command
{
"http://s3.madgeekonline.com/totalfreedom/BukkitHttpd.jar",
"http://s3.madgeekonline.com/totalfreedom/BukkitTelnet.jar",
"http://s3.madgeekonline.com/totalfreedom/DisguiseCraft.jar",
"http://s3.madgeekonline.com/totalfreedom/Essentials.jar",
"http://s3.madgeekonline.com/totalfreedom/EssentialsSpawn.jar",
"http://s3.madgeekonline.com/totalfreedom/TotalFreedomMod.jar",
@ -34,7 +36,7 @@ public class Command_tfupdate extends TFM_Command
for (final String url : FILES)
{
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
@ -60,7 +62,7 @@ public class Command_tfupdate extends TFM_Command
TFM_Log.severe(ex);
}
}
});
}.runTaskAsynchronously(plugin);
}
return true;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -15,17 +15,7 @@ public class Command_uall extends TFM_Command
{
TFM_Util.adminAction(sender.getName(), "Undisguising all players", true);
if (senderIsConsole)
{
for (Player p : Bukkit.getOnlinePlayers())
{
server.dispatchCommand(p, "u");
}
}
else
{
server.dispatchCommand(sender, "u *");
}
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
return true;
}

View File

@ -0,0 +1,79 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "See who has a block and optionally smite", usage = "/<command> <item> [smite]", aliases = "wh")
public class Command_whohas extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
if (args.length != 1)
{
if (args.length == 2 && args[1].equals("smite"))
{
smite = true;
}
else
{
return false;
}
}
Material material = Material.matchMaterial(args[0]);
if (material == null)
{
try
{
material = Material.getMaterial(Integer.parseInt(args[0]));
}
catch (NumberFormatException ex)
{
}
if (material == null)
{
playerMsg("Invalid block: " + args[0], ChatColor.RED);
return true;
}
}
List<String> players = new ArrayList<String>();
for (Player p : server.getOnlinePlayers())
{
if (p.getInventory().contains(material))
{
players.add(p.getName());
if (smite & !TFM_SuperadminList.isUserSuperadmin(p))
{
Command_smite.smite(p);
}
}
}
if (players.isEmpty())
{
playerMsg("There are no players with that item");
}
else
{
playerMsg("Players with item " + material.name() + ": " + StringUtils.join(players, ", "));
}
return true;
}
}

View File

@ -18,6 +18,21 @@ public class Command_wildcard extends TFM_Command
playerMsg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
return true;
}
if (args[0].equals("gtfo"))
{
playerMsg("Nice try", ChatColor.RED);
return true;
}
if (args[0].equals("doom"))
{
playerMsg("Look, we all hate people, but this is not the way to deal with it, doom is evil enough!", ChatColor.RED);
return true;
}
if (args[0].equals("saconfig"))
{
playerMsg("WOA, WTF are you trying to do???", ChatColor.RED);
return true;
}
String base_command = StringUtils.join(args, " ");

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -22,7 +23,7 @@ import org.bukkit.plugin.Plugin;
public class TFM_CommandLoader
{
public static Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
public static final Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
private List<TFM_CommandInfo> commandList = null;
private TFM_CommandLoader()
@ -31,10 +32,10 @@ public class TFM_CommandLoader
public void scan()
{
CommandMap commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
CommandMap commandMap = getCommandMap();
if (commandMap == null)
{
TFM_Log.severe("Error loading command map.");
TFM_Log.severe("Error loading commandMap.");
return;
}
@ -58,9 +59,82 @@ public class TFM_CommandLoader
description = "OP Command - " + description;
break;
}
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
Command existing = commandMap.getCommand(dynamicCommand.getName());
if (existing != null)
{
TFM_Log.info("Replacing command: " + existing.getName());
unregisterCommand(existing, commandMap);
}
commandMap.register(TotalFreedomMod.plugin.getDescription().getName(), dynamicCommand);
}
TFM_Log.info("TFM commands loaded.");
}
public void unregisterCommand(String commandName)
{
CommandMap commandMap = getCommandMap();
if (commandMap != null)
{
Command command = commandMap.getCommand(commandName.toLowerCase());
if (command != null)
{
unregisterCommand(command, commandMap);
}
}
}
public void unregisterCommand(Command command, CommandMap commandMap)
{
try
{
command.unregister(commandMap);
HashMap<String, Command> knownCommands = getKnownCommands(commandMap);
if (knownCommands != null)
{
knownCommands.remove(command.getName());
for (String alias : command.getAliases())
{
knownCommands.remove(alias);
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
@SuppressWarnings("unchecked")
public CommandMap getCommandMap()
{
Object commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
if (commandMap != null)
{
if (commandMap instanceof CommandMap)
{
return (CommandMap) commandMap;
}
}
return null;
}
@SuppressWarnings("unchecked")
public HashMap<String, Command> getKnownCommands(CommandMap commandMap)
{
Object knownCommands = TFM_Util.getField(commandMap, "knownCommands");
if (knownCommands != null)
{
if (knownCommands instanceof HashMap)
{
return (HashMap<String, Command>) knownCommands;
}
}
return null;
}
private static List<TFM_CommandInfo> getCommands()
@ -138,7 +212,7 @@ public class TFM_CommandLoader
this.blockHostConsole = blockHostConsole;
this.description = description;
this.usage = usage;
this.aliases = Arrays.asList(aliases.split(","));
this.aliases = ("".equals(aliases) ? new ArrayList<String>() : Arrays.asList(aliases.split(",")));
}
public List<String> getAliases()

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -24,7 +25,6 @@ public class TFM_BlockListener implements Listener
if (!TotalFreedomMod.allowFireSpread)
{
event.setCancelled(true);
return;
}
}
@ -34,7 +34,6 @@ public class TFM_BlockListener implements Listener
if (!TotalFreedomMod.allowFirePlace)
{
event.setCancelled(true);
return;
}
}
@ -95,12 +94,17 @@ public class TFM_BlockListener implements Listener
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
{
event.setCancelled(true);
return;
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockBreak(BlockBreakEvent event)
{
TFM_RollbackManager.blockBreak(event);
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
@ -180,7 +184,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -199,7 +202,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -217,7 +219,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -235,13 +236,18 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockPlace(BlockPlaceEvent event)
{
TFM_RollbackManager.blockPlace(event);
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(BlockFromToEvent event)
{
@ -250,23 +256,4 @@ public class TFM_BlockListener implements Listener
event.setCancelled(true);
}
}
// @EventHandler(priority = EventPriority.NORMAL)
// public void onCommandBlockChangeEvent(CommandBlockChangeEvent event)
// {
// Player player = event.getPlayer();
//
// if (!TFM_SuperadminList.isUserSuperadmin(player))
// {
// TFM_Util.playerMsg(player, "You do not have permission to set Command Block commands.");
// event.setCancelled(true);
// return;
// }
//
// if (!TFM_SuperadminList.isSeniorAdmin(player))
// {
// TFM_Util.playerMsg(player, "You do not have permission to set Command Block commands.");
// event.setCancelled(true);
// return;
// }
// }
}

View File

@ -36,7 +36,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event)
{
if (!TotalFreedomMod.allowFireSpread)
if (!TotalFreedomMod.allowExplosions)
{
event.setCancelled(true);
}
@ -50,6 +50,19 @@ public class TFM_EntityListener implements Listener
case LAVA:
{
if (!TotalFreedomMod.allowLavaDamage)
{
event.setCancelled(true);
return;
}
}
}
if (TotalFreedomMod.petProtectEnabled)
{
Entity entity = event.getEntity();
if (entity instanceof Tameable)
{
if (((Tameable) entity).isTamed())
{
event.setCancelled(true);
}

View File

@ -23,8 +23,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class TFM_PlayerListener implements Listener
@ -44,21 +44,36 @@ public class TFM_PlayerListener implements Listener
switch (event.getMaterial())
{
case WATER_BUCKET:
{
if (!TotalFreedomMod.allowWaterPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
return;
}
break;
}
case LAVA_BUCKET:
{
if (!TotalFreedomMod.allowLavaPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
return;
}
case POTION:
break;
}
case EXPLOSIVE_MINECART:
{
if (!TotalFreedomMod.allowTntMinecarts)
{
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
event.setCancelled(true);
}
break;
}
}
break;
@ -81,7 +96,6 @@ public class TFM_PlayerListener implements Listener
playerdata.enqueueMob(rezzed_mob);
event.setCancelled(true);
return;
}
break;
}
@ -100,7 +114,6 @@ public class TFM_PlayerListener implements Listener
}
event.setCancelled(true);
return;
}
break;
}
@ -177,7 +190,7 @@ public class TFM_PlayerListener implements Listener
last_block = test_block;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
@ -189,7 +202,7 @@ public class TFM_PlayerListener implements Listener
tnt_block.setType(Material.AIR);
}
}
}, 30L);
}.runTaskLater(TotalFreedomMod.plugin, 30L);
event.setCancelled(true);
}
@ -356,7 +369,7 @@ public class TFM_PlayerListener implements Listener
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
playerdata.incrementMsgCount();
// check for spam
// Check for spam
if (playerdata.getMsgCount() > 10)
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
@ -368,7 +381,7 @@ public class TFM_PlayerListener implements Listener
return;
}
// check for message repeat
// Check for message repeat
if (playerdata.getLastMessage().equalsIgnoreCase(message))
{
TFM_Util.playerMsg(p, "Please do not repeat messages.");
@ -377,7 +390,7 @@ public class TFM_PlayerListener implements Listener
}
playerdata.setLastMessage(message);
// check for muted
// Check for muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
@ -392,17 +405,17 @@ public class TFM_PlayerListener implements Listener
}
}
// strip color from messages
// Strip color from messages
message = ChatColor.stripColor(message);
// truncate messages that are too long - 100 characters is vanilla client max
// Truncate messages that are too long - 100 characters is vanilla client max
if (message.length() > 100)
{
message = message.substring(0, 100);
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
}
// check for caps - Quit messing with this :-/
// Check for caps
if (message.length() >= 6)
{
int caps = 0;
@ -419,7 +432,7 @@ public class TFM_PlayerListener implements Listener
}
}
// check for adminchat
// Check for adminchat
if (playerdata.inAdminChat())
{
TFM_Util.adminChatMessage(p, message, false);
@ -427,7 +440,7 @@ public class TFM_PlayerListener implements Listener
return;
}
// finally, set message
// Finally, set message
event.setMessage(message);
}
catch (Exception ex)
@ -444,6 +457,7 @@ public class TFM_PlayerListener implements Listener
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
playerdata.incrementMsgCount();
playerdata.setLastCommand(command);
if (playerdata.getMsgCount() > 10)
{
@ -465,116 +479,14 @@ public class TFM_PlayerListener implements Listener
return;
}
if (TotalFreedomMod.preprocessLogEnabled)
{
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
}
playerdata.setLastCommand(command);
command = command.toLowerCase().trim();
boolean block_command = false;
//Commands that will auto-kick the user:
if (Pattern.compile("^/stop").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/reload").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/save-").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
if (block_command)
{
TFM_Util.autoEject(p, "You used a prohibited command: " + command);
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
// commands that will not auto-kick the user, but still deny:
if (Pattern.compile("^/time").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
block_command = true;
}
else if (Pattern.compile("^/md").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.");
block_command = true;
}
else if (Pattern.compile("^/gamemode").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "Use /creative and /survival to set your gamemode.");
block_command = true;
}
else if (Pattern.compile("^/ban").matcher(command).find())
{
if (!Pattern.compile("^/banlist").matcher(command).find())
{
block_command = true;
}
}
else if (Pattern.compile("^/kick").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/kill").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/socialspy").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/pardon").matcher(command).find())
{
block_command = true;
}
else if (Pattern.compile("^/toggledownfall").matcher(command).find())
{
block_command = true;
}
}
if (block_command)
{
p.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true);
return;
}
// block commands while player is muted
// Block commands if player is muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
for (String test_command : BLOCKED_MUTED_CMDS)
{
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command.toLowerCase()).find())
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
{
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
@ -586,7 +498,20 @@ public class TFM_PlayerListener implements Listener
{
playerdata.setMuted(false);
}
return;
}
if (TotalFreedomMod.preprocessLogEnabled)
{
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
}
command = command.toLowerCase().trim();
// Blocked commands
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(command, event.getPlayer()))
{
// CommandBlocker handles messages and broadcasts
event.setCancelled(true);
}
if (!TFM_SuperadminList.isUserSuperadmin(p))
@ -696,14 +621,14 @@ public class TFM_PlayerListener implements Listener
if (TotalFreedomMod.adminOnlyMode)
{
TotalFreedomMod.plugin.getServer().getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
new BukkitRunnable()
{
@Override
public void run()
{
p.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
}
}, 60L);
}.runTaskLater(TotalFreedomMod.plugin, 20L * 3L);
}
}
catch (Throwable ex)
@ -716,16 +641,4 @@ public class TFM_PlayerListener implements Listener
{
TFM_ServerInterface.handlePlayerLogin(event);
}
@EventHandler()
public void onServerPing(ServerListPingEvent event)
{
// Colorize :)
event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
{
event.setMotd(ChatColor.RED + "You are banned!");
}
}
}

View File

@ -0,0 +1,211 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlockerNew;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
public class TFM_ServerListener implements Listener
{
// CommandBlockSetEvent does not exist in "vanilla" Bukkit/CraftBukkit.
// Comment this method out if you want to compile this without a custom CraftBukkit.
// Just make sure that enable-command-block=false in server.properties.
// -Madgeek
@EventHandler(priority = EventPriority.NORMAL)
public void onCommandBlockSet(org.bukkit.event.server.CommandBlockSetEvent event)
{
Player player = event.getPlayer();
String newCommandRaw = event.getNewCommand();
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
{
player.sendMessage(ChatColor.GRAY + "Only senior admins may set command block commands.");
event.setCancelled(true);
return;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(newCommandRaw);
if (matcher.find())
{
String topLevelCommand = matcher.group(1);
if (topLevelCommand != null)
{
topLevelCommand = topLevelCommand.toLowerCase().trim();
//We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy:
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
{
player.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true);
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onRemoteServerCommand(RemoteServerCommandEvent event)
{
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
{
event.setCommand("");
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onServerCommand(ServerCommandEvent event)
{
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
{
event.setCommand("");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event)
{
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
{
event.setMotd(ChatColor.RED + "You are banned.");
}
else if (TotalFreedomMod.adminOnlyMode)
{
event.setMotd(ChatColor.RED + "Server is closed.");
}
else if (Bukkit.hasWhitelist())
{
event.setMotd(ChatColor.RED + "Whitelist enabled.");
}
else if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
{
event.setMotd(ChatColor.RED + "Server is full.");
}
}
private static class TFM_ServerListener_DummyCommandSender implements CommandSender
{
private final String senderName;
public TFM_ServerListener_DummyCommandSender(String senderName)
{
this.senderName = senderName;
}
@Override
public void sendMessage(String message)
{
}
@Override
public void sendMessage(String[] messages)
{
}
@Override
public Server getServer()
{
return null;
}
@Override
public String getName()
{
return senderName;
}
@Override
public boolean isPermissionSet(String name)
{
return true;
}
@Override
public boolean isPermissionSet(Permission perm)
{
return true;
}
@Override
public boolean hasPermission(String name)
{
return true;
}
@Override
public boolean hasPermission(Permission perm)
{
return true;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value)
{
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin)
{
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks)
{
return null;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, int ticks)
{
return null;
}
@Override
public void removeAttachment(PermissionAttachment attachment)
{
}
@Override
public void recalculatePermissions()
{
}
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions()
{
return null;
}
@Override
public boolean isOp()
{
return true;
}
@Override
public void setOp(boolean value)
{
}
}
}

View File

@ -0,0 +1,164 @@
package me.StevenLawson.TotalFreedomMod;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TFM_CommandBlocker
{
public static boolean isCommandBlocked(String usedcommand, CommandSender sender)
{
String name = sender.getName();
usedcommand = usedcommand.toLowerCase().trim();
for (String blocked_command : TotalFreedomMod.blockedCommands)
{
String[] parts = blocked_command.split(":");
if (parts.length < 3 || parts.length > 4)
{
continue;
}
if (!(usedcommand + " ").startsWith(parts[2] + " "))
{
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
if (commandMap == null)
{
continue;
}
Command command = commandMap.getCommand(parts[2].replaceAll("/", ""));
if (command == null)
{
continue;
}
boolean block = false;
for (String alias : command.getAliases())
{
if (usedcommand.replaceAll("/", "").startsWith(alias))
{
block = true;
break;
}
}
if (!block)
{
continue;
}
}
if (SenderRank.hasPermissions(sender, parts[0]))
{
continue;
}
// Past this line indicates that the command is blocked.
// Optional: Send a message
if (parts.length == 4)
{
if ("_".equals(parts[3]))
{
sender.sendMessage(ChatColor.GRAY + "That command is blocked.");
}
else
{
sender.sendMessage(ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', parts[3]));
}
}
// Action
if ("b".equals(parts[1]))
{
return true;
}
else if ("a".equals(parts[1]))
{
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + usedcommand);
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
return true;
}
else if ("u".equals(parts[1]))
{
sender.sendMessage("Unknown command. Type \"help\" for help.");
return true;
}
return false;
}
return false;
}
public enum SenderRank
{
ANYONE("a", 0),
OP("o", 1),
SUPER("s", 2),
TELNET("t", 3),
SENIOR("c", 4),
NOBODY("n", 5);
private String letter = "n";
private int rank = 5;
SenderRank(String letter, int rank)
{
this.letter = letter;
this.rank = rank;
}
public static boolean hasPermissions(CommandSender sender, String letter)
{
return (getSenderRank(sender).rank >= getSenderRankByLetter(letter).rank);
}
public static SenderRank getSenderRank(CommandSender sender)
{
if (!(sender instanceof Player))
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
{
return SenderRank.SENIOR;
}
else
{
return SenderRank.TELNET;
}
}
if (TFM_SuperadminList.isUserSuperadmin(sender))
{
return SenderRank.SUPER;
}
if (sender.isOp())
{
return SenderRank.OP;
}
return SenderRank.ANYONE;
}
public static SenderRank getSenderRankByLetter(String letter)
{
for (SenderRank rank : SenderRank.values())
{
if (letter.equals(rank.letter))
{
return rank;
}
}
return SenderRank.NOBODY;
}
}
}

View File

@ -0,0 +1,328 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TFM_CommandBlockerNew
{
private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
private TFM_CommandBlockerNew()
{
parseBlockingRules();
}
public final void parseBlockingRules()
{
blockedCommands.clear();
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
if (commandMap == null)
{
TFM_Log.severe("Error loading commandMap.");
return;
}
for (String rawEntry : TotalFreedomMod.blockedCommands)
{
String[] parts = rawEntry.split(":");
if (parts.length < 3 || parts.length > 4)
{
continue;
}
CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
if (rank == null)
{
continue;
}
CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
if (action == null)
{
continue;
}
String command = parts[2];
if (command == null || command.isEmpty())
{
continue;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{
continue;
}
else
{
command = command.toLowerCase().trim();
}
}
else
{
continue;
}
String message = null;
if (parts.length == 4)
{
message = parts[3];
}
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
Command bukkitCommand = commandMap.getCommand(command);
if (bukkitCommand == null)
{
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
}
else
{
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
for (String alias : bukkitCommand.getAliases())
{
//TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
}
}
}
}
public boolean isCommandBlocked(String command, CommandSender sender)
{
return isCommandBlocked(command, sender, true);
}
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
{
if (command == null || command.isEmpty())
{
return false;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{
return false;
}
else
{
command = command.toLowerCase().trim();
}
}
else
{
return false;
}
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
if (blockedCommandEntry != null)
{
if (!blockedCommandEntry.getRank().hasPermission(sender))
{
if (doAction)
{
blockedCommandEntry.doActions(sender);
}
return true;
}
}
return false;
}
private static enum CommandBlockerRank
{
ANYONE("a", 0),
OP("o", 1),
SUPER("s", 2),
TELNET("t", 3),
SENIOR("c", 4),
NOBODY("n", 5);
private final String token;
private final int level;
private CommandBlockerRank(String token, int level)
{
this.token = token;
this.level = level;
}
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return getSenderRank(sender).level >= this.level;
}
public static CommandBlockerRank getSenderRank(CommandSender sender)
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
if (sender.isOp())
{
return OP;
}
return ANYONE;
}
else
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
{
return SENIOR;
}
if (!(sender instanceof Player))
{
return TELNET;
}
return SUPER;
}
}
public static CommandBlockerRank fromToken(String token)
{
for (CommandBlockerRank rank : CommandBlockerRank.values())
{
if (rank.getToken().equalsIgnoreCase(token))
{
return rank;
}
}
return ANYONE;
}
}
private enum CommandBlockerAction
{
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token)
{
for (CommandBlockerAction action : CommandBlockerAction.values())
{
if (action.getToken().equalsIgnoreCase(token))
{
return action;
}
}
return null;
}
}
private static class TFM_CommandBlocker_BlockedCommandEntry
{
private final CommandBlockerRank rank;
private final CommandBlockerAction action;
private String command;
private final String message;
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this.rank = rank;
this.action = action;
this.command = command;
this.message = message;
}
public CommandBlockerAction getAction()
{
return this.action;
}
public String getCommand()
{
return this.command;
}
public String getMessage()
{
return this.message;
}
public CommandBlockerRank getRank()
{
return this.rank;
}
public void setCommand(String command)
{
this.command = command;
}
private void doActions(CommandSender sender)
{
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
String response;
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
{
response = "Unknown command. Type \"help\" for help.";
}
else if (this.message == null || "_".equals(this.message))
{
response = ChatColor.GRAY + "That command is blocked.";
}
else
{
response = ChatColor.GRAY + ChatColor.translateAlternateColorCodes('&', this.message);
}
sender.sendMessage(response);
}
}
}
public static TFM_CommandBlockerNew getInstance()
{
return TFM_CommandBlockerNewHolder.INSTANCE;
}
private static class TFM_CommandBlockerNewHolder
{
private static final TFM_CommandBlockerNew INSTANCE = new TFM_CommandBlockerNew();
}
}

View File

@ -0,0 +1,74 @@
package me.StevenLawson.TotalFreedomMod;
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;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.World;
public class TFM_GameRuleHandler
{
private static final EnumMap<TFM_GameRule, TFM_GameRule_Value> GAME_RULES = new EnumMap<TFM_GameRule, TFM_GameRule_Value>(TFM_GameRule.class);
static
{
for (TFM_GameRule gameRule : TFM_GameRule.values())
{
GAME_RULES.put(gameRule, gameRule.getDefaultValue());
}
}
private TFM_GameRuleHandler()
{
throw new AssertionError();
}
public static void setGameRule(TFM_GameRule gameRule, boolean value)
{
setGameRule(gameRule, value, true);
}
public static void setGameRule(TFM_GameRule gameRule, boolean value, boolean doCommit)
{
GAME_RULES.put(gameRule, TFM_GameRule_Value.fromBoolean(value));
if (doCommit)
{
commitGameRules();
}
}
public static void commitGameRules()
{
List<World> worlds = Bukkit.getWorlds();
Iterator<Map.Entry<TFM_GameRule, TFM_GameRule_Value>> it = GAME_RULES.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<TFM_GameRule, TFM_GameRule_Value> gameRuleEntry = it.next();
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
String gameRuleValue = gameRuleEntry.getValue().toString();
for (World world : worlds)
{
world.setGameRuleValue(gameRuleName, gameRuleValue);
if (gameRuleEntry.getKey() == TFM_GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue().toBoolean())
{
TFM_Util.setWorldTime(world, 6000L);
}
}
}
}
public enum TFM_GameRule
{
DO_FIRE_TICK("doFireTick", TFM_GameRule_Value.TRUE),
MOB_GRIEFING("mobGriefing", TFM_GameRule_Value.TRUE),
KEEP_INVENTORY("keepInventory", TFM_GameRule_Value.FALSE),
DO_MOB_SPAWNING("doMobSpawning", TFM_GameRule_Value.TRUE),
DO_MOB_LOOT("doMobLoot", TFM_GameRule_Value.TRUE),
DO_TILE_DROPS("doTileDrops", TFM_GameRule_Value.TRUE),
COMMAND_BLOCK_OUTPUT("commandBlockOutput", TFM_GameRule_Value.TRUE),
NATURAL_REGENERATION("naturalRegeneration", TFM_GameRule_Value.TRUE),
DO_DAYLIGHT_CYCLE("doDaylightCycle", TFM_GameRule_Value.TRUE);
private final String gameRuleName;
private final TFM_GameRule_Value defaultValue;
private TFM_GameRule(String gameRuleName, TFM_GameRule_Value defaultValue)
{
this.gameRuleName = gameRuleName;
this.defaultValue = defaultValue;
}
public String getGameRuleName()
{
return gameRuleName;
}
public TFM_GameRule_Value getDefaultValue()
{
return defaultValue;
}
}
public enum TFM_GameRule_Value
{
TRUE("true"), FALSE("false");
private final String value;
private TFM_GameRule_Value(String value)
{
this.value = value;
}
@Override
public String toString()
{
return this.value;
}
public boolean toBoolean()
{
return (this.value.equals(TFM_GameRule_Value.TRUE.value) ? true : false);
}
public static TFM_GameRule_Value fromBoolean(boolean in)
{
return (in ? TFM_GameRule_Value.TRUE : TFM_GameRule_Value.FALSE);
}
}
}

View File

@ -3,8 +3,9 @@ package me.StevenLawson.TotalFreedomMod;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class TFM_Heartbeat implements Runnable
public class TFM_Heartbeat extends BukkitRunnable
{
private final TotalFreedomMod plugin;
private final Server server;
@ -31,23 +32,6 @@ public class TFM_Heartbeat implements Runnable
TFM_Util.wipeEntities(!TotalFreedomMod.allowExplosions, false);
}
if (TotalFreedomMod.disableNight)
{
try
{
for (World world : server.getWorlds())
{
if (world.getTime() > 12000L)
{
TFM_Util.setWorldTime(world, 1000L);
}
}
}
catch (NullPointerException ex)
{
}
}
if (TotalFreedomMod.disableWeather)
{
for (World world : server.getWorlds())

View File

@ -7,12 +7,15 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class TFM_PlayerData
@ -320,7 +323,7 @@ public class TFM_PlayerData
LivingEntity oldmob = mob_thrower_queue.remove(0);
if (oldmob != null)
{
oldmob.damage(500);
oldmob.damage(500.0);
}
}
}
@ -328,7 +331,7 @@ public class TFM_PlayerData
public void startArrowShooter(TotalFreedomMod plugin)
{
this.stopArrowShooter();
this.mp44_schedule_id = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new ArrowShooter(this.player), 1L, 1L);
this.mp44_schedule_id = new ArrowShooter(this.player).runTaskTimer(plugin, 1L, 1L);
mp44_firing = true;
}
@ -342,7 +345,7 @@ public class TFM_PlayerData
mp44_firing = false;
}
class ArrowShooter implements Runnable
private class ArrowShooter extends BukkitRunnable
{
private Player _player;
@ -400,6 +403,32 @@ public class TFM_PlayerData
public void setHalted(boolean is_halted)
{
this.is_halted = is_halted;
if (is_halted)
{
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
player.setDisplayName(player_name);
player.closeInventory();
player.setTotalExperience(0);
stopOrbiting();
setFrozen(true);
setMuted(true);
player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
}
else
{
player.setOp(true);
player.setGameMode(GameMode.CREATIVE);
setFrozen(false);
setMuted(false);
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
public BukkitTask getLockupScheduleID()

View File

@ -1,40 +0,0 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.Comparator;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public 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

@ -0,0 +1,138 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class TFM_RollbackManager
{
private static final Map<String, List<TFM_RollbackManager_Entry>> PLAYER_HISTORY_MAP = new HashMap<String, List<TFM_RollbackManager_Entry>>();
private TFM_RollbackManager()
{
throw new AssertionError();
}
public static void blockPlace(org.bukkit.event.block.BlockPlaceEvent event)
{
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_PLACE));
}
public static void blockBreak(org.bukkit.event.block.BlockBreakEvent event)
{
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_BREAK));
}
private static void storeEntry(Player player, TFM_RollbackManager_Entry entry)
{
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(player.getName());
if (playerEntryList != null)
{
playerEntryList.add(0, entry);
}
}
public static int purgeEntries()
{
Iterator<List<TFM_RollbackManager_Entry>> it = PLAYER_HISTORY_MAP.values().iterator();
while (it.hasNext())
{
List<TFM_RollbackManager_Entry> playerEntryList = it.next();
if (playerEntryList != null)
{
playerEntryList.clear();
}
}
return PLAYER_HISTORY_MAP.size();
}
public static int purgeEntries(String playerName)
{
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(playerName);
if (playerEntryList != null)
{
int count = playerEntryList.size();
playerEntryList.clear();
return count;
}
return 0;
}
public static boolean canRollback(String playerName)
{
return PLAYER_HISTORY_MAP.containsKey(playerName.toLowerCase());
}
public static int rollback(String playerName)
{
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(playerName);
if (playerEntryList != null)
{
int count = playerEntryList.size();
Iterator<TFM_RollbackManager_Entry> it = playerEntryList.iterator();
while (it.hasNext())
{
TFM_RollbackManager_Entry entry = it.next();
if (entry != null)
{
entry.restore();
}
it.remove();
}
return count;
}
return 0;
}
private static List<TFM_RollbackManager_Entry> getPlayerEntryList(String playerName)
{
playerName = playerName.toLowerCase();
List<TFM_RollbackManager_Entry> playerEntryList = PLAYER_HISTORY_MAP.get(playerName);
if (playerEntryList == null)
{
playerEntryList = new ArrayList<TFM_RollbackManager_Entry>();
PLAYER_HISTORY_MAP.put(playerName, playerEntryList);
}
return playerEntryList;
}
private enum TFM_RollbackManager_EntryType
{
BLOCK_PLACE, BLOCK_BREAK
}
private static class TFM_RollbackManager_Entry
{
private final Location location;
private final Material material;
private final byte data;
public TFM_RollbackManager_Entry(Block block, TFM_RollbackManager_EntryType entryType)
{
this.location = block.getLocation();
if (entryType == TFM_RollbackManager_EntryType.BLOCK_BREAK)
{
this.material = block.getType();
this.data = block.getData();
}
else
{
this.material = Material.AIR;
this.data = 0;
}
}
public void restore()
{
Block b = this.location.getWorld().getBlockAt(this.location);
b.setType(this.material);
b.setData(this.data);
}
}
}

View File

@ -1,60 +0,0 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class TFM_RunSystemCommand implements Runnable
{
private final String command;
private final TotalFreedomMod plugin;
public TFM_RunSystemCommand(String command, TotalFreedomMod plugin)
{
this.command = command;
this.plugin = plugin;
}
@Override
public void run()
{
try
{
final ProcessBuilder childBuilder = new ProcessBuilder(command);
childBuilder.redirectErrorStream(true);
childBuilder.directory(plugin.getDataFolder().getParentFile().getParentFile());
final Process child = childBuilder.start();
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
try
{
child.waitFor();
String line;
do
{
line = reader.readLine();
if (line != null)
{
TFM_Log.info(line);
}
}
while (line != null);
}
finally
{
reader.close();
}
}
catch (InterruptedException ex)
{
TFM_Log.severe(ex.getMessage());
}
catch (IOException ex)
{
TFM_Log.severe(ex.getMessage());
}
catch (Throwable ex)
{
TFM_Log.severe(ex);
}
}
}

View File

@ -5,11 +5,11 @@ import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.regex.Pattern;
import net.minecraft.server.v1_5_R3.BanEntry;
import net.minecraft.server.v1_5_R3.BanList;
import net.minecraft.server.v1_5_R3.MinecraftServer;
import net.minecraft.server.v1_5_R3.PlayerList;
import net.minecraft.server.v1_5_R3.PropertyManager;
import net.minecraft.server.v1_6_R2.BanEntry;
import net.minecraft.server.v1_6_R2.BanList;
import net.minecraft.server.v1_6_R2.MinecraftServer;
import net.minecraft.server.v1_6_R2.PlayerList;
import net.minecraft.server.v1_6_R2.PropertyManager;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -121,6 +121,8 @@ public class TFM_ServerInterface
public static void handlePlayerLogin(PlayerLoginEvent event)
{
// this should supersede all other onPlayerLogin authentication on the TFM server.
// when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication.
final Server server = TotalFreedomMod.plugin.getServer();
@ -135,8 +137,7 @@ public class TFM_ServerInterface
if (player_name.trim().length() <= 2)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
"Your username is too short (must be at least 3 characters long).");
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long).");
return;
}
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find())
@ -145,8 +146,7 @@ public class TFM_ServerInterface
return;
}
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress()
// will return a null until after player login.
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login.
boolean is_superadmin;
if (server.getOnlineMode())
{
@ -171,8 +171,7 @@ public class TFM_ServerInterface
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
if (ban_entry.getExpires() != null)
{
kick_message = kick_message + "\nYour ban will be removed on "
+ date_format.format(ban_entry.getExpires());
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
}
}
@ -216,8 +215,7 @@ public class TFM_ServerInterface
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
if (ban_entry.getExpires() != null)
{
kick_message = kick_message + "\nYour ban will be removed on "
+ date_format.format(ban_entry.getExpires());
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
}
}
@ -229,8 +227,7 @@ public class TFM_ServerInterface
{
if (test_player.equalsIgnoreCase(player_name))
{
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
+ "Your username is permanently banned from this server.");
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.");
return;
}
}
@ -239,8 +236,7 @@ public class TFM_ServerInterface
{
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
{
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
+ "Your IP address is permanently banned from this server.");
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.");
return;
}
}
@ -275,21 +271,8 @@ public class TFM_ServerInterface
}
}
}
else // if user is superadmin
else
{
// force-allow superadmins to log in
event.allow();
if (isIPBanned(player_ip))
{
unbanIP(player_ip);
}
if (isNameBanned(player_name))
{
unbanUsername(player_name);
}
for (Player test_player : server.getOnlinePlayers())
{
if (test_player.getName().equalsIgnoreCase(player_name))
@ -298,23 +281,25 @@ public class TFM_ServerInterface
}
}
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
boolean can_kick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
while (server.getOnlinePlayers().length >= server.getMaxPlayers() && can_kick)
{
for (Player op : server.getOnlinePlayers())
can_kick = false;
for (Player test_player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isUserSuperadmin(op))
if (!TFM_SuperadminList.isUserSuperadmin(test_player))
{
op.kickPlayer("You have been kicked to free up space for an admin");
return;
can_kick = true;
test_player.kickPlayer("You have been kicked to free up room for an admin.");
break;
}
}
}
}
}
// if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
public static String getVersion()
{
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, this server is full");
}
}
}
return MinecraftServer.getServer().getVersion();
}
}

View File

@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import me.StevenLawson.TotalFreedomMod.Commands.Command_logs;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
@ -386,6 +387,7 @@ public class TFM_SuperadminList
{
TFM_Superadmin superadmin = superadminList.get(admin_name);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
saveSuperadminList();
}
}
@ -423,6 +425,7 @@ public class TFM_SuperadminList
}
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
}
}
}

View File

@ -4,8 +4,10 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -125,6 +127,25 @@ public class TFM_UserList
exportList();
}
public String searchByPartialName(String needle)
{
needle = needle.toLowerCase().trim();
Integer minEditDistance = null;
String minEditMatch = null;
Iterator<String> it = _userlist.keySet().iterator();
while (it.hasNext())
{
String haystack = it.next();
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
if (minEditDistance == null || minEditDistance.intValue() > editDistance)
{
minEditDistance = editDistance;
minEditMatch = haystack;
}
}
return minEditMatch;
}
public class TFM_UserListEntry
{
private String _username;

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
@ -13,8 +12,6 @@ import java.util.jar.JarFile;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.*;
@ -27,6 +24,7 @@ public class TFM_Util
private static final Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "disaster839");
static
{
@ -304,77 +302,6 @@ public class TFM_Util
return TFM_Util.mobtypes.get(mobname);
}
public static void zip(File directory, File zipfile, boolean verbose, CommandSender sender) throws IOException
{
URI base = directory.toURI();
Deque<File> queue = new LinkedList<File>();
queue.push(directory);
OutputStream out = new FileOutputStream(zipfile);
Closeable res = out;
try
{
ZipOutputStream zout = new ZipOutputStream(out);
res = zout;
while (!queue.isEmpty())
{
directory = queue.pop();
for (File kid : directory.listFiles())
{
String name = base.relativize(kid.toURI()).getPath();
if (kid.isDirectory())
{
queue.push(kid);
name = name.endsWith("/") ? name : name + "/";
zout.putNextEntry(new ZipEntry(name));
}
else
{
zout.putNextEntry(new ZipEntry(name));
copy(kid, zout);
zout.closeEntry();
}
if (verbose)
{
sender.sendMessage("Zipping: " + name);
}
}
}
}
finally
{
res.close();
}
}
public static void unzip(File zipfile, File directory) throws IOException
{
ZipFile zfile = new ZipFile(zipfile);
Enumeration<? extends ZipEntry> entries = zfile.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = entries.nextElement();
File file = new File(directory, entry.getName());
if (entry.isDirectory())
{
file.mkdirs();
}
else
{
file.getParentFile().mkdirs();
InputStream in = zfile.getInputStream(entry);
try
{
copy(in, file);
}
finally
{
in.close();
}
}
}
}
private static void copy(InputStream in, OutputStream out) throws IOException
{
byte[] buffer = new byte[1024];
@ -968,8 +895,7 @@ public class TFM_Util
{
if (TFM_SuperadminList.isUserSuperadmin(p))
{
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED
+ name + ": " + ChatColor.AQUA + message);
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.AQUA + message);
}
}
}
@ -977,18 +903,21 @@ public class TFM_Util
public static String getPrefix(CommandSender sender, boolean senderIsConsole)
{
String prefix;
if (senderIsConsole) {
if (senderIsConsole)
{
prefix = ChatColor.BLUE + "(Console)";
} else {
}
else
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
{
prefix = ChatColor.LIGHT_PURPLE + "(SrA)";
} else
}
else
{
prefix = ChatColor.GOLD + "(SA)";
}
if (sender.getName().equalsIgnoreCase("Madgeek1450")
|| sender.getName().equalsIgnoreCase("DarthSalamon"))
if (DEVELOPERS.contains(sender.getName()))
{
prefix = ChatColor.DARK_PURPLE + "(Dev)";
}
@ -1031,4 +960,23 @@ public class TFM_Util
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
return null;
}
public static final List<ChatColor> COLOR_POOL = Arrays.asList(
ChatColor.DARK_BLUE,
ChatColor.DARK_GREEN,
ChatColor.DARK_AQUA,
ChatColor.DARK_RED,
ChatColor.DARK_PURPLE,
ChatColor.GOLD,
ChatColor.BLUE,
ChatColor.GREEN,
ChatColor.AQUA,
ChatColor.RED,
ChatColor.LIGHT_PURPLE,
ChatColor.YELLOW);
private static final Random RANDOM = new Random();
public static ChatColor randomChatColor()
{
return COLOR_POOL.get(RANDOM.nextInt(COLOR_POOL.size()));
}
}

View File

@ -0,0 +1,123 @@
package me.StevenLawson.TotalFreedomMod;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
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 p)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.wrapPlayer(p);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public LocalSession getPlayerSession(Player p)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.getSession(p);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void undo(Player p, int count)
{
try
{
LocalSession session = getPlayerSession(p);
if (session != null)
{
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
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 p, int limit)
{
try
{
LocalSession session = getPlayerSession(p);
if (session != null)
{
session.setBlockChangeLimit(limit);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
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

@ -6,10 +6,7 @@ import java.io.InputStream;
import java.util.*;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_PlayerListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_WeatherListener;
import me.StevenLawson.TotalFreedomMod.Listener.*;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.Bukkit;
@ -23,39 +20,42 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.mcstats.Metrics;
public class TotalFreedomMod extends JavaPlugin
{
public static final Server server = Bukkit.getServer();
//
public static final long HEARTBEAT_RATE = 5L; //Seconds
public static final long SERVICE_CHECKER_RATE = 30L;
//
public static final String CONFIG_FILE = "config.yml";
public static final String SUPERADMIN_FILE = "superadmin.yml";
public static final String PERMBAN_FILE = "permban.yml";
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
public static final String SAVED_FLAGS_FILE = "savedflags.dat";
//
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
public static final String COMMAND_PREFIX = "Command_";
//
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
//
public static boolean allPlayersFrozen = false;
public static int freezePurgeEventId = 0;
public static int mutePurgeEventId = 0;
public static BukkitTask freezePurgeTask = null;
public static BukkitTask mutePurgeTask = null;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
//
public static String pluginVersion = "";
public static String buildNumber = "";
public static String buildDate = "";
public static String pluginName = "";
//
public static TotalFreedomMod plugin = null;
public static File plugin_file = null;
@ -94,6 +94,16 @@ public class TotalFreedomMod extends JavaPlugin
}
}
// Initialize game rules
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !disableNight, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, allowFireSpread, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !mobLimiterEnabled, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
TFM_GameRuleHandler.commitGameRules();
if (TotalFreedomMod.protectedAreasEnabled)
{
TFM_ProtectedArea.loadProtectedAreas();
@ -102,9 +112,23 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Util.deleteFolder(new File("./_deleteme"));
server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
File[] coreDumps = new File(".").listFiles(new java.io.FileFilter()
{
@Override
public boolean accept(File file)
{
return file.getName().startsWith("java.core");
}
});
TFM_CommandLoader.getInstance().scan();
for (File dump : coreDumps)
{
TFM_Log.info("Removing core dump file: " + dump.getName());
dump.delete();
}
// Heartbeat
new TFM_Heartbeat(this).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
try
@ -117,15 +141,24 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
}
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "."
+ TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
new BukkitRunnable()
{
@Override
public void run()
{
TFM_CommandLoader.getInstance().scan();
TFM_CommandBlockerNew.getInstance().parseBlockingRules();
}
}.runTaskLater(this, 20L);
}
@Override
public void onDisable()
{
server.getScheduler().cancelTasks(this);
TFM_Log.info("Plugin Disabled");
TFM_Log.info("Plugin disabled");
}
@Override
@ -157,8 +190,7 @@ public class TotalFreedomMod extends JavaPlugin
try
{
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX,
cmd.getName().toLowerCase())).newInstance();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
dispatcher.setup(this, sender, dispatcher.getClass());
}
catch (Throwable ex)
@ -181,10 +213,9 @@ public class TotalFreedomMod extends JavaPlugin
}
catch (Throwable ex)
{
sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage());
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
}
dispatcher = null;
}
catch (Throwable ex)
{
@ -194,23 +225,26 @@ public class TotalFreedomMod extends JavaPlugin
return true;
}
//
public static boolean allowFirePlace = false;
public static Boolean allowFireSpread = false;
public static Boolean allowLavaDamage = false;
public static boolean allowFireSpread = false;
public static boolean allowLavaDamage = false;
public static boolean allowLavaPlace = false;
public static boolean allowWaterPlace = false;
public static Boolean allowExplosions = false;
public static boolean allowExplosions = false;
public static boolean allowFliudSpread = false;
public static boolean allowTntMinecarts = false;
public static double explosiveRadius = 4.0D;
public static List<String> blockedCommands = new ArrayList<String>();
public static boolean autoEntityWipe = true;
public static boolean nukeMonitor = true;
public static int nukeMonitorCountBreak = 100;
public static int nukeMonitorCountPlace = 25;
public static double nukeMonitorRange = 10.0D;
public static int freecamTriggerCount = 10;
public static Boolean preprocessLogEnabled = true;
public static Boolean disableNight = true;
public static Boolean disableWeather = true;
public static boolean preprocessLogEnabled = true;
public static boolean disableNight = true;
public static boolean disableWeather = true;
public static boolean landminesEnabled = false;
public static boolean mp44Enabled = false;
public static boolean mobLimiterEnabled = true;
@ -222,15 +256,17 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean tossmobEnabled = false;
public static boolean generateFlatlands = true;
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
public static boolean allowFliudSpread = false;
public static boolean adminOnlyMode = false;
public static boolean protectedAreasEnabled = true;
public static boolean autoProtectSpawnpoints = true;
public static double autoProtectRadius = 25.0D;
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
public static boolean twitterbotEnabled = false;
public static String twitterbotUrl = "http://tftwitter.darthcraft.net/";
public static String twitterbotUrl = "";
public static String twitterbotSecret = "";
public static boolean petProtectEnabled = true;
public static String logsRegisterPassword = "";
public static String logsRegisterURL = "";
public static void loadMainConfig()
{
@ -245,7 +281,9 @@ public class TotalFreedomMod extends JavaPlugin
allowLavaPlace = config.getBoolean("allow_lava_place", allowLavaPlace);
allowWaterPlace = config.getBoolean("allow_water_place", allowWaterPlace);
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
blockedCommands = config.getStringList("blocked_commands");
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);
nukeMonitorCountBreak = config.getInt("nuke_monitor_count_break", nukeMonitorCountBreak);
@ -272,16 +310,19 @@ public class TotalFreedomMod extends JavaPlugin
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
host_sender_names = config.getStringList("host_sender_names");
twitterbotEnabled = config.getBoolean("twitterbot_enabled");
twitterbotUrl = config.getString("twitterbot_url");
twitterbotSecret = config.getString("twitterbot_secret");
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
logsRegisterPassword = config.getString("logs_register_password", logsRegisterPassword);
logsRegisterURL = config.getString("logs_register_url", logsRegisterURL);
}
catch (Exception ex)
{
TFM_Log.severe("Error loading main config: " + ex.getMessage());
}
}
//
@Deprecated
public static List<String> superadmins = new ArrayList<String>();
@Deprecated
@ -302,7 +343,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
}
}
//
public static List<String> permbanned_players = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>();
@ -345,6 +386,7 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvents(new TFM_BlockListener(), plugin);
pm.registerEvents(new TFM_PlayerListener(), plugin);
pm.registerEvents(new TFM_WeatherListener(), plugin);
pm.registerEvents(new TFM_ServerListener(), plugin);
}
private static void setAppProperties()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2011 Tyler Blair. All rights reserved.
* Copyright 2011-2013 Tyler Blair. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@ -25,21 +25,21 @@
* authors and contributors and should not be interpreted as representing official policies,
* either expressed or implied, of anybody else.
*/
package org.mcstats;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URL;
@ -52,47 +52,29 @@ import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
/**
* <p>
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
* </p>
* <p>
* Public methods provided by this class:
* </p>
* <code>
* Graph createGraph(String name); <br/>
* void addCustomData(Metrics.Plotter plotter); <br/>
* void start(); <br/>
* </code>
*/
public class Metrics {
/**
* The current revision number
*/
private final static int REVISION = 6;
private final static int REVISION = 7;
/**
* The base url of the metrics domain
*/
private static final String BASE_URL = "http://mcstats.org";
private static final String BASE_URL = "http://report.mcstats.org";
/**
* The url used to report a server's status
*/
private static final String REPORT_URL = "/report/%s";
/**
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
* version of metrics and want to change it.
*/
private static final String CUSTOM_DATA_SEPARATOR = "~~";
private static final String REPORT_URL = "/plugin/%s";
/**
* Interval of time to ping (in minutes)
*/
private static final int PING_INTERVAL = 10;
private static final int PING_INTERVAL = 15;
/**
* The plugin this metrics submits for
@ -104,11 +86,6 @@ public class Metrics {
*/
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* The default graph, used for addCustomData when you don't want a specific graph
*/
private final Graph defaultGraph = new Graph("Default");
/**
* The plugin configuration file
*/
@ -167,8 +144,8 @@ public class Metrics {
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
* on the metrics website. Plotters can be added to the graph object returned.
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
* website. Plotters can be added to the graph object returned.
*
* @param name The name of the graph
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
@ -189,7 +166,7 @@ public class Metrics {
}
/**
* Add a Graph object to Metrics that represents data for the plugin that should be sent to the backend
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
*
* @param graph The name of the graph
*/
@ -202,26 +179,9 @@ public class Metrics {
}
/**
* Adds a custom data plotter to the default graph
*
* @param plotter The plotter to use to plot custom data
*/
public void addCustomData(final Plotter plotter) {
if (plotter == null) {
throw new IllegalArgumentException("Plotter cannot be null");
}
// Add the plotter to the graph o/
defaultGraph.addPlotter(plotter);
// Ensure the default graph is included in the submitted graphs
graphs.add(defaultGraph);
}
/**
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send
* the initial data to the metrics backend, and then after that it will post in increments of
* PING_INTERVAL * 1200 ticks.
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
* ticks.
*
* @return True if statistics measuring is running, otherwise false.
*/
@ -305,7 +265,7 @@ public class Metrics {
/**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws IOException
* @throws java.io.IOException
*/
public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
@ -326,7 +286,7 @@ public class Metrics {
/**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
*
* @throws IOException
* @throws java.io.IOException
*/
public void disable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
@ -377,14 +337,14 @@ public class Metrics {
// END server software specific section -- all code below does not use any code outside of this class / Java
// Construct the post data
final StringBuilder data = new StringBuilder();
StringBuilder json = new StringBuilder(1024);
json.append('{');
// The plugin's description file containg all of the plugin data such as name, version, author, etc
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", pluginVersion);
encodeDataPair(data, "server", serverVersion);
encodeDataPair(data, "players", Integer.toString(playersOnline));
encodeDataPair(data, "revision", String.valueOf(REVISION));
appendJSONPair(json, "guid", guid);
appendJSONPair(json, "plugin_version", pluginVersion);
appendJSONPair(json, "server_version", serverVersion);
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
// New data as of R6
String osname = System.getProperty("os.name");
@ -398,44 +358,63 @@ public class Metrics {
osarch = "x86_64";
}
encodeDataPair(data, "osname", osname);
encodeDataPair(data, "osarch", osarch);
encodeDataPair(data, "osversion", osversion);
encodeDataPair(data, "cores", Integer.toString(coreCount));
encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
encodeDataPair(data, "java_version", java_version);
appendJSONPair(json, "osname", osname);
appendJSONPair(json, "osarch", osarch);
appendJSONPair(json, "osversion", osversion);
appendJSONPair(json, "cores", Integer.toString(coreCount));
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
appendJSONPair(json, "java_version", java_version);
// If we're pinging, append it
if (isPing) {
encodeDataPair(data, "ping", "true");
appendJSONPair(json, "ping", "1");
}
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
// inside of the graph (e.g plotters)
if (graphs.size() > 0) {
synchronized (graphs) {
json.append(',');
json.append('"');
json.append("graphs");
json.append('"');
json.append(':');
json.append('{');
boolean firstGraph = true;
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext()) {
final Graph graph = iter.next();
Graph graph = iter.next();
StringBuilder graphJson = new StringBuilder();
graphJson.append('{');
for (Plotter plotter : graph.getPlotters()) {
// The key name to send to the metrics server
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
final String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
}
// The value to send, which for the foreseeable future is just the string
// value of plotter.getValue()
final String value = Integer.toString(plotter.getValue());
graphJson.append('}');
// Add it to the http post data :)
encodeDataPair(data, key, value);
}
if (!firstGraph) {
json.append(',');
}
json.append(escapeJSON(graph.getName()));
json.append(':');
json.append(graphJson);
firstGraph = false;
}
json.append('}');
}
}
// close json
json.append('}');
// Create the url
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(pluginName)));
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
// Connect to the website
URLConnection connection;
@ -448,26 +427,48 @@ public class Metrics {
connection = url.openConnection();
}
byte[] uncompressed = json.toString().getBytes();
byte[] compressed = gzip(json.toString());
// Headers
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("Content-Encoding", "gzip");
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close");
connection.setDoOutput(true);
if (debug) {
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
}
// Write the data
final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(data.toString());
writer.flush();
OutputStream os = connection.getOutputStream();
os.write(compressed);
os.flush();
// Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final String response = reader.readLine();
String response = reader.readLine();
// close resources
writer.close();
os.close();
reader.close();
if (response == null || response.startsWith("ERR")) {
throw new IOException(response); //Throw the exception
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
if (response == null) {
response = "null";
} else if (response.startsWith("7")) {
response = response.substring(response.startsWith("7,") ? 2 : 1);
}
throw new IOException(response);
} else {
// Is this the first update this hour?
if (response.contains("OK This is your first update this hour")) {
if (response.equals("1") || response.contains("This is your first update this hour")) {
synchronized (graphs) {
final Iterator<Graph> iter = graphs.iterator();
@ -483,6 +484,31 @@ public class Metrics {
}
}
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) try {
gzos.close();
} catch (IOException ignore) {
}
}
return baos.toByteArray();
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
@ -498,20 +524,83 @@ public class Metrics {
}
/**
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
* key/value pair MUST be included manually, e.g:</p>
* <code>
* StringBuffer data = new StringBuffer();
* data.append(encode("guid")).append('=').append(encode(guid));
* encodeDataPair(data, "version", description.getVersion());
* </code>
* Appends a json encoded key/value pair to the given string builder.
*
* @param buffer the stringbuilder to append the data pair onto
* @param key the key value
* @param value the value
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
buffer.append('&').append(encode(key)).append('=').append(encode(value));
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
@ -520,7 +609,7 @@ public class Metrics {
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String encode(final String text) throws UnsupportedEncodingException {
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
@ -530,8 +619,8 @@ public class Metrics {
public static class Graph {
/**
* The graph's name, alphanumeric and spaces only :)
* If it does not comply to the above when submitted, it is rejected
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
* rejected
*/
private final String name;
@ -574,7 +663,7 @@ public class Metrics {
/**
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
*
* @return an unmodifiable {@link Set} of the plotter objects
* @return an unmodifiable {@link java.util.Set} of the plotter objects
*/
public Set<Plotter> getPlotters() {
return Collections.unmodifiableSet(plotters);
@ -596,11 +685,10 @@ public class Metrics {
}
/**
* Called when the server owner decides to opt-out of Metrics while the server is running.
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
*/
protected void onOptOut() {
}
}
/**
@ -630,10 +718,9 @@ public class Metrics {
}
/**
* Get the current value for the plotted point. Since this function defers to an external function
* it may or may not return immediately thus cannot be guaranteed to be thread friendly or safe.
* This function can be called from any thread so care should be taken when accessing resources
* that need to be synchronized.
* Get the current value for the plotted point. Since this function defers to an external function it may or may
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
* from any thread so care should be taken when accessing resources that need to be synchronized.
*
* @return the current value for the point to be plotted.
*/
@ -668,7 +755,5 @@ public class Metrics {
final Plotter plotter = (Plotter) object;
return plotter.name.equals(name) && plotter.getValue() == getValue();
}
}
}

View File

@ -7,3 +7,4 @@ badplayer1:
- 321.321.321.321
badplayer2:
- 111.111.111.111
badplayer3: []

View File

@ -1,6 +1,6 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 2.14
version: 2.22
description: Plugin for the Total Freedom server.
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]

View File

@ -15,7 +15,7 @@ superadmins:
- 127.0.0.1
- 8.8.8.8
last_login: Sun, 11 Nov 2012 01:09:14 -0500
custom_login_message: the &5Chief-Developer&b and &6Master-ass-kicker&b.
custom_login_message: the &4Co-Founder&b and &6Master-ass-kicker&b.
is_senior_admin: true
console_aliases:
- madgeek