mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
184 Commits
Author | SHA1 | Date | |
---|---|---|---|
fd372066eb | |||
122bef2d5a | |||
339518f4f4 | |||
8ce0defb52 | |||
ec6e8431e3 | |||
0964871e8b | |||
422a7716f3 | |||
f1ab8296e4 | |||
f9cbf11abb | |||
b0090a5412 | |||
b94efb525f | |||
5c8f98089e | |||
7879fa24e4 | |||
6fcaed6253 | |||
656dbf8867 | |||
23032e6f9a | |||
ad5a236bc2 | |||
e23db244a5 | |||
eb4622fc28 | |||
0f6b053727 | |||
259335958a | |||
31375b82c3 | |||
0a2d5c8258 | |||
bac25258b0 | |||
c69918d725 | |||
c1d0c01524 | |||
a59e6added | |||
56493adcae | |||
4b91de7414 | |||
c636ee043a | |||
6a5306dd7a | |||
4603dc5613 | |||
af7e6c5d41 | |||
699d366efb | |||
41ed416a51 | |||
074630f720 | |||
4e3c9a6b9e | |||
bea480c1f1 | |||
69fd3566af | |||
f3ac19a616 | |||
696ec119c6 | |||
326c3f6a2b | |||
38b1035020 | |||
1ae6eb8a5a | |||
2c4eca8551 | |||
f23c61d0b3 | |||
c10e0deb8b | |||
d4dfe06ec0 | |||
bcd9658b3d | |||
9b62731e94 | |||
03553b6254 | |||
d40c143afc | |||
95afb51321 | |||
4813b8ae27 | |||
e8d36b31f7 | |||
b2eec1ef01 | |||
3bcc4fd7a7 | |||
e0efb63123 | |||
028d1a07b2 | |||
5b34facdd3 | |||
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 | |||
44f72815e1 | |||
391e417882 | |||
0dca359e4c | |||
15fbd0e1f3 | |||
1d9e6ae931 | |||
a0cf0e9352 | |||
797de66e10 | |||
d40d5b461d | |||
8751e0454c | |||
3f29f788d5 | |||
5c2e67ae1d | |||
61db5de20d | |||
ed9204c735 | |||
9fc237390e | |||
ba22aedc58 | |||
44fb26b27f | |||
fab341608b | |||
4f6a0ca5d3 | |||
f3684cc2ce | |||
772b7e43f7 | |||
c308c9a268 | |||
fcb424a793 | |||
be1acb4e03 | |||
386989fa69 | |||
4c7cd9cb23 | |||
1f87c05547 | |||
a2a6e39db9 | |||
c6ca262472 | |||
c96bdea066 | |||
893c7c2991 | |||
201d27e070 | |||
36ceb7007a | |||
6519ead121 | |||
95805dd9c1 | |||
6768854eda | |||
83176ba0b9 | |||
4a2b58bf97 | |||
79fc01eae7 | |||
d1d220f618 | |||
f6943b9754 | |||
2977167bd3 | |||
ad9e901aa0 | |||
4f6e4e2e87 | |||
d8ae364300 | |||
7f9661ec11 | |||
8d59ba59f4 | |||
6a7e866a53 | |||
63508addf4 | |||
b8ab56bed5 | |||
4853cc439b | |||
3b7a8d4d88 | |||
d016e1ff08 | |||
ab9650dc54 | |||
d3139dd39f | |||
ba834b6b92 | |||
ccd4237491 | |||
ff51bb1980 | |||
d2457adf68 | |||
aea65815a8 | |||
6abd2491f1 | |||
31b5c99007 | |||
4aebf33006 | |||
e29a820398 | |||
fabbc78d22 | |||
a8b4f1d950 | |||
b7c9f4e02d | |||
ba9289e1a3 | |||
47dec49381 | |||
b1202c7871 |
52
CONTRIBUTING.md
Normal file
52
CONTRIBUTING.md
Normal file
@ -0,0 +1,52 @@
|
||||
# Contributing to TotalFreedomMod #
|
||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss.
|
||||
|
||||
For those who wish to contribute, we encourage you to fork the repository and submit pull requests. Below you will find guidelines that will explain this process in further detail.
|
||||
|
||||
## Getting Started ##
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* If the issue is a bug, submit a ticket for it, assuming one does not already exist.
|
||||
* Clearly describe the issue including steps to reproduce it.
|
||||
* Make sure you fill in the earliest version that you know has the issue.
|
||||
* Fork the repository on GitHub
|
||||
|
||||
## Making Changes ##
|
||||
* Create a topic branch from where you want to base your work.
|
||||
* This is usually the master branch.
|
||||
* Only target release branches if you are certain your addition must be on that branch.
|
||||
* To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch.
|
||||
* Make changes and commit where necessary.
|
||||
* Check for unnecessary whitespace with `git diff --check` before committing.
|
||||
* Make sure your commit messages are in line with those which are already made.
|
||||
* Make sure your changes build (<b>and work!</b>).
|
||||
|
||||
## Tips - How To Get Your Pull Request Accepted ##
|
||||
* Make sure your changes work and compile without difficulty.
|
||||
* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands)
|
||||
* __Commands that make use of `org.bukkit.Server.dispatchCommand()` will probably be rejected.__
|
||||
* Features must be in line the general idea of "Total Freedom".
|
||||
* Changes must be directed towards the main "TotalFreedom" server. Adding names such as the name of your own TotalFreedom-like server will get your pull request denied.
|
||||
* Do not add yourself to the developer list.
|
||||
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
|
||||
* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command.
|
||||
* __Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).__
|
||||
* Do not increment the version number.
|
||||
* If you want to add multiple changes, please make one pull request per change. This way, it's easier to accept your changes faster and won't block the other changes if there is an issue with a specific line of code.
|
||||
* Please make sure there are no bugs in your code.
|
||||
* Please avoid having to add files in the main namespace where possible.
|
||||
* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits.
|
||||
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
|
||||
* Please do not spread your addition over several pull-requests.
|
||||
|
||||
## Submitting Your Changes ##
|
||||
* Push your changes to a topic branch in your fork of the repository.
|
||||
* Submit a pull request to this repository.
|
||||
* Explain in detail what each one of your commits changes and point out any big changes.
|
||||
* Wait as a developer evaluates your changes.
|
||||
|
||||
## Additional Resources ##
|
||||
* [TotalFreedom information](http://totalfreedom.me)
|
||||
* [TotalFreedom forums](http://totalfreedom.boards.net)
|
||||
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
|
||||
* [General GitHub documentation](http://help.github.com/)
|
||||
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
11
LICENSE.md
Normal file
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 +0,0 @@
|
||||
TotalFreedomMod
|
||||
===============
|
||||
|
||||
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
|
||||
|
||||
Information about the TotalFreedom server can be found at http://totalfreedom.me/
|
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# TotalFreedomMod #
|
||||
|
||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||
|
||||
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||
|
||||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
@ -1,5 +1,5 @@
|
||||
#Wed, 15 May 2013 15:22:48 +0200
|
||||
#Wed, 14 Aug 2013 15:57:37 +0200
|
||||
|
||||
program.VERSION=2.15
|
||||
program.BUILDNUM=190
|
||||
program.BUILDDATE=05/15/2013 03\:22 PM
|
||||
program.VERSION=3.00
|
||||
program.BUILDNUM=459
|
||||
program.BUILDDATE=08/14/2013 03\:57 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Wed May 15 15:22:48 CEST 2013
|
||||
build.number=191
|
||||
#Wed Aug 14 15:57:37 CEST 2013
|
||||
build.number=460
|
||||
|
@ -5,6 +5,22 @@ annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=TotalFreedomMod
|
||||
application.vendor=Michael
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enableCommentFormatting=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@ -32,7 +48,9 @@ jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${libs.CraftBukkit.classpath}
|
||||
${libs.CraftBukkit.classpath}:\
|
||||
${libs.WorldEdit.classpath}:\
|
||||
${libs.DisguiseCraft.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||
javac.deprecation=false
|
||||
|
@ -1,4 +1,4 @@
|
||||
# TotalFreedomMod v2.15 Configuration
|
||||
# TotalFreedomMod v3.00 Configuration
|
||||
# by Madgeek1450 and DarthSalamon
|
||||
|
||||
# Block placement prevention:
|
||||
@ -8,12 +8,71 @@ allow_lava_damage: false
|
||||
allow_lava_place: false
|
||||
allow_water_place: false
|
||||
allow_fluid_spread: false
|
||||
allow_tnt_minecarts: false
|
||||
|
||||
# Explosion management:
|
||||
allow_explosions: false
|
||||
explosiveRadius: 4.0
|
||||
|
||||
#Automatically wipe dropped objects:
|
||||
# Blocked commands:
|
||||
#
|
||||
# How blocked commands work:
|
||||
# All sections described below are delimited by colon-characters.
|
||||
# Make sure that you block a command by it's main command name, not an alias
|
||||
# -as all aliases are blocked by default. Commands are case-insensitive ofcourse.
|
||||
# You can block specific subcommands aswell. eg: /mail sendall
|
||||
#
|
||||
# * The first section is a letter which indicates which rank may use this command
|
||||
# Valid ranks:
|
||||
# n - Nobody (Completely disabled)
|
||||
# c - Senior Admins (Console)
|
||||
# t - Telnet Admins (Console)
|
||||
# s - SuperAdmins
|
||||
# o - Ops (Non-Ops won't be able to use it)
|
||||
#
|
||||
# * The second section is a letter which indicates what to do when a player executes that command.
|
||||
# Valid actions:
|
||||
# b - Block the command
|
||||
# a - Block the command and auto-eject that player (for ops and below)
|
||||
# u - Block the command and Return an "Unknown command" message (Used to hide commands)
|
||||
#
|
||||
# * The third section is the command to be blocked, prefixed with a slash
|
||||
#
|
||||
# * The fourth section is the message to send to the player when executing that command.
|
||||
# This should be ommited if unwanted. ChatColors are supported with the &-key. By default
|
||||
# -the starting ChatColor is set to gray. You can use the default 'That command is blocked.' message
|
||||
# by using a single underscore.
|
||||
#
|
||||
# Examples:
|
||||
# - 'n:b:/mail sendall:&4You can't send mails to everyone!'
|
||||
# - 's:a:/stop'
|
||||
# - 'n:b:/ban:_'
|
||||
#
|
||||
blocked_commands:
|
||||
# Disabled commands
|
||||
- n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.
|
||||
- n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.
|
||||
- n:b:/gamemode:Use /creative and /survival to set your gamemode.
|
||||
- n:b:/gamerule:_
|
||||
- n:b:/ban:_
|
||||
- n:b:/pardon:_
|
||||
- n:b:/toggledownfall:_
|
||||
- n:b:/ban-ip:_
|
||||
- n:b:/pardon-ip:_
|
||||
|
||||
# Superadmin commands
|
||||
- s:b:/kick:_
|
||||
- s:b:/socialspy:_
|
||||
- s:b:/kill:_
|
||||
- s:b:/clearhistory:_
|
||||
- s:a:/stop:_
|
||||
- s:a:/reload:_
|
||||
- s:a:/nuke:_
|
||||
- s:a:/save-all:_
|
||||
- s:a:/save-on:_
|
||||
- s:a:/save-off:_
|
||||
|
||||
# Automatically wipe dropped objects:
|
||||
auto_wipe: true
|
||||
|
||||
# Nuking prevention:
|
||||
@ -67,5 +126,15 @@ host_sender_names:
|
||||
|
||||
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
||||
twitterbot_enabled: false
|
||||
twitterbot_url: 'http://tftwitter.darthcraft.net/'
|
||||
twitterbot_secret: ''
|
||||
twitterbot_url:
|
||||
twitterbot_secret:
|
||||
|
||||
# Pet Protect - Prevent tamed pets from being killed.
|
||||
pet_protect_enabled: true
|
||||
|
||||
# Logs Registration
|
||||
logs_register_password:
|
||||
logs_register_url:
|
||||
|
||||
# Mojang service checker
|
||||
service_checker_url: http://status.mojang.com/check
|
||||
|
@ -15,7 +15,6 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.Random;
|
||||
@ -26,6 +25,7 @@ import org.bukkit.generator.BlockPopulator;
|
||||
public class CleanroomBlockPopulator extends BlockPopulator
|
||||
{
|
||||
byte[] layerDataValues;
|
||||
|
||||
protected CleanroomBlockPopulator(byte[] layerDataValues)
|
||||
{
|
||||
this.layerDataValues = layerDataValues;
|
||||
@ -38,10 +38,13 @@ public class CleanroomBlockPopulator extends BlockPopulator
|
||||
int x = chunk.getX() << 4;
|
||||
int z = chunk.getZ() << 4;
|
||||
|
||||
for (int y = 0; y < layerDataValues.length ; y++)
|
||||
for (int y = 0; y < layerDataValues.length; y++)
|
||||
{
|
||||
byte dataValue = layerDataValues[y];
|
||||
if (dataValue == 0) continue;
|
||||
if (dataValue == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int xx = 0; xx < 16; xx++)
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
|
@ -15,7 +15,6 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
@ -24,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -32,7 +32,7 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
private Logger log = Logger.getLogger("Minecraft-Server");
|
||||
private static final Logger log = Bukkit.getLogger();
|
||||
private short[] layer;
|
||||
private byte[] layerDataValues;
|
||||
|
||||
@ -55,16 +55,20 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
if ((id.length() > 0) && (id.charAt(0) == '.')) // Is the first character a '.'? If so, skip bedrock generation.
|
||||
{
|
||||
id = id.substring(1); // Skip bedrock then and remove the .
|
||||
} else // Guess not, bedrock at layer0 it is then.
|
||||
}
|
||||
else // Guess not, bedrock at layer0 it is then.
|
||||
{
|
||||
layer[y++] = (short)Material.BEDROCK.getId();
|
||||
layer[y++] = (short) Material.BEDROCK.getId();
|
||||
}
|
||||
|
||||
if (id.length() > 0)
|
||||
{
|
||||
String tokens[] = id.split("[,]");
|
||||
|
||||
if ((tokens.length % 2) != 0) throw new Exception();
|
||||
if ((tokens.length % 2) != 0)
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
for (int i = 0; i < tokens.length; i += 2)
|
||||
{
|
||||
@ -83,7 +87,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
// Lets try to read the data value
|
||||
dataValue = Byte.parseByte(materialTokens[1]);
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
|
||||
dataValue = 0;
|
||||
@ -96,7 +101,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
// Mabe it's an integer?
|
||||
mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Well, I guess it wasn't an integer after all... Awkward...
|
||||
}
|
||||
@ -127,7 +133,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
Arrays.fill(layer, y, y + height, (short)mat.getId());
|
||||
Arrays.fill(layer, y, y + height, (short) mat.getId());
|
||||
if (dataValue != 0)
|
||||
{
|
||||
if (layerDataValues == null)
|
||||
@ -153,21 +159,23 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
|
||||
layerDataValues = newLayerDataValues;
|
||||
}
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
|
||||
e.printStackTrace();
|
||||
layerDataValues = null;
|
||||
layer = new short[65];
|
||||
layer[0] = (short)Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
|
||||
layer[0] = (short) Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
layerDataValues = null;
|
||||
layer = new short[65];
|
||||
layer[0] = (short)Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
|
||||
layer[0] = (short) Material.BEDROCK.getId();
|
||||
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,8 +208,9 @@ public class CleanroomChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
if (layerDataValues != null)
|
||||
{
|
||||
return Arrays.asList((BlockPopulator)new CleanroomBlockPopulator(layerDataValues));
|
||||
} else
|
||||
return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues));
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is the default, but just in case default populators change to stock minecraft populators by default...
|
||||
return new ArrayList<BlockPopulator>();
|
||||
|
@ -14,6 +14,11 @@ public class Command_adminmode extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
TotalFreedomMod.adminOnlyMode = false;
|
||||
@ -24,11 +29,11 @@ public class Command_adminmode extends TFM_Command
|
||||
{
|
||||
TotalFreedomMod.adminOnlyMode = true;
|
||||
TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
p.kickPlayer("Server is now closed to non-superadmins.");
|
||||
player.kickPlayer("Server is now closed to non-superadmins.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the AdminWorld.", usage = "/<command>")
|
||||
public class Command_adminworld extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (sender_p.getWorld() == TFM_AdminWorld.getInstance().getAdminWorld())
|
||||
{
|
||||
playerMsg("Going to the main world.");
|
||||
sender_p.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Going to the AdminWorld.");
|
||||
TFM_AdminWorld.getInstance().sendToAdminWorld(sender_p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -23,9 +23,9 @@ public class Command_blockcmd extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
||||
int counter = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.allCommandsBlocked())
|
||||
{
|
||||
counter += 1;
|
||||
@ -36,28 +36,28 @@ public class Command_blockcmd extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
playerMsg(p.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
||||
playerMsg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + p.getName(), true);
|
||||
TFM_Util.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
|
||||
playerMsg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
||||
|
||||
return true;
|
||||
|
@ -21,18 +21,18 @@ public class Command_cage extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Material cage_material_outer = Material.GLASS;
|
||||
Material cage_material_inner = Material.AIR;
|
||||
@ -40,7 +40,7 @@ public class Command_cage extends TFM_Command
|
||||
{
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Uncaging " + p.getName() + ".", true);
|
||||
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName() + ".", true);
|
||||
|
||||
playerdata.setCaged(false);
|
||||
playerdata.regenerateHistory();
|
||||
@ -70,17 +70,17 @@ public class Command_cage extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
Location target_pos = p.getLocation().add(0, 1, 0);
|
||||
playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner);
|
||||
Location targetPos = player.getLocation().add(0, 1, 0);
|
||||
playerdata.setCaged(true, targetPos, cage_material_outer, cage_material_inner);
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
||||
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
||||
TFM_Util.generateCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Caging " + p.getName() + ".", true);
|
||||
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + ".", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -27,10 +28,14 @@ public class Command_cake extends TFM_Command
|
||||
output.append(ChatColor.COLOR_CHAR).append(color_code).append(word).append(" ");
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
|
||||
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
|
||||
player.getInventory().setItem(player.getInventory().firstEmpty(), heldItem);
|
||||
player.awardAchievement(Achievement.MINE_WOOD);
|
||||
player.awardAchievement(Achievement.BUILD_WORKBENCH);
|
||||
player.awardAchievement(Achievement.BUILD_HOE);
|
||||
player.awardAchievement(Achievement.BAKE_CAKE);
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(output.toString());
|
||||
|
@ -13,15 +13,15 @@ public class Command_cartsit extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Player target_player = sender_p;
|
||||
Player targetPlayer = sender_p;
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
target_player = getPlayer(args[0]);
|
||||
targetPlayer = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
@ -30,26 +30,26 @@ public class Command_cartsit extends TFM_Command
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
if (target_player == null)
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (target_player != sender_p && !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
else if (targetPlayer != sender_p && !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target_player.isInsideVehicle())
|
||||
if (targetPlayer.isInsideVehicle())
|
||||
{
|
||||
target_player.getVehicle().eject();
|
||||
targetPlayer.getVehicle().eject();
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecart nearest_cart = null;
|
||||
for (Minecart cart : target_player.getWorld().getEntitiesByClass(Minecart.class))
|
||||
for (Minecart cart : targetPlayer.getWorld().getEntitiesByClass(Minecart.class))
|
||||
{
|
||||
if (cart.isEmpty())
|
||||
{
|
||||
@ -59,7 +59,7 @@ public class Command_cartsit extends TFM_Command
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cart.getLocation().distanceSquared(target_player.getLocation()) < nearest_cart.getLocation().distanceSquared(target_player.getLocation()))
|
||||
if (cart.getLocation().distanceSquared(targetPlayer.getLocation()) < nearest_cart.getLocation().distanceSquared(targetPlayer.getLocation()))
|
||||
{
|
||||
nearest_cart = cart;
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class Command_cartsit extends TFM_Command
|
||||
|
||||
if (nearest_cart != null)
|
||||
{
|
||||
nearest_cart.setPassenger(target_player);
|
||||
nearest_cart.setPassenger(targetPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,20 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Removes all entities, nicks and disguises.", usage = "/<command>")
|
||||
public class Command_clearall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
server.dispatchCommand(sender, "rd");
|
||||
server.dispatchCommand(sender, "potion clearall");
|
||||
server.dispatchCommand(sender, "uall");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -21,11 +21,11 @@ public class Command_cmdlist extends TFM_Command
|
||||
{
|
||||
List<String> commands = new ArrayList<String>();
|
||||
|
||||
for (Plugin p : server.getPluginManager().getPlugins())
|
||||
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginDescriptionFile desc = p.getDescription();
|
||||
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) desc.getCommands();
|
||||
|
||||
if (map != null)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -22,35 +24,51 @@ public class Command_creative extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
if (args.length == 0)
|
||||
{
|
||||
p = sender_p;
|
||||
player = sender_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
if (args[0].equalsIgnoreCase("-a"))
|
||||
{
|
||||
try
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player targetPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
if (!(senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender)))
|
||||
{
|
||||
playerMsg("Only superadmins can change other user's gamemode.");
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
playerMsg("Setting " + p.getName() + " to game mode 'Creative'.");
|
||||
playerMsg(p, sender.getName() + " set your game mode to 'Creative'.");
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
playerMsg("Setting " + player.getName() + " to game mode 'Creative'.");
|
||||
playerMsg(player, sender.getName() + " set your game mode to 'Creative'.");
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||
@ -17,20 +18,20 @@ public class Command_deafen extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
for (final Player p : server.getOnlinePlayers())
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
||||
{
|
||||
final float pitch = (float) (percent * 2.0);
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.playSound(randomOffset(p.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
player.playSound(randomOffset(player.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||
}
|
||||
}, Math.round(20.0 * percent * 2.0));
|
||||
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,25 +18,25 @@ public class Command_deop extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
OfflinePlayer p = null;
|
||||
OfflinePlayer player = null;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
|
||||
{
|
||||
p = onlinePlayer;
|
||||
player = onlinePlayer;
|
||||
}
|
||||
}
|
||||
|
||||
// if the player is not online
|
||||
if (p == null)
|
||||
if (player == null)
|
||||
{
|
||||
p = server.getOfflinePlayer(args[0]);
|
||||
player = server.getOfflinePlayer(args[0]);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);
|
||||
|
||||
p.setOp(false);
|
||||
player.setOp(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ public class Command_deopall extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping all players on the server", true);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
player.setOp(false);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -74,13 +74,13 @@ public class Command_dispfill extends TFM_Command
|
||||
{
|
||||
for (int z_offset = -radius; z_offset <= radius; z_offset++)
|
||||
{
|
||||
Block target_block = center_block.getRelative(x_offset, y_offset, z_offset);
|
||||
if (target_block.getLocation().distanceSquared(center_location) < (radius * radius))
|
||||
Block targetBlock = center_block.getRelative(x_offset, y_offset, z_offset);
|
||||
if (targetBlock.getLocation().distanceSquared(center_location) < (radius * radius))
|
||||
{
|
||||
if (target_block.getType().equals(Material.DISPENSER))
|
||||
if (targetBlock.getType().equals(Material.DISPENSER))
|
||||
{
|
||||
sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(target_block.getLocation()));
|
||||
setDispenserContents(target_block, items_array);
|
||||
sender.sendMessage("Filling dispenser @ " + TFM_Util.formatLocation(targetBlock.getLocation()));
|
||||
setDispenserContents(targetBlock, items_array);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
@ -98,9 +98,9 @@ public class Command_dispfill extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void setDispenserContents(Block target_block, ItemStack[] items)
|
||||
private static void setDispenserContents(Block targetBlock, ItemStack[] items)
|
||||
{
|
||||
Dispenser dispenser = (Dispenser) target_block.getState();
|
||||
Dispenser dispenser = (Dispenser) targetBlock.getState();
|
||||
Inventory disp_inv = dispenser.getInventory();
|
||||
disp_inv.clear();
|
||||
disp_inv.addItem(items);
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
||||
@CommandParameters(description = "For the bad Superadmins.", usage = "/<command> <playername>")
|
||||
@ -21,82 +22,82 @@ public class Command_doom extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player p;
|
||||
final Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true);
|
||||
TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||
TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||
TFM_Util.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||
|
||||
final String IP = p.getAddress().getAddress().getHostAddress().trim();
|
||||
final String IP = player.getAddress().getAddress().getHostAddress().trim();
|
||||
|
||||
// remove from superadmin
|
||||
if (TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + " from the superadmin list.", true);
|
||||
TFM_SuperadminList.removeSuperadmin(p);
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list.", true);
|
||||
TFM_SuperadminList.removeSuperadmin(player);
|
||||
}
|
||||
|
||||
// remove from whitelist
|
||||
p.setWhitelisted(false);
|
||||
player.setWhitelisted(false);
|
||||
|
||||
// deop
|
||||
p.setOp(false);
|
||||
player.setOp(false);
|
||||
|
||||
// ban IP
|
||||
TFM_ServerInterface.banIP(IP, null, null, null);
|
||||
|
||||
// ban name
|
||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
||||
TFM_ServerInterface.banUsername(player.getName(), null, null, null);
|
||||
|
||||
// set gamemode to survival
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// clear inventory
|
||||
p.closeInventory();
|
||||
p.getInventory().clear();
|
||||
player.closeInventory();
|
||||
player.getInventory().clear();
|
||||
|
||||
// ignite player
|
||||
p.setFireTicks(10000);
|
||||
player.setFireTicks(10000);
|
||||
|
||||
// generate explosion
|
||||
p.getWorld().createExplosion(p.getLocation(), 4F);
|
||||
player.getWorld().createExplosion(player.getLocation(), 4F);
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// strike lightning
|
||||
p.getWorld().strikeLightning(p.getLocation());
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
|
||||
// kill (if not done already)
|
||||
p.setHealth(0);
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
}, 40L); // 2 seconds
|
||||
}.runTaskLater(plugin, 20L * 2L);
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// message
|
||||
TFM_Util.adminAction(sender.getName(), "Banning " + p.getName() + ", IP: " + IP, true);
|
||||
TFM_Util.adminAction(sender.getName(), "Banning " + player.getName() + ", IP: " + IP, true);
|
||||
|
||||
// generate explosion
|
||||
p.getWorld().createExplosion(p.getLocation(), 4F);
|
||||
player.getWorld().createExplosion(player.getLocation(), 4F);
|
||||
|
||||
// kick player
|
||||
p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||
}
|
||||
}, 60L); // 3 seconds
|
||||
}.runTaskLater(plugin, 20L * 3L);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shortcut to enable/disable DisguiseCraft.", usage = "/<command>")
|
||||
public class Command_dtoggle extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
|
||||
if (disguiseCraft != null)
|
||||
{
|
||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
|
||||
boolean enabled = disguiseCraft.isEnabled();
|
||||
if (enabled)
|
||||
{
|
||||
pluginManager.disablePlugin(disguiseCraft);
|
||||
}
|
||||
else
|
||||
{
|
||||
pluginManager.enablePlugin(disguiseCraft);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), (!enabled ? "Enabled" : "Disabled") + " DisguiseCraft.", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage("DisguiseCraft is not installed on this server.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -53,9 +54,23 @@ public class Command_enchant extends TFM_Command
|
||||
{
|
||||
for (Enchantment ench : Enchantment.values())
|
||||
{
|
||||
if (ench.canEnchantItem(itemInHand))
|
||||
/*
|
||||
2013-07-20 23:17:13 [INFO] [TotalFreedomMod]: Command Error: enchant
|
||||
java.lang.NullPointerException
|
||||
at net.minecraft.server.v1_6_R2.EnchantmentDurability.canEnchant(SourceFile:33)
|
||||
at org.bukkit.craftbukkit.v1_6_R2.enchantments.CraftEnchantment.canEnchantItem(CraftEnchantment.java:55)
|
||||
at me.StevenLawson.TotalFreedomMod.Commands.Command_enchant.run(Command_enchant.java:56)
|
||||
*/
|
||||
try
|
||||
{
|
||||
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
||||
if (ench.canEnchantItem(itemInHand))
|
||||
{
|
||||
itemInHand.addEnchantment(ench, ench.getMaxLevel());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.info("Error using " + ench.getName() + " on " + itemInHand.getType().name() + " held by " + sender_p.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,16 +38,16 @@ public class Command_expel extends TFM_Command
|
||||
}
|
||||
|
||||
Location sender_pos = sender_p.getLocation();
|
||||
for (Player p : sender_pos.getWorld().getPlayers())
|
||||
for (Player player : sender_pos.getWorld().getPlayers())
|
||||
{
|
||||
if (!p.equals(sender_p))
|
||||
if (!player.equals(sender_p))
|
||||
{
|
||||
Location target_pos = p.getLocation();
|
||||
Location targetPos = player.getLocation();
|
||||
|
||||
boolean in_range = false;
|
||||
try
|
||||
{
|
||||
in_range = target_pos.distanceSquared(sender_pos) < (radius * radius);
|
||||
in_range = targetPos.distanceSquared(sender_pos) < (radius * radius);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
@ -55,8 +55,8 @@ public class Command_expel extends TFM_Command
|
||||
|
||||
if (in_range)
|
||||
{
|
||||
p.setVelocity(target_pos.clone().subtract(sender_pos).toVector().normalize().multiply(strength));
|
||||
playerMsg("Pushing " + p.getName() + ".");
|
||||
player.setVelocity(targetPos.clone().subtract(sender_pos).toVector().normalize().multiply(strength));
|
||||
playerMsg("Pushing " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all IPs registered to a player", usage = "/<command> <player>")
|
||||
public class Command_findip extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Player player;
|
||||
try
|
||||
{
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Player IPs: " + StringUtils.join(TFM_UserList.getInstance(TotalFreedomMod.plugin).getEntry(player).getIpAddresses(), ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,16 +18,9 @@ public class Command_firespread extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowFireSpread = true;
|
||||
playerMsg("Fire spread is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowFireSpread = false;
|
||||
playerMsg("Fire spread is now disabled.");
|
||||
}
|
||||
playerMsg("Fire spread is now " + ((TotalFreedomMod.allowFireSpread = !args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TotalFreedomMod.allowFireSpread);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
@ -8,6 +7,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]")
|
||||
@ -24,33 +24,30 @@ public class Command_fr extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
|
||||
TotalFreedomMod.allPlayersFrozen = true;
|
||||
TotalFreedomMod.freezePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
|
||||
if (TotalFreedomMod.freezePurgeTask != null)
|
||||
{
|
||||
TotalFreedomMod.freezePurgeTask.cancel();
|
||||
}
|
||||
TotalFreedomMod.freezePurgeTask = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (TotalFreedomMod.freezePurgeEventId == 0)
|
||||
{
|
||||
TFM_Log.warning("Freeze autopurge task was improperly cancelled!");
|
||||
return;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FreezeTimer", "Unfreezing all players", false);
|
||||
|
||||
TotalFreedomMod.allPlayersFrozen = false;
|
||||
TotalFreedomMod.freezePurgeEventId = 0;
|
||||
}
|
||||
}, 6000L); // five minutes in ticks: 20*60*5
|
||||
}.runTaskLater(plugin, 20L * 60L * 5L);
|
||||
|
||||
playerMsg("Players are now frozen.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
|
||||
TotalFreedomMod.allPlayersFrozen = false;
|
||||
if (TotalFreedomMod.freezePurgeEventId != 0)
|
||||
if (TotalFreedomMod.freezePurgeTask != null)
|
||||
{
|
||||
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
|
||||
TotalFreedomMod.freezePurgeEventId = 0;
|
||||
TotalFreedomMod.freezePurgeTask.cancel();
|
||||
}
|
||||
playerMsg("Players are now free to move.");
|
||||
}
|
||||
@ -60,10 +57,14 @@ public class Command_fr extends TFM_Command
|
||||
if (args[0].toLowerCase().equals("purge"))
|
||||
{
|
||||
TotalFreedomMod.allPlayersFrozen = false;
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
if (TotalFreedomMod.freezePurgeTask != null)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TotalFreedomMod.freezePurgeTask.cancel();
|
||||
}
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setFrozen(false);
|
||||
}
|
||||
|
||||
@ -71,22 +72,22 @@ public class Command_fr extends TFM_Command
|
||||
}
|
||||
else
|
||||
{
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setFrozen(!playerdata.isFrozen());
|
||||
|
||||
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
playerMsg(p, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
||||
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,77 +30,77 @@ public class Command_gadmin extends TFM_Command
|
||||
playerMsg("[ Real Name ] : [ Display Name ] - Hash:");
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
String hash = p.getUniqueId().toString().substring(0, 4);
|
||||
String hash = player.getUniqueId().toString().substring(0, 4);
|
||||
if (mode.equals("list"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
|
||||
p.getName(),
|
||||
ChatColor.stripColor(p.getDisplayName()),
|
||||
player.getName(),
|
||||
ChatColor.stripColor(player.getDisplayName()),
|
||||
hash));
|
||||
}
|
||||
else if (hash.equalsIgnoreCase(args[1]))
|
||||
{
|
||||
if (mode.equals("kick"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Kicking: %s.", p.getName()), false);
|
||||
p.kickPlayer("Kicked by Administrator");
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Kicking: %s.", player.getName()), false);
|
||||
player.kickPlayer("Kicked by Administrator");
|
||||
}
|
||||
else if (mode.equals("nameban"))
|
||||
{
|
||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s.", p.getName()), true);
|
||||
p.kickPlayer("Username banned by Administrator.");
|
||||
TFM_ServerInterface.banUsername(player.getName(), null, null, null);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s.", player.getName()), true);
|
||||
player.kickPlayer("Username banned by Administrator.");
|
||||
}
|
||||
else if (mode.equals("ipban"))
|
||||
{
|
||||
String user_ip = p.getAddress().getAddress().getHostAddress();
|
||||
String user_ip = player.getAddress().getAddress().getHostAddress();
|
||||
String[] ip_parts = user_ip.split("\\.");
|
||||
if (ip_parts.length == 4)
|
||||
{
|
||||
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning IP: %s.", p.getName(), user_ip), true);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning IP: %s.", player.getName(), user_ip), true);
|
||||
TFM_ServerInterface.banIP(user_ip, null, null, null);
|
||||
p.kickPlayer("IP address banned by Administrator.");
|
||||
player.kickPlayer("IP address banned by Administrator.");
|
||||
}
|
||||
else if (mode.equals("ban"))
|
||||
{
|
||||
String user_ip = p.getAddress().getAddress().getHostAddress();
|
||||
String user_ip = player.getAddress().getAddress().getHostAddress();
|
||||
String[] ip_parts = user_ip.split("\\.");
|
||||
if (ip_parts.length == 4)
|
||||
{
|
||||
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), true);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", player.getName(), user_ip), true);
|
||||
TFM_ServerInterface.banIP(user_ip, null, null, null);
|
||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
||||
p.kickPlayer("IP and username banned by Administrator.");
|
||||
TFM_ServerInterface.banUsername(player.getName(), null, null, null);
|
||||
player.kickPlayer("IP and username banned by Administrator.");
|
||||
}
|
||||
else if (mode.equals("op"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Opping %s.", p.getName()), false);
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Opping %s.", player.getName()), false);
|
||||
player.setOp(false);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
}
|
||||
else if (mode.equals("deop"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Deopping %s.", p.getName()), false);
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
TFM_Util.adminAction(sender.getName(), String.format("Deopping %s.", player.getName()), false);
|
||||
player.setOp(false);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
else if (mode.equals("ci"))
|
||||
{
|
||||
p.getInventory().clear();
|
||||
player.getInventory().clear();
|
||||
}
|
||||
else if (mode.equals("fr"))
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setFrozen(!playerdata.isFrozen());
|
||||
|
||||
playerMsg(p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
player.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -17,12 +17,12 @@ public class Command_gcmd extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
@ -46,8 +46,8 @@ public class Command_gcmd extends TFM_Command
|
||||
|
||||
try
|
||||
{
|
||||
playerMsg("Sending command as " + p.getName() + ": " + outcommand);
|
||||
if (server.dispatchCommand(p, outcommand))
|
||||
playerMsg("Sending command as " + player.getName() + ": " + outcommand);
|
||||
if (server.dispatchCommand(player, outcommand))
|
||||
{
|
||||
playerMsg("Command sent.");
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ public class Command_glist extends TFM_Command
|
||||
|
||||
try
|
||||
{
|
||||
Player p = getPlayer(args[1]);
|
||||
Player player = getPlayer(args[1]);
|
||||
|
||||
username = p.getName();
|
||||
ip_addresses.add(p.getAddress().getAddress().getHostAddress());
|
||||
username = player.getName();
|
||||
ip_addresses.add(player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
TFM_UserListEntry entry = TFM_UserList.getInstance(plugin).getEntry(args[1]);
|
||||
|
||||
@ -75,11 +75,11 @@ public class Command_glist extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ip_addresses, ","), true);
|
||||
|
||||
Player p = server.getPlayerExact(username);
|
||||
if (p != null)
|
||||
Player player = server.getPlayerExact(username);
|
||||
if (player != null)
|
||||
{
|
||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
||||
p.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
|
||||
TFM_ServerInterface.banUsername(player.getName(), null, null, null);
|
||||
player.kickPlayer("You have been banned by " + sender.getName() + "\n If you think you have been banned wrongly, appeal here: http://www.totalfreedom.boards.net");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,7 +1,11 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -16,71 +20,71 @@ public class Command_gtfo extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
if (args.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
String ban_reason = null;
|
||||
if (args.length >= 2)
|
||||
{
|
||||
ban_reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
|
||||
// Op Player
|
||||
p.setOp(true);
|
||||
|
||||
//Undo WorldEdits:
|
||||
server.dispatchCommand(p, "/undo 15");
|
||||
|
||||
//rollback
|
||||
|
||||
server.dispatchCommand(sender, "rollback " + p.getName() + " all");
|
||||
// Undo WorldEdits:
|
||||
TFM_WorldEditBridge.getInstance().undo(player, 15);
|
||||
|
||||
// rollback
|
||||
TFM_RollbackManager.rollback(player.getName());
|
||||
|
||||
// deop
|
||||
p.setOp(false);
|
||||
player.setOp(false);
|
||||
|
||||
// set gamemode to survival:
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// clear inventory:
|
||||
p.getInventory().clear();
|
||||
player.getInventory().clear();
|
||||
|
||||
// strike with lightning effect:
|
||||
final Location target_pos = p.getLocation();
|
||||
final Location targetPos = player.getLocation();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
|
||||
target_pos.getWorld().strikeLightning(strike_pos);
|
||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
targetPos.getWorld().strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
// ban IP address:
|
||||
String user_ip = p.getAddress().getAddress().getHostAddress();
|
||||
String user_ip = player.getAddress().getAddress().getHostAddress();
|
||||
String[] ip_parts = user_ip.split("\\.");
|
||||
if (ip_parts.length == 4)
|
||||
{
|
||||
user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||
}
|
||||
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
|
||||
TFM_ServerInterface.banIP(user_ip, null, null, null);
|
||||
TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", player.getName(), user_ip), ChatColor.RED);
|
||||
TFM_ServerInterface.banIP(user_ip, ban_reason, null, null);
|
||||
|
||||
// ban username:
|
||||
TFM_ServerInterface.banUsername(p.getName(), null, null, null);
|
||||
TFM_ServerInterface.banUsername(player.getName(), ban_reason, null, null);
|
||||
|
||||
// kick Player:
|
||||
p.kickPlayer("GTFO");
|
||||
player.kickPlayer(ChatColor.RED + "GTFO" + (ban_reason != null ? ("\nReason: " + ChatColor.YELLOW + ban_reason) : ""));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,11 +23,11 @@ public class Command_halt extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Halting all non-superadmins.", true);
|
||||
int counter = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
setHalted(p, true);
|
||||
TFM_PlayerData.getPlayerData(player).setHalted(true);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@ -41,11 +39,12 @@ public class Command_halt extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unhalting all players.", true);
|
||||
int counter = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (TFM_PlayerData.getPlayerData(p).isHalted())
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (TFM_PlayerData.getPlayerData(player).isHalted())
|
||||
{
|
||||
setHalted(p, false);
|
||||
playerdata.setHalted(false);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
@ -77,60 +76,30 @@ public class Command_halt extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (!TFM_PlayerData.getPlayerData(p).isHalted())
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
|
||||
setHalted(p, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
|
||||
setHalted(p, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setHalted(Player p, boolean is_halted)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
|
||||
if (is_halted)
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (!playerdata.isHalted())
|
||||
{
|
||||
p.setOp(false);
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
p.setFlying(false);
|
||||
p.setDisplayName(p.getName());
|
||||
p.closeInventory();
|
||||
p.setTotalExperience(0);
|
||||
|
||||
playerdata.stopOrbiting();
|
||||
playerdata.setFrozen(true);
|
||||
playerdata.setMuted(true);
|
||||
TFM_Util.adminAction(sender.getName(), "Halting " + player.getName(), true);
|
||||
playerdata.setHalted(true);
|
||||
|
||||
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.setOp(true);
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
playerdata.setFrozen(false);
|
||||
playerdata.setMuted(false);
|
||||
TFM_Util.adminAction(sender.getName(), "Unhalting " + player.getName(), true);
|
||||
playerdata.setHalted(false);
|
||||
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +1,100 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_TickMeter;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.math.DoubleRange;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "View ticks-per-second", usage = "/<command>")
|
||||
public class Command_health extends TFM_Command
|
||||
{
|
||||
private static final int BYTES_PER_MB = 1024 * 1024;
|
||||
private static final DoubleRange TPS_RANGE = new DoubleRange(20.0 - 0.1, 20.0 + 0.1);
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long usedMem = runtime.totalMemory() - runtime.freeMemory();
|
||||
|
||||
Runnable task;
|
||||
task = new Runnable() // async
|
||||
playerMsg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb");
|
||||
playerMsg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB) + "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)");
|
||||
playerMsg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb");
|
||||
playerMsg("Calculating ticks per second, please wait...");
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
TFM_TickMeter meter = new TFM_TickMeter(plugin);
|
||||
meter.startTicking();
|
||||
Thread.sleep(1000); // per second
|
||||
meter.stopTicking();
|
||||
TFM_TickMeter tickMeter = new TFM_TickMeter(plugin);
|
||||
tickMeter.startTicking();
|
||||
Thread.sleep(2500);
|
||||
final double ticksPerSecond = tickMeter.stopTicking();
|
||||
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
int mb = 1048576; // 1024 * 1024
|
||||
|
||||
float usedMem = runtime.totalMemory() - runtime.freeMemory();
|
||||
|
||||
playerMsg("Reserved Memory: " + runtime.totalMemory() / mb + "mb");
|
||||
playerMsg("Used Memory: " + new DecimalFormat("#").format(usedMem / mb) + "mb (" + new DecimalFormat("#").format(usedMem / runtime.totalMemory() * 100) + "%)");
|
||||
playerMsg("Max Memory: " + runtime.maxMemory() / mb + "mb");
|
||||
playerMsg("Ticks per second: " + (meter.getTicks() == 20 ? ChatColor.GREEN : ChatColor.RED) + meter.getTicks());
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
playerMsg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
catch (Exception iex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.warning("Exception in TFM_TickMeter: Thread was interupted in sleeping process.");
|
||||
TFM_Log.warning(ExceptionUtils.getStackTrace(iex));
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
new Thread(task, "TickMeter").start();
|
||||
}.runTaskAsynchronously(plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TFM_TickMeter
|
||||
{
|
||||
private final AtomicInteger ticks = new AtomicInteger();
|
||||
private final TotalFreedomMod plugin;
|
||||
private long startTime;
|
||||
private BukkitTask task;
|
||||
|
||||
public TFM_TickMeter(TotalFreedomMod plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void startTicking()
|
||||
{
|
||||
startTime = System.currentTimeMillis();
|
||||
ticks.set(0);
|
||||
|
||||
task = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ticks.incrementAndGet();
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
public double stopTicking()
|
||||
{
|
||||
task.cancel();
|
||||
long elapsed = System.currentTimeMillis() - startTime;
|
||||
int tickCount = ticks.get();
|
||||
|
||||
return (double) tickCount / ((double) elapsed / 1000.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
|
||||
public class Command_invis extends TFM_Command {
|
||||
public class Command_invis extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -33,19 +33,21 @@ public class Command_invis extends TFM_Command {
|
||||
List<String> players = new ArrayList<String>();
|
||||
int smites = 0;
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
|
||||
players.add(p.getName());
|
||||
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (smite && !TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
server.dispatchCommand(sender, "smite " + p.getName());
|
||||
Command_smite.smite(player);
|
||||
smites++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (players.isEmpty()) {
|
||||
if (players.isEmpty())
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "There are no invisible players");
|
||||
return true;
|
||||
}
|
||||
@ -56,7 +58,7 @@ public class Command_invis extends TFM_Command {
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Invisble players (" + players.size() + "): " + StringUtils.join(players, ","));
|
||||
TFM_Util.playerMsg(sender, "Invisble players (" + players.size() + "): " + StringUtils.join(players, ", "));
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,94 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Jumppads;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info |sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
|
||||
public class Command_jumppads extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0 || args.length > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Strength: " + (TFM_Jumppads.getInstance().getStrength() * 10 - 1), ChatColor.BLUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TFM_Util.isStopCommand(args[0]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("sideways"))
|
||||
{
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("strength"))
|
||||
{
|
||||
final float strength;
|
||||
try
|
||||
{
|
||||
strength = Float.parseFloat(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
playerMsg("Invalid Strength");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strength > 10 || strength < 1)
|
||||
{
|
||||
playerMsg("Invalid Strength: The strength may be 1 through 10.");
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
|
||||
TFM_Jumppads.getInstance().setStrength((strength / 10) + 0.1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -16,11 +16,11 @@ public class Command_kicknoob extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Disconnecting all non-superadmins.", true);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
p.kickPlayer(ChatColor.RED + "Disconnected by admin.");
|
||||
player.kickPlayer(ChatColor.RED + "Disconnected by admin.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,18 +18,18 @@ public class Command_lastcmd extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
if (playerdata != null)
|
||||
{
|
||||
@ -38,7 +38,7 @@ public class Command_lastcmd extends TFM_Command
|
||||
{
|
||||
last_command = "(none)";
|
||||
}
|
||||
playerMsg(p.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
|
||||
playerMsg(player.getName() + " - Last Command: " + last_command, ChatColor.GRAY);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -25,9 +25,9 @@ public class Command_list extends TFM_Command
|
||||
if (TFM_Util.isFromHostConsole(sender.getName()))
|
||||
{
|
||||
List<String> player_names = new ArrayList<String>();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player_names.add(p.getName());
|
||||
player_names.add(player.getName());
|
||||
}
|
||||
playerMsg("There are " + player_names.size() + "/" + server.getMaxPlayers() + " players online:\n" + StringUtils.join(player_names, ", "), ChatColor.WHITE);
|
||||
return true;
|
||||
@ -50,9 +50,9 @@ public class Command_list extends TFM_Command
|
||||
onlineStats.append(ChatColor.BLUE).append(" players online.");
|
||||
|
||||
List<String> player_names = new ArrayList<String>();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(p);
|
||||
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
|
||||
|
||||
if (listFilter == ListFilter.SHOW_ADMINS && !userSuperadmin)
|
||||
{
|
||||
@ -63,7 +63,7 @@ public class Command_list extends TFM_Command
|
||||
|
||||
if (userSuperadmin)
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(p))
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player))
|
||||
{
|
||||
prefix = (ChatColor.LIGHT_PURPLE + "[SrA]");
|
||||
}
|
||||
@ -72,20 +72,25 @@ public class Command_list extends TFM_Command
|
||||
prefix = (ChatColor.GOLD + "[SA]");
|
||||
}
|
||||
|
||||
if (p.getName().equalsIgnoreCase("madgeek1450") || p.getName().equalsIgnoreCase("darthsalamon"))
|
||||
if (TFM_Util.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
prefix = (ChatColor.DARK_PURPLE + "[Dev]");
|
||||
}
|
||||
|
||||
if (player.getName().equals("markbyron"))
|
||||
{
|
||||
prefix = (ChatColor.BLUE + "[Owner]");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.isOp())
|
||||
if (player.isOp())
|
||||
{
|
||||
prefix = (ChatColor.RED + "[OP]");
|
||||
}
|
||||
}
|
||||
|
||||
player_names.add(prefix + p.getName() + ChatColor.WHITE);
|
||||
player_names.add(prefix + player.getName() + ChatColor.WHITE);
|
||||
}
|
||||
|
||||
onlineUsers.append("Connected ").append(listFilter == ListFilter.SHOW_ADMINS ? "admins" : "players").append(": ").append(StringUtils.join(player_names, ", "));
|
||||
|
@ -0,0 +1,34 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Prevents new players from joining the server", usage = "/<command> <on | off>")
|
||||
public class Command_lockdown extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TFM_Util.isStopCommand(args[0]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "De-activating server lockdown", true);
|
||||
TotalFreedomMod.lockdownEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Activating server lockdown", true);
|
||||
TotalFreedomMod.lockdownEnabled = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@ -22,18 +21,18 @@ public class Command_lockup extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Locking up all players", true);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
startLockup(p);
|
||||
startLockup(player);
|
||||
}
|
||||
playerMsg("Locked up all players.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unlocking all players", true);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
cancelLockup(p);
|
||||
cancelLockup(player);
|
||||
}
|
||||
|
||||
playerMsg("Unlocked all players.");
|
||||
@ -47,37 +46,37 @@ public class Command_lockup extends TFM_Command
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("on"))
|
||||
{
|
||||
final Player p;
|
||||
final Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Locking up " + p.getName(), true);
|
||||
startLockup(p);
|
||||
playerMsg("Locked up " + p.getName() + ".");
|
||||
TFM_Util.adminAction(sender.getName(), "Locking up " + player.getName(), true);
|
||||
startLockup(player);
|
||||
playerMsg("Locked up " + player.getName() + ".");
|
||||
}
|
||||
else if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
final Player p;
|
||||
final Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Unlocking " + p.getName(), true);
|
||||
cancelLockup(p);
|
||||
playerMsg("Unlocked " + p.getName() + ".");
|
||||
TFM_Util.adminAction(sender.getName(), "Unlocking " + player.getName(), true);
|
||||
cancelLockup(player);
|
||||
playerMsg("Unlocked " + player.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -102,38 +101,31 @@ public class Command_lockup extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelLockup(final Player p)
|
||||
private void cancelLockup(final Player player)
|
||||
{
|
||||
cancelLockup(TFM_PlayerData.getPlayerData(p));
|
||||
cancelLockup(TFM_PlayerData.getPlayerData(player));
|
||||
}
|
||||
|
||||
private void startLockup(final Player p)
|
||||
private void startLockup(final Player player)
|
||||
{
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
cancelLockup(playerdata);
|
||||
|
||||
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
|
||||
playerdata.setLockupScheduleID(new BukkitRunnable()
|
||||
{
|
||||
private Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (p.isOnline())
|
||||
if (player.isOnline())
|
||||
{
|
||||
p.openWorkbench(null, true);
|
||||
|
||||
Location l = p.getLocation().clone();
|
||||
l.setPitch(random.nextFloat() * 360.0f);
|
||||
l.setYaw(random.nextFloat() * 360.0f);
|
||||
p.teleport(l);
|
||||
player.openInventory(player.getInventory());
|
||||
}
|
||||
else
|
||||
{
|
||||
cancelLockup(playerdata);
|
||||
}
|
||||
}
|
||||
}, 0L, 5L));
|
||||
}.runTaskTimer(plugin, 0L, 5L));
|
||||
}
|
||||
}
|
||||
|
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,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -74,6 +75,8 @@ public class Command_moblimiter extends TFM_Command
|
||||
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
|
||||
}
|
||||
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TotalFreedomMod.mobLimiterEnabled);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,27 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Purge all mobs in all worlds.", usage = "/<command>")
|
||||
public class Command_mp extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Purging all mobs...");
|
||||
playerMsg("Purging all mobs...");
|
||||
playerMsg(purgeMobs() + " mobs removed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int purgeMobs()
|
||||
{
|
||||
int removed = 0;
|
||||
for (World world : server.getWorlds())
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity ent : world.getLivingEntities())
|
||||
{
|
||||
@ -28,8 +33,6 @@ public class Command_mp extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(removed + " mobs removed.");
|
||||
|
||||
return true;
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
|
125
src/me/StevenLawson/TotalFreedomMod/Commands/Command_nf.java
Normal file
125
src/me/StevenLawson/TotalFreedomMod/Commands/Command_nf.java
Normal file
@ -0,0 +1,125 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "NickFilter: Prefix any command with this command to replace nicknames in that command with real names. Nicknames should be prefixed with a !.", usage = "/<command> <other_command> !<playernick>")
|
||||
public class Command_nf extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
boolean nickMatched = false;
|
||||
|
||||
final List<String> outputCommand = new ArrayList<String>();
|
||||
|
||||
if (args.length >= 1)
|
||||
{
|
||||
final List<String> argsList = Arrays.asList(args);
|
||||
for (String arg : argsList)
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
Matcher matcher = Pattern.compile("^!(.+)$").matcher(arg);
|
||||
if (matcher.find())
|
||||
{
|
||||
String displayName = matcher.group(1);
|
||||
try
|
||||
{
|
||||
player = getPlayerByDisplayName(displayName);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
if (player == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
player = getPlayerByDisplayNameAlt(displayName);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
outputCommand.add(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
nickMatched = true;
|
||||
outputCommand.add(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nickMatched)
|
||||
{
|
||||
sender.sendMessage("No nicknames replaced in command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String newCommand = StringUtils.join(outputCommand, " ");
|
||||
sender.sendMessage("Sending command: \"" + newCommand + "\".");
|
||||
server.dispatchCommand(sender, newCommand);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayName(String needle) throws PlayerNotFoundException
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
Player[] onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
for (Player player : onlinePlayers)
|
||||
{
|
||||
if (player.getDisplayName().toLowerCase().trim().contains(needle))
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
private static Player getPlayerByDisplayNameAlt(String needle) throws PlayerNotFoundException
|
||||
{
|
||||
needle = needle.toLowerCase().trim();
|
||||
|
||||
Integer minEditDistance = null;
|
||||
Player minEditMatch = null;
|
||||
|
||||
Player[] onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
for (Player player : onlinePlayers)
|
||||
{
|
||||
String haystack = player.getDisplayName().toLowerCase().trim();
|
||||
int editDistance = StringUtils.getLevenshteinDistance(needle, haystack.toLowerCase());
|
||||
if (minEditDistance == null || minEditDistance.intValue() > editDistance)
|
||||
{
|
||||
minEditDistance = editDistance;
|
||||
minEditMatch = player;
|
||||
}
|
||||
}
|
||||
|
||||
if (minEditMatch == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
return minEditMatch;
|
||||
}
|
||||
}
|
@ -43,9 +43,9 @@ public class Command_onlinemode extends TFM_Command
|
||||
|
||||
if (online_mode)
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
||||
player.kickPlayer("Server is activating \"online-mode=true\". Please reconnect.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,21 +26,21 @@ public class Command_op extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer p = null;
|
||||
OfflinePlayer player = null;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
|
||||
{
|
||||
p = onlinePlayer;
|
||||
player = onlinePlayer;
|
||||
}
|
||||
}
|
||||
|
||||
// if the player is not online
|
||||
if (p == null)
|
||||
if (player == null)
|
||||
{
|
||||
if (TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
|
||||
{
|
||||
p = server.getOfflinePlayer(args[0]);
|
||||
player = server.getOfflinePlayer(args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -50,8 +50,8 @@ public class Command_op extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
|
||||
p.setOp(true);
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
|
||||
player.setOp(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ public class Command_opall extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.setOp(true);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
player.setOp(true);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
|
||||
if (doSetGamemode)
|
||||
{
|
||||
p.setGameMode(targetGamemode);
|
||||
player.setGameMode(targetGamemode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ public class Command_ops extends TFM_Command
|
||||
int offlineOPs = 0;
|
||||
int totalOPs = 0;
|
||||
|
||||
for (OfflinePlayer p : server.getOperators())
|
||||
for (OfflinePlayer player : server.getOperators())
|
||||
{
|
||||
if (p.isOnline())
|
||||
if (player.isOnline())
|
||||
{
|
||||
onlineOPs++;
|
||||
}
|
||||
@ -61,13 +61,13 @@ public class Command_ops extends TFM_Command
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all operators", true);
|
||||
|
||||
for (OfflinePlayer p : server.getOperators())
|
||||
for (OfflinePlayer player : server.getOperators())
|
||||
{
|
||||
p.setOp(false);
|
||||
player.setOp(false);
|
||||
|
||||
if (p.isOnline())
|
||||
if (player.isOnline())
|
||||
{
|
||||
p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
player.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,18 +21,18 @@ public class Command_orbit extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
double strength = 10.0;
|
||||
|
||||
@ -40,7 +40,7 @@ public class Command_orbit extends TFM_Command
|
||||
{
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
playerMsg("Stopped orbiting " + p.getName());
|
||||
playerMsg("Stopped orbiting " + player.getName());
|
||||
playerdata.stopOrbiting();
|
||||
return true;
|
||||
}
|
||||
@ -56,11 +56,11 @@ public class Command_orbit extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
playerdata.startOrbiting(strength);
|
||||
|
||||
p.setVelocity(new Vector(0, strength, 0));
|
||||
TFM_Util.adminAction(sender.getName(), "Orbiting " + p.getName() + ".", false);
|
||||
player.setVelocity(new Vector(0, strength, 0));
|
||||
TFM_Util.adminAction(sender.getName(), "Orbiting " + player.getName() + ".", false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -58,20 +58,20 @@ public class Command_plugincontrol extends TFM_Command
|
||||
else if (commandMode == CommandMode.RELOAD)
|
||||
{
|
||||
playerMsg("Disabling all plugins.");
|
||||
for (Plugin p : pluginManager.getPlugins())
|
||||
for (Plugin targetPlugin : pluginManager.getPlugins())
|
||||
{
|
||||
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||
if (!targetPlugin.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||
{
|
||||
pluginManager.disablePlugin(p);
|
||||
pluginManager.disablePlugin(targetPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg("Enabling all plugins.");
|
||||
for (Plugin p : pluginManager.getPlugins())
|
||||
for (Plugin targetPlugin : pluginManager.getPlugins())
|
||||
{
|
||||
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||
if (!targetPlugin.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||
{
|
||||
pluginManager.enablePlugin(p);
|
||||
pluginManager.enablePlugin(targetPlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,11 +81,11 @@ public class Command_plugincontrol extends TFM_Command
|
||||
|
||||
Plugin targetPlugin = null;
|
||||
|
||||
for (Plugin p : pluginManager.getPlugins())
|
||||
for (Plugin serverPlugin : pluginManager.getPlugins())
|
||||
{
|
||||
if (searchPluginName.equalsIgnoreCase(p.getName().toLowerCase().trim()))
|
||||
if (searchPluginName.equalsIgnoreCase(serverPlugin.getName().toLowerCase().trim()))
|
||||
{
|
||||
targetPlugin = p;
|
||||
targetPlugin = serverPlugin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(
|
||||
description = "Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).",
|
||||
usage = "/<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>")
|
||||
usage = "/<command> <list | clear [target name] | add <type> <duration> <amplifier> [target name]>")
|
||||
public class Command_potion extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public class Command_potion extends TFM_Command
|
||||
{
|
||||
target = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
@ -107,7 +107,7 @@ public class Command_potion extends TFM_Command
|
||||
{
|
||||
target = getPlayer(args[4]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
|
@ -0,0 +1,72 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Validates if a given account is premium.", usage = "/<command> <player>", aliases = "prem")
|
||||
public class Command_premium extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String name;
|
||||
try
|
||||
{
|
||||
name = getPlayer(args[0]).getName();
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
name = args[0];
|
||||
}
|
||||
|
||||
final String playername = name;
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final URL getUrl = new URL("https://minecraft.net/haspaid.jsp?user=" + playername);
|
||||
final URLConnection urlConnection = getUrl.openConnection();
|
||||
// Read the response
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
||||
final String message = ("false".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
||||
in.close();
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
playerMsg("Player " + playername + " is premium: " + message);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ExceptionUtils.getStackTrace(ex));
|
||||
playerMsg("There was an error querying the mojang server.", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
|
||||
public class Command_purgeall extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
|
||||
|
||||
// Purge entities
|
||||
TFM_Util.TFM_EntityWiper.wipeEntities(true, true);
|
||||
|
||||
// Undisguise all players
|
||||
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
// Unmute all players
|
||||
if (playerdata.isMuted())
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
}
|
||||
|
||||
// Unblock all commands
|
||||
if (playerdata.allCommandsBlocked())
|
||||
{
|
||||
playerdata.setCommandsBlocked(false);
|
||||
}
|
||||
|
||||
// Unhalt all players
|
||||
if (playerdata.isHalted())
|
||||
{
|
||||
playerdata.setHalted(false);
|
||||
}
|
||||
|
||||
// Stop orbiting
|
||||
if (playerdata.isOrbiting())
|
||||
{
|
||||
playerdata.stopOrbiting();
|
||||
}
|
||||
|
||||
// Unfreeze
|
||||
if (playerdata.isFrozen())
|
||||
{
|
||||
playerdata.setFrozen(false);
|
||||
}
|
||||
|
||||
// Purge potion effects
|
||||
for (PotionEffect potion_effect : player.getActivePotionEffects())
|
||||
{
|
||||
player.removePotionEffect(potion_effect.getType());
|
||||
}
|
||||
|
||||
// Uncage
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
playerdata.setCaged(false);
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear auto-unmute and auto-unfreeze tasks
|
||||
if (TotalFreedomMod.mutePurgeTask != null)
|
||||
{
|
||||
TotalFreedomMod.mutePurgeTask.cancel();
|
||||
}
|
||||
|
||||
TotalFreedomMod.allPlayersFrozen = false;
|
||||
if (TotalFreedomMod.freezePurgeTask != null)
|
||||
{
|
||||
TotalFreedomMod.freezePurgeTask.cancel();
|
||||
}
|
||||
|
||||
// Remove all mobs
|
||||
Command_mp.purgeMobs();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -26,20 +26,20 @@ public class Command_qdeop extends TFM_Command
|
||||
|
||||
boolean matched_player = false;
|
||||
|
||||
String target_name = args[0].toLowerCase();
|
||||
String targetName = args[0].toLowerCase();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.getName().toLowerCase().indexOf(target_name) != -1 || p.getDisplayName().toLowerCase().indexOf(target_name) != -1)
|
||||
if (player.getName().toLowerCase().indexOf(targetName) != -1 || player.getDisplayName().toLowerCase().indexOf(targetName) != -1)
|
||||
{
|
||||
matched_player = true;
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping " + p.getName(), false);
|
||||
TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false);
|
||||
}
|
||||
p.setOp(false);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
player.setOp(false);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,20 +26,20 @@ public class Command_qop extends TFM_Command
|
||||
|
||||
boolean matched_player = false;
|
||||
|
||||
String target_name = args[0].toLowerCase();
|
||||
String targetName = args[0].toLowerCase();
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.getName().toLowerCase().indexOf(target_name) != -1 || p.getDisplayName().toLowerCase().indexOf(target_name) != -1)
|
||||
if (player.getName().toLowerCase().indexOf(targetName) != -1 || player.getDisplayName().toLowerCase().indexOf(targetName) != -1)
|
||||
{
|
||||
matched_player = true;
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + p.getName(), false);
|
||||
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
|
||||
}
|
||||
p.setOp(true);
|
||||
p.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
player.setOp(true);
|
||||
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RadarData;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -21,13 +21,13 @@ public class Command_radar extends TFM_Command
|
||||
|
||||
List<TFM_RadarData> radar_data = new ArrayList<TFM_RadarData>();
|
||||
|
||||
for (Player p : sender_pos.getWorld().getPlayers())
|
||||
for (Player player : sender_pos.getWorld().getPlayers())
|
||||
{
|
||||
if (!p.equals(sender_p))
|
||||
if (!player.equals(sender_p))
|
||||
{
|
||||
try
|
||||
{
|
||||
radar_data.add(new TFM_RadarData(p, sender_pos.distance(p.getLocation()), p.getLocation()));
|
||||
radar_data.add(new TFM_RadarData(player, sender_pos.distance(player.getLocation()), player.getLocation()));
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
@ -71,4 +71,39 @@ public class Command_radar extends TFM_Command
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TFM_RadarData implements Comparator<TFM_RadarData>
|
||||
{
|
||||
public Player player;
|
||||
public double distance;
|
||||
public Location location;
|
||||
|
||||
public TFM_RadarData(Player player, double distance, Location location)
|
||||
{
|
||||
this.player = player;
|
||||
this.distance = distance;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public TFM_RadarData()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(TFM_RadarData t1, TFM_RadarData t2)
|
||||
{
|
||||
if (t1.distance > t2.distance)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (t1.distance < t2.distance)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ public class Command_rank extends TFM_Command
|
||||
{
|
||||
if (senderIsConsole && args.length < 1)
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
playerMsg(p.getName() + " is " + TFM_Util.getRank(p));
|
||||
playerMsg(player.getName() + " is " + TFM_Util.getRank(player));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -33,18 +33,18 @@ public class Command_rank extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg(p.getName() + " is " + TFM_Util.getRank(p), ChatColor.AQUA);
|
||||
playerMsg(player.getName() + " is " + TFM_Util.getRank(player), ChatColor.AQUA);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,7 +15,7 @@ public class Command_rawsay extends TFM_Command
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
TFM_Util.bcastMsg(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, " ")));
|
||||
TFM_Util.bcastMsg(TFM_Util.colorise(StringUtils.join(args, " ")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -13,7 +13,7 @@ public class Command_rd extends TFM_Command
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all server entities.", true);
|
||||
playerMsg((TFM_Util.wipeEntities(true, true)) + " enties removed.");
|
||||
playerMsg((TFM_Util.TFM_EntityWiper.wipeEntities(true, true)) + " enties removed.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -51,14 +51,14 @@ public class Command_ro extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
Player target_player = null;
|
||||
Player targetPlayer = null;
|
||||
if (args.length == 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
target_player = getPlayer(args[2]);
|
||||
targetPlayer = getPlayer(args[2]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
@ -67,18 +67,18 @@ public class Command_ro extends TFM_Command
|
||||
|
||||
int affected = 0;
|
||||
|
||||
if (target_player == null)
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of all players. Brace for lag...", senderIsConsole);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
affected += TFM_Util.replaceBlocks(p.getLocation(), from_material, Material.AIR, radius);
|
||||
affected += TFM_Util.replaceBlocks(player.getLocation(), from_material, Material.AIR, radius);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of " + target_player.getName() + ".", senderIsConsole);
|
||||
affected += TFM_Util.replaceBlocks(target_player.getLocation(), from_material, Material.AIR, radius);
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all " + from_material.name() + " within " + radius + " blocks of " + targetPlayer.getName() + ".", senderIsConsole);
|
||||
affected += TFM_Util.replaceBlocks(targetPlayer.getLocation(), from_material, Material.AIR, radius);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Remove complete. " + affected + " blocks removed.", senderIsConsole);
|
||||
|
@ -0,0 +1,74 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | purge [partialname] | purgeall>", aliases = "rb")
|
||||
public class Command_rollback extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("purgeall"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Purging all rollback history.", false);
|
||||
playerMsg("Purged all rollback history for " + TFM_RollbackManager.purgeEntries() + " players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String playerName = getPlayerName(args[0]);
|
||||
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
|
||||
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
|
||||
}
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
String playerName = getPlayerName(args[1]);
|
||||
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getPlayerName(String playerNameInput)
|
||||
{
|
||||
String playerName = null;
|
||||
|
||||
try
|
||||
{
|
||||
Player player = getPlayer(playerNameInput);
|
||||
if (player != null)
|
||||
{
|
||||
playerName = player.getName();
|
||||
}
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (playerName == null)
|
||||
{
|
||||
playerName = TFM_UserList.getInstance(plugin).searchByPartialName(playerNameInput);
|
||||
}
|
||||
|
||||
return playerName;
|
||||
}
|
||||
}
|
@ -26,15 +26,15 @@ public class Command_saconfig extends TFM_Command
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!senderIsConsole)
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
{
|
||||
playerMsg("This command may only be used from the console.");
|
||||
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equals("clean"))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list.", true);
|
||||
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
|
||||
TFM_SuperadminList.cleanSuperadminList(true);
|
||||
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "), ChatColor.YELLOW);
|
||||
}
|
||||
@ -66,7 +66,7 @@ public class Command_saconfig extends TFM_Command
|
||||
{
|
||||
superadmin = TFM_SuperadminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class Command_saconfig extends TFM_Command
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', superadmin.toString())));
|
||||
playerMsg(ChatColor.stripColor(TFM_Util.colorise(superadmin.toString())));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -91,14 +91,14 @@ public class Command_saconfig extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
Player p = null;
|
||||
Player player = null;
|
||||
String admin_name = null;
|
||||
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[1]);
|
||||
player = getPlayer(args[1]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
TFM_Superadmin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
|
||||
if (superadmin != null)
|
||||
@ -112,10 +112,10 @@ public class Command_saconfig extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
if (p != null)
|
||||
if (player != null)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the superadmin list.", true);
|
||||
TFM_SuperadminList.addSuperadmin(p);
|
||||
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list.", true);
|
||||
TFM_SuperadminList.addSuperadmin(player);
|
||||
}
|
||||
else if (admin_name != null)
|
||||
{
|
||||
@ -131,24 +131,24 @@ public class Command_saconfig extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
String target_name = args[1];
|
||||
String targetName = args[1];
|
||||
|
||||
try
|
||||
{
|
||||
target_name = getPlayer(target_name).getName();
|
||||
targetName = getPlayer(targetName).getName();
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.getSuperadminNames().contains(target_name.toLowerCase()))
|
||||
if (!TFM_SuperadminList.getSuperadminNames().contains(targetName.toLowerCase()))
|
||||
{
|
||||
playerMsg("Superadmin not found: " + target_name);
|
||||
playerMsg("Superadmin not found: " + targetName);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from the superadmin list", true);
|
||||
TFM_SuperadminList.removeSuperadmin(target_name);
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
|
||||
TFM_SuperadminList.removeSuperadmin(targetName);
|
||||
|
||||
if (!TotalFreedomMod.twitterbotEnabled)
|
||||
{
|
||||
@ -157,15 +157,15 @@ public class Command_saconfig extends TFM_Command
|
||||
|
||||
// Twitterbot
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
|
||||
String reply = twitterbot.delTwitter(target_name);
|
||||
String reply = twitterbot.delTwitter(targetName);
|
||||
if ("ok".equals(reply))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from TwitterBot", true);
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from TwitterBot", true);
|
||||
}
|
||||
else if ("disabled".equals(reply))
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "Warning: Could not check if player has a twitter handle!");
|
||||
TFM_Util.playerMsg(sender, "TwitterBot has been temporarily disabled,, please wait until it get re-enabled", ChatColor.RED);
|
||||
TFM_Util.playerMsg(sender, "TwitterBot has been temporarily disabled, please wait until it gets re-enabled", ChatColor.RED);
|
||||
}
|
||||
else if ("failed".equals(reply))
|
||||
{
|
||||
@ -184,7 +184,7 @@ public class Command_saconfig extends TFM_Command
|
||||
}
|
||||
else if ("notfound".equals(reply))
|
||||
{
|
||||
TFM_Util.playerMsg(sender, target_name + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
|
||||
TFM_Util.playerMsg(sender, targetName + " did not have a twitter handle registered to their name.", ChatColor.GREEN);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ public class Command_say extends TFM_Command
|
||||
{
|
||||
TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.kickPlayer("Server is going offline, come back in a few minutes.");
|
||||
player.kickPlayer("Server is going offline, come back in a few minutes.");
|
||||
}
|
||||
|
||||
server.shutdown();
|
||||
|
@ -0,0 +1,28 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker.TFM_ServiceChecker_ServiceStatus;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows the status of all Mojang services", usage = "/<command>")
|
||||
public class Command_services extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerMsg("Mojang Services" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
|
||||
for (TFM_ServiceChecker_ServiceStatus service : TFM_ServiceChecker.getInstance().getAllStatuses())
|
||||
{
|
||||
playerMsg(service.getFormattedStatus());
|
||||
}
|
||||
playerMsg("Version" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().version, ChatColor.DARK_PURPLE);
|
||||
playerMsg("Last Check" + ChatColor.WHITE + ": " + TFM_ServiceChecker.getInstance().lastCheck, ChatColor.DARK_PURPLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to 500.", usage = "/<command>")
|
||||
public class Command_setl extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
||||
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
{
|
||||
web.setLimit(player, 500);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -21,43 +21,48 @@ public class Command_smite extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
smite(player);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void smite(final Player player)
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
|
||||
//Deop
|
||||
p.setOp(false);
|
||||
player.setOp(false);
|
||||
|
||||
//Set gamemode to survival:
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
//Clear inventory:
|
||||
p.getInventory().clear();
|
||||
player.getInventory().clear();
|
||||
|
||||
//Strike with lightning effect:
|
||||
final Location target_pos = p.getLocation();
|
||||
final World world = p.getWorld();
|
||||
final Location targetPos = player.getLocation();
|
||||
final World world = player.getWorld();
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
final Location strike_pos = new Location(world, target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
|
||||
final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||
world.strikeLightning(strike_pos);
|
||||
}
|
||||
}
|
||||
|
||||
//Kill:
|
||||
p.setHealth(0);
|
||||
|
||||
return true;
|
||||
player.setHealth(0.0);
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,12 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
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 me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
||||
@ -40,11 +27,9 @@ public class Command_status extends TFM_Command
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerMsg(String.format("Total Freedom Mod v%s.%s, built %s.", TotalFreedomMod.pluginVersion, TotalFreedomMod.buildNumber, TotalFreedomMod.buildDate), ChatColor.GOLD);
|
||||
playerMsg("TotalFreedomMod was created by Madgeek1450 and DarthSalamon.", ChatColor.GOLD);
|
||||
playerMsg("For information about TotalFreedomMod, try /tfm", ChatColor.GREEN); // Temporary
|
||||
|
||||
playerMsg("Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'.", ChatColor.YELLOW);
|
||||
|
||||
playerMsg("Loaded worlds:", ChatColor.BLUE);
|
||||
int i = 0;
|
||||
for (World world : server.getWorlds())
|
||||
@ -52,59 +37,6 @@ public class Command_status extends TFM_Command
|
||||
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
||||
}
|
||||
|
||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
@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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> [<player> | list | purge | all]", aliases = "mute")
|
||||
@ -54,10 +54,9 @@ public class Command_stfu extends TFM_Command
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (TotalFreedomMod.mutePurgeEventId != 0)
|
||||
if (TotalFreedomMod.mutePurgeTask != null)
|
||||
{
|
||||
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
|
||||
TotalFreedomMod.mutePurgeEventId = 0;
|
||||
TotalFreedomMod.mutePurgeTask.cancel();
|
||||
}
|
||||
playerMsg("Unmuted " + count + " players.");
|
||||
}
|
||||
@ -67,69 +66,67 @@ public class Command_stfu extends TFM_Command
|
||||
|
||||
TFM_PlayerData playerdata;
|
||||
int counter = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setMuted(true);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
TotalFreedomMod.mutePurgeEventId = server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
if (TotalFreedomMod.mutePurgeTask != null)
|
||||
{
|
||||
TotalFreedomMod.mutePurgeTask.cancel();
|
||||
}
|
||||
|
||||
TotalFreedomMod.mutePurgeTask = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (TotalFreedomMod.mutePurgeEventId == 0)
|
||||
{
|
||||
TFM_Log.warning("Mute autopurge task was improperly cancelled!");
|
||||
return;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("MuteTimer", "Unmuting all players", false);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData.getPlayerData(p).setMuted(false);
|
||||
TFM_PlayerData.getPlayerData(player).setMuted(false);
|
||||
}
|
||||
|
||||
TotalFreedomMod.mutePurgeEventId = 0;
|
||||
}
|
||||
}, 6000L); // five minutes in ticks: 20*60*5
|
||||
}.runTaskLater(plugin, 20L * 60L * 5L);
|
||||
|
||||
playerMsg("Muted " + counter + " players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.isMuted())
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Unmuting " + p.getName(), true);
|
||||
TFM_Util.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||
playerdata.setMuted(false);
|
||||
playerMsg("Unmuted " + p.getName());
|
||||
playerMsg("Unmuted " + player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Muting " + p.getName(), true);
|
||||
TFM_Util.adminAction(sender.getName(), "Muting " + player.getName(), true);
|
||||
playerdata.setMuted(true);
|
||||
playerMsg("Muted " + p.getName());
|
||||
playerMsg("Muted " + player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg(p.getName() + " is a superadmin, and can't be muted.");
|
||||
playerMsg(player.getName() + " is a superadmin, and can't be muted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ public class Command_stop extends TFM_Command
|
||||
{
|
||||
TFM_Util.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.kickPlayer("Server is going offline, come back in a few minutes.");
|
||||
player.kickPlayer("Server is going offline, come back in about 20 seconds.");
|
||||
}
|
||||
|
||||
server.shutdown();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
@ -8,7 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> [partialname]")
|
||||
@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/<command> <[partialname] | -a>")
|
||||
public class Command_survival extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
@ -23,20 +25,38 @@ public class Command_survival extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
p = sender_p;
|
||||
player = sender_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("-a"))
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Player targetPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Changing everyone's gamemode to survival", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (senderIsConsole || TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
@ -49,9 +69,9 @@ public class Command_survival extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg("Setting " + p.getName() + " to game mode 'Survival'.");
|
||||
p.sendMessage(sender.getName() + " set your game mode to 'Survival'.");
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
playerMsg("Setting " + player.getName() + " to game mode 'Survival'.");
|
||||
player.sendMessage(sender.getName() + " set your game mode to 'Survival'.");
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
128
src/me/StevenLawson/TotalFreedomMod/Commands/Command_tag.java
Normal file
128
src/me/StevenLawson/TotalFreedomMod/Commands/Command_tag.java
Normal file
@ -0,0 +1,128 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sets yourself a prefix", usage = "/<command> <<prefix> | off | clear <player> | clearall>")
|
||||
public class Command_tag extends TFM_Command
|
||||
{
|
||||
public static final List<String> FORBIDDEN_WORDS = Arrays.asList(new String[]
|
||||
{
|
||||
"admin", "owner", "moderator", "developer", "&k"
|
||||
});
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if ("clearall".equals(args[0]))
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Removing all tags", false);
|
||||
int count = 0;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
if (playerdata.getTag() != null)
|
||||
{
|
||||
count++;
|
||||
TFM_PlayerData.getPlayerData(player).setTag(null);
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(count + " tag(s) removed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
playerMsg("Only in-game players can set tags. Use \"/tag clearall\" to reset all tags.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TFM_Util.isStopCommand(args[0]))
|
||||
{
|
||||
TFM_PlayerData.getPlayerData(sender_p).setTag(null);
|
||||
playerMsg("Your tag has been removed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].length() > 15)
|
||||
{
|
||||
playerMsg("That tag is too long.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
for (String word : FORBIDDEN_WORDS)
|
||||
{
|
||||
if (args[0].toLowerCase().contains(word.toLowerCase()))
|
||||
{
|
||||
if (word.contains(String.valueOf(ChatColor.COLOR_CHAR)))
|
||||
{
|
||||
playerMsg("That tag contains a forbidden color-code.");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("That tag contains a forbidden word.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TFM_PlayerData.getPlayerData(sender_p).setTag(args[0]);
|
||||
playerMsg("Tag set.");
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if ("clear".equals(args[0]))
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
final Player player;
|
||||
try
|
||||
{
|
||||
player = getPlayer(args[1]);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_PlayerData.getPlayerData(player).setTag(null);
|
||||
playerMsg("Removed " + player.getName() + "'s tag.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope")
|
||||
public class Command_tban extends TFM_Command {
|
||||
|
||||
public class Command_tban extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -19,23 +19,22 @@ public class Command_tban extends TFM_Command {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "NOPE: " + p.getName(), true);
|
||||
TFM_ServerInterface.banUsername(p.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes",
|
||||
TFM_Util.adminAction(sender.getName(), "NOPE: " + player.getName(), true);
|
||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes",
|
||||
sender.getName(), TFM_Util.parseDateOffset("5m"));
|
||||
p.kickPlayer(ChatColor.RED + "NOPE!\nYou have been temporarily banned for five minutes.");
|
||||
player.kickPlayer(ChatColor.RED + "NOPE!\nYou have been temporarily banned for five minutes.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,18 +25,18 @@ public class Command_tempban extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
Player p;
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(args[0]);
|
||||
player = getPlayer(args[0]);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
playerMsg(ex.getMessage(), ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
StringBuilder bcast_msg = new StringBuilder("Temporarily banned " + p.getName());
|
||||
StringBuilder bcast_msg = new StringBuilder("Temporarily banned " + player.getName());
|
||||
|
||||
Date ban_duration = TFM_Util.parseDateOffset("30m");
|
||||
if (args.length >= 2)
|
||||
@ -57,9 +57,9 @@ public class Command_tempban extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), bcast_msg.toString(), true);
|
||||
TFM_ServerInterface.banUsername(p.getName(), ban_reason, sender.getName(), ban_duration);
|
||||
TFM_ServerInterface.banIP(p.getAddress().getAddress().getHostAddress().trim(), ban_reason, sender.getName(), ban_duration);
|
||||
p.kickPlayer(sender.getName() + " - " + bcast_msg.toString());
|
||||
TFM_ServerInterface.banUsername(player.getName(), ban_reason, sender.getName(), ban_duration);
|
||||
TFM_ServerInterface.banIP(player.getAddress().getAddress().getHostAddress().trim(), ban_reason, sender.getName(), ban_duration);
|
||||
player.kickPlayer(sender.getName() + " - " + bcast_msg.toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ public class Command_tfbanlist extends TFM_Command
|
||||
StringBuilder banned_players = new StringBuilder();
|
||||
banned_players.append("Banned Players: ");
|
||||
boolean first = true;
|
||||
for (OfflinePlayer p : server.getBannedPlayers())
|
||||
for (OfflinePlayer player : server.getBannedPlayers())
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
banned_players.append(", ");
|
||||
}
|
||||
first = false;
|
||||
banned_players.append(p.getName().trim());
|
||||
banned_players.append(player.getName().trim());
|
||||
}
|
||||
|
||||
playerMsg(banned_players.toString());
|
||||
|
@ -0,0 +1,23 @@
|
||||
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.GREEN);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
||||
@ -16,6 +17,7 @@ public class Command_tfupdate extends TFM_Command
|
||||
{
|
||||
"http://s3.madgeekonline.com/totalfreedom/BukkitHttpd.jar",
|
||||
"http://s3.madgeekonline.com/totalfreedom/BukkitTelnet.jar",
|
||||
"http://s3.madgeekonline.com/totalfreedom/DisguiseCraft.jar",
|
||||
"http://s3.madgeekonline.com/totalfreedom/Essentials.jar",
|
||||
"http://s3.madgeekonline.com/totalfreedom/EssentialsSpawn.jar",
|
||||
"http://s3.madgeekonline.com/totalfreedom/TotalFreedomMod.jar",
|
||||
@ -34,7 +36,7 @@ public class Command_tfupdate extends TFM_Command
|
||||
|
||||
for (final String url : FILES)
|
||||
{
|
||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -60,7 +62,7 @@ public class Command_tfupdate extends TFM_Command
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
108
src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java
Normal file
108
src/me/StevenLawson/TotalFreedomMod/Commands/Command_trail.java
Normal file
@ -0,0 +1,108 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
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.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Pretty rainbow trails.", usage = "/<command> [off]")
|
||||
public class Command_trail extends TFM_Command
|
||||
{
|
||||
private static Listener movementListener = null;
|
||||
private static final List<Player> trailPlayers = new ArrayList<Player>();
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0 && TFM_Util.isStopCommand(args[0]))
|
||||
{
|
||||
trailPlayers.remove(sender_p);
|
||||
|
||||
playerMsg("Trail disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!trailPlayers.contains(sender_p))
|
||||
{
|
||||
trailPlayers.add(sender_p);
|
||||
}
|
||||
|
||||
playerMsg("Trail enabled. Use \"/trail off\" to disable.");
|
||||
}
|
||||
|
||||
if (!trailPlayers.isEmpty())
|
||||
{
|
||||
registerMovementHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
unregisterMovementHandler();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void registerMovementHandler()
|
||||
{
|
||||
if (getRegisteredListener(movementListener) == null)
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(movementListener = new Listener()
|
||||
{
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (trailPlayers.contains(player))
|
||||
{
|
||||
Block fromBlock = event.getFrom().getBlock();
|
||||
if (fromBlock.isEmpty())
|
||||
{
|
||||
Block toBlock = event.getTo().getBlock();
|
||||
if (!fromBlock.equals(toBlock))
|
||||
{
|
||||
fromBlock.setType(Material.WOOL);
|
||||
fromBlock.setData((byte) RANDOM.nextInt(16));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, TotalFreedomMod.plugin);
|
||||
}
|
||||
}
|
||||
|
||||
private static void unregisterMovementHandler()
|
||||
{
|
||||
Listener registeredListener = getRegisteredListener(movementListener);
|
||||
if (registeredListener != null)
|
||||
{
|
||||
PlayerMoveEvent.getHandlerList().unregister(registeredListener);
|
||||
}
|
||||
}
|
||||
|
||||
private static Listener getRegisteredListener(Listener listener)
|
||||
{
|
||||
RegisteredListener[] registeredListeners = PlayerMoveEvent.getHandlerList().getRegisteredListeners();
|
||||
for (RegisteredListener registeredListener : registeredListeners)
|
||||
{
|
||||
if (registeredListener.getListener() == listener)
|
||||
{
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_DisguiseCraftBridge;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,17 +15,7 @@ public class Command_uall extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Undisguising all players", true);
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
server.dispatchCommand(p, "u");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
server.dispatchCommand(sender, "u *");
|
||||
}
|
||||
TFM_DisguiseCraftBridge.undisguiseAllPlayers();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ public class Command_whitelist extends TFM_Command
|
||||
int offlineWPs = 0;
|
||||
int totalWPs = 0;
|
||||
|
||||
for (OfflinePlayer p : server.getWhitelistedPlayers())
|
||||
for (OfflinePlayer player : server.getWhitelistedPlayers())
|
||||
{
|
||||
if (p.isOnline())
|
||||
if (player.isOnline())
|
||||
{
|
||||
onlineWPs++;
|
||||
}
|
||||
@ -88,18 +88,18 @@ public class Command_whitelist extends TFM_Command
|
||||
|
||||
String search_name = args[1].trim().toLowerCase();
|
||||
|
||||
OfflinePlayer p;
|
||||
OfflinePlayer player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(search_name);
|
||||
player = getPlayer(search_name);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
p = server.getOfflinePlayer(search_name);
|
||||
player = server.getOfflinePlayer(search_name);
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the whitelist.", false);
|
||||
p.setWhitelisted(true);
|
||||
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the whitelist.", false);
|
||||
player.setWhitelisted(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -113,20 +113,20 @@ public class Command_whitelist extends TFM_Command
|
||||
|
||||
String search_name = args[1].trim().toLowerCase();
|
||||
|
||||
OfflinePlayer p;
|
||||
OfflinePlayer player;
|
||||
try
|
||||
{
|
||||
p = getPlayer(search_name);
|
||||
player = getPlayer(search_name);
|
||||
}
|
||||
catch (CantFindPlayerException ex)
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
p = server.getOfflinePlayer(search_name);
|
||||
player = server.getOfflinePlayer(search_name);
|
||||
}
|
||||
|
||||
if (p.isWhitelisted())
|
||||
if (player.isWhitelisted())
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + " from the whitelist.", false);
|
||||
p.setWhitelisted(false);
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + player.getName() + " from the whitelist.", false);
|
||||
player.setWhitelisted(false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -142,11 +142,11 @@ public class Command_whitelist extends TFM_Command
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Adding all online players to the whitelist.", false);
|
||||
int counter = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!p.isWhitelisted())
|
||||
if (!player.isWhitelisted())
|
||||
{
|
||||
p.setWhitelisted(true);
|
||||
player.setWhitelisted(true);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
@ -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 player : server.getOnlinePlayers())
|
||||
{
|
||||
if (player.getInventory().contains(material))
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (smite & !TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
Command_smite.smite(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
playerMsg("There are no players with that item");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Players with item " + material.name() + ": " + StringUtils.join(players, ", "));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
@ -18,12 +18,27 @@ public class Command_wildcard extends TFM_Command
|
||||
playerMsg("What the hell are you trying to do, you stupid idiot...", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("gtfo"))
|
||||
{
|
||||
playerMsg("Nice try", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("doom"))
|
||||
{
|
||||
playerMsg("Look, we all hate people, but this is not the way to deal with it, doom is evil enough!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("saconfig"))
|
||||
{
|
||||
playerMsg("WOA, WTF are you trying to do???", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
String base_command = StringUtils.join(args, " ");
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
String out_command = base_command.replaceAll("\\x3f", p.getName());
|
||||
String out_command = base_command.replaceAll("\\x3f", player.getName());
|
||||
playerMsg("Running Command: " + out_command);
|
||||
server.dispatchCommand(sender, out_command);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ public class Command_wipeflatlands extends TFM_Command
|
||||
|
||||
TFM_Util.bcastMsg("Server is going offline for flatlands wipe.", ChatColor.GRAY);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
p.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
|
||||
player.kickPlayer("Server is going offline for flatlands wipe, come back in a few minutes.");
|
||||
}
|
||||
|
||||
server.shutdown();
|
||||
|
@ -2,17 +2,17 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CantFindPlayerException extends Exception
|
||||
public class PlayerNotFoundException extends Exception
|
||||
{
|
||||
// apparently, java needs this
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CantFindPlayerException()
|
||||
public PlayerNotFoundException()
|
||||
{
|
||||
super(ChatColor.GRAY + "Can't find player.");
|
||||
}
|
||||
|
||||
public CantFindPlayerException(String msg)
|
||||
public PlayerNotFoundException(String msg)
|
||||
{
|
||||
super(ChatColor.GRAY + "Can't find player: " + msg);
|
||||
}
|
@ -138,19 +138,19 @@ public abstract class TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
public Player getPlayer(final String partialname) throws CantFindPlayerException
|
||||
public Player getPlayer(final String partialname) throws PlayerNotFoundException
|
||||
{
|
||||
List<Player> matches = server.matchPlayer(partialname);
|
||||
if (matches.isEmpty())
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (p.getDisplayName().toLowerCase().contains(partialname.toLowerCase()))
|
||||
if (player.getDisplayName().toLowerCase().contains(partialname.toLowerCase()))
|
||||
{
|
||||
return p;
|
||||
return player;
|
||||
}
|
||||
}
|
||||
throw new CantFindPlayerException(partialname);
|
||||
throw new PlayerNotFoundException(partialname);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -22,7 +23,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM_CommandLoader
|
||||
{
|
||||
public static Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
|
||||
public static final Pattern COMMAND_CLASS_PATTERN = Pattern.compile(TotalFreedomMod.COMMAND_PATH.replace('.', '/') + "/(" + TotalFreedomMod.COMMAND_PREFIX + "[^\\$]+)\\.class");
|
||||
private List<TFM_CommandInfo> commandList = null;
|
||||
|
||||
private TFM_CommandLoader()
|
||||
@ -31,10 +32,10 @@ public class TFM_CommandLoader
|
||||
|
||||
public void scan()
|
||||
{
|
||||
CommandMap commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
||||
CommandMap commandMap = getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
TFM_Log.severe("Error loading command map.");
|
||||
TFM_Log.severe("Error loading commandMap.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,9 +59,82 @@ public class TFM_CommandLoader
|
||||
description = "OP Command - " + description;
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
|
||||
|
||||
Command existing = commandMap.getCommand(dynamicCommand.getName());
|
||||
if (existing != null)
|
||||
{
|
||||
TFM_Log.info("Replacing command: " + existing.getName());
|
||||
unregisterCommand(existing, commandMap);
|
||||
}
|
||||
|
||||
commandMap.register(TotalFreedomMod.plugin.getDescription().getName(), dynamicCommand);
|
||||
}
|
||||
|
||||
TFM_Log.info("TFM commands loaded.");
|
||||
}
|
||||
|
||||
public void unregisterCommand(String commandName)
|
||||
{
|
||||
CommandMap commandMap = getCommandMap();
|
||||
if (commandMap != null)
|
||||
{
|
||||
Command command = commandMap.getCommand(commandName.toLowerCase());
|
||||
if (command != null)
|
||||
{
|
||||
unregisterCommand(command, commandMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterCommand(Command command, CommandMap commandMap)
|
||||
{
|
||||
try
|
||||
{
|
||||
command.unregister(commandMap);
|
||||
HashMap<String, Command> knownCommands = getKnownCommands(commandMap);
|
||||
if (knownCommands != null)
|
||||
{
|
||||
knownCommands.remove(command.getName());
|
||||
for (String alias : command.getAliases())
|
||||
{
|
||||
knownCommands.remove(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CommandMap getCommandMap()
|
||||
{
|
||||
Object commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
|
||||
if (commandMap != null)
|
||||
{
|
||||
if (commandMap instanceof CommandMap)
|
||||
{
|
||||
return (CommandMap) commandMap;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public HashMap<String, Command> getKnownCommands(CommandMap commandMap)
|
||||
{
|
||||
Object knownCommands = TFM_Util.getField(commandMap, "knownCommands");
|
||||
if (knownCommands != null)
|
||||
{
|
||||
if (knownCommands instanceof HashMap)
|
||||
{
|
||||
return (HashMap<String, Command>) knownCommands;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<TFM_CommandInfo> getCommands()
|
||||
@ -138,7 +212,7 @@ public class TFM_CommandLoader
|
||||
this.blockHostConsole = blockHostConsole;
|
||||
this.description = description;
|
||||
this.usage = usage;
|
||||
this.aliases = Arrays.asList(aliases.split(","));
|
||||
this.aliases = ("".equals(aliases) ? new ArrayList<String>() : Arrays.asList(aliases.split(",")));
|
||||
}
|
||||
|
||||
public List<String> getAliases()
|
||||
|
@ -1,8 +1,10 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Heartbeat;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
@ -24,7 +26,6 @@ public class TFM_BlockListener implements Listener
|
||||
if (!TotalFreedomMod.allowFireSpread)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,21 +35,20 @@ public class TFM_BlockListener implements Listener
|
||||
if (!TotalFreedomMod.allowFirePlace)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
Location block_pos = event.getBlock().getLocation();
|
||||
|
||||
if (TotalFreedomMod.nukeMonitor)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Location player_pos = p.getLocation();
|
||||
Location player_pos = player.getLocation();
|
||||
|
||||
boolean out_of_range = false;
|
||||
if (!player_pos.getWorld().equals(block_pos.getWorld()))
|
||||
@ -62,11 +62,10 @@ public class TFM_BlockListener implements Listener
|
||||
|
||||
if (out_of_range)
|
||||
{
|
||||
playerdata.incrementFreecamDestroyCount();
|
||||
if (playerdata.getFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
if (playerdata.incrementAndGetFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "Freecam (extended range) block breaking is not permitted on this server.");
|
||||
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
||||
|
||||
playerdata.resetFreecamDestroyCount();
|
||||
|
||||
@ -75,43 +74,55 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
playerdata.incrementBlockDestroyCount();
|
||||
if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
|
||||
playerdata.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
else
|
||||
{
|
||||
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
|
||||
if (playerdata.incrementAndGetBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
|
||||
playerdata.resetBlockDestroyCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
TFM_RollbackManager.blockBreak(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
Location block_pos = event.getBlock().getLocation();
|
||||
|
||||
if (TotalFreedomMod.nukeMonitor)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Location player_pos = p.getLocation();
|
||||
Location player_pos = player.getLocation();
|
||||
|
||||
boolean out_of_range = false;
|
||||
if (!player_pos.getWorld().equals(block_pos.getWorld()))
|
||||
@ -125,11 +136,10 @@ public class TFM_BlockListener implements Listener
|
||||
|
||||
if (out_of_range)
|
||||
{
|
||||
playerdata.incrementFreecamPlaceCount();
|
||||
if (playerdata.getFreecamPlaceCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
if (playerdata.incrementAndGetFreecamPlaceCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "Freecam (extended range) block building is not permitted on this server.");
|
||||
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
||||
|
||||
playerdata.resetFreecamPlaceCount();
|
||||
|
||||
@ -138,22 +148,29 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
playerdata.incrementBlockPlaceCount();
|
||||
if (playerdata.getBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "You are placing blocks too fast.");
|
||||
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.incrementAndGetBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "You are placing blocks too fast.");
|
||||
|
||||
playerdata.resetBlockPlaceCount();
|
||||
playerdata.resetBlockPlaceCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
|
||||
{
|
||||
@ -170,17 +187,16 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
if (TotalFreedomMod.allowLavaPlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed lava @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
TFM_Log.info(String.format("%s placed lava @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -189,17 +205,16 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
if (TotalFreedomMod.allowWaterPlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed water @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
TFM_Log.info(String.format("%s placed water @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -207,17 +222,16 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
if (TotalFreedomMod.allowFirePlace)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed fire @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
TFM_Log.info(String.format("%s placed fire @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
p.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -225,23 +239,28 @@ public class TFM_BlockListener implements Listener
|
||||
{
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed TNT @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
TFM_Log.info(String.format("%s placed TNT @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
p.getInventory().clear(p.getInventory().getHeldItemSlot());
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
|
||||
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||
player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
TFM_RollbackManager.blockPlace(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
@ -250,23 +269,4 @@ public class TFM_BlockListener implements Listener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
// @EventHandler(priority = EventPriority.NORMAL)
|
||||
// public void onCommandBlockChangeEvent(CommandBlockChangeEvent event)
|
||||
// {
|
||||
// Player player = event.getPlayer();
|
||||
//
|
||||
// if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
// {
|
||||
// TFM_Util.playerMsg(player, "You do not have permission to set Command Block commands.");
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!TFM_SuperadminList.isSeniorAdmin(player))
|
||||
// {
|
||||
// TFM_Util.playerMsg(player, "You do not have permission to set Command Block commands.");
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowFireSpread)
|
||||
if (!TotalFreedomMod.allowExplosions)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -50,6 +50,19 @@ public class TFM_EntityListener implements Listener
|
||||
case LAVA:
|
||||
{
|
||||
if (!TotalFreedomMod.allowLavaDamage)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.petProtectEnabled)
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Tameable)
|
||||
{
|
||||
if (((Tameable) entity).isTamed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -112,9 +125,9 @@ public class TFM_EntityListener implements Listener
|
||||
{
|
||||
int mobcount = 0;
|
||||
|
||||
for (Entity ent : event.getLocation().getWorld().getLivingEntities())
|
||||
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
||||
{
|
||||
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
|
||||
if (!(entity instanceof HumanEntity))
|
||||
{
|
||||
mobcount++;
|
||||
}
|
||||
|
@ -23,13 +23,14 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
private static final List<String> BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ","));
|
||||
private static final int MSG_PER_HEARTBEAT = 10;
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
@ -45,20 +46,33 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
case WATER_BUCKET:
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (!TotalFreedomMod.allowWaterPlace)
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LAVA_BUCKET:
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (!TotalFreedomMod.allowLavaPlace)
|
||||
{
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case POTION:
|
||||
case EXPLOSIVE_MINECART:
|
||||
{
|
||||
if (!TotalFreedomMod.allowTntMinecarts)
|
||||
{
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -81,7 +95,6 @@ public class TFM_PlayerListener implements Listener
|
||||
playerdata.enqueueMob(rezzed_mob);
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -100,7 +113,6 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -110,21 +122,21 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
Block target_block;
|
||||
Block targetBlock;
|
||||
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
|
||||
{
|
||||
target_block = player.getTargetBlock(null, 120);
|
||||
targetBlock = player.getTargetBlock(null, 120);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_block = event.getClickedBlock();
|
||||
targetBlock = event.getClickedBlock();
|
||||
}
|
||||
|
||||
if (target_block != null)
|
||||
if (targetBlock != null)
|
||||
{
|
||||
player.getWorld().createExplosion(target_block.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(target_block.getLocation());
|
||||
player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -148,10 +160,10 @@ public class TFM_PlayerListener implements Listener
|
||||
Vector player_dir = player_location.getDirection().normalize();
|
||||
|
||||
double distance = 150.0;
|
||||
Block target_block = player.getTargetBlock(null, Math.round((float) distance));
|
||||
if (target_block != null)
|
||||
Block targetBlock = player.getTargetBlock(null, Math.round((float) distance));
|
||||
if (targetBlock != null)
|
||||
{
|
||||
distance = player_location.distance(target_block.getLocation());
|
||||
distance = player_location.distance(targetBlock.getLocation());
|
||||
}
|
||||
|
||||
final List<Block> affected = new ArrayList<Block>();
|
||||
@ -177,7 +189,7 @@ public class TFM_PlayerListener implements Listener
|
||||
last_block = test_block;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -189,7 +201,7 @@ public class TFM_PlayerListener implements Listener
|
||||
tnt_block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}, 30L);
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 30L);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -202,24 +214,49 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
TFM_AdminWorld.getInstance().validateMovement(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo();
|
||||
try
|
||||
{
|
||||
if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0001 * 0.0001))
|
||||
{
|
||||
// If player just rotated, but didn't move, don't process this event.
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (!TFM_AdminWorld.getInstance().validateMovement(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet())
|
||||
{
|
||||
Player fuckoff_player = fuckoff.getKey();
|
||||
|
||||
if (fuckoff_player.equals(p) || !fuckoff_player.isOnline())
|
||||
if (fuckoff_player.equals(player) || !fuckoff_player.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double fuckoff_range = fuckoff.getValue().doubleValue();
|
||||
|
||||
Location mover_pos = p.getLocation();
|
||||
Location mover_pos = player.getLocation();
|
||||
Location fuckoff_pos = fuckoff_player.getLocation();
|
||||
|
||||
double distanceSquared;
|
||||
@ -242,7 +279,7 @@ public class TFM_PlayerListener implements Listener
|
||||
boolean do_freeze = false;
|
||||
if (TotalFreedomMod.allPlayersFrozen)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
do_freeze = true;
|
||||
}
|
||||
@ -257,49 +294,53 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
if (do_freeze)
|
||||
{
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo().clone();
|
||||
Location freezeTo = to.clone();
|
||||
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
freezeTo.setX(from.getX());
|
||||
freezeTo.setY(from.getY());
|
||||
freezeTo.setZ(from.getZ());
|
||||
|
||||
event.setTo(to);
|
||||
event.setTo(freezeTo);
|
||||
}
|
||||
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
Location target_pos = p.getLocation().add(0, 1, 0);
|
||||
Location targetPos = player.getLocation().add(0, 1, 0);
|
||||
|
||||
boolean out_of_cage;
|
||||
if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld()))
|
||||
if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld()))
|
||||
{
|
||||
out_of_cage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_of_cage = target_pos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
out_of_cage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
}
|
||||
|
||||
if (out_of_cage)
|
||||
{
|
||||
playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
playerdata.setCaged(true, targetPos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
||||
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
||||
TFM_Util.generateCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
}
|
||||
}
|
||||
|
||||
if (playerdata.isOrbiting())
|
||||
{
|
||||
if (p.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0))
|
||||
if (player.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0))
|
||||
{
|
||||
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||
player.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (TFM_Jumppads.getInstance().getMode().isOn())
|
||||
{
|
||||
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
||||
{
|
||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||
@ -314,29 +355,30 @@ public class TFM_PlayerListener implements Listener
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!landmine.player.equals(p))
|
||||
if (!landmine.player.equals(player))
|
||||
{
|
||||
if (p.getWorld().equals(landmine_pos.getWorld()))
|
||||
if (player.getWorld().equals(landmine_pos.getWorld()))
|
||||
{
|
||||
if (p.getLocation().distanceSquared(landmine_pos) <= (landmine.radius * landmine.radius))
|
||||
if (player.getLocation().distanceSquared(landmine_pos) <= (landmine.radius * landmine.radius))
|
||||
{
|
||||
landmine.landmine_pos.getBlock().setType(Material.AIR);
|
||||
|
||||
TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class);
|
||||
tnt1.setFuseTicks(40);
|
||||
tnt1.setPassenger(p);
|
||||
tnt1.setPassenger(player);
|
||||
tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
|
||||
|
||||
TNTPrimed tnt2 = landmine_pos.getWorld().spawn(p.getLocation(), TNTPrimed.class);
|
||||
TNTPrimed tnt2 = landmine_pos.getWorld().spawn(player.getLocation(), TNTPrimed.class);
|
||||
tnt2.setFuseTicks(1);
|
||||
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
landmines.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -350,39 +392,46 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
final Player p = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
String message = event.getMessage().trim();
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
playerdata.incrementMsgCount();
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
// check for spam
|
||||
if (playerdata.getMsgCount() > 10)
|
||||
// Check for spam
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "Kicked for spamming chat.");
|
||||
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_HEARTBEAT)
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Kicked for spamming chat.");
|
||||
|
||||
playerdata.resetMsgCount();
|
||||
playerdata.resetMsgCount();
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check for message repeat
|
||||
// Check for message repeat
|
||||
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
||||
{
|
||||
TFM_Util.playerMsg(p, "Please do not repeat messages.");
|
||||
TFM_Util.playerMsg(player, "Please do not repeat messages.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
playerdata.setLastMessage(message);
|
||||
|
||||
// check for muted
|
||||
// Check for muted
|
||||
if (playerdata.isMuted())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
p.sendMessage(ChatColor.RED + "You are muted, STFU!");
|
||||
player.sendMessage(ChatColor.RED + "You are muted, STFU!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -392,17 +441,17 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
// strip color from messages
|
||||
// Strip color from messages
|
||||
message = ChatColor.stripColor(message);
|
||||
|
||||
// truncate messages that are too long - 100 characters is vanilla client max
|
||||
// Truncate messages that are too long - 100 characters is vanilla client max
|
||||
if (message.length() > 100)
|
||||
{
|
||||
message = message.substring(0, 100);
|
||||
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
|
||||
TFM_Util.playerMsg(player, "Message was shortened because it was too long to send.");
|
||||
}
|
||||
|
||||
// check for caps - Quit messing with this :-/
|
||||
// Check for caps
|
||||
if (message.length() >= 6)
|
||||
{
|
||||
int caps = 0;
|
||||
@ -419,16 +468,23 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
// check for adminchat
|
||||
// Check for adminchat
|
||||
if (playerdata.inAdminChat())
|
||||
{
|
||||
TFM_Util.adminChatMessage(p, message, false);
|
||||
TFM_Util.adminChatMessage(player, message, false);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// finally, set message
|
||||
// Finally, set message
|
||||
event.setMessage(message);
|
||||
|
||||
// Set the tag
|
||||
if (playerdata.getTag() != null)
|
||||
{
|
||||
player.setDisplayName((playerdata.getTag() + " " + player.getDisplayName().replaceAll(" ", "")));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -440,19 +496,19 @@ public class TFM_PlayerListener implements Listener
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
String command = event.getMessage();
|
||||
Player p = event.getPlayer();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
playerdata.incrementMsgCount();
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setLastCommand(command);
|
||||
|
||||
if (playerdata.getMsgCount() > 10)
|
||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_HEARTBEAT)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||
TFM_Util.autoEject(p, "Kicked for spamming commands.");
|
||||
TFM_Util.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Kicked for spamming commands.");
|
||||
|
||||
playerdata.resetMsgCount();
|
||||
|
||||
TFM_Util.wipeEntities(true, true);
|
||||
TFM_Util.TFM_EntityWiper.wipeEntities(true, true);
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -460,123 +516,21 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
if (playerdata.allCommandsBlocked())
|
||||
{
|
||||
TFM_Util.playerMsg(p, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||
TFM_Util.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.preprocessLogEnabled)
|
||||
{
|
||||
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
|
||||
}
|
||||
|
||||
playerdata.setLastCommand(command);
|
||||
|
||||
command = command.toLowerCase().trim();
|
||||
|
||||
boolean block_command = false;
|
||||
|
||||
//Commands that will auto-kick the user:
|
||||
if (Pattern.compile("^/stop").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/reload").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/save-").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (block_command)
|
||||
{
|
||||
TFM_Util.autoEject(p, "You used a prohibited command: " + command);
|
||||
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
// commands that will not auto-kick the user, but still deny:
|
||||
if (Pattern.compile("^/time").matcher(command).find())
|
||||
{
|
||||
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
|
||||
block_command = true;
|
||||
}
|
||||
else if (Pattern.compile("^/md").matcher(command).find())
|
||||
{
|
||||
p.sendMessage(ChatColor.GRAY + "This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.");
|
||||
block_command = true;
|
||||
}
|
||||
else if (Pattern.compile("^/gamemode").matcher(command).find())
|
||||
{
|
||||
p.sendMessage(ChatColor.GRAY + "Use /creative and /survival to set your gamemode.");
|
||||
block_command = true;
|
||||
}
|
||||
else if (Pattern.compile("^/ban").matcher(command).find())
|
||||
{
|
||||
if (!Pattern.compile("^/banlist").matcher(command).find())
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/kick").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/kill").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/socialspy").matcher(command).find())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (Pattern.compile("^/pardon").matcher(command).find())
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
else if (Pattern.compile("^/toggledownfall").matcher(command).find())
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (block_command)
|
||||
{
|
||||
p.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// block commands while player is muted
|
||||
// Block commands if player is muted
|
||||
if (playerdata.isMuted())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
for (String test_command : BLOCKED_MUTED_CMDS)
|
||||
{
|
||||
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command.toLowerCase()).find())
|
||||
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
|
||||
{
|
||||
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -586,16 +540,29 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
playerdata.setMuted(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (TotalFreedomMod.preprocessLogEnabled)
|
||||
{
|
||||
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
|
||||
}
|
||||
|
||||
command = command.toLowerCase().trim();
|
||||
|
||||
// Blocked commands
|
||||
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(command, event.getPlayer()))
|
||||
{
|
||||
// CommandBlocker handles messages and broadcasts
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
for (Player pl : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (TFM_SuperadminList.isUserSuperadmin(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled())
|
||||
{
|
||||
TFM_Util.playerMsg(pl, p.getName() + ": " + command);
|
||||
TFM_Util.playerMsg(pl, player.getName() + ": " + command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -620,12 +587,12 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(p))
|
||||
Player player = event.getPlayer();
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||
{
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(p);
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||
}
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.disarmMP44();
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
@ -637,12 +604,12 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(p))
|
||||
Player player = event.getPlayer();
|
||||
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(player))
|
||||
{
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(p);
|
||||
TotalFreedomMod.fuckoffEnabledFor.remove(player);
|
||||
}
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.disarmMP44();
|
||||
if (playerdata.isCaged())
|
||||
{
|
||||
@ -656,54 +623,54 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
try
|
||||
{
|
||||
final Player p = event.getPlayer();
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
|
||||
final Player player = event.getPlayer();
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.setSuperadminIdVerified(null);
|
||||
|
||||
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(p);
|
||||
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player);
|
||||
|
||||
boolean superadmin_impostor = TFM_SuperadminList.isSuperadminImpostor(p);
|
||||
boolean superadmin_impostor = TFM_SuperadminList.isSuperadminImpostor(player);
|
||||
|
||||
if (superadmin_impostor || TFM_SuperadminList.isUserSuperadmin(p))
|
||||
if (superadmin_impostor || TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
TFM_Util.bcastMsg(ChatColor.AQUA + p.getName() + " is " + TFM_Util.getRank(p));
|
||||
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_Util.getRank(player));
|
||||
|
||||
if (superadmin_impostor)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
p.setOp(false);
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
TFM_Util.bcastMsg("Warning: " + p.getName() + " has been flagged as an impostor!", ChatColor.RED);
|
||||
player.getInventory().clear();
|
||||
player.setOp(false);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
TFM_Util.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor!", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_SuperadminList.verifyIdentity(p.getName(), p.getAddress().getAddress().getHostAddress()))
|
||||
if (TFM_SuperadminList.verifyIdentity(player.getName(), player.getAddress().getAddress().getHostAddress()))
|
||||
{
|
||||
playerdata.setSuperadminIdVerified(Boolean.TRUE);
|
||||
|
||||
TFM_SuperadminList.updateLastLogin(p);
|
||||
TFM_SuperadminList.updateLastLogin(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerdata.setSuperadminIdVerified(Boolean.FALSE);
|
||||
|
||||
TFM_Util.bcastMsg("Warning: " + p.getName() + " is an admin, but is using a username not registered to one of their IPs.", ChatColor.RED);
|
||||
TFM_Util.bcastMsg("Warning: " + player.getName() + " is an admin, but is using a username not registered to one of their IPs.", ChatColor.RED);
|
||||
}
|
||||
|
||||
p.setOp(true);
|
||||
player.setOp(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.adminOnlyMode)
|
||||
{
|
||||
TotalFreedomMod.plugin.getServer().getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable()
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||
}
|
||||
}, 60L);
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L * 3L);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@ -716,16 +683,4 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
TFM_ServerInterface.handlePlayerLogin(event);
|
||||
}
|
||||
|
||||
@EventHandler()
|
||||
public void onServerPing(ServerListPingEvent event)
|
||||
{
|
||||
// Colorize :)
|
||||
event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
|
||||
|
||||
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "You are banned!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
149
src/me/StevenLawson/TotalFreedomMod/TFM_AdminWorld.java
Normal file
149
src/me/StevenLawson/TotalFreedomMod/TFM_AdminWorld.java
Normal file
@ -0,0 +1,149 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TFM_AdminWorld
|
||||
{
|
||||
private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds
|
||||
private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds
|
||||
private static final String GENERATION_PARAMETERS = "16,stone,32,dirt,1,grass";
|
||||
private static final String ADMINWORLD_NAME = "adminworld";
|
||||
//
|
||||
private final Map<Player, Long> teleportCooldown = new HashMap<Player, Long>();
|
||||
private final Map<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
||||
//
|
||||
private Long cacheLastCleared = null;
|
||||
private World adminWorld = null;
|
||||
|
||||
private TFM_AdminWorld()
|
||||
{
|
||||
}
|
||||
|
||||
public void sendToAdminWorld(Player player)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(getAdminWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
public boolean validateMovement(PlayerMoveEvent event)
|
||||
{
|
||||
if (adminWorld != null)
|
||||
{
|
||||
if (event.getTo().getWorld() == adminWorld)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
if (!cachedIsUserSuperadmin(player))
|
||||
{
|
||||
Long lastTP = teleportCooldown.get(player);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (lastTP == null || lastTP.longValue() + TP_COOLDOWN_TIME <= currentTimeMillis)
|
||||
{
|
||||
teleportCooldown.put(player, currentTimeMillis);
|
||||
TFM_Log.info(player.getName() + " attempted to access the AdminWorld.");
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 1L);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public World getAdminWorld()
|
||||
{
|
||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
||||
{
|
||||
generateWorld();
|
||||
}
|
||||
|
||||
return adminWorld;
|
||||
}
|
||||
|
||||
public void wipeSuperadminCache()
|
||||
{
|
||||
cacheLastCleared = System.currentTimeMillis();
|
||||
superadminCache.clear();
|
||||
}
|
||||
|
||||
private boolean cachedIsUserSuperadmin(CommandSender user)
|
||||
{
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() + CACHE_CLEAR_FREQUENCY <= currentTimeMillis)
|
||||
{
|
||||
cacheLastCleared = currentTimeMillis;
|
||||
superadminCache.clear();
|
||||
}
|
||||
|
||||
Boolean cached = superadminCache.get(user);
|
||||
if (cached == null)
|
||||
{
|
||||
cached = TFM_SuperadminList.isUserSuperadmin(user);
|
||||
superadminCache.put(user, cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
private void generateWorld()
|
||||
{
|
||||
WorldCreator adminWorldCreator = new WorldCreator(ADMINWORLD_NAME);
|
||||
adminWorldCreator.generateStructures(false);
|
||||
adminWorldCreator.type(WorldType.NORMAL);
|
||||
adminWorldCreator.environment(World.Environment.NORMAL);
|
||||
adminWorldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||
|
||||
adminWorld = Bukkit.getServer().createWorld(adminWorldCreator);
|
||||
|
||||
adminWorld.setSpawnFlags(false, false);
|
||||
adminWorld.setSpawnLocation(0, 50, 0);
|
||||
|
||||
Block welcomeSignBlock = adminWorld.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
}
|
||||
|
||||
public static TFM_AdminWorld getInstance()
|
||||
{
|
||||
return TFM_AdminWorldHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_AdminWorldHolder
|
||||
{
|
||||
private static final TFM_AdminWorld INSTANCE = new TFM_AdminWorld();
|
||||
}
|
||||
}
|
164
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
Normal file
164
src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java
Normal file
@ -0,0 +1,164 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlocker
|
||||
{
|
||||
public static boolean isCommandBlocked(String usedcommand, CommandSender sender)
|
||||
{
|
||||
|
||||
String name = sender.getName();
|
||||
usedcommand = usedcommand.toLowerCase().trim();
|
||||
|
||||
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
||||
{
|
||||
String[] parts = blocked_command.split(":");
|
||||
if (parts.length < 3 || parts.length > 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(usedcommand + " ").startsWith(parts[2] + " "))
|
||||
{
|
||||
|
||||
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Command command = commandMap.getCommand(parts[2].replaceAll("/", ""));
|
||||
if (command == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean block = false;
|
||||
for (String alias : command.getAliases())
|
||||
{
|
||||
if (usedcommand.replaceAll("/", "").startsWith(alias))
|
||||
{
|
||||
block = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!block)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SenderRank.hasPermissions(sender, parts[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Past this line indicates that the command is blocked.
|
||||
|
||||
// Optional: Send a message
|
||||
if (parts.length == 4)
|
||||
{
|
||||
if ("_".equals(parts[3]))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + TFM_Util.colorise(parts[3]));
|
||||
}
|
||||
}
|
||||
|
||||
// Action
|
||||
if ("b".equals(parts[1]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ("a".equals(parts[1]))
|
||||
{
|
||||
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
|
||||
{
|
||||
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + usedcommand);
|
||||
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ("u".equals(parts[1]))
|
||||
{
|
||||
sender.sendMessage("Unknown command. Type \"help\" for help.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum SenderRank
|
||||
{
|
||||
ANYONE("a", 0),
|
||||
OP("o", 1),
|
||||
SUPER("s", 2),
|
||||
TELNET("t", 3),
|
||||
SENIOR("c", 4),
|
||||
NOBODY("n", 5);
|
||||
private String letter = "n";
|
||||
private int rank = 5;
|
||||
|
||||
SenderRank(String letter, int rank)
|
||||
{
|
||||
this.letter = letter;
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public static boolean hasPermissions(CommandSender sender, String letter)
|
||||
{
|
||||
return (getSenderRank(sender).rank >= getSenderRankByLetter(letter).rank);
|
||||
}
|
||||
|
||||
public static SenderRank getSenderRank(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
{
|
||||
return SenderRank.SENIOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SenderRank.TELNET;
|
||||
}
|
||||
}
|
||||
|
||||
if (TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
return SenderRank.SUPER;
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
{
|
||||
return SenderRank.OP;
|
||||
}
|
||||
|
||||
return SenderRank.ANYONE;
|
||||
}
|
||||
|
||||
public static SenderRank getSenderRankByLetter(String letter)
|
||||
{
|
||||
for (SenderRank rank : SenderRank.values())
|
||||
{
|
||||
if (letter.equals(rank.letter))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return SenderRank.NOBODY;
|
||||
}
|
||||
}
|
||||
}
|
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 + TFM_Util.colorise(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);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user