Converting things to static that should have been static.

Signed-off-by: Steven Lawson <steven@smlawson.com>
This commit is contained in:
Steven Lawson 2011-11-07 19:29:33 -05:00
parent 1ef9ec5211
commit 061fd64020
25 changed files with 217 additions and 177 deletions

View File

@ -34,7 +34,7 @@ public class Command_cage extends TFM_Command
return true; return true;
} }
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
Material cage_material_outer = Material.GLASS; Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR; Material cage_material_inner = Material.AIR;

View File

@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
{ {
try try
{ {
plugin.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))); TotalFreedomMod.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -31,12 +31,12 @@ public class Command_explosives extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowExplosions = true; TotalFreedomMod.allowExplosions = true;
sender.sendMessage("Explosives are now enabled, radius set to " + plugin.explosiveRadius + " blocks."); sender.sendMessage("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
} }
else else
{ {
plugin.allowExplosions = false; TotalFreedomMod.allowExplosions = false;
sender.sendMessage("Explosives are now disabled."); sender.sendMessage("Explosives are now disabled.");
} }
} }

View File

@ -20,12 +20,12 @@ public class Command_fireplace extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowFirePlace = true; TotalFreedomMod.allowFirePlace = true;
sender.sendMessage("Fire placement is now enabled."); sender.sendMessage("Fire placement is now enabled.");
} }
else else
{ {
plugin.allowFirePlace = false; TotalFreedomMod.allowFirePlace = false;
sender.sendMessage("Fire placement is now disabled."); sender.sendMessage("Fire placement is now disabled.");
} }
} }

View File

@ -20,12 +20,12 @@ public class Command_firespread extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowFireSpread = true; TotalFreedomMod.allowFireSpread = true;
sender.sendMessage("Fire spread is now enabled."); sender.sendMessage("Fire spread is now enabled.");
} }
else else
{ {
plugin.allowFireSpread = false; TotalFreedomMod.allowFireSpread = false;
sender.sendMessage("Fire spread is now disabled."); sender.sendMessage("Fire spread is now disabled.");
} }
} }

View File

@ -17,17 +17,17 @@ public class Command_fr extends TFM_Command
{ {
if (args.length == 0) if (args.length == 0)
{ {
plugin.allPlayersFrozen = !plugin.allPlayersFrozen; TotalFreedomMod.allPlayersFrozen = !TotalFreedomMod.allPlayersFrozen;
if (plugin.allPlayersFrozen) if (TotalFreedomMod.allPlayersFrozen)
{ {
plugin.allPlayersFrozen = true; TotalFreedomMod.allPlayersFrozen = true;
sender.sendMessage("Players are now frozen."); sender.sendMessage("Players are now frozen.");
TFM_Util.bcastMsg(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA); TFM_Util.bcastMsg(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA);
} }
else else
{ {
plugin.allPlayersFrozen = false; TotalFreedomMod.allPlayersFrozen = false;
sender.sendMessage("Players are now free to move."); sender.sendMessage("Players are now free to move.");
TFM_Util.bcastMsg(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA); TFM_Util.bcastMsg(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA);
} }
@ -45,7 +45,7 @@ public class Command_fr extends TFM_Command
return true; return true;
} }
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen()); playerdata.setFrozen(!playerdata.isFrozen());
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");

View File

@ -93,7 +93,7 @@ public class Command_gadmin extends TFM_Command
} }
else if (mode.equals("fr")) else if (mode.equals("fr"))
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen()); playerdata.setFrozen(!playerdata.isFrozen());
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");

View File

@ -19,11 +19,11 @@ public class Command_landmine extends TFM_Command
{ {
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
} }
else if (!plugin.landminesEnabled) else if (!TotalFreedomMod.landminesEnabled)
{ {
sender.sendMessage(ChatColor.GREEN + "The landmine is currently disabled."); sender.sendMessage(ChatColor.GREEN + "The landmine is currently disabled.");
} }
else if (!plugin.allowExplosions) else if (!TotalFreedomMod.allowExplosions)
{ {
sender.sendMessage(ChatColor.GREEN + "Explosions are currently disabled."); sender.sendMessage(ChatColor.GREEN + "Explosions are currently disabled.");
} }
@ -43,7 +43,7 @@ public class Command_landmine extends TFM_Command
Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN); Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
landmine.setType(Material.TNT); landmine.setType(Material.TNT);
plugin.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius)); TFM_LandmineData.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p, radius));
sender.sendMessage(ChatColor.GREEN + "Landmine planted. Radius: " + radius + " blocks."); sender.sendMessage(ChatColor.GREEN + "Landmine planted. Radius: " + radius + " blocks.");
} }

View File

@ -20,12 +20,12 @@ public class Command_lavadmg extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowLavaDamage = true; TotalFreedomMod.allowLavaDamage = true;
sender.sendMessage("Lava damage is now enabled."); sender.sendMessage("Lava damage is now enabled.");
} }
else else
{ {
plugin.allowLavaDamage = false; TotalFreedomMod.allowLavaDamage = false;
sender.sendMessage("Lava damage is now disabled."); sender.sendMessage("Lava damage is now disabled.");
} }
} }

View File

@ -20,12 +20,12 @@ public class Command_lavaplace extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowLavaPlace = true; TotalFreedomMod.allowLavaPlace = true;
sender.sendMessage("Lava placement is now enabled."); sender.sendMessage("Lava placement is now enabled.");
} }
else else
{ {
plugin.allowLavaPlace = false; TotalFreedomMod.allowLavaPlace = false;
sender.sendMessage("Lava placement is now disabled."); sender.sendMessage("Lava placement is now disabled.");
} }
} }

View File

@ -18,7 +18,7 @@ public class Command_mp44 extends TFM_Command
{ {
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
} }
else if (!plugin.mp44Enabled) else if (!TotalFreedomMod.mp44Enabled)
{ {
sender.sendMessage(ChatColor.GREEN + "The mp44 is currently disabled."); sender.sendMessage(ChatColor.GREEN + "The mp44 is currently disabled.");
} }
@ -29,7 +29,7 @@ public class Command_mp44 extends TFM_Command
return false; return false;
} }
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p);
if (args[0].equalsIgnoreCase("draw")) if (args[0].equalsIgnoreCase("draw"))
{ {

View File

@ -23,7 +23,7 @@ public class Command_nonuke extends TFM_Command
{ {
try try
{ {
plugin.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))); TotalFreedomMod.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -34,7 +34,7 @@ public class Command_nonuke extends TFM_Command
{ {
try try
{ {
plugin.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2]))); TotalFreedomMod.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2])));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -43,14 +43,14 @@ public class Command_nonuke extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.nukeMonitor = true; TotalFreedomMod.nukeMonitor = true;
sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled."); sender.sendMessage(ChatColor.GRAY + "Nuke monitor is enabled.");
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + plugin.nukeMonitorRange + " blocks."); sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + plugin.nukeMonitorCountBreak + " blocks destroyed per 5 seconds."); sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
} }
else else
{ {
plugin.nukeMonitor = false; TotalFreedomMod.nukeMonitor = false;
sender.sendMessage("Nuke monitor is disabled."); sender.sendMessage("Nuke monitor is disabled.");
} }
} }

View File

@ -33,7 +33,7 @@ public class Command_orbit extends TFM_Command
return true; return true;
} }
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
double strength = 10.0; double strength = 10.0;

View File

@ -20,12 +20,12 @@ public class Command_prelog extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.preprocessLogEnabled = true; TotalFreedomMod.preprocessLogEnabled = true;
sender.sendMessage("Command preprocess logging is now enabled. This will be spammy in the log."); sender.sendMessage("Command preprocess logging is now enabled. This will be spammy in the log.");
} }
else else
{ {
plugin.preprocessLogEnabled = false; TotalFreedomMod.preprocessLogEnabled = false;
sender.sendMessage("Command preprocess logging is now disabled."); sender.sendMessage("Command preprocess logging is now disabled.");
} }
} }

View File

@ -60,7 +60,7 @@ public class Command_tfsmite extends TFM_Command
p.getInventory().clear(); p.getInventory().clear();
//Flag for insta-kill: //Flag for insta-kill:
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setForcedDeath(true); playerdata.setForcedDeath(true);
//Strike with lightning effect: //Strike with lightning effect:

View File

@ -22,7 +22,7 @@ public class Command_tossmob extends TFM_Command
} }
else if (sender.isOp()) else if (sender.isOp())
{ {
TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p, plugin); TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p);
CreatureType creature = CreatureType.PIG; CreatureType creature = CreatureType.PIG;
if (args.length >= 1) if (args.length >= 1)

View File

@ -20,12 +20,12 @@ public class Command_waterplace extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
plugin.allowWaterPlace = true; TotalFreedomMod.allowWaterPlace = true;
sender.sendMessage("Water placement is now enabled."); sender.sendMessage("Water placement is now enabled.");
} }
else else
{ {
plugin.allowWaterPlace = false; TotalFreedomMod.allowWaterPlace = false;
sender.sendMessage("Water placement is now disabled."); sender.sendMessage("Water placement is now disabled.");
} }
} }

View File

@ -4,9 +4,7 @@ import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -26,7 +24,7 @@ public class TFM_BlockListener extends BlockListener
@Override @Override
public void onBlockBurn(BlockBurnEvent event) public void onBlockBurn(BlockBurnEvent event)
{ {
if (!plugin.allowFireSpread) if (!TotalFreedomMod.allowFireSpread)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -36,7 +34,7 @@ public class TFM_BlockListener extends BlockListener
@Override @Override
public void onBlockIgnite(BlockIgniteEvent event) public void onBlockIgnite(BlockIgniteEvent event)
{ {
if (!plugin.allowFirePlace) if (!TotalFreedomMod.allowFirePlace)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -46,10 +44,10 @@ public class TFM_BlockListener extends BlockListener
@Override @Override
public void onBlockBreak(BlockBreakEvent event) public void onBlockBreak(BlockBreakEvent event)
{ {
if (plugin.nukeMonitor) if (TotalFreedomMod.nukeMonitor)
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
Location player_pos = p.getLocation(); Location player_pos = p.getLocation();
Location block_pos = event.getBlock().getLocation(); Location block_pos = event.getBlock().getLocation();
@ -59,7 +57,7 @@ public class TFM_BlockListener extends BlockListener
{ {
out_of_range = true; out_of_range = true;
} }
else if (player_pos.distance(block_pos) > plugin.nukeMonitorRange) else if (player_pos.distance(block_pos) > TotalFreedomMod.nukeMonitorRange)
{ {
out_of_range = true; out_of_range = true;
} }
@ -67,34 +65,24 @@ public class TFM_BlockListener extends BlockListener
if (out_of_range) if (out_of_range)
{ {
playerdata.incrementFreecamDestroyCount(); playerdata.incrementFreecamDestroyCount();
if (playerdata.getFreecamDestroyCount() > plugin.freecamTriggerCount) if (playerdata.getFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount)
{ {
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
p.kickPlayer("Freecam (extended range) block breaking is not permitted on this server."); TFM_Util.autoEject(p, "Freecam (extended range) block breaking is not permitted on this server.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
playerdata.resetFreecamDestroyCount(); playerdata.resetFreecamDestroyCount();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
playerdata.incrementBlockDestroyCount(); playerdata.incrementBlockDestroyCount();
if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCountBreak) if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
{ {
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED); 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.");
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
p.kickPlayer("You are breaking blocks too fast. Nukers are not permitted on this server.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -106,19 +94,19 @@ public class TFM_BlockListener extends BlockListener
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (plugin.nukeMonitor) if (TotalFreedomMod.nukeMonitor)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
Location player_pos = p.getLocation(); Location player_pos = p.getLocation();
Location block_pos = event.getBlock().getLocation(); Location block_pos = event.getBlock().getLocation();
boolean out_of_range = false; boolean out_of_range = false;
if (!player_pos.getWorld().equals(block_pos.getWorld())) if (!player_pos.getWorld().equals(block_pos.getWorld()))
{ {
out_of_range = true; out_of_range = true;
} }
else if (player_pos.distance(block_pos) > plugin.nukeMonitorRange) else if (player_pos.distance(block_pos) > TotalFreedomMod.nukeMonitorRange)
{ {
out_of_range = true; out_of_range = true;
} }
@ -126,34 +114,24 @@ public class TFM_BlockListener extends BlockListener
if (out_of_range) if (out_of_range)
{ {
playerdata.incrementFreecamPlaceCount(); playerdata.incrementFreecamPlaceCount();
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount) if (playerdata.getFreecamPlaceCount() > TotalFreedomMod.freecamTriggerCount)
{ {
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
p.kickPlayer("Freecam (extended range) block building is not permitted on this server."); TFM_Util.autoEject(p, "Freecam (extended range) block building is not permitted on this server.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
playerdata.resetFreecamPlaceCount(); playerdata.resetFreecamPlaceCount();
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
playerdata.incrementBlockPlaceCount(); playerdata.incrementBlockPlaceCount();
if (playerdata.getBlockPlaceCount() > plugin.nukeMonitorCountPlace) if (playerdata.getBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
{ {
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
TFM_Util.autoEject(p, "You are placing blocks too fast.");
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
p.kickPlayer("You are placing blocks too fast.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -162,7 +140,7 @@ public class TFM_BlockListener extends BlockListener
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData()); ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA) if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
{ {
if (plugin.allowLavaPlace) if (TotalFreedomMod.allowLavaPlace)
{ {
log.info(String.format("%s placed lava @ %s", log.info(String.format("%s placed lava @ %s",
p.getName(), p.getName(),
@ -184,7 +162,7 @@ public class TFM_BlockListener extends BlockListener
} }
else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER) else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER)
{ {
if (plugin.allowWaterPlace) if (TotalFreedomMod.allowWaterPlace)
{ {
log.info(String.format("%s placed water @ %s", log.info(String.format("%s placed water @ %s",
p.getName(), p.getName(),
@ -206,7 +184,7 @@ public class TFM_BlockListener extends BlockListener
} }
else if (is.getType() == Material.FIRE) else if (is.getType() == Material.FIRE)
{ {
if (plugin.allowFirePlace) if (TotalFreedomMod.allowFirePlace)
{ {
log.info(String.format("%s placed fire @ %s", log.info(String.format("%s placed fire @ %s",
p.getName(), p.getName(),
@ -228,7 +206,7 @@ public class TFM_BlockListener extends BlockListener
} }
else if (is.getType() == Material.TNT) else if (is.getType() == Material.TNT)
{ {
if (plugin.allowExplosions) if (TotalFreedomMod.allowExplosions)
{ {
log.info(String.format("%s placed TNT @ %s", log.info(String.format("%s placed TNT @ %s",
p.getName(), p.getName(),

View File

@ -18,7 +18,7 @@ public class TFM_EntityListener extends EntityListener
@Override @Override
public void onEntityExplode(EntityExplodeEvent event) public void onEntityExplode(EntityExplodeEvent event)
{ {
if (!plugin.allowExplosions) if (!TotalFreedomMod.allowExplosions)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -30,19 +30,19 @@ public class TFM_EntityListener extends EntityListener
@Override @Override
public void onExplosionPrime(ExplosionPrimeEvent event) public void onExplosionPrime(ExplosionPrimeEvent event)
{ {
if (!plugin.allowExplosions) if (!TotalFreedomMod.allowExplosions)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
event.setRadius((float) plugin.explosiveRadius); event.setRadius((float) TotalFreedomMod.explosiveRadius);
} }
@Override @Override
public void onEntityCombust(EntityCombustEvent event) public void onEntityCombust(EntityCombustEvent event)
{ {
if (!plugin.allowFireSpread) if (!TotalFreedomMod.allowFireSpread)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -57,7 +57,7 @@ public class TFM_EntityListener extends EntityListener
Player p = (Player) event.getEntity(); Player p = (Player) event.getEntity();
if (p != null) if (p != null)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
if (playerdata.getForcedDeath()) if (playerdata.getForcedDeath())
{ {
event.setCancelled(false); event.setCancelled(false);
@ -70,7 +70,7 @@ public class TFM_EntityListener extends EntityListener
} }
} }
if (event.getCause() == DamageCause.LAVA && !plugin.allowLavaDamage) if (event.getCause() == DamageCause.LAVA && !TotalFreedomMod.allowLavaDamage)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -58,7 +58,7 @@ public class TFM_PlayerListener extends PlayerListener
{ {
if (material == Material.STICK) if (material == Material.STICK)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.mobThrowerEnabled()) if (playerdata.mobThrowerEnabled())
{ {
Location player_pos = player.getLocation(); Location player_pos = player.getLocation();
@ -73,7 +73,7 @@ public class TFM_PlayerListener extends PlayerListener
} }
else if (material == Material.SULPHUR) else if (material == Material.SULPHUR)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.isMP44Armed()) if (playerdata.isMP44Armed())
{ {
@ -96,10 +96,10 @@ public class TFM_PlayerListener extends PlayerListener
public void onPlayerMove(PlayerMoveEvent event) public void onPlayerMove(PlayerMoveEvent event)
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
boolean do_freeze = false; boolean do_freeze = false;
if (plugin.allPlayersFrozen) if (TotalFreedomMod.allPlayersFrozen)
{ {
if (!TFM_Util.isUserSuperadmin(p, plugin)) if (!TFM_Util.isUserSuperadmin(p, plugin))
{ {
@ -159,9 +159,9 @@ public class TFM_PlayerListener extends PlayerListener
} }
} }
if (plugin.landminesEnabled && plugin.allowExplosions) if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
{ {
Iterator<TFM_LandmineData> landmines = plugin.landmines.iterator(); Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
while (landmines.hasNext()) while (landmines.hasNext())
{ {
TFM_LandmineData landmine = landmines.next(); TFM_LandmineData landmine = landmines.next();
@ -203,15 +203,13 @@ public class TFM_PlayerListener extends PlayerListener
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.incrementMsgCount(); playerdata.incrementMsgCount();
if (playerdata.getMsgCount() > 10) 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 chat.", ChatColor.RED); TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
TFM_Util.autoEject(p, "No Spamming");
playerdata.resetMsgCount(); playerdata.resetMsgCount();
event.setCancelled(true); event.setCancelled(true);
@ -225,15 +223,13 @@ public class TFM_PlayerListener extends PlayerListener
String command = event.getMessage(); String command = event.getMessage();
Player p = event.getPlayer(); Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.incrementMsgCount(); playerdata.incrementMsgCount();
if (playerdata.getMsgCount() > 10) 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); TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
TFM_Util.autoEject(p, "No Spamming");
playerdata.resetMsgCount(); playerdata.resetMsgCount();
TFM_Util.wipeDropEntities(true); TFM_Util.wipeDropEntities(true);
@ -242,7 +238,7 @@ public class TFM_PlayerListener extends PlayerListener
return; return;
} }
if (plugin.preprocessLogEnabled) if (TotalFreedomMod.preprocessLogEnabled)
{ {
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command)); log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command));
} }
@ -275,9 +271,8 @@ public class TFM_PlayerListener extends PlayerListener
if (block_command) if (block_command)
{ {
p.kickPlayer("That command is prohibited."); TFM_Util.autoEject(p, "That command is prohibited.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using evil commands.", ChatColor.RED);
} }
else else
{ {
@ -299,7 +294,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override @Override
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
{ {
if (plugin.autoEntityWipe) if (TotalFreedomMod.autoEntityWipe)
{ {
if (event.getPlayer().getWorld().getEntities().size() > 750) if (event.getPlayer().getWorld().getEntities().size() > 750)
{ {
@ -315,7 +310,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override @Override
public void onPlayerKick(PlayerKickEvent event) public void onPlayerKick(PlayerKickEvent event)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
playerdata.disarmMP44(); playerdata.disarmMP44();
if (playerdata.isCaged()) if (playerdata.isCaged())
{ {
@ -327,7 +322,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override @Override
public void onPlayerQuit(PlayerQuitEvent event) public void onPlayerQuit(PlayerQuitEvent event)
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
playerdata.disarmMP44(); playerdata.disarmMP44();
if (playerdata.isCaged()) if (playerdata.isCaged())
{ {

View File

@ -15,7 +15,7 @@ public class TFM_WeatherListener extends WeatherListener
@Override @Override
public void onThunderChange(ThunderChangeEvent event) public void onThunderChange(ThunderChangeEvent event)
{ {
if (event.toThunderState() && plugin.disableWeather) if (event.toThunderState() && TotalFreedomMod.disableWeather)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -25,7 +25,7 @@ public class TFM_WeatherListener extends WeatherListener
@Override @Override
public void onWeatherChange(WeatherChangeEvent event) public void onWeatherChange(WeatherChangeEvent event)
{ {
if (event.toWeatherState() && plugin.disableWeather) if (event.toWeatherState() && TotalFreedomMod.disableWeather)
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -18,18 +18,18 @@ public class TFM_Heartbeat implements Runnable
{ {
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers())
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.resetMsgCount(); playerdata.resetMsgCount();
playerdata.resetBlockDestroyCount(); playerdata.resetBlockDestroyCount();
playerdata.resetBlockPlaceCount(); playerdata.resetBlockPlaceCount();
} }
if (plugin.autoEntityWipe) if (TotalFreedomMod.autoEntityWipe)
{ {
TFM_Util.wipeDropEntities(!plugin.allowExplosions); TFM_Util.wipeDropEntities(!TotalFreedomMod.allowExplosions);
} }
if (plugin.disableNight) if (TotalFreedomMod.disableNight)
{ {
try try
{ {
@ -46,7 +46,7 @@ public class TFM_Heartbeat implements Runnable
} }
} }
if (plugin.disableWeather) if (TotalFreedomMod.disableWeather)
{ {
for (World world : Bukkit.getWorlds()) for (World world : Bukkit.getWorlds())
{ {

View File

@ -1,10 +1,14 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class TFM_LandmineData public class TFM_LandmineData
{ {
public static List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
public Location landmine_pos; public Location landmine_pos;
public Player player; public Player player;
public double radius; public double radius;

View File

@ -1,7 +1,9 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -31,19 +33,21 @@ public class TFM_UserInfo
private int mp44_schedule_id = -1; private int mp44_schedule_id = -1;
private boolean mp44_armed = false; private boolean mp44_armed = false;
private boolean mp44_firing = false; private boolean mp44_firing = false;
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
private TFM_UserInfo(Player player) private TFM_UserInfo(Player player)
{ {
this.player = player; this.player = player;
} }
public static TFM_UserInfo getPlayerData(Player p, TotalFreedomMod tfm) public static TFM_UserInfo getPlayerData(Player p)
{ {
TFM_UserInfo playerdata = tfm.userinfo.get(p); TFM_UserInfo playerdata = TFM_UserInfo.userinfo.get(p);
if (playerdata == null) if (playerdata == null)
{ {
playerdata = new TFM_UserInfo(p); playerdata = new TFM_UserInfo(p);
tfm.userinfo.put(p, playerdata); TFM_UserInfo.userinfo.put(p, playerdata);
} }
return playerdata; return playerdata;
} }

View File

@ -24,6 +24,7 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -36,6 +37,28 @@ import org.bukkit.entity.*;
public class TFM_Util public class TFM_Util
{ {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private static Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
private static final Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
private static final List<String> stop_commands = new ArrayList<String>();
static
{
mobtypes.put("chicken", CreatureType.CHICKEN);
mobtypes.put("cow", CreatureType.COW);
mobtypes.put("creeper", CreatureType.CREEPER);
mobtypes.put("pig", CreatureType.PIG);
mobtypes.put("sheep", CreatureType.SHEEP);
mobtypes.put("skeleton", CreatureType.SKELETON);
mobtypes.put("spider", CreatureType.SPIDER);
mobtypes.put("zombie", CreatureType.ZOMBIE);
mobtypes.put("wolf", CreatureType.WOLF);
stop_commands.add("stop");
stop_commands.add("off");
stop_commands.add("end");
stop_commands.add("halt");
stop_commands.add("die");
}
private TFM_Util() private TFM_Util()
{ {
@ -371,20 +394,6 @@ public class TFM_Util
return false; return false;
} }
} }
private static final Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
static
{
mobtypes.put("chicken", CreatureType.CHICKEN);
mobtypes.put("cow", CreatureType.COW);
mobtypes.put("creeper", CreatureType.CREEPER);
mobtypes.put("pig", CreatureType.PIG);
mobtypes.put("sheep", CreatureType.SHEEP);
mobtypes.put("skeleton", CreatureType.SKELETON);
mobtypes.put("spider", CreatureType.SPIDER);
mobtypes.put("zombie", CreatureType.ZOMBIE);
mobtypes.put("wolf", CreatureType.WOLF);
}
public static CreatureType getCreatureType(String mobname) public static CreatureType getCreatureType(String mobname)
{ {
@ -420,7 +429,7 @@ public class TFM_Util
copy(kid, zout); copy(kid, zout);
zout.closeEntry(); zout.closeEntry();
} }
if (verbose) if (verbose)
{ {
sender.sendMessage("Zipping: " + name); sender.sendMessage("Zipping: " + name);
@ -435,7 +444,7 @@ public class TFM_Util
} }
public static void unzip(File zipfile, File directory) throws IOException public static void unzip(File zipfile, File directory) throws IOException
{ {
ZipFile zfile = new ZipFile(zipfile); ZipFile zfile = new ZipFile(zipfile);
Enumeration<? extends ZipEntry> entries = zfile.entries(); Enumeration<? extends ZipEntry> entries = zfile.entries();
while (entries.hasMoreElements()) while (entries.hasMoreElements())
@ -501,19 +510,74 @@ 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) public static boolean isStopCommand(String command)
{ {
return stop_commands.contains(command.toLowerCase()); return stop_commands.contains(command.toLowerCase());
}
enum EjectMethod
{
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
}
public static void autoEject(Player p, String kickMessage)
{
EjectMethod method = EjectMethod.STRIKE_ONE;
String player_ip = null;
try
{
player_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
Integer num_kicks = eject_tracker.get(player_ip);
if (num_kicks == null)
{
num_kicks = new Integer(0);
}
num_kicks = new Integer(num_kicks.intValue() + 1);
if (num_kicks <= 1)
{
method = EjectMethod.STRIKE_ONE;
}
else if (num_kicks == 2)
{
method = EjectMethod.STRIKE_TWO;
}
else if (num_kicks >= 3)
{
method = EjectMethod.STRIKE_THREE;
}
}
catch (Throwable ex)
{
}
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
p.kickPlayer(kickMessage);
switch (method)
{
case STRIKE_ONE:
{
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
break;
}
case STRIKE_TWO:
{
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 3m", p.getName()));
break;
}
case STRIKE_THREE:
{
Bukkit.banIP(player_ip);
Bukkit.getOfflinePlayer(p.getName()).setBanned(true);
break;
}
}
} }
} }

View File

@ -3,9 +3,7 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command; import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
@ -28,18 +26,15 @@ public class TotalFreedomMod extends JavaPlugin
public static final long HEARTBEAT_RATE = 5L; //Seconds public static final long HEARTBEAT_RATE = 5L; //Seconds
public static final String CONFIG_FILE = "config.yml"; public static final String CONFIG_FILE = "config.yml";
public static final String SUPERADMIN_FILE = "superadmin.yml"; public static final String SUPERADMIN_FILE = "superadmin.yml";
private static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands"; public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
private static final String COMMAND_PREFIX = "Command_"; public static final String COMMAND_PREFIX = "Command_";
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command."; public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!"; public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!"; public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake."; public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console."; public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>(); public static boolean allPlayersFrozen = false;
public List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
public boolean allPlayersFrozen = false;
@Override @Override
public void onEnable() public void onEnable()
@ -122,24 +117,24 @@ public class TotalFreedomMod extends JavaPlugin
return true; return true;
} }
public boolean allowFirePlace = false; public static boolean allowFirePlace = false;
public Boolean allowFireSpread = false; public static Boolean allowFireSpread = false;
public Boolean allowLavaDamage = false; public static Boolean allowLavaDamage = false;
public boolean allowLavaPlace = false; public static boolean allowLavaPlace = false;
public boolean allowWaterPlace = false; public static boolean allowWaterPlace = false;
public Boolean allowExplosions = false; public static Boolean allowExplosions = false;
public double explosiveRadius = 4.0D; public static double explosiveRadius = 4.0D;
public boolean autoEntityWipe = true; public static boolean autoEntityWipe = true;
public boolean nukeMonitor = true; public static boolean nukeMonitor = true;
public int nukeMonitorCountBreak = 100; public static int nukeMonitorCountBreak = 100;
public int nukeMonitorCountPlace = 25; public static int nukeMonitorCountPlace = 25;
public double nukeMonitorRange = 10.0D; public static double nukeMonitorRange = 10.0D;
public int freecamTriggerCount = 10; public static int freecamTriggerCount = 10;
public Boolean preprocessLogEnabled = true; public static Boolean preprocessLogEnabled = true;
public Boolean disableNight = true; public static Boolean disableNight = true;
public Boolean disableWeather = true; public static Boolean disableWeather = true;
public boolean landminesEnabled = false; public static boolean landminesEnabled = false;
public boolean mp44Enabled = false; public static boolean mp44Enabled = false;
public void loadMainConfig() public void loadMainConfig()
{ {