This commit is contained in:
Steven Lawson 2011-11-07 08:11:13 -05:00
parent 35d0631387
commit 1ef9ec5211
8 changed files with 110 additions and 90 deletions

View file

@ -40,7 +40,7 @@ public class Command_cage extends TFM_Command
Material cage_material_inner = Material.AIR; Material cage_material_inner = Material.AIR;
if (args.length >= 2) if (args.length >= 2)
{ {
if (args[1].equalsIgnoreCase("end") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("stop")) if (TFM_Util.isStopCommand(args[1]))
{ {
playerdata.setCaged(false); playerdata.setCaged(false);
playerdata.regenerateHistory(); playerdata.regenerateHistory();

View file

@ -39,7 +39,7 @@ public class Command_orbit extends TFM_Command
if (args.length >= 2) if (args.length >= 2)
{ {
if (args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("end")) if (TFM_Util.isStopCommand(args[1]))
{ {
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName()); sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
playerdata.stopOrbiting(); playerdata.stopOrbiting();

View file

@ -1,68 +1,58 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
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.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_qjail extends TFM_Command public class Command_qjail extends TFM_Command
{ {
@Override // @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) // public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{ // {
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) // if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{ // {
if (args.length < 1) // if (args.length < 1)
{ // {
return false; // return false;
} // }
//
Player p; // Player p;
try // try
{ // {
p = getPlayer(args[0]); // p = getPlayer(args[0]);
} // }
catch (CantFindPlayerException ex) // catch (CantFindPlayerException ex)
{ // {
sender.sendMessage(ex.getMessage()); // sender.sendMessage(ex.getMessage());
return true; // return true;
} // }
//
//Deop // //Deop
p.setOp(false); // p.setOp(false);
//
//Set gamemode to survival: // //Set gamemode to survival:
p.setGameMode(GameMode.SURVIVAL); // p.setGameMode(GameMode.SURVIVAL);
//
//Clear inventory: // //Clear inventory:
p.getInventory().clear(); // p.getInventory().clear();
//
//Strike with lightning effect: // //Strike with lightning effect:
final Location target_pos = p.getLocation(); // final Location target_pos = p.getLocation();
for (int x = -1; x <= 1; x++) // for (int x = -1; x <= 1; x++)
{ // {
for (int z = -1; z <= 1; z++) // 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); // 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); // target_pos.getWorld().strikeLightning(strike_pos);
} // }
} // }
//
//Send to jail "mgjail": // //Send to jail "mgjail":
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim())); // Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
//
TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED); // TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED);
} // }
else // else
{ // {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); // sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
} // }
//
return true; // return true;
} // }
} }

View file

@ -13,7 +13,7 @@ public class Command_stacker extends TFM_Command
// { // {
// if (args.length >= 1) // if (args.length >= 1)
// { // {
// if (args[0].equalsIgnoreCase("end") || args[0].equalsIgnoreCase("stop")) // if (TFM_Util.isStopCommand(args[0]))
// { // {
// for (World world : Bukkit.getWorlds()) // for (World world : Bukkit.getWorlds())
// { // {

View file

@ -27,7 +27,7 @@ public class Command_tossmob extends TFM_Command
CreatureType creature = CreatureType.PIG; CreatureType creature = CreatureType.PIG;
if (args.length >= 1) if (args.length >= 1)
{ {
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("end")) if (TFM_Util.isStopCommand(args[0]))
{ {
playerData.disableMobThrower(); playerData.disableMobThrower();
sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled."); sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled.");

View file

@ -217,27 +217,34 @@ public class TFM_PlayerListener extends PlayerListener
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
// String message = event.getMessage().toLowerCase();
// if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find()
// || Pattern.compile("\\shave\\s.*admin").matcher(message).find())
// {
// log.info("Kicked " + p.getName() + " for being annoying.");
// p.kickPlayer("No, bitch.");
// event.setCancelled(true);
// return;
// }
} }
@Override @Override
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{ {
String command = event.getMessage(); String command = event.getMessage();
Player player = event.getPlayer(); Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.incrementMsgCount();
if (playerdata.getMsgCount() > 10)
{
p.setOp(false);
p.kickPlayer("No Spamming");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
playerdata.resetMsgCount();
TFM_Util.wipeDropEntities(true);
event.setCancelled(true);
return;
}
if (plugin.preprocessLogEnabled) if (plugin.preprocessLogEnabled)
{ {
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command)); log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command));
} }
command = command.toLowerCase().trim(); command = command.toLowerCase().trim();
@ -246,21 +253,21 @@ public class TFM_PlayerListener extends PlayerListener
if (Pattern.compile("^/stop").matcher(command).find()) if (Pattern.compile("^/stop").matcher(command).find())
{ {
if (!TFM_Util.isUserSuperadmin(player, plugin)) if (!TFM_Util.isUserSuperadmin(p, plugin))
{ {
block_command = true; block_command = true;
} }
} }
else if (Pattern.compile("^/reload").matcher(command).find()) else if (Pattern.compile("^/reload").matcher(command).find())
{ {
if (!TFM_Util.isUserSuperadmin(player, plugin)) if (!TFM_Util.isUserSuperadmin(p, plugin))
{ {
block_command = true; block_command = true;
} }
} }
else if (Pattern.compile("^/save-").matcher(command).find()) else if (Pattern.compile("^/save-").matcher(command).find())
{ {
if (!TFM_Util.isUserSuperadmin(player, plugin)) if (!TFM_Util.isUserSuperadmin(p, plugin))
{ {
block_command = true; block_command = true;
} }
@ -268,22 +275,22 @@ public class TFM_PlayerListener extends PlayerListener
if (block_command) if (block_command)
{ {
player.kickPlayer("That command is prohibited."); p.kickPlayer("That command is prohibited.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", player.getName())); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
TFM_Util.bcastMsg(player.getName() + " was automatically kicked for using evil commands.", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using evil commands.", ChatColor.RED);
} }
else else
{ {
if (Pattern.compile("^/time").matcher(command).find()) if (Pattern.compile("^/time").matcher(command).find())
{ {
player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time."); p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
block_command = true; block_command = true;
} }
} }
if (block_command) if (block_command)
{ {
player.sendMessage(ChatColor.RED + "That command is prohibited."); p.sendMessage(ChatColor.RED + "That command is prohibited.");
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -310,6 +317,11 @@ public class TFM_PlayerListener extends PlayerListener
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
playerdata.disarmMP44(); playerdata.disarmMP44();
if (playerdata.isCaged())
{
playerdata.regenerateHistory();
playerdata.clearHistory();
}
} }
@Override @Override
@ -317,6 +329,11 @@ public class TFM_PlayerListener extends PlayerListener
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
playerdata.disarmMP44(); playerdata.disarmMP44();
if (playerdata.isCaged())
{
playerdata.regenerateHistory();
playerdata.clearHistory();
}
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URI; import java.net.URI;
import java.util.ArrayList;
import java.util.Deque; import java.util.Deque;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
@ -500,4 +501,19 @@ public class TFM_Util
out.close(); out.close();
} }
} }
private static final List<String> stop_commands = new ArrayList<String>();
static
{
stop_commands.add("stop");
stop_commands.add("off");
stop_commands.add("end");
stop_commands.add("halt");
stop_commands.add("die");
}
public static boolean isStopCommand(String command)
{
return stop_commands.contains(command.toLowerCase());
}
} }

View file

@ -86,9 +86,6 @@ commands:
qdeop: qdeop:
description: Quick De-Op - deop someone based on a partial name. description: Quick De-Op - deop someone based on a partial name.
usage: /<command> <partialname> usage: /<command> <partialname>
qjail:
description: Quick Jail - Quickly jail someone (mgjail must be set as a jail!)
usage: /<command> <partialname>
qop: qop:
description: Quick Op - op someone based on a partial name. description: Quick Op - op someone based on a partial name.
usage: /<command> <partialname> usage: /<command> <partialname>