mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
66 Commits
Author | SHA1 | Date | |
---|---|---|---|
d40c143afc | |||
95afb51321 | |||
4813b8ae27 | |||
e8d36b31f7 | |||
b2eec1ef01 | |||
3bcc4fd7a7 | |||
e0efb63123 | |||
028d1a07b2 | |||
218fd21774 | |||
0901c02c7e | |||
a4e9bc76a3 | |||
be8314cf63 | |||
f21c7aa5c5 | |||
3f61e05609 | |||
fe93d1ce07 | |||
5132bb6550 | |||
6b7a5d8d70 | |||
6a4a11a2f4 | |||
cbe7cdc474 | |||
07f4bf82ea | |||
8e7c9dcd8e | |||
1ab74dae05 | |||
8ac91f7097 | |||
c482349f47 | |||
b24f1d9247 | |||
2079e0ea66 | |||
0e477f8437 | |||
c3fc085adc | |||
aad8f17455 | |||
d43fa35e52 | |||
fdfa30b349 | |||
e56c273457 | |||
f3087f0dca | |||
dbed7b7f83 | |||
4caa984cef | |||
ef2e17c33f | |||
53614d174e | |||
123884329c | |||
37e78dceec | |||
8f6d71fffb | |||
3935bcf09f | |||
b9bd046105 | |||
1fcda4a8fc | |||
f8e62a9893 | |||
aaf96d00a9 | |||
4903f009b3 | |||
3dc51715c5 | |||
f2aaba17de | |||
fa1c9a255c | |||
3c80aaa7c4 | |||
279f69e3de | |||
22bf0c2f62 | |||
f21e50e002 | |||
6d9e9406ec | |||
cd16c7fb10 | |||
11c945c504 | |||
c70e3ad8fd | |||
f63805cca2 | |||
5868540cbb | |||
8ca518528f | |||
4cbbf10871 | |||
93914370a1 | |||
ee87d1147d | |||
391e417882 | |||
0dca359e4c | |||
15fbd0e1f3 |
@ -1,63 +1,50 @@
|
|||||||
# How to contribute
|
# Contributing to TotalFreedomMod #
|
||||||
|
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss.
|
||||||
|
|
||||||
TotalFreedomMod aims to be a fully functional all-op server mod which works in
|
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.
|
||||||
a large range of configurations. In order to be as flexible as possible on the
|
|
||||||
server-end, we encourage contributing to TotalFreedomMod by making 'pull-requests'
|
|
||||||
to this repository.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
|
## Getting Started ##
|
||||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
* 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.
|
* 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.
|
* Clearly describe the issue including steps to reproduce it.
|
||||||
* Make sure you fill in the earliest version that you know has the issue.
|
* Make sure you fill in the earliest version that you know has the issue.
|
||||||
* Fork the repository on GitHub
|
* Fork the repository on GitHub
|
||||||
|
|
||||||
## Making Changes
|
## Making Changes ##
|
||||||
|
|
||||||
* Create a topic branch from where you want to base your work.
|
* Create a topic branch from where you want to base your work.
|
||||||
* This is usually the master branch.
|
* This is usually the master branch.
|
||||||
* Only target release branches if you are certain your addition must be on that
|
* Only target release branches if you are certain your addition must be on that branch.
|
||||||
branch.
|
* To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` 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.
|
* Make changes and commit where necessary.
|
||||||
* Check for unnecessary whitespace with `git diff --check` before committing.
|
* 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 commit messages are in line with those which are already made.
|
||||||
* Make sure your changes build (*and work!*).
|
* Make sure your changes build (<b>and work!</b>).
|
||||||
|
|
||||||
## Tips on getting your pull request accepted
|
## Tips - How To Get Your Pull Request Accepted ##
|
||||||
* Make sure your changes work and compile without difficulty.
|
* Make sure your changes work and compile without difficulty.
|
||||||
* Make sure your change adds something useful, do not add commands to micromanage
|
* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands)
|
||||||
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".
|
* Features must be in line the general idea of "Total Freedom".
|
||||||
* Changes must be directed towards the main "TotalFreedom" server. Adding names such
|
* 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.
|
||||||
as the name of your own TotalFreedom-like server will get your pull request denied.
|
|
||||||
* Do not add yourself to the developer list.
|
* Do not add yourself to the developer list.
|
||||||
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
|
* 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
|
* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command.
|
||||||
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).__
|
||||||
* 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.
|
* Do not increment the version number.
|
||||||
* If you want to add multiple changes, please make one pull request per change. This
|
* 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.
|
||||||
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 make sure there are no bugs in your code.
|
||||||
* Please avoid having to add files in the main namespace where possible.
|
* 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
|
* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits.
|
||||||
unnecessary commits.
|
|
||||||
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
|
* 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.
|
* Please do not spread your addition over several pull-requests.
|
||||||
|
|
||||||
## Submitting Changes
|
## Submitting Your Changes ##
|
||||||
|
|
||||||
* Push your changes to a topic branch in your fork of the repository.
|
* Push your changes to a topic branch in your fork of the repository.
|
||||||
* Submit a pull request to this repository.
|
* Submit a pull request to this repository.
|
||||||
* Explain in detail what each one of your commits changes and point out any big changes.
|
* Explain in detail what each one of your commits changes and point out any big changes.
|
||||||
* Wait as a developer evaluates your changes.
|
* Wait as a developer evaluates your changes.
|
||||||
|
|
||||||
# Additional Resources
|
## Additional Resources ##
|
||||||
|
|
||||||
* [TotalFreedom information](http://totalfreedom.me)
|
* [TotalFreedom information](http://totalfreedom.me)
|
||||||
* [TotalFreedom forums](http://totalfreedom.boards.net)
|
* [TotalFreedom forums](http://totalfreedom.boards.net)
|
||||||
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
|
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
|
||||||
|
16
LICENCE.md
16
LICENCE.md
@ -1,16 +0,0 @@
|
|||||||
# Legal
|
|
||||||
|
|
||||||
TotalFreedomMod by Madgeek1450 and DarthSalamon is an effort to create an opensource plugin to effectively run a "Total Freedom" like all-Op server. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together with the main server "TotalFreedom" (http://totalfreedom.me) TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feel of openness towards the administrators and the players themselves.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
TotalFreedomMod sourcecode is freely available under the GNU GPLv3 License with a few restrictions in place. The license is available here: http://www.gnu.org/licenses/gpl.txt
|
|
||||||
|
|
||||||
The few restrictions are in place to make sure that credit is given to the original authors who remain the maintainers of the plugin and it's sourcecode.
|
|
||||||
|
|
||||||
These are the restrictions under which the sourcecode is licensed:
|
|
||||||
* A un-edited copy of this license must always be included with this sourcecode.
|
|
||||||
* TotalFreedomMod sourcecode and its derrivations are freely distributable between anyone who choses to download it.
|
|
||||||
* You may not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" and "jeromsar" from any part of the sourcecode.
|
|
||||||
* However, compiled binaries (*.jar's) are not to be distributed. If you wish to obtain a copy of TotalFreedomMod you must compile the original sourcecode or it's derivations yourself using an IDE like netbeans. Official superadmins and above of the TotalFreedom (totalfreedom.me) server may obtain a compiled libary with the same limitations as described in this document.
|
|
||||||
* Any conditions on this license may be waived by any of the official developers.
|
|
11
LICENSE.md
Normal file
11
LICENSE.md
Normal 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.
|
@ -1,6 +1,7 @@
|
|||||||
TotalFreedomMod
|
# TotalFreedomMod #
|
||||||
===============
|
|
||||||
|
|
||||||
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
|
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||||
|
|
||||||
Information about the TotalFreedom server can be found at http://totalfreedom.me/
|
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||||
|
|
||||||
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#Thu, 04 Jul 2013 22:45:10 +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.21
|
|
||||||
program.BUILDNUM=255
|
|
||||||
program.BUILDDATE=07/04/2013 10\:45 PM
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Thu Jul 04 22:45:10 CEST 2013
|
#Fri Aug 09 15:38:23 CEST 2013
|
||||||
build.number=256
|
build.number=379
|
||||||
|
@ -32,7 +32,9 @@ jar.archive.disabled=${jnlp.enabled}
|
|||||||
jar.compress=false
|
jar.compress=false
|
||||||
jar.index=${jnlp.enabled}
|
jar.index=${jnlp.enabled}
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${libs.CraftBukkit.classpath}
|
${libs.CraftBukkit.classpath}:\
|
||||||
|
${libs.WorldEdit.classpath}:\
|
||||||
|
${libs.DisguiseCraft.classpath}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# TotalFreedomMod v2.21 Configuration
|
# TotalFreedomMod v2.22 Configuration
|
||||||
# by Madgeek1450 and DarthSalamon
|
# by Madgeek1450 and DarthSalamon
|
||||||
|
|
||||||
# Block placement prevention:
|
# Block placement prevention:
|
||||||
@ -50,26 +50,27 @@ explosiveRadius: 4.0
|
|||||||
#
|
#
|
||||||
blocked_commands:
|
blocked_commands:
|
||||||
# Disabled commands
|
# Disabled commands
|
||||||
- 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.'
|
- 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:/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:/gamemode:Use /creative and /survival to set your gamemode.
|
||||||
- 'n:b:/ban:_'
|
- n:b:/gamerule:_
|
||||||
- 'n:b:/pardon:_'
|
- n:b:/ban:_
|
||||||
- 'n:b:/toggledownfall:_'
|
- n:b:/pardon:_
|
||||||
|
- n:b:/toggledownfall:_
|
||||||
|
- n:b:/ban-ip:_
|
||||||
|
- n:b:/pardon-ip:_
|
||||||
|
|
||||||
# Superadmin commands
|
# Superadmin commands
|
||||||
- 's:b:/kick:_'
|
- s:b:/kick:_
|
||||||
- 's:b:/socialspy:_'
|
- s:b:/socialspy:_
|
||||||
- 's:b:/kill:_'
|
- s:b:/kill:_
|
||||||
- 's:a:/stop'
|
- s:b:/clearhistory:_
|
||||||
- 's:a:/reload'
|
- s:a:/stop:_
|
||||||
- 's:a:/nuke'
|
- s:a:/reload:_
|
||||||
- 's:a:/save-all'
|
- s:a:/nuke:_
|
||||||
- 's:a:/save-on'
|
- s:a:/save-all:_
|
||||||
- 's:a:/save-off'
|
- s:a:/save-on:_
|
||||||
- 's:a:/clearhistory'
|
- s:a:/save-off:_
|
||||||
- 's:a:/butcher'
|
|
||||||
- 's:a://butcher'
|
|
||||||
|
|
||||||
# Automatically wipe dropped objects:
|
# Automatically wipe dropped objects:
|
||||||
auto_wipe: true
|
auto_wipe: true
|
||||||
@ -125,5 +126,12 @@ host_sender_names:
|
|||||||
|
|
||||||
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
||||||
twitterbot_enabled: false
|
twitterbot_enabled: false
|
||||||
twitterbot_url: 'http://tftwitter.darthcraft.net/'
|
twitterbot_url:
|
||||||
twitterbot_secret: ''
|
twitterbot_secret:
|
||||||
|
|
||||||
|
# Pet Protect - Prevent tamed pets from being killed.
|
||||||
|
pet_protect_enabled: true
|
||||||
|
|
||||||
|
# Logs Registration
|
||||||
|
logs_register_password:
|
||||||
|
logs_register_url:
|
||||||
|
@ -14,6 +14,11 @@ public class Command_adminmode extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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"))
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
TotalFreedomMod.adminOnlyMode = false;
|
TotalFreedomMod.adminOnlyMode = false;
|
||||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.Achievement;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -31,6 +32,10 @@ public class Command_cake extends TFM_Command
|
|||||||
{
|
{
|
||||||
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
|
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
|
||||||
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
|
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());
|
TFM_Util.bcastMsg(output.toString());
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Sound;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
@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);
|
final float pitch = (float) (percent * 2.0);
|
||||||
|
|
||||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
p.playSound(randomOffset(p.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
111
src/me/StevenLawson/TotalFreedomMod/Commands/Command_debug.java
Normal file
111
src/me/StevenLawson/TotalFreedomMod/Commands/Command_debug.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "For the bad Superadmins.", usage = "/<command> <playername>")
|
@CommandParameters(description = "For the bad Superadmins.", usage = "/<command> <playername>")
|
||||||
@ -69,7 +70,7 @@ public class Command_doom extends TFM_Command
|
|||||||
// generate explosion
|
// generate explosion
|
||||||
p.getWorld().createExplosion(p.getLocation(), 4F);
|
p.getWorld().createExplosion(p.getLocation(), 4F);
|
||||||
|
|
||||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@ -80,9 +81,9 @@ public class Command_doom extends TFM_Command
|
|||||||
// kill (if not done already)
|
// kill (if not done already)
|
||||||
p.setHealth(0.0);
|
p.setHealth(0.0);
|
||||||
}
|
}
|
||||||
}, 40L); // 2 seconds
|
}.runTaskLater(plugin, 20L * 2L);
|
||||||
|
|
||||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@ -96,7 +97,7 @@ public class Command_doom extends TFM_Command
|
|||||||
// kick player
|
// kick player
|
||||||
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||||
}
|
}
|
||||||
}, 60L); // 3 seconds
|
}.runTaskLater(plugin, 20L * 3L);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -53,9 +54,23 @@ public class Command_enchant extends TFM_Command
|
|||||||
{
|
{
|
||||||
for (Enchantment ench : Enchantment.values())
|
for (Enchantment ench : Enchantment.values())
|
||||||
{
|
{
|
||||||
if (ench.canEnchantItem(itemInHand))
|
/*
|
||||||
|
2013-07-20 23:17:13 [INFO] [TotalFreedomMod]: Command Error: enchant
|
||||||
|
java.lang.NullPointerException
|
||||||
|
at net.minecraft.server.v1_6_R2.EnchantmentDurability.canEnchant(SourceFile:33)
|
||||||
|
at org.bukkit.craftbukkit.v1_6_R2.enchantments.CraftEnchantment.canEnchantItem(CraftEnchantment.java:55)
|
||||||
|
at me.StevenLawson.TotalFreedomMod.Commands.Command_enchant.run(Command_enchant.java:56)
|
||||||
|
*/
|
||||||
|
try
|
||||||
{
|
{
|
||||||
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
if (ench.canEnchantItem(itemInHand))
|
||||||
|
{
|
||||||
|
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TFM_Log.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + sender_p.getName() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -17,16 +18,9 @@ public class Command_firespread extends TFM_Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
playerMsg("Fire spread is now " + ((TotalFreedomMod.allowFireSpread = !args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||||
{
|
|
||||||
TotalFreedomMod.allowFireSpread = true;
|
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TotalFreedomMod.allowFireSpread);
|
||||||
playerMsg("Fire spread is now enabled.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TotalFreedomMod.allowFireSpread = false;
|
|
||||||
playerMsg("Fire spread is now disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
@ -8,6 +7,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
|
@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);
|
TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
|
||||||
TotalFreedomMod.allPlayersFrozen = true;
|
TotalFreedomMod.allPlayersFrozen = true;
|
||||||
TotalFreedomMod.freezePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
|
||||||
|
if (TotalFreedomMod.freezePurgeTask != null)
|
||||||
|
{
|
||||||
|
TotalFreedomMod.freezePurgeTask.cancel();
|
||||||
|
}
|
||||||
|
TotalFreedomMod.freezePurgeTask = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
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);
|
TFM_Util.adminAction("FreezeTimer", "Unfreezing all players", false);
|
||||||
|
|
||||||
TotalFreedomMod.allPlayersFrozen = 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.");
|
playerMsg("Players are now frozen.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
|
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
|
||||||
TotalFreedomMod.allPlayersFrozen = false;
|
TotalFreedomMod.allPlayersFrozen = false;
|
||||||
if (TotalFreedomMod.freezePurgeEventId != 0)
|
if (TotalFreedomMod.freezePurgeTask != null)
|
||||||
{
|
{
|
||||||
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
|
TotalFreedomMod.freezePurgeTask.cancel();
|
||||||
TotalFreedomMod.freezePurgeEventId = 0;
|
|
||||||
}
|
}
|
||||||
playerMsg("Players are now free to move.");
|
playerMsg("Players are now free to move.");
|
||||||
}
|
}
|
||||||
@ -60,6 +57,10 @@ public class Command_fr extends TFM_Command
|
|||||||
if (args[0].toLowerCase().equals("purge"))
|
if (args[0].toLowerCase().equals("purge"))
|
||||||
{
|
{
|
||||||
TotalFreedomMod.allPlayersFrozen = false;
|
TotalFreedomMod.allPlayersFrozen = false;
|
||||||
|
if (TotalFreedomMod.freezePurgeTask != null)
|
||||||
|
{
|
||||||
|
TotalFreedomMod.freezePurgeTask.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
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.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -16,7 +20,7 @@ public class Command_gtfo extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -32,19 +36,19 @@ public class Command_gtfo extends TFM_Command
|
|||||||
return true;
|
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);
|
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
|
// Undo WorldEdits:
|
||||||
|
TFM_WorldEditBridge.getInstance().undo(p, 15);
|
||||||
|
|
||||||
// Op Player
|
// rollback
|
||||||
p.setOp(true);
|
TFM_RollbackManager.rollback(p.getName());
|
||||||
|
|
||||||
//Undo WorldEdits:
|
|
||||||
server.dispatchCommand(p, "/undo 15");
|
|
||||||
|
|
||||||
//rollback
|
|
||||||
|
|
||||||
server.dispatchCommand(sender, "rollback " + p.getName());
|
|
||||||
|
|
||||||
|
|
||||||
// deop
|
// deop
|
||||||
p.setOp(false);
|
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]);
|
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_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:
|
// ban username:
|
||||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
TFM_ServerInterface.banUsername(p.getName(), ban_reason, null, null);
|
||||||
|
|
||||||
// kick Player:
|
// kick Player:
|
||||||
p.kickPlayer("GTFO");
|
p.kickPlayer(ChatColor.RED + "GTFO" + (ban_reason != null ? ("\nReason: " + ChatColor.YELLOW + ban_reason) : ""));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,6 @@ public class Command_halt extends TFM_Command
|
|||||||
{
|
{
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -103,5 +102,4 @@ public class Command_halt extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_TickMeter;
|
import me.StevenLawson.TotalFreedomMod.TFM_TickMeter;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
|
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
|
||||||
@ -16,29 +18,35 @@ public class Command_health extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
Runnable task;
|
new BukkitRunnable()
|
||||||
task = new Runnable() // async
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TFM_TickMeter meter = new TFM_TickMeter(plugin);
|
final TFM_TickMeter meter = new TFM_TickMeter(plugin);
|
||||||
meter.startTicking();
|
meter.startTicking();
|
||||||
Thread.sleep(1000); // per second
|
Thread.sleep(1000); // per second
|
||||||
meter.stopTicking();
|
meter.stopTicking();
|
||||||
|
|
||||||
Runtime runtime = Runtime.getRuntime();
|
final Runtime runtime = Runtime.getRuntime();
|
||||||
int mb = 1048576; // 1024 * 1024
|
final int mb = 1048576; // 1024 * 1024
|
||||||
|
|
||||||
float usedMem = runtime.totalMemory() - runtime.freeMemory();
|
final float usedMem = runtime.totalMemory() - runtime.freeMemory();
|
||||||
|
|
||||||
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
|
new BukkitRunnable()
|
||||||
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem / runtime.totalMemory() * 100) + "%)");
|
{
|
||||||
playerMsg("Max Memory: " + runtime.maxMemory() / mb + "mb");
|
@Override
|
||||||
playerMsg("Ticks per second: " + (meter.getTicks() == 20 ? ChatColor.GREEN : ChatColor.RED) + meter.getTicks());
|
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("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)
|
catch (Exception iex)
|
||||||
{
|
{
|
||||||
@ -46,8 +54,9 @@ public class Command_health extends TFM_Command
|
|||||||
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
|
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
new Thread(task, "TickMeter").start();
|
}.runTaskAsynchronously(TotalFreedomMod.plugin);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class Command_invis extends TFM_Command
|
|||||||
players.add(p.getName());
|
players.add(p.getName());
|
||||||
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
server.dispatchCommand(sender, "smite " + p.getName());
|
Command_smite.smite(p);
|
||||||
smites++;
|
smites++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ public class Command_list extends TFM_Command
|
|||||||
{
|
{
|
||||||
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
|
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.getName().equals("markbyron"))
|
||||||
|
{
|
||||||
|
prefix = (ChatColor.BLUE + "[Owner]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||||
@ -113,27 +112,20 @@ public class Command_lockup extends TFM_Command
|
|||||||
|
|
||||||
cancelLockup(playerdata);
|
cancelLockup(playerdata);
|
||||||
|
|
||||||
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
|
playerdata.setLockupScheduleID(new BukkitRunnable()
|
||||||
{
|
{
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (p.isOnline())
|
if (p.isOnline())
|
||||||
{
|
{
|
||||||
p.openWorkbench(null, true);
|
p.openInventory(p.getInventory());
|
||||||
|
|
||||||
Location l = p.getLocation().clone();
|
|
||||||
l.setPitch(random.nextFloat() * 360.0f);
|
|
||||||
l.setYaw(random.nextFloat() * 360.0f);
|
|
||||||
p.teleport(l);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cancelLockup(playerdata);
|
cancelLockup(playerdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0L, 5L));
|
}.runTaskTimer(plugin, 0L, 5L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
167
src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java
Normal file
167
src/me/StevenLawson/TotalFreedomMod/Commands/Command_logs.java
Normal 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, "&"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
|
||||||
@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/<command>")
|
|
||||||
public class Command_minecraft extends TFM_Command
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
playerMsg("Status of Mojang services:", ChatColor.BLUE);
|
|
||||||
for (String service : TFM_ServiceChecker.getAllStatuses())
|
|
||||||
{
|
|
||||||
playerMsg(service);
|
|
||||||
}
|
|
||||||
playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
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.");
|
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TotalFreedomMod.mobLimiterEnabled);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -13,10 +13,15 @@ public class Command_mp extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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;
|
int removed = 0;
|
||||||
for (World world : server.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
for (Entity ent : world.getLivingEntities())
|
for (Entity ent : world.getLivingEntities())
|
||||||
{
|
{
|
||||||
@ -28,8 +33,6 @@ public class Command_mp extends TFM_Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playerMsg(removed + " mobs removed.");
|
return removed;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,12 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Ambient;
|
|
||||||
import org.bukkit.entity.Creature;
|
|
||||||
import org.bukkit.entity.EnderDragon;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Ghast;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Slime;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||||
@ -22,15 +16,13 @@ public class Command_purgeall extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
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);
|
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
|
||||||
|
|
||||||
// Purge entities
|
// Purge entities
|
||||||
TFM_Util.wipeEntities(true, true);
|
TFM_Util.wipeEntities(true, true);
|
||||||
|
|
||||||
// Undisguise all players
|
// Undisguise all players
|
||||||
server.dispatchCommand(sender, "u *");
|
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
|
||||||
|
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -71,32 +63,30 @@ public class Command_purgeall extends TFM_Command
|
|||||||
{
|
{
|
||||||
p.removePotionEffect(potion_effect.getType());
|
p.removePotionEffect(potion_effect.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncage
|
||||||
|
if (playerdata.isCaged())
|
||||||
|
{
|
||||||
|
playerdata.setCaged(false);
|
||||||
|
playerdata.regenerateHistory();
|
||||||
|
playerdata.clearHistory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear auto-unmute and auto-unfreeze tasks
|
// Clear auto-unmute and auto-unfreeze tasks
|
||||||
if (TotalFreedomMod.mutePurgeEventId != 0)
|
if (TotalFreedomMod.mutePurgeTask != null)
|
||||||
{
|
{
|
||||||
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
|
TotalFreedomMod.mutePurgeTask.cancel();
|
||||||
TotalFreedomMod.mutePurgeEventId = 0;
|
|
||||||
}
|
|
||||||
if (TotalFreedomMod.freezePurgeEventId != 0)
|
|
||||||
{
|
|
||||||
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
|
|
||||||
TotalFreedomMod.freezePurgeEventId = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TotalFreedomMod.allPlayersFrozen = false;
|
||||||
|
if (TotalFreedomMod.freezePurgeTask != null)
|
||||||
|
{
|
||||||
|
TotalFreedomMod.freezePurgeTask.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
// Remove all mobs
|
// Remove all mobs
|
||||||
for (World world : server.getWorlds())
|
Command_mp.purgeMobs();
|
||||||
{
|
|
||||||
for (Entity ent : world.getLivingEntities())
|
|
||||||
{
|
|
||||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
|
|
||||||
{
|
|
||||||
ent.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_RadarData;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -71,4 +71,39 @@ public class Command_radar extends TFM_Command
|
|||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,74 +14,61 @@ public class Command_rollback extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length > 2)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return false;
|
if (args[0].equalsIgnoreCase("purgeall"))
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 1 && args[0].equalsIgnoreCase("purgeall"))
|
|
||||||
{
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Puring all rollback data", false);
|
|
||||||
playerMsg("Purged entries for " + TFM_RollbackManager.purgeEntries() + " players.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2 && args[0].equalsIgnoreCase("purge"))
|
|
||||||
{
|
|
||||||
OfflinePlayer p;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
p = getPlayer(args[1]);
|
TFM_Util.adminAction(sender.getName(), "Purging all rollback history.", false);
|
||||||
}
|
playerMsg("Purged all rollback history for " + TFM_RollbackManager.purgeEntries() + " players.");
|
||||||
catch (CantFindPlayerException ex)
|
|
||||||
{
|
|
||||||
p = server.getOfflinePlayer(args[1]);
|
|
||||||
if (!p.hasPlayedBefore())
|
|
||||||
{
|
|
||||||
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TFM_RollbackManager.canRollback(p.getName()))
|
|
||||||
{
|
|
||||||
playerMsg("No rollback data found for that player", ChatColor.RED);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries.");
|
String playerName = getPlayerName(args[0]);
|
||||||
return true;
|
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.length != 1)
|
{
|
||||||
|
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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer p;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPlayerName(String playerNameInput)
|
||||||
|
{
|
||||||
|
String playerName = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = getPlayer(args[0]);
|
Player player = getPlayer(playerNameInput);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
playerName = player.getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CantFindPlayerException ex)
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = server.getOfflinePlayer(args[0]);
|
|
||||||
if (!p.hasPlayedBefore())
|
|
||||||
{
|
|
||||||
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TFM_RollbackManager.canRollback(p.getName()))
|
if (playerName == null)
|
||||||
{
|
{
|
||||||
playerMsg("Player has no rollback data set.", ChatColor.RED);
|
playerName = TFM_UserList.getInstance(plugin).searchByPartialName(playerNameInput);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + p.getName(), false);
|
return playerName;
|
||||||
playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,34 +13,12 @@ public class Command_setl extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
//server.dispatchCommand(sender, "wildcard gcmd ? /limit 500"); - Madgeek: No, no, hell no.
|
|
||||||
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
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())
|
for (final Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final boolean isOp = p.isOp();
|
web.setLimit(p, 500);
|
||||||
|
|
||||||
if (!isOp)
|
|
||||||
{
|
|
||||||
p.setOp(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
server.dispatchCommand(p, "/limit 500");
|
|
||||||
|
|
||||||
if (!isOp)
|
|
||||||
{
|
|
||||||
server.getScheduler().runTaskLater(plugin, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
p.setOp(false);
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,13 @@ public class Command_smite extends TFM_Command
|
|||||||
return true;
|
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);
|
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
//Deop
|
//Deop
|
||||||
@ -57,7 +64,5 @@ public class Command_smite extends TFM_Command
|
|||||||
|
|
||||||
//Kill:
|
//Kill:
|
||||||
p.setHealth(0.0);
|
p.setHealth(0.0);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,48 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
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 org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.JSONValue;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
||||||
public class Command_status extends TFM_Command
|
public class Command_status extends TFM_Command
|
||||||
{
|
{
|
||||||
|
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
|
||||||
|
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
|
||||||
|
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
|
||||||
|
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
|
||||||
|
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
|
||||||
|
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, Player 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("For information about TotalFreedomMod, try /tfm", ChatColor.GREEN); // Temporary
|
||||||
playerMsg("TotalFreedomMod was created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
|
|
||||||
|
|
||||||
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
|
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
|
||||||
|
|
||||||
playerMsg("Loaded worlds:", ChatColor.BLUE);
|
playerMsg("Loaded worlds:", ChatColor.BLUE);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (World world : server.getWorlds())
|
for (World world : server.getWorlds())
|
||||||
@ -26,6 +50,66 @@ public class Command_status extends TFM_Command
|
|||||||
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
URL mojang_status = new URL("http://status.mojang.com/check");
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
||||||
|
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
|
||||||
|
|
||||||
|
Iterator status_it = status_json.iterator();
|
||||||
|
while (status_it.hasNext())
|
||||||
|
{
|
||||||
|
JSONObject service = (JSONObject) status_it.next();
|
||||||
|
Iterator service_it = service.entrySet().iterator();
|
||||||
|
while (service_it.hasNext())
|
||||||
|
{
|
||||||
|
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
||||||
|
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> status_output = new ArrayList<String>();
|
||||||
|
|
||||||
|
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
|
||||||
|
while (output_it.hasNext())
|
||||||
|
{
|
||||||
|
Entry<String, Boolean> pair = output_it.next();
|
||||||
|
String service_name = pair.getKey();
|
||||||
|
boolean service_online = pair.getValue().booleanValue();
|
||||||
|
|
||||||
|
if (SERVICE_MAP.containsKey(service_name))
|
||||||
|
{
|
||||||
|
service_name = SERVICE_MAP.get(service_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
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_PlayerData;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [<player> | list | purge | all]", aliases = "mute")
|
@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++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TotalFreedomMod.mutePurgeEventId != 0)
|
if (TotalFreedomMod.mutePurgeTask != null)
|
||||||
{
|
{
|
||||||
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
|
TotalFreedomMod.mutePurgeTask.cancel();
|
||||||
TotalFreedomMod.mutePurgeEventId = 0;
|
|
||||||
}
|
}
|
||||||
playerMsg("Unmuted " + count + " players.");
|
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
|
@Override
|
||||||
public void run()
|
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);
|
TFM_Util.adminAction("MuteTimer", "Unmuting all players", false);
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
TFM_PlayerData.getPlayerData(p).setMuted(false);
|
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.");
|
playerMsg("Muted " + counter + " players.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,6 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||||
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
@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/BukkitHttpd.jar",
|
||||||
"http://s3.madgeekonline.com/totalfreedom/BukkitTelnet.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/Essentials.jar",
|
||||||
"http://s3.madgeekonline.com/totalfreedom/EssentialsSpawn.jar",
|
"http://s3.madgeekonline.com/totalfreedom/EssentialsSpawn.jar",
|
||||||
"http://s3.madgeekonline.com/totalfreedom/TotalFreedomMod.jar",
|
"http://s3.madgeekonline.com/totalfreedom/TotalFreedomMod.jar",
|
||||||
@ -34,7 +36,7 @@ public class Command_tfupdate extends TFM_Command
|
|||||||
|
|
||||||
for (final String url : FILES)
|
for (final String url : FILES)
|
||||||
{
|
{
|
||||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@ -60,7 +62,7 @@ public class Command_tfupdate extends TFM_Command
|
|||||||
TFM_Log.severe(ex);
|
TFM_Log.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,17 +15,7 @@ public class Command_uall extends TFM_Command
|
|||||||
{
|
{
|
||||||
TFM_Util.adminAction(sender.getName(), "Undisguising all players", true);
|
TFM_Util.adminAction(sender.getName(), "Undisguising all players", true);
|
||||||
|
|
||||||
if (senderIsConsole)
|
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
|
||||||
{
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
server.dispatchCommand(p, "u");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server.dispatchCommand(sender, "u *");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
|||||||
import java.security.CodeSource;
|
import java.security.CodeSource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -22,7 +23,7 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
public class TFM_CommandLoader
|
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 List<TFM_CommandInfo> commandList = null;
|
||||||
|
|
||||||
private TFM_CommandLoader()
|
private TFM_CommandLoader()
|
||||||
@ -31,10 +32,10 @@ public class TFM_CommandLoader
|
|||||||
|
|
||||||
public void scan()
|
public void scan()
|
||||||
{
|
{
|
||||||
CommandMap commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
CommandMap commandMap = getCommandMap();
|
||||||
if (commandMap == null)
|
if (commandMap == null)
|
||||||
{
|
{
|
||||||
TFM_Log.severe("Error loading command map.");
|
TFM_Log.severe("Error loading commandMap.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +59,82 @@ public class TFM_CommandLoader
|
|||||||
description = "OP Command - " + description;
|
description = "OP Command - " + description;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
|
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);
|
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()
|
private static List<TFM_CommandInfo> getCommands()
|
||||||
@ -138,7 +212,7 @@ public class TFM_CommandLoader
|
|||||||
this.blockHostConsole = blockHostConsole;
|
this.blockHostConsole = blockHostConsole;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.usage = usage;
|
this.usage = usage;
|
||||||
this.aliases = Arrays.asList(aliases.split(","));
|
this.aliases = ("".equals(aliases) ? new ArrayList<String>() : Arrays.asList(aliases.split(",")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getAliases()
|
public List<String> getAliases()
|
||||||
|
@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Listener;
|
|||||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackEntry;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
@ -100,6 +99,12 @@ public class TFM_BlockListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
TFM_RollbackManager.blockBreak(event);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
@ -237,6 +242,12 @@ public class TFM_BlockListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onRollbackBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
TFM_RollbackManager.blockPlace(event);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockFromTo(BlockFromToEvent event)
|
public void onBlockFromTo(BlockFromToEvent event)
|
||||||
{
|
{
|
||||||
@ -245,38 +256,4 @@ public class TFM_BlockListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onBlockPlaceRollback(BlockPlaceEvent event)
|
|
||||||
{
|
|
||||||
TFM_RollbackEntry entry = new TFM_RollbackEntry();
|
|
||||||
entry.setLocation(event.getBlock().getLocation());
|
|
||||||
entry.setMaterial(Material.AIR);
|
|
||||||
TFM_RollbackManager.blockUpdate(event.getPlayer(), entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onBlockBreakRollback(BlockBreakEvent event)
|
|
||||||
{
|
|
||||||
TFM_RollbackManager.blockUpdate(event.getPlayer(), event.getBlock());
|
|
||||||
}
|
|
||||||
// @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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,19 @@ public class TFM_EntityListener implements Listener
|
|||||||
case LAVA:
|
case LAVA:
|
||||||
{
|
{
|
||||||
if (!TotalFreedomMod.allowLavaDamage)
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
import me.StevenLawson.TotalFreedomMod.*;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -30,19 +22,9 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class TFM_PlayerListener implements Listener
|
public class TFM_PlayerListener implements Listener
|
||||||
@ -70,6 +52,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case LAVA_BUCKET:
|
case LAVA_BUCKET:
|
||||||
{
|
{
|
||||||
@ -80,6 +63,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case EXPLOSIVE_MINECART:
|
case EXPLOSIVE_MINECART:
|
||||||
{
|
{
|
||||||
@ -89,8 +73,8 @@ public class TFM_PlayerListener implements Listener
|
|||||||
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -206,7 +190,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
last_block = test_block;
|
last_block = test_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@ -218,7 +202,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
tnt_block.setType(Material.AIR);
|
tnt_block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 30L);
|
}.runTaskLater(TotalFreedomMod.plugin, 30L);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -524,7 +508,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
command = command.toLowerCase().trim();
|
command = command.toLowerCase().trim();
|
||||||
|
|
||||||
// Blocked commands
|
// Blocked commands
|
||||||
if (TFM_CommandBlocker.isCommandBlocked(command, event.getPlayer()))
|
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(command, event.getPlayer()))
|
||||||
{
|
{
|
||||||
// CommandBlocker handles messages and broadcasts
|
// CommandBlocker handles messages and broadcasts
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -542,24 +526,6 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onRemoteServerCommand(RemoteServerCommandEvent event)
|
|
||||||
{
|
|
||||||
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
|
|
||||||
{
|
|
||||||
event.setCommand("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onServerCommand(ServerCommandEvent event)
|
|
||||||
{
|
|
||||||
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
|
|
||||||
{
|
|
||||||
event.setCommand("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
@ -655,14 +621,14 @@ public class TFM_PlayerListener implements Listener
|
|||||||
|
|
||||||
if (TotalFreedomMod.adminOnlyMode)
|
if (TotalFreedomMod.adminOnlyMode)
|
||||||
{
|
{
|
||||||
TotalFreedomMod.plugin.getServer().getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
p.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
p.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||||
}
|
}
|
||||||
}, 60L);
|
}.runTaskLater(TotalFreedomMod.plugin, 20L * 3L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
@ -675,21 +641,4 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
TFM_ServerInterface.handlePlayerLogin(event);
|
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!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TotalFreedomMod.adminOnlyMode)
|
|
||||||
{
|
|
||||||
event.setMotd(ChatColor.RED + "Server in AdminMode!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,20 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public class TFM_CommandBlocker
|
public class TFM_CommandBlocker
|
||||||
{
|
{
|
||||||
|
public static boolean isCommandBlocked(String usedcommand, CommandSender sender)
|
||||||
public static boolean isCommandBlocked(String command, CommandSender sender)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
String name = sender.getName();
|
String name = sender.getName();
|
||||||
command = command.toLowerCase().trim();
|
usedcommand = usedcommand.toLowerCase().trim();
|
||||||
|
|
||||||
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
||||||
{
|
{
|
||||||
String[] parts = blocked_command.split(":");
|
String[] parts = blocked_command.split(":");
|
||||||
@ -22,11 +23,38 @@ public class TFM_CommandBlocker
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(command + " ").startsWith(parts[2] + " "))
|
if (!(usedcommand + " ").startsWith(parts[2] + " "))
|
||||||
{
|
{
|
||||||
continue;
|
|
||||||
|
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]))
|
if (SenderRank.hasPermissions(sender, parts[0]))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -47,8 +75,6 @@ public class TFM_CommandBlocker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Log.info("Player Rank: " + SenderRank.getSenderRank(sender).rank);
|
|
||||||
|
|
||||||
// Action
|
// Action
|
||||||
if ("b".equals(parts[1]))
|
if ("b".equals(parts[1]))
|
||||||
{
|
{
|
||||||
@ -58,7 +84,7 @@ public class TFM_CommandBlocker
|
|||||||
{
|
{
|
||||||
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
|
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
|
||||||
{
|
{
|
||||||
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + command);
|
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + usedcommand);
|
||||||
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -82,7 +108,6 @@ public class TFM_CommandBlocker
|
|||||||
TELNET("t", 3),
|
TELNET("t", 3),
|
||||||
SENIOR("c", 4),
|
SENIOR("c", 4),
|
||||||
NOBODY("n", 5);
|
NOBODY("n", 5);
|
||||||
|
|
||||||
private String letter = "n";
|
private String letter = "n";
|
||||||
private int rank = 5;
|
private int rank = 5;
|
||||||
|
|
||||||
@ -135,10 +160,5 @@ public class TFM_CommandBlocker
|
|||||||
}
|
}
|
||||||
return SenderRank.NOBODY;
|
return SenderRank.NOBODY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
328
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlockerNew.java
Normal file
328
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlockerNew.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
118
src/me/StevenLawson/TotalFreedomMod/TFM_GameRuleHandler.java
Normal file
118
src/me/StevenLawson/TotalFreedomMod/TFM_GameRuleHandler.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,9 @@ package me.StevenLawson.TotalFreedomMod;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
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 TotalFreedomMod plugin;
|
||||||
private final Server server;
|
private final Server server;
|
||||||
@ -31,23 +32,6 @@ public class TFM_Heartbeat implements Runnable
|
|||||||
TFM_Util.wipeEntities(!TotalFreedomMod.allowExplosions, false);
|
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)
|
if (TotalFreedomMod.disableWeather)
|
||||||
{
|
{
|
||||||
for (World world : server.getWorlds())
|
for (World world : server.getWorlds())
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class TFM_PlayerData
|
public class TFM_PlayerData
|
||||||
@ -330,7 +331,7 @@ public class TFM_PlayerData
|
|||||||
public void startArrowShooter(TotalFreedomMod plugin)
|
public void startArrowShooter(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
this.stopArrowShooter();
|
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;
|
mp44_firing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +345,7 @@ public class TFM_PlayerData
|
|||||||
mp44_firing = false;
|
mp44_firing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArrowShooter implements Runnable
|
private class ArrowShooter extends BukkitRunnable
|
||||||
{
|
{
|
||||||
private Player _player;
|
private Player _player;
|
||||||
|
|
||||||
@ -415,7 +416,6 @@ public class TFM_PlayerData
|
|||||||
stopOrbiting();
|
stopOrbiting();
|
||||||
setFrozen(true);
|
setFrozen(true);
|
||||||
setMuted(true);
|
setMuted(true);
|
||||||
setHalted(true);
|
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
|
player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
|
||||||
}
|
}
|
||||||
@ -425,11 +425,10 @@ public class TFM_PlayerData
|
|||||||
player.setGameMode(GameMode.CREATIVE);
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
setFrozen(false);
|
setFrozen(false);
|
||||||
setMuted(false);
|
setMuted(false);
|
||||||
setHalted(false);
|
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitTask getLockupScheduleID()
|
public BukkitTask getLockupScheduleID()
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
public class TFM_RollbackEntry
|
|
||||||
{
|
|
||||||
private Location location;
|
|
||||||
private Material material;
|
|
||||||
private byte data;
|
|
||||||
|
|
||||||
public TFM_RollbackEntry()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public TFM_RollbackEntry(Block block)
|
|
||||||
{
|
|
||||||
location = block.getLocation();
|
|
||||||
material = block.getType();
|
|
||||||
data = block.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlock(Block block)
|
|
||||||
{
|
|
||||||
location = block.getLocation();
|
|
||||||
material = block.getType();
|
|
||||||
data = block.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(Location location)
|
|
||||||
{
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaterial(Material material)
|
|
||||||
{
|
|
||||||
this.material = material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(byte data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restore()
|
|
||||||
{
|
|
||||||
Block b = location.getWorld().getBlockAt(location);
|
|
||||||
b.setType(material);
|
|
||||||
b.setData(data);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,85 +2,137 @@ package me.StevenLawson.TotalFreedomMod;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TFM_RollbackManager
|
public class TFM_RollbackManager
|
||||||
{
|
{
|
||||||
public static Map<String, List<TFM_RollbackEntry>> entries = new HashMap<String, List<TFM_RollbackEntry>>();
|
private static final Map<String, List<TFM_RollbackManager_Entry>> PLAYER_HISTORY_MAP = new HashMap<String, List<TFM_RollbackManager_Entry>>();
|
||||||
|
|
||||||
public static void blockUpdate(OfflinePlayer player, Block block)
|
private TFM_RollbackManager()
|
||||||
{
|
{
|
||||||
List<TFM_RollbackEntry> e;
|
throw new AssertionError();
|
||||||
if (entries.containsKey(player.getName()))
|
|
||||||
{
|
|
||||||
e = entries.get(player.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e = new ArrayList<TFM_RollbackEntry>();
|
|
||||||
}
|
|
||||||
e.add(0, new TFM_RollbackEntry(block));
|
|
||||||
entries.put(player.getName(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void blockUpdate(OfflinePlayer player, TFM_RollbackEntry entry)
|
public static void blockPlace(org.bukkit.event.block.BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
List<TFM_RollbackEntry> e;
|
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_PLACE));
|
||||||
if (entries.containsKey(player.getName()))
|
|
||||||
{
|
|
||||||
e = entries.get(player.getName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e = new ArrayList<TFM_RollbackEntry>();
|
|
||||||
}
|
|
||||||
e.add(0, entry);
|
|
||||||
entries.put(player.getName(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int rollback(OfflinePlayer player)
|
public static void blockBreak(org.bukkit.event.block.BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (!canRollback(player.getName()))
|
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_BREAK));
|
||||||
{
|
|
||||||
TFM_Log.severe("Could not rollback player: " + player.getName() + "! No entries are set");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TFM_RollbackEntry> e = entries.get(player.getName());
|
|
||||||
int counter = 0;
|
|
||||||
for (TFM_RollbackEntry entry : e)
|
|
||||||
{
|
|
||||||
entry.restore();
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
entries.remove(player.getName());
|
|
||||||
return counter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canRollback(String player)
|
private static void storeEntry(Player player, TFM_RollbackManager_Entry entry)
|
||||||
{
|
{
|
||||||
return entries.containsKey(player);
|
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(player.getName());
|
||||||
|
if (playerEntryList != null)
|
||||||
|
{
|
||||||
|
playerEntryList.add(0, entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int purgeEntries()
|
public static int purgeEntries()
|
||||||
{
|
{
|
||||||
int counter = entries.size();
|
Iterator<List<TFM_RollbackManager_Entry>> it = PLAYER_HISTORY_MAP.values().iterator();
|
||||||
entries.clear();
|
while (it.hasNext())
|
||||||
return counter;
|
{
|
||||||
|
List<TFM_RollbackManager_Entry> playerEntryList = it.next();
|
||||||
|
if (playerEntryList != null)
|
||||||
|
{
|
||||||
|
playerEntryList.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PLAYER_HISTORY_MAP.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int purgeEntries(String player)
|
public static int purgeEntries(String playerName)
|
||||||
{
|
{
|
||||||
if (!canRollback(player))
|
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(playerName);
|
||||||
|
if (playerEntryList != null)
|
||||||
{
|
{
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int counter = entries.get(player).size();
|
public void restore()
|
||||||
entries.remove(player);
|
{
|
||||||
return counter;
|
Block b = this.location.getWorld().getBlockAt(this.location);
|
||||||
|
b.setType(this.material);
|
||||||
|
b.setData(this.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,11 +5,11 @@ import java.util.Date;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import net.minecraft.server.v1_6_R1.BanEntry;
|
import net.minecraft.server.v1_6_R2.BanEntry;
|
||||||
import net.minecraft.server.v1_6_R1.BanList;
|
import net.minecraft.server.v1_6_R2.BanList;
|
||||||
import net.minecraft.server.v1_6_R1.MinecraftServer;
|
import net.minecraft.server.v1_6_R2.MinecraftServer;
|
||||||
import net.minecraft.server.v1_6_R1.PlayerList;
|
import net.minecraft.server.v1_6_R2.PlayerList;
|
||||||
import net.minecraft.server.v1_6_R1.PropertyManager;
|
import net.minecraft.server.v1_6_R2.PropertyManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -121,6 +121,8 @@ public class TFM_ServerInterface
|
|||||||
|
|
||||||
public static void handlePlayerLogin(PlayerLoginEvent event)
|
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();
|
final Server server = TotalFreedomMod.plugin.getServer();
|
||||||
|
|
||||||
@ -135,8 +137,7 @@ public class TFM_ServerInterface
|
|||||||
|
|
||||||
if (player_name.trim().length() <= 2)
|
if (player_name.trim().length() <= 2)
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long).");
|
||||||
"Your username is too short (must be at least 3 characters long).");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find())
|
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find())
|
||||||
@ -145,8 +146,7 @@ public class TFM_ServerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress()
|
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login.
|
||||||
// will return a null until after player login.
|
|
||||||
boolean is_superadmin;
|
boolean is_superadmin;
|
||||||
if (server.getOnlineMode())
|
if (server.getOnlineMode())
|
||||||
{
|
{
|
||||||
@ -171,8 +171,7 @@ public class TFM_ServerInterface
|
|||||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||||
if (ban_entry.getExpires() != null)
|
if (ban_entry.getExpires() != null)
|
||||||
{
|
{
|
||||||
kick_message = kick_message + "\nYour ban will be removed on "
|
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||||
+ date_format.format(ban_entry.getExpires());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +215,7 @@ public class TFM_ServerInterface
|
|||||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||||
if (ban_entry.getExpires() != null)
|
if (ban_entry.getExpires() != null)
|
||||||
{
|
{
|
||||||
kick_message = kick_message + "\nYour ban will be removed on "
|
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||||
+ date_format.format(ban_entry.getExpires());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +227,7 @@ public class TFM_ServerInterface
|
|||||||
{
|
{
|
||||||
if (test_player.equalsIgnoreCase(player_name))
|
if (test_player.equalsIgnoreCase(player_name))
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.");
|
||||||
+ "Your username is permanently banned from this server.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,8 +236,7 @@ public class TFM_ServerInterface
|
|||||||
{
|
{
|
||||||
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
|
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.");
|
||||||
+ "Your IP address is permanently banned from this server.");
|
|
||||||
return;
|
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())
|
for (Player test_player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (test_player.getName().equalsIgnoreCase(player_name))
|
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");
|
can_kick = true;
|
||||||
return;
|
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())
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, this server is full");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVersion()
|
||||||
|
{
|
||||||
|
return MinecraftServer.getServer().getVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,208 +0,0 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.apache.commons.lang.WordUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.JSONValue;
|
|
||||||
|
|
||||||
public class TFM_ServiceChecker
|
|
||||||
{
|
|
||||||
private static final Map<String, String[]> SERVICE_MAP = new HashMap<String, String[]>();
|
|
||||||
public static String check_url = "http://xpaw.ru/mcstatus/status.json";
|
|
||||||
public static String version = "1.0";
|
|
||||||
public static String last_updated = ""; // On xpaw.ru
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
// <"up", "down", "problem">, <"Online", "Quite Slow", "Error 505", etc>, <String (Uptime percentage)>
|
|
||||||
SERVICE_MAP.put("website", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
SERVICE_MAP.put("session", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
SERVICE_MAP.put("login", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
SERVICE_MAP.put("account", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
SERVICE_MAP.put("skins", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
SERVICE_MAP.put("realms", new String[]
|
|
||||||
{
|
|
||||||
"up", "Online", "100.00"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public static Runnable checker = new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
runCheck();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void runCheck()
|
|
||||||
{
|
|
||||||
TotalFreedomMod.server.getScheduler().runTaskAsynchronously(TotalFreedomMod.plugin, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
/* // Nubcakes be 403'ing us >;o
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(check_url).openStream()));
|
|
||||||
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
|
|
||||||
in.close();
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Well, lets bypass that! >:D
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(check_url).openConnection();
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
|
||||||
connection.setRequestProperty("Host", "xpaw.ru");
|
|
||||||
connection.setRequestProperty("Accept", "*/*");
|
|
||||||
connection.setUseCaches(false);
|
|
||||||
connection.setDoInput(true);
|
|
||||||
connection.setDoOutput(false);
|
|
||||||
InputStream is = connection.getInputStream();
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(is));
|
|
||||||
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
|
|
||||||
in.close();
|
|
||||||
connection.disconnect();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
version = String.valueOf(service_json.get("v"));
|
|
||||||
last_updated = (String) service_json.get("last_updated");
|
|
||||||
|
|
||||||
JSONObject services = (JSONObject) service_json.get("report");
|
|
||||||
for (String service : SERVICE_MAP.keySet())
|
|
||||||
{
|
|
||||||
JSONObject service_info = (JSONObject) services.get(service);
|
|
||||||
SERVICE_MAP.put(service, new String[]
|
|
||||||
{
|
|
||||||
(String) service_info.get("status"),
|
|
||||||
(String) service_info.get("title"),
|
|
||||||
(String) service_info.get("uptime")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TFM_Log.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getFormattedStatus(String service_name)
|
|
||||||
{
|
|
||||||
String[] service = SERVICE_MAP.get(service_name);
|
|
||||||
String status = ("up".equals(service[0]) ? ChatColor.GREEN
|
|
||||||
: ("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString();
|
|
||||||
|
|
||||||
status += service[1] + ChatColor.GRAY + " (";
|
|
||||||
|
|
||||||
status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN
|
|
||||||
: (Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED));
|
|
||||||
|
|
||||||
status += service[2] + "%" + ChatColor.GRAY + ")";
|
|
||||||
|
|
||||||
return ChatColor.GRAY + WordUtils.capitalize(service_name) + ChatColor.WHITE + ": " + status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAllStatuses()
|
|
||||||
{
|
|
||||||
List<String> statuses = new ArrayList<String>();
|
|
||||||
for (String status : SERVICE_MAP.keySet())
|
|
||||||
{
|
|
||||||
statuses.add(getFormattedStatus(status));
|
|
||||||
}
|
|
||||||
return statuses;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* // Mojang status
|
|
||||||
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
|
|
||||||
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
|
|
||||||
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
|
|
||||||
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
|
|
||||||
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
|
|
||||||
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
|
|
||||||
}
|
|
||||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
|
||||||
{
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
URL mojang_status = new URL("http://status.mojang.com/check");
|
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
|
||||||
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
|
|
||||||
|
|
||||||
Iterator status_it = status_json.iterator();
|
|
||||||
while (status_it.hasNext())
|
|
||||||
{
|
|
||||||
JSONObject service = (JSONObject) status_it.next();
|
|
||||||
Iterator service_it = service.entrySet().iterator();
|
|
||||||
while (service_it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
|
||||||
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> status_output = new ArrayList<String>();
|
|
||||||
|
|
||||||
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
|
|
||||||
while (output_it.hasNext())
|
|
||||||
{
|
|
||||||
Entry<String, Boolean> pair = output_it.next();
|
|
||||||
String service_name = pair.getKey();
|
|
||||||
boolean service_online = pair.getValue().booleanValue();
|
|
||||||
|
|
||||||
if (SERVICE_MAP.containsKey(service_name))
|
|
||||||
{
|
|
||||||
service_name = SERVICE_MAP.get(service_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
|
|
||||||
}
|
|
||||||
|
|
||||||
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TFM_Log.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.Commands.Command_logs;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -386,6 +387,7 @@ public class TFM_SuperadminList
|
|||||||
{
|
{
|
||||||
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
||||||
superadmin.setActivated(false);
|
superadmin.setActivated(false);
|
||||||
|
Command_logs.deactivateSuperadmin(superadmin);
|
||||||
saveSuperadminList();
|
saveSuperadminList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,6 +425,7 @@ public class TFM_SuperadminList
|
|||||||
}
|
}
|
||||||
|
|
||||||
superadmin.setActivated(false);
|
superadmin.setActivated(false);
|
||||||
|
Command_logs.deactivateSuperadmin(superadmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class TFM_TickMeter
|
|||||||
{
|
{
|
||||||
ticks += 1;
|
ticks += 1;
|
||||||
}
|
}
|
||||||
}, 1L, 1L); // ticks (20 in 1 second)
|
}, 1L, 1L); // ticks (20 in 1 second)
|
||||||
|
|
||||||
taskId = tId;
|
taskId = tId;
|
||||||
return tId;
|
return tId;
|
||||||
|
@ -4,8 +4,10 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -125,6 +127,25 @@ public class TFM_UserList
|
|||||||
exportList();
|
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
|
public class TFM_UserListEntry
|
||||||
{
|
{
|
||||||
private String _username;
|
private String _username;
|
||||||
|
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
@ -13,8 +12,6 @@ import java.util.jar.JarFile;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.ZipEntry;
|
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.StringUtils;
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -305,77 +302,6 @@ public class TFM_Util
|
|||||||
return TFM_Util.mobtypes.get(mobname);
|
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
|
private static void copy(InputStream in, OutputStream out) throws IOException
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
@ -969,8 +895,7 @@ public class TFM_Util
|
|||||||
{
|
{
|
||||||
if (TFM_SuperadminList.isUserSuperadmin(p))
|
if (TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED
|
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.AQUA + message);
|
||||||
+ name + ": " + ChatColor.AQUA + message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1035,4 +960,23 @@ public class TFM_Util
|
|||||||
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||||
return 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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
123
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal file
123
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,7 @@ import java.io.InputStream;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener;
|
import me.StevenLawson.TotalFreedomMod.Listener.*;
|
||||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_PlayerListener;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.Listener.TFM_WeatherListener;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,40 +20,42 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.mcstats.Metrics;
|
import org.mcstats.Metrics;
|
||||||
|
|
||||||
public class TotalFreedomMod extends JavaPlugin
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
public static final Server server = Bukkit.getServer();
|
public static final Server server = Bukkit.getServer();
|
||||||
|
//
|
||||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||||
public static final long SERVICE_CHECKER_RATE = 30L;
|
public static final long SERVICE_CHECKER_RATE = 30L;
|
||||||
|
//
|
||||||
public static final String CONFIG_FILE = "config.yml";
|
public static final String CONFIG_FILE = "config.yml";
|
||||||
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||||
public static final String PERMBAN_FILE = "permban.yml";
|
public static final String PERMBAN_FILE = "permban.yml";
|
||||||
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
|
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
|
||||||
public static final String SAVED_FLAGS_FILE = "savedflags.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_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
||||||
public static final String COMMAND_PREFIX = "Command_";
|
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 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_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 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 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 final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||||
|
//
|
||||||
public static boolean allPlayersFrozen = false;
|
public static boolean allPlayersFrozen = false;
|
||||||
public static int freezePurgeEventId = 0;
|
public static BukkitTask freezePurgeTask = null;
|
||||||
public static int mutePurgeEventId = 0;
|
public static BukkitTask mutePurgeTask = null;
|
||||||
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
|
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
|
||||||
|
//
|
||||||
public static String pluginVersion = "";
|
public static String pluginVersion = "";
|
||||||
public static String buildNumber = "";
|
public static String buildNumber = "";
|
||||||
public static String buildDate = "";
|
public static String buildDate = "";
|
||||||
public static String pluginName = "";
|
public static String pluginName = "";
|
||||||
|
//
|
||||||
public static TotalFreedomMod plugin = null;
|
public static TotalFreedomMod plugin = null;
|
||||||
public static File plugin_file = null;
|
public static File plugin_file = null;
|
||||||
|
|
||||||
@ -95,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)
|
if (TotalFreedomMod.protectedAreasEnabled)
|
||||||
{
|
{
|
||||||
TFM_ProtectedArea.loadProtectedAreas();
|
TFM_ProtectedArea.loadProtectedAreas();
|
||||||
@ -103,15 +112,23 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
TFM_Util.deleteFolder(new File("./_deleteme"));
|
TFM_Util.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
|
File[] coreDumps = new File(".").listFiles(new java.io.FileFilter()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean accept(File file)
|
||||||
|
{
|
||||||
|
return file.getName().startsWith("java.core");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (File dump : coreDumps)
|
||||||
|
{
|
||||||
|
TFM_Log.info("Removing core dump file: " + dump.getName());
|
||||||
|
dump.delete();
|
||||||
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
new TFM_Heartbeat(this).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||||
|
|
||||||
// Service uptime checker
|
|
||||||
server.getScheduler().scheduleSyncRepeatingTask(this, TFM_ServiceChecker.checker, SERVICE_CHECKER_RATE * 20L, 5 * 20L);
|
|
||||||
|
|
||||||
TFM_CommandLoader.getInstance().scan();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||||
try
|
try
|
||||||
@ -124,15 +141,24 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "."
|
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
||||||
+ TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
TFM_CommandLoader.getInstance().scan();
|
||||||
|
TFM_CommandBlockerNew.getInstance().parseBlockingRules();
|
||||||
|
}
|
||||||
|
}.runTaskLater(this, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
server.getScheduler().cancelTasks(this);
|
server.getScheduler().cancelTasks(this);
|
||||||
TFM_Log.info("Plugin Disabled");
|
TFM_Log.info("Plugin disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -164,8 +190,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
||||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX,
|
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
|
||||||
cmd.getName().toLowerCase())).newInstance();
|
|
||||||
dispatcher.setup(this, sender, dispatcher.getClass());
|
dispatcher.setup(this, sender, dispatcher.getClass());
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
@ -188,10 +213,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
catch (Throwable ex)
|
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)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
@ -201,13 +225,13 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
public static boolean allowFirePlace = false;
|
public static boolean allowFirePlace = false;
|
||||||
public static Boolean allowFireSpread = false;
|
public static boolean allowFireSpread = false;
|
||||||
public static Boolean allowLavaDamage = false;
|
public static boolean allowLavaDamage = false;
|
||||||
public static boolean allowLavaPlace = false;
|
public static boolean allowLavaPlace = false;
|
||||||
public static boolean allowWaterPlace = false;
|
public static boolean allowWaterPlace = false;
|
||||||
public static Boolean allowExplosions = false;
|
public static boolean allowExplosions = false;
|
||||||
public static boolean allowFliudSpread = false;
|
public static boolean allowFliudSpread = false;
|
||||||
public static boolean allowTntMinecarts = false;
|
public static boolean allowTntMinecarts = false;
|
||||||
public static double explosiveRadius = 4.0D;
|
public static double explosiveRadius = 4.0D;
|
||||||
@ -218,9 +242,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static int nukeMonitorCountPlace = 25;
|
public static int nukeMonitorCountPlace = 25;
|
||||||
public static double nukeMonitorRange = 10.0D;
|
public static double nukeMonitorRange = 10.0D;
|
||||||
public static int freecamTriggerCount = 10;
|
public static int freecamTriggerCount = 10;
|
||||||
public static Boolean preprocessLogEnabled = true;
|
public static boolean preprocessLogEnabled = true;
|
||||||
public static Boolean disableNight = true;
|
public static boolean disableNight = true;
|
||||||
public static Boolean disableWeather = true;
|
public static boolean disableWeather = true;
|
||||||
public static boolean landminesEnabled = false;
|
public static boolean landminesEnabled = false;
|
||||||
public static boolean mp44Enabled = false;
|
public static boolean mp44Enabled = false;
|
||||||
public static boolean mobLimiterEnabled = true;
|
public static boolean mobLimiterEnabled = true;
|
||||||
@ -238,8 +262,11 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static double autoProtectRadius = 25.0D;
|
public static double autoProtectRadius = 25.0D;
|
||||||
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
|
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
|
||||||
public static boolean twitterbotEnabled = false;
|
public static boolean twitterbotEnabled = false;
|
||||||
public static String twitterbotUrl = "http://tftwitter.darthcraft.net/";
|
public static String twitterbotUrl = "";
|
||||||
public static String twitterbotSecret = "";
|
public static String twitterbotSecret = "";
|
||||||
|
public static boolean petProtectEnabled = true;
|
||||||
|
public static String logsRegisterPassword = "";
|
||||||
|
public static String logsRegisterURL = "";
|
||||||
|
|
||||||
public static void loadMainConfig()
|
public static void loadMainConfig()
|
||||||
{
|
{
|
||||||
@ -286,13 +313,16 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
||||||
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
|
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
|
||||||
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
|
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)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TFM_Log.severe("Error loading main config: " + ex.getMessage());
|
TFM_Log.severe("Error loading main config: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static List<String> superadmins = new ArrayList<String>();
|
public static List<String> superadmins = new ArrayList<String>();
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -313,7 +343,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
|
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
public static List<String> permbanned_players = new ArrayList<String>();
|
public static List<String> permbanned_players = new ArrayList<String>();
|
||||||
public static List<String> permbanned_ips = new ArrayList<String>();
|
public static List<String> permbanned_ips = new ArrayList<String>();
|
||||||
|
|
||||||
@ -356,6 +386,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
pm.registerEvents(new TFM_BlockListener(), plugin);
|
pm.registerEvents(new TFM_BlockListener(), plugin);
|
||||||
pm.registerEvents(new TFM_PlayerListener(), plugin);
|
pm.registerEvents(new TFM_PlayerListener(), plugin);
|
||||||
pm.registerEvents(new TFM_WeatherListener(), plugin);
|
pm.registerEvents(new TFM_WeatherListener(), plugin);
|
||||||
|
pm.registerEvents(new TFM_ServerListener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setAppProperties()
|
private static void setAppProperties()
|
||||||
|
@ -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
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
@ -25,21 +25,21 @@
|
|||||||
* authors and contributors and should not be interpreted as representing official policies,
|
* authors and contributors and should not be interpreted as representing official policies,
|
||||||
* either expressed or implied, of anybody else.
|
* either expressed or implied, of anybody else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.mcstats;
|
package org.mcstats;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -52,47 +52,29 @@ import java.util.LinkedHashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
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 {
|
public class Metrics {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current revision number
|
* The current revision number
|
||||||
*/
|
*/
|
||||||
private final static int REVISION = 6;
|
private final static int REVISION = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base url of the metrics domain
|
* 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
|
* The url used to report a server's status
|
||||||
*/
|
*/
|
||||||
private static final String REPORT_URL = "/report/%s";
|
private static final String REPORT_URL = "/plugin/%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 = "~~";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interval of time to ping (in minutes)
|
* 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
|
* The plugin this metrics submits for
|
||||||
@ -104,16 +86,11 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
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
|
* The plugin configuration file
|
||||||
*/
|
*/
|
||||||
private final YamlConfiguration configuration;
|
private final YamlConfiguration configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plugin configuration file
|
* 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
|
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||||
* on the metrics website. Plotters can be added to the graph object returned.
|
* website. Plotters can be added to the graph object returned.
|
||||||
*
|
*
|
||||||
* @param name The name of the graph
|
* @param name The name of the graph
|
||||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
* @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
|
* @param graph The name of the graph
|
||||||
*/
|
*/
|
||||||
@ -202,26 +179,9 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a custom data plotter to the default graph
|
* 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
|
||||||
* @param plotter The plotter to use to plot custom data
|
* ticks.
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*
|
*
|
||||||
* @return True if statistics measuring is running, otherwise false.
|
* @return True if statistics measuring is running, otherwise false.
|
||||||
*/
|
*/
|
||||||
@ -251,7 +211,7 @@ public class Metrics {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
task = null;
|
task = null;
|
||||||
// Tell all plotters to stop gathering information.
|
// Tell all plotters to stop gathering information.
|
||||||
for (Graph graph : graphs){
|
for (Graph graph : graphs) {
|
||||||
graph.onOptOut();
|
graph.onOptOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +243,7 @@ public class Metrics {
|
|||||||
* @return true if metrics should be opted out of it
|
* @return true if metrics should be opted out of it
|
||||||
*/
|
*/
|
||||||
public boolean isOptOut() {
|
public boolean isOptOut() {
|
||||||
synchronized(optOutLock) {
|
synchronized (optOutLock) {
|
||||||
try {
|
try {
|
||||||
// Reload the metrics file
|
// Reload the metrics file
|
||||||
configuration.load(getConfigFile());
|
configuration.load(getConfigFile());
|
||||||
@ -303,30 +263,30 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
* 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 {
|
public void enable() throws IOException {
|
||||||
// This has to be synchronized or it can collide with the check in the task.
|
// This has to be synchronized or it can collide with the check in the task.
|
||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Check if the server owner has already set opt-out, if not, set it.
|
// Check if the server owner has already set opt-out, if not, set it.
|
||||||
if (isOptOut()) {
|
if (isOptOut()) {
|
||||||
configuration.set("opt-out", false);
|
configuration.set("opt-out", false);
|
||||||
configuration.save(configurationFile);
|
configuration.save(configurationFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Task, if it is not running
|
// Enable Task, if it is not running
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
* 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 {
|
public void disable() throws IOException {
|
||||||
// This has to be synchronized or it can collide with the check in the task.
|
// 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
|
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||||
|
|
||||||
// Construct the post data
|
// 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
|
// 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));
|
appendJSONPair(json, "guid", guid);
|
||||||
encodeDataPair(data, "version", pluginVersion);
|
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||||
encodeDataPair(data, "server", serverVersion);
|
appendJSONPair(json, "server_version", serverVersion);
|
||||||
encodeDataPair(data, "players", Integer.toString(playersOnline));
|
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||||
encodeDataPair(data, "revision", String.valueOf(REVISION));
|
|
||||||
|
|
||||||
// New data as of R6
|
// New data as of R6
|
||||||
String osname = System.getProperty("os.name");
|
String osname = System.getProperty("os.name");
|
||||||
@ -398,44 +358,63 @@ public class Metrics {
|
|||||||
osarch = "x86_64";
|
osarch = "x86_64";
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeDataPair(data, "osname", osname);
|
appendJSONPair(json, "osname", osname);
|
||||||
encodeDataPair(data, "osarch", osarch);
|
appendJSONPair(json, "osarch", osarch);
|
||||||
encodeDataPair(data, "osversion", osversion);
|
appendJSONPair(json, "osversion", osversion);
|
||||||
encodeDataPair(data, "cores", Integer.toString(coreCount));
|
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||||
encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
|
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
||||||
encodeDataPair(data, "java_version", java_version);
|
appendJSONPair(json, "java_version", java_version);
|
||||||
|
|
||||||
// If we're pinging, append it
|
// If we're pinging, append it
|
||||||
if (isPing) {
|
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
|
if (graphs.size() > 0) {
|
||||||
// inside of the graph (e.g plotters)
|
synchronized (graphs) {
|
||||||
synchronized (graphs) {
|
json.append(',');
|
||||||
final Iterator<Graph> iter = graphs.iterator();
|
json.append('"');
|
||||||
|
json.append("graphs");
|
||||||
|
json.append('"');
|
||||||
|
json.append(':');
|
||||||
|
json.append('{');
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
boolean firstGraph = true;
|
||||||
final Graph graph = iter.next();
|
|
||||||
|
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
final Iterator<Graph> iter = graphs.iterator();
|
||||||
// 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());
|
|
||||||
|
|
||||||
// The value to send, which for the foreseeable future is just the string
|
while (iter.hasNext()) {
|
||||||
// value of plotter.getValue()
|
Graph graph = iter.next();
|
||||||
final String value = Integer.toString(plotter.getValue());
|
|
||||||
|
|
||||||
// Add it to the http post data :)
|
StringBuilder graphJson = new StringBuilder();
|
||||||
encodeDataPair(data, key, value);
|
graphJson.append('{');
|
||||||
|
|
||||||
|
for (Plotter plotter : graph.getPlotters()) {
|
||||||
|
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
graphJson.append('}');
|
||||||
|
|
||||||
|
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
|
// 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
|
// Connect to the website
|
||||||
URLConnection connection;
|
URLConnection connection;
|
||||||
@ -448,26 +427,48 @@ public class Metrics {
|
|||||||
connection = url.openConnection();
|
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);
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||||
|
}
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
OutputStream os = connection.getOutputStream();
|
||||||
writer.write(data.toString());
|
os.write(compressed);
|
||||||
writer.flush();
|
os.flush();
|
||||||
|
|
||||||
// Now read the response
|
// Now read the response
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
final String response = reader.readLine();
|
String response = reader.readLine();
|
||||||
|
|
||||||
// close resources
|
// close resources
|
||||||
writer.close();
|
os.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
if (response == null || response.startsWith("ERR")) {
|
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||||
throw new IOException(response); //Throw the exception
|
if (response == null) {
|
||||||
|
response = "null";
|
||||||
|
} else if (response.startsWith("7")) {
|
||||||
|
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IOException(response);
|
||||||
} else {
|
} else {
|
||||||
// Is this the first update this hour?
|
// 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) {
|
synchronized (graphs) {
|
||||||
final Iterator<Graph> iter = graphs.iterator();
|
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
|
* 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
|
* Appends a json encoded key/value pair to the given string builder.
|
||||||
* 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>
|
|
||||||
*
|
*
|
||||||
* @param buffer the stringbuilder to append the data pair onto
|
* @param json
|
||||||
* @param key the key value
|
* @param key
|
||||||
* @param value the value
|
* @param value
|
||||||
|
* @throws UnsupportedEncodingException
|
||||||
*/
|
*/
|
||||||
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException {
|
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
|
||||||
buffer.append('&').append(encode(key)).append('=').append(encode(value));
|
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
|
* @param text the text to encode
|
||||||
* @return the encoded text, as UTF-8
|
* @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");
|
return URLEncoder.encode(text, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,8 +619,8 @@ public class Metrics {
|
|||||||
public static class Graph {
|
public static class Graph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The graph's name, alphanumeric and spaces only :)
|
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||||
* If it does not comply to the above when submitted, it is rejected
|
* rejected
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@ -574,7 +663,7 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
* 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() {
|
public Set<Plotter> getPlotters() {
|
||||||
return Collections.unmodifiableSet(plotters);
|
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() {
|
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
|
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||||
* it may or may not return immediately thus cannot be guaranteed to be thread friendly or safe.
|
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||||
* This function can be called from any thread so care should be taken when accessing resources
|
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||||
* that need to be synchronized.
|
|
||||||
*
|
*
|
||||||
* @return the current value for the point to be plotted.
|
* @return the current value for the point to be plotted.
|
||||||
*/
|
*/
|
||||||
@ -668,7 +755,5 @@ public class Metrics {
|
|||||||
final Plotter plotter = (Plotter) object;
|
final Plotter plotter = (Plotter) object;
|
||||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
name: TotalFreedomMod
|
name: TotalFreedomMod
|
||||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||||
version: 2.21
|
version: 2.22
|
||||||
description: Plugin for the Total Freedom server.
|
description: Plugin for the Total Freedom server.
|
||||||
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]
|
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user