Merge pull request #6 from TotalFreedom/master

Update primary repository
This commit is contained in:
Steven Lawson 2013-07-12 04:04:17 -07:00
commit 3935bcf09f
52 changed files with 1461 additions and 391 deletions

52
CONTRIBUTING.md Normal file
View File

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

11
LICENSE.md Normal file
View File

@ -0,0 +1,11 @@
# TotalFreedomMod License #
TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt
We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code.
* A un-edited copy of this LICENSE.md shall always be included with this source code.
* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it.
* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "jeromsar" from any part of the source code.
* Compiled binaries (*.jar's) shall not to be distributed.
* If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself.
* The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis.
* Any restrictions listed here may be waived by any of the above mentioned primary developers.

View File

@ -1,6 +0,0 @@
TotalFreedomMod
===============
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
Information about the TotalFreedom server can be found at http://totalfreedom.me/

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# TotalFreedomMod #
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).

View File

@ -1,5 +1,5 @@
#Tue, 09 Apr 2013 22:30:34 -0400
#Thu, 11 Jul 2013 20:20:19 -0400
program.VERSION=2.13
program.BUILDNUM=157
program.BUILDDATE=04/09/2013 10\:30 PM
program.VERSION=2.21
program.BUILDNUM=301
program.BUILDDATE=07/11/2013 08\:20 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Apr 09 22:30:34 EDT 2013
build.number=158
#Thu Jul 11 20:20:19 EDT 2013
build.number=302

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Achievement;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
@ -31,6 +32,10 @@ public class Command_cake extends TFM_Command
{
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
p.awardAchievement(Achievement.MINE_WOOD);
p.awardAchievement(Achievement.BUILD_WORKBENCH);
p.awardAchievement(Achievement.BUILD_HOE);
p.awardAchievement(Achievement.BAKE_CAKE);
}
TFM_Util.bcastMsg(output.toString());

View File

@ -1,20 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Removes all entities, nicks and disguises.", usage = "/<command>")
public class Command_clearall extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
server.dispatchCommand(sender, "rd");
server.dispatchCommand(sender, "potion clearall");
server.dispatchCommand(sender, "uall");
return true;
}
}

View File

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

View File

@ -78,7 +78,7 @@ public class Command_doom extends TFM_Command
p.getWorld().strikeLightning(p.getLocation());
// kill (if not done already)
p.setHealth(0);
p.setHealth(0.0);
}
}, 40L); // 2 seconds

View File

@ -1,7 +1,9 @@
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.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -35,18 +37,10 @@ public class Command_gtfo extends TFM_Command
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Undo WorldEdits:
if (senderIsConsole)
{
}
else
{
server.dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName()));
}
TFM_WorldEditBridge.getInstance().undo(p, 15);
// rollback
server.dispatchCommand(sender, "rollback " + p.getName() + " all");
TFM_RollbackManager.rollback(p);
// deop
p.setOp(false);

View File

@ -1,10 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -29,7 +27,7 @@ public class Command_halt extends TFM_Command
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
setHalted(p, true);
TFM_PlayerData.getPlayerData(p).setHalted(true);
counter++;
}
}
@ -43,9 +41,10 @@ public class Command_halt extends TFM_Command
int counter = 0;
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (TFM_PlayerData.getPlayerData(p).isHalted())
{
setHalted(p, false);
playerdata.setHalted(false);
counter++;
}
}
@ -86,51 +85,21 @@ public class Command_halt extends TFM_Command
{
sender.sendMessage(ex.getMessage());
return true;
}
if (!TFM_PlayerData.getPlayerData(p).isHalted())
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (!playerdata.isHalted())
{
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
setHalted(p, true);
playerdata.setHalted(true);
return true;
}
else
{
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
setHalted(p, false);
playerdata.setHalted(false);
return true;
}
}
private static void setHalted(Player p, boolean is_halted)
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
if (is_halted)
{
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.setFlying(false);
p.setDisplayName(p.getName());
p.closeInventory();
p.setTotalExperience(0);
playerdata.stopOrbiting();
playerdata.setFrozen(true);
playerdata.setMuted(true);
playerdata.setHalted(true);
p.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
}
else
{
p.setOp(true);
p.setGameMode(GameMode.CREATIVE);
playerdata.setFrozen(false);
playerdata.setMuted(false);
playerdata.setHalted(false);
p.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
}

View File

@ -0,0 +1,67 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
public class Command_invis extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("smite"))
{
smite = true;
}
else
{
return false;
}
}
List<String> players = new ArrayList<String>();
int smites = 0;
for (Player p : server.getOnlinePlayers())
{
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(p.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
{
Command_smite.smite(p);
smites++;
}
}
}
if (players.isEmpty())
{
TFM_Util.playerMsg(sender, "There are no invisible players");
return true;
}
if (smite)
{
TFM_Util.playerMsg(sender, "Smitten " + smites + " players");
}
else
{
TFM_Util.playerMsg(sender, "Invisble players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
}

View File

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

View File

@ -1,9 +1,7 @@
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;
@ -115,19 +113,12 @@ public class Command_lockup extends TFM_Command
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
{
private Random random = new Random();
@Override
public void run()
{
if (p.isOnline())
{
p.openWorkbench(null, true);
Location l = p.getLocation().clone();
l.setPitch(random.nextFloat() * 360.0f);
l.setYaw(random.nextFloat() * 360.0f);
p.teleport(l);
p.openInventory(p.getInventory());
}
else
{

View File

@ -6,7 +6,7 @@ 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
{

View File

@ -7,7 +7,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
public class Command_permban extends TFM_Command
{

View File

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

View File

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

View File

@ -0,0 +1,103 @@
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.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.potion.PotionEffect;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
public class Command_purgeall extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
// Purge entities
TFM_Util.wipeEntities(true, true);
// Undisguise all players
TFM_DisguiseCraftBridge.getInstance().undisguiseAllPlayers();
for (Player p : server.getOnlinePlayers())
{
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
// Unmute all players
if (playerdata.isMuted())
{
playerdata.setMuted(false);
}
// Unblock all commands
if (playerdata.allCommandsBlocked())
{
playerdata.setCommandsBlocked(false);
}
// Unhalt all players
if (playerdata.isHalted())
{
playerdata.setHalted(false);
}
// Stop orbiting
if (playerdata.isOrbiting())
{
playerdata.stopOrbiting();
}
// Unfreeze
if (playerdata.isFrozen())
{
playerdata.setFrozen(false);
}
// Purge potion effects
for (PotionEffect potion_effect : p.getActivePotionEffects())
{
p.removePotionEffect(potion_effect.getType());
}
}
// Clear auto-unmute and auto-unfreeze tasks
if (TotalFreedomMod.mutePurgeEventId != 0)
{
server.getScheduler().cancelTask(TotalFreedomMod.mutePurgeEventId);
TotalFreedomMod.mutePurgeEventId = 0;
}
if (TotalFreedomMod.freezePurgeEventId != 0)
{
server.getScheduler().cancelTask(TotalFreedomMod.freezePurgeEventId);
TotalFreedomMod.freezePurgeEventId = 0;
}
// Remove all mobs
for (World world : server.getWorlds())
{
for (Entity ent : world.getLivingEntities())
{
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient)
{
ent.remove();
}
}
}
return true;
}
}

View File

@ -2,12 +2,13 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
@CommandParameters(description = "Broadcasts the given message with no extra formatting.", usage = "/<command> <message>")
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
public class Command_rawsay extends TFM_Command
{
@Override
@ -15,7 +16,7 @@ public class Command_rawsay extends TFM_Command
{
if (args.length > 0)
{
TFM_Util.bcastMsg(StringUtils.join(args, " "));
TFM_Util.bcastMsg(ChatColor.translateAlternateColorCodes('&', StringUtils.join(args, " ")));
}
return true;

View File

@ -0,0 +1,88 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 2)
{
return false;
}
if (args.length == 1 && args[0].equalsIgnoreCase("purgeall"))
{
TFM_Util.adminAction(sender.getName(), "Puring all rollback data", false);
playerMsg("Purged entries for " + TFM_RollbackManager.purgeEntries() + " players.");
return true;
}
if (args.length == 2 && args[0].equalsIgnoreCase("purge"))
{
OfflinePlayer p;
try
{
p = getPlayer(args[1]);
}
catch (CantFindPlayerException ex)
{
p = server.getOfflinePlayer(args[1]);
if (!p.hasPlayedBefore())
{
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
return true;
}
}
if (!TFM_RollbackManager.canRollback(p.getName()))
{
playerMsg("No rollback data found for that player", ChatColor.RED);
}
else
{
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries.");
return true;
}
}
if (args.length != 1)
{
return false;
}
OfflinePlayer p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
p = server.getOfflinePlayer(args[0]);
if (!p.hasPlayedBefore())
{
playerMsg("Player is not online, or never joined the server.", ChatColor.RED);
return true;
}
}
if (!TFM_RollbackManager.canRollback(p.getName()))
{
playerMsg("Player has no rollback data set.", ChatColor.RED);
return true;
}
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + p.getName(), false);
playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks");
return true;
}
}

View File

@ -150,6 +150,11 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(target_name);
if (!TotalFreedomMod.twitterbotEnabled)
{
return true;
}
// Twitterbot
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
String reply = twitterbot.delTwitter(target_name);

View File

@ -0,0 +1,24 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Sets everyone's Worldedit block modification limit to 500.", usage = "/<command>")
public class Command_setl extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
for (final Player p : server.getOnlinePlayers())
{
web.setLimit(p, 500);
}
return true;
}
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,40 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope")
public class Command_tban extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
Player p;
try
{
p = getPlayer(args[0]);
}
catch (CantFindPlayerException ex)
{
playerMsg(ex.getMessage(), ChatColor.RED);
return true;
}
TFM_Util.adminAction(sender.getName(), "NOPE: " + p.getName(), true);
TFM_ServerInterface.banUsername(p.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes",
sender.getName(), TFM_Util.parseDateOffset("5m"));
p.kickPlayer(ChatColor.RED + "NOPE!\nYou have been temporarily banned for five minutes.");
return true;
}
}

View File

@ -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.getInstance().undisguiseAllPlayers();
return true;
}

View File

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

View File

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

View File

@ -22,7 +22,8 @@ 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");
public static CommandMap commandMap;
private List<TFM_CommandInfo> commandList = null;
private TFM_CommandLoader()
@ -31,7 +32,7 @@ public class TFM_CommandLoader
public void scan()
{
CommandMap commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
commandMap = TFM_Util.getField(Bukkit.getServer().getPluginManager(), "commandMap");
if (commandMap == null)
{
TFM_Log.severe("Error loading command map.");

View File

@ -3,6 +3,8 @@ package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackEntry;
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,7 +35,6 @@ public class TFM_BlockListener implements Listener
if (!TotalFreedomMod.allowFirePlace)
{
event.setCancelled(true);
return;
}
}
@ -95,7 +95,6 @@ public class TFM_BlockListener implements Listener
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
{
event.setCancelled(true);
return;
}
}
}
@ -180,7 +179,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -199,7 +197,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -217,7 +214,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -235,7 +231,6 @@ public class TFM_BlockListener implements Listener
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
@ -250,6 +245,21 @@ public class TFM_BlockListener implements Listener
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlaceRollback(BlockPlaceEvent event)
{
TFM_RollbackEntry entry = new TFM_RollbackEntry();
entry.setLocation(event.getBlock().getLocation());
entry.setMaterial(Material.AIR);
TFM_RollbackManager.blockUpdate(event.getPlayer(), entry);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakRollback(BlockBreakEvent event)
{
TFM_RollbackManager.blockUpdate(event.getPlayer(), event.getBlock());
}
// @EventHandler(priority = EventPriority.NORMAL)
// public void onCommandBlockChangeEvent(CommandBlockChangeEvent event)
// {

View File

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

View File

@ -6,7 +6,15 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.*;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_UserList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -22,7 +30,18 @@ import org.bukkit.event.EventPriority;
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.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.RemoteServerCommandEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -43,21 +62,33 @@ public class TFM_PlayerListener implements Listener
switch (event.getMaterial())
{
case WATER_BUCKET:
{
if (!TotalFreedomMod.allowWaterPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
return;
}
}
case LAVA_BUCKET:
{
if (!TotalFreedomMod.allowLavaPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
return;
}
case POTION:
}
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;
@ -80,7 +111,6 @@ public class TFM_PlayerListener implements Listener
playerdata.enqueueMob(rezzed_mob);
event.setCancelled(true);
return;
}
break;
}
@ -99,7 +129,6 @@ public class TFM_PlayerListener implements Listener
}
event.setCancelled(true);
return;
}
break;
}
@ -355,7 +384,7 @@ public class TFM_PlayerListener implements Listener
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
playerdata.incrementMsgCount();
// check for spam
// Check for spam
if (playerdata.getMsgCount() > 10)
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
@ -367,7 +396,7 @@ public class TFM_PlayerListener implements Listener
return;
}
// check for message repeat
// Check for message repeat
if (playerdata.getLastMessage().equalsIgnoreCase(message))
{
TFM_Util.playerMsg(p, "Please do not repeat messages.");
@ -376,7 +405,7 @@ public class TFM_PlayerListener implements Listener
}
playerdata.setLastMessage(message);
// check for muted
// Check for muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
@ -391,17 +420,17 @@ public class TFM_PlayerListener implements Listener
}
}
// strip color from messages
// Strip color from messages
message = ChatColor.stripColor(message);
// truncate messages that are too long - 100 characters is vanilla client max
// Truncate messages that are too long - 100 characters is vanilla client max
if (message.length() > 100)
{
message = message.substring(0, 100);
TFM_Util.playerMsg(p, "Message was shortened because it was too long to send.");
}
// check for caps - Quit messing with this :-/
// Check for caps
if (message.length() >= 6)
{
int caps = 0;
@ -418,7 +447,7 @@ public class TFM_PlayerListener implements Listener
}
}
// check for adminchat
// Check for adminchat
if (playerdata.inAdminChat())
{
TFM_Util.adminChatMessage(p, message, false);
@ -426,7 +455,7 @@ public class TFM_PlayerListener implements Listener
return;
}
// finally, set message
// Finally, set message
event.setMessage(message);
}
catch (Exception ex)
@ -443,6 +472,7 @@ public class TFM_PlayerListener implements Listener
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p);
playerdata.incrementMsgCount();
playerdata.setLastCommand(command);
if (playerdata.getMsgCount() > 10)
{
@ -464,116 +494,14 @@ public class TFM_PlayerListener implements Listener
return;
}
if (TotalFreedomMod.preprocessLogEnabled)
{
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
}
playerdata.setLastCommand(command);
command = command.toLowerCase().trim();
boolean block_command = false;
//Commands that will auto-kick the user:
if (Pattern.compile("^/stop").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/reload").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/save-").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
if (block_command)
{
TFM_Util.autoEject(p, "You used a prohibited command: " + command);
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
// commands that will not auto-kick the user, but still deny:
if (Pattern.compile("^/time").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
block_command = true;
}
else if (Pattern.compile("^/md").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.");
block_command = true;
}
else if (Pattern.compile("^/gamemode").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "Use /creative and /survival to set your gamemode.");
block_command = true;
}
else if (Pattern.compile("^/ban").matcher(command).find())
{
if (!Pattern.compile("^/banlist").matcher(command).find())
{
block_command = true;
}
}
else if (Pattern.compile("^/kick").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/kill").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/socialspy").matcher(command).find())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
block_command = true;
}
}
else if (Pattern.compile("^/pardon").matcher(command).find())
{
block_command = true;
}
else if (Pattern.compile("^/toggledownfall").matcher(command).find())
{
block_command = true;
}
}
if (block_command)
{
p.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true);
return;
}
// block commands while player is muted
// Block commands if player is muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isUserSuperadmin(p))
{
for (String test_command : BLOCKED_MUTED_CMDS)
{
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command.toLowerCase()).find())
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
{
p.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
event.setCancelled(true);
@ -585,7 +513,20 @@ public class TFM_PlayerListener implements Listener
{
playerdata.setMuted(false);
}
return;
}
if (TotalFreedomMod.preprocessLogEnabled)
{
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true);
}
command = command.toLowerCase().trim();
// Blocked commands
if (TFM_CommandBlocker.isCommandBlocked(command, event.getPlayer()))
{
// CommandBlocker handles messages and broadcasts
event.setCancelled(true);
}
if (!TFM_SuperadminList.isUserSuperadmin(p))
@ -600,6 +541,24 @@ public class TFM_PlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onRemoteServerCommand(RemoteServerCommandEvent event)
{
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
{
event.setCommand("");
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onServerCommand(ServerCommandEvent event)
{
if (TFM_CommandBlocker.isCommandBlocked("/" + event.getCommand(), event.getSender()))
{
event.setCommand("");
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
@ -715,4 +674,27 @@ public class TFM_PlayerListener implements Listener
{
TFM_ServerInterface.handlePlayerLogin(event);
}
@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.");
}
}
}

View File

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

View File

@ -0,0 +1,61 @@
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 boolean undisguisePlayer(Player player)
{
try
{
DisguiseCraftAPI api = DisguiseCraft.getAPI();
if (api != null)
{
return api.undisguisePlayer(player);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return false;
}
public void undisguiseAllPlayers()
{
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 TFM_DisguiseCraftBridge getInstance()
{
return TFM_DisguiseCraftBridgeHolder.INSTANCE;
}
private static class TFM_DisguiseCraftBridgeHolder
{
private static final TFM_DisguiseCraftBridge INSTANCE = new TFM_DisguiseCraftBridge();
}
}

View File

@ -7,6 +7,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
@ -320,7 +322,7 @@ public class TFM_PlayerData
LivingEntity oldmob = mob_thrower_queue.remove(0);
if (oldmob != null)
{
oldmob.damage(500);
oldmob.damage(500.0);
}
}
}
@ -400,6 +402,32 @@ public class TFM_PlayerData
public void setHalted(boolean is_halted)
{
this.is_halted = is_halted;
if (is_halted)
{
player.setOp(false);
player.setGameMode(GameMode.SURVIVAL);
player.setFlying(false);
player.setDisplayName(player_name);
player.closeInventory();
player.setTotalExperience(0);
stopOrbiting();
setFrozen(true);
setMuted(true);
player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!");
}
else
{
player.setOp(true);
player.setGameMode(GameMode.CREATIVE);
setFrozen(false);
setMuted(false);
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
public BukkitTask getLockupScheduleID()

View File

@ -0,0 +1,52 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class TFM_RollbackEntry
{
private Location location;
private Material material;
private byte data;
public TFM_RollbackEntry()
{
}
public TFM_RollbackEntry(Block block)
{
location = block.getLocation();
material = block.getType();
data = block.getData();
}
public void setBlock(Block block)
{
location = block.getLocation();
material = block.getType();
data = block.getData();
}
public void setLocation(Location location)
{
this.location = location;
}
public void setMaterial(Material material)
{
this.material = material;
}
public void setData(byte data)
{
this.data = data;
}
public void restore()
{
Block b = location.getWorld().getBlockAt(location);
b.setType(material);
b.setData(data);
}
}

View File

@ -0,0 +1,86 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
public class TFM_RollbackManager
{
public static Map<String, List<TFM_RollbackEntry>> entries = new HashMap<String, List<TFM_RollbackEntry>>();
public static void blockUpdate(OfflinePlayer player, Block block)
{
List<TFM_RollbackEntry> e;
if (entries.containsKey(player.getName()))
{
e = entries.get(player.getName());
}
else
{
e = new ArrayList<TFM_RollbackEntry>();
}
e.add(0, new TFM_RollbackEntry(block));
entries.put(player.getName(), e);
}
public static void blockUpdate(OfflinePlayer player, TFM_RollbackEntry entry)
{
List<TFM_RollbackEntry> e;
if (entries.containsKey(player.getName()))
{
e = entries.get(player.getName());
}
else
{
e = new ArrayList<TFM_RollbackEntry>();
}
e.add(0, entry);
entries.put(player.getName(), e);
}
public static int rollback(OfflinePlayer player)
{
if (!canRollback(player.getName()))
{
TFM_Log.severe("Could not rollback player: " + player.getName() + "! No entries are set");
return 0;
}
List<TFM_RollbackEntry> e = entries.get(player.getName());
int counter = 0;
for (TFM_RollbackEntry entry : e)
{
entry.restore();
counter++;
}
entries.remove(player.getName());
return counter;
}
public static boolean canRollback(String player)
{
return entries.containsKey(player);
}
public static int purgeEntries()
{
int counter = entries.size();
entries.clear();
return counter;
}
public static int purgeEntries(String player)
{
if (!canRollback(player))
{
return 0;
}
int counter = entries.get(player).size();
entries.remove(player);
return counter;
}
}

View File

@ -5,11 +5,11 @@ import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.regex.Pattern;
import net.minecraft.server.v1_5_R2.BanEntry;
import net.minecraft.server.v1_5_R2.BanList;
import net.minecraft.server.v1_5_R2.MinecraftServer;
import net.minecraft.server.v1_5_R2.PlayerList;
import net.minecraft.server.v1_5_R2.PropertyManager;
import net.minecraft.server.v1_6_R2.BanEntry;
import net.minecraft.server.v1_6_R2.BanList;
import net.minecraft.server.v1_6_R2.MinecraftServer;
import net.minecraft.server.v1_6_R2.PlayerList;
import net.minecraft.server.v1_6_R2.PropertyManager;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -165,7 +165,7 @@ public class TFM_ServerInterface
{
ban_entry = (BanEntry) banByName.getEntries().get(player_name.toLowerCase());
String kick_message = "You are banned from this server.";
String kick_message = ChatColor.RED + "You are banned from this server.";
if (ban_entry != null)
{
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
@ -209,7 +209,7 @@ public class TFM_ServerInterface
if (is_ip_banned)
{
String kick_message = "Your IP address is banned from this server.";
String kick_message = ChatColor.RED + "Your IP address is banned from this server.";
if (ban_entry != null)
{
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
@ -297,4 +297,9 @@ public class TFM_ServerInterface
}
}
}
public static String getVersion()
{
return MinecraftServer.getServer().getVersion();
}
}

View File

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

View File

@ -0,0 +1,123 @@
package me.StevenLawson.TotalFreedomMod;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class TFM_WorldEditBridge
{
private WorldEditPlugin worldEditPlugin = null;
private TFM_WorldEditBridge()
{
}
public WorldEditPlugin getWorldEditPlugin()
{
if (this.worldEditPlugin == null)
{
try
{
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (we != null)
{
if (we instanceof WorldEditPlugin)
{
this.worldEditPlugin = (WorldEditPlugin) we;
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
return this.worldEditPlugin;
}
public BukkitPlayer getBukkitPlayer(Player p)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.wrapPlayer(p);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public LocalSession getPlayerSession(Player p)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.getSession(p);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void undo(Player p, int count)
{
try
{
LocalSession session = getPlayerSession(p);
if (session != null)
{
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
if (bukkitPlayer != null)
{
for (int i = 0; i < count; i++)
{
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
}
}
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public void setLimit(Player p, int limit)
{
try
{
LocalSession session = getPlayerSession(p);
if (session != null)
{
session.setBlockChangeLimit(limit);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public static TFM_WorldEditBridge getInstance()
{
return TFM_WorldEditBridgeHolder.INSTANCE;
}
private static class TFM_WorldEditBridgeHolder
{
private static final TFM_WorldEditBridge INSTANCE = new TFM_WorldEditBridge();
}
}

View File

@ -28,34 +28,35 @@ import org.mcstats.Metrics;
public class TotalFreedomMod extends JavaPlugin
{
public static final Server server = Bukkit.getServer();
//
public static final long HEARTBEAT_RATE = 5L; //Seconds
public static final long SERVICE_CHECKER_RATE = 30L;
//
public static final String CONFIG_FILE = "config.yml";
public static final String SUPERADMIN_FILE = "superadmin.yml";
public static final String PERMBAN_FILE = "permban.yml";
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
public static final String SAVED_FLAGS_FILE = "savedflags.dat";
//
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
public static final String COMMAND_PREFIX = "Command_";
//
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
//
public static boolean allPlayersFrozen = false;
public static int freezePurgeEventId = 0;
public static int mutePurgeEventId = 0;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
//
public static String pluginVersion = "";
public static String buildNumber = "";
public static String buildDate = "";
public static String pluginName = "";
//
public static TotalFreedomMod plugin = null;
public static File plugin_file = null;
@ -102,6 +103,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Util.deleteFolder(new File("./_deleteme"));
// Heartbeat
server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
TFM_CommandLoader.getInstance().scan();
@ -179,7 +181,7 @@ public class TotalFreedomMod extends JavaPlugin
}
catch (Throwable ex)
{
sender.sendMessage(ChatColor.RED + "Command Error: " + ex.getMessage());
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
}
dispatcher = null;
@ -192,14 +194,17 @@ public class TotalFreedomMod extends JavaPlugin
return true;
}
//
public static boolean allowFirePlace = false;
public static Boolean allowFireSpread = false;
public static Boolean allowLavaDamage = false;
public static boolean allowLavaPlace = false;
public static boolean allowWaterPlace = false;
public static Boolean allowExplosions = false;
public static boolean allowFliudSpread = false;
public static boolean allowTntMinecarts = false;
public static double explosiveRadius = 4.0D;
public static List<String> blockedCommands = new ArrayList<String>();
public static boolean autoEntityWipe = true;
public static boolean nukeMonitor = true;
public static int nukeMonitorCountBreak = 100;
@ -220,15 +225,15 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean tossmobEnabled = false;
public static boolean generateFlatlands = true;
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
public static boolean allowFliudSpread = false;
public static boolean adminOnlyMode = false;
public static boolean protectedAreasEnabled = true;
public static boolean autoProtectSpawnpoints = true;
public static double autoProtectRadius = 25.0D;
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
public static boolean twitterbotEnabled = false;
public static String twitterbotUrl = "http://tftwitter.darthcraft.net/";
public static String twitterbotUrl = "";
public static String twitterbotSecret = "";
public static boolean petProtectEnabled = true;
public static void loadMainConfig()
{
@ -243,7 +248,9 @@ public class TotalFreedomMod extends JavaPlugin
allowLavaPlace = config.getBoolean("allow_lava_place", allowLavaPlace);
allowWaterPlace = config.getBoolean("allow_water_place", allowWaterPlace);
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
blockedCommands = config.getStringList("blocked_commands");
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);
nukeMonitorCountBreak = config.getInt("nuke_monitor_count_break", nukeMonitorCountBreak);
@ -270,16 +277,17 @@ public class TotalFreedomMod extends JavaPlugin
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
host_sender_names = config.getStringList("host_sender_names");
twitterbotEnabled = config.getBoolean("twitterbot_enabled");
twitterbotUrl = config.getString("twitterbot_url");
twitterbotSecret = config.getString("twitterbot_secret");
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
}
catch (Exception ex)
{
TFM_Log.severe("Error loading main config: " + ex.getMessage());
}
}
//
@Deprecated
public static List<String> superadmins = new ArrayList<String>();
@Deprecated
@ -300,7 +308,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
}
}
//
public static List<String> permbanned_players = new ArrayList<String>();
public static List<String> permbanned_ips = new ArrayList<String>();

View File

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

View File

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

View File

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