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;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR;

View File

@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
{
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)
{
@ -31,12 +31,12 @@ public class Command_explosives extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
plugin.allowExplosions = true;
sender.sendMessage("Explosives are now enabled, radius set to " + plugin.explosiveRadius + " blocks.");
TotalFreedomMod.allowExplosions = true;
sender.sendMessage("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
}
else
{
plugin.allowExplosions = false;
TotalFreedomMod.allowExplosions = false;
sender.sendMessage("Explosives are now disabled.");
}
}

View File

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

View File

@ -17,17 +17,17 @@ public class Command_fr extends TFM_Command
{
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.");
TFM_Util.bcastMsg(sender.getName() + " has temporarily frozen everyone on the server.", ChatColor.AQUA);
}
else
{
plugin.allPlayersFrozen = false;
TotalFreedomMod.allPlayersFrozen = false;
sender.sendMessage("Players are now free to move.");
TFM_Util.bcastMsg(sender.getName() + " has unfrozen everyone.", ChatColor.AQUA);
}
@ -45,7 +45,7 @@ public class Command_fr extends TFM_Command
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen());
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"))
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen());
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);
}
else if (!plugin.landminesEnabled)
else if (!TotalFreedomMod.landminesEnabled)
{
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.");
}
@ -43,7 +43,7 @@ public class Command_landmine extends TFM_Command
Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
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.");
}

View File

@ -20,12 +20,12 @@ public class Command_lavadmg extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
plugin.allowLavaDamage = true;
TotalFreedomMod.allowLavaDamage = true;
sender.sendMessage("Lava damage is now enabled.");
}
else
{
plugin.allowLavaDamage = false;
TotalFreedomMod.allowLavaDamage = false;
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"))
{
plugin.allowLavaPlace = true;
TotalFreedomMod.allowLavaPlace = true;
sender.sendMessage("Lava placement is now enabled.");
}
else
{
plugin.allowLavaPlace = false;
TotalFreedomMod.allowLavaPlace = false;
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);
}
else if (!plugin.mp44Enabled)
else if (!TotalFreedomMod.mp44Enabled)
{
sender.sendMessage(ChatColor.GREEN + "The mp44 is currently disabled.");
}
@ -29,7 +29,7 @@ public class Command_mp44 extends TFM_Command
return false;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p);
if (args[0].equalsIgnoreCase("draw"))
{

View File

@ -23,7 +23,7 @@ public class Command_nonuke extends TFM_Command
{
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)
{
@ -34,7 +34,7 @@ public class Command_nonuke extends TFM_Command
{
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)
{
@ -43,14 +43,14 @@ public class Command_nonuke extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
plugin.nukeMonitor = true;
TotalFreedomMod.nukeMonitor = true;
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 + "Block throttle rate is set to " + plugin.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
sender.sendMessage(ChatColor.GRAY + "Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
sender.sendMessage(ChatColor.GRAY + "Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
}
else
{
plugin.nukeMonitor = false;
TotalFreedomMod.nukeMonitor = false;
sender.sendMessage("Nuke monitor is disabled.");
}
}

View File

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

View File

@ -20,12 +20,12 @@ public class Command_prelog extends TFM_Command
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.");
}
else
{
plugin.preprocessLogEnabled = false;
TotalFreedomMod.preprocessLogEnabled = false;
sender.sendMessage("Command preprocess logging is now disabled.");
}
}

View File

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

View File

@ -22,7 +22,7 @@ public class Command_tossmob extends TFM_Command
}
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;
if (args.length >= 1)

View File

@ -20,12 +20,12 @@ public class Command_waterplace extends TFM_Command
if (args[0].equalsIgnoreCase("on"))
{
plugin.allowWaterPlace = true;
TotalFreedomMod.allowWaterPlace = true;
sender.sendMessage("Water placement is now enabled.");
}
else
{
plugin.allowWaterPlace = false;
TotalFreedomMod.allowWaterPlace = false;
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_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.Material;
import org.bukkit.entity.Player;
@ -26,7 +24,7 @@ public class TFM_BlockListener extends BlockListener
@Override
public void onBlockBurn(BlockBurnEvent event)
{
if (!plugin.allowFireSpread)
if (!TotalFreedomMod.allowFireSpread)
{
event.setCancelled(true);
return;
@ -36,7 +34,7 @@ public class TFM_BlockListener extends BlockListener
@Override
public void onBlockIgnite(BlockIgniteEvent event)
{
if (!plugin.allowFirePlace)
if (!TotalFreedomMod.allowFirePlace)
{
event.setCancelled(true);
return;
@ -46,10 +44,10 @@ public class TFM_BlockListener extends BlockListener
@Override
public void onBlockBreak(BlockBreakEvent event)
{
if (plugin.nukeMonitor)
if (TotalFreedomMod.nukeMonitor)
{
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 block_pos = event.getBlock().getLocation();
@ -59,7 +57,7 @@ public class TFM_BlockListener extends BlockListener
{
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;
}
@ -67,34 +65,24 @@ public class TFM_BlockListener extends BlockListener
if (out_of_range)
{
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);
p.kickPlayer("Freecam (extended range) block breaking is not permitted on this server.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
TFM_Util.autoEject(p, "Freecam (extended range) block breaking is not permitted on this server.");
playerdata.resetFreecamDestroyCount();
event.setCancelled(true);
return;
}
}
playerdata.incrementBlockDestroyCount();
if (playerdata.getBlockDestroyCount() > plugin.nukeMonitorCountBreak)
if (playerdata.getBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
{
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
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()));
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
event.setCancelled(true);
return;
}
@ -106,19 +94,19 @@ public class TFM_BlockListener extends BlockListener
{
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 block_pos = event.getBlock().getLocation();
boolean out_of_range = false;
if (!player_pos.getWorld().equals(block_pos.getWorld()))
{
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;
}
@ -126,34 +114,24 @@ public class TFM_BlockListener extends BlockListener
if (out_of_range)
{
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);
p.kickPlayer("Freecam (extended range) block building is not permitted on this server.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
TFM_Util.autoEject(p, "Freecam (extended range) block building is not permitted on this server.");
playerdata.resetFreecamPlaceCount();
event.setCancelled(true);
return;
}
}
playerdata.incrementBlockPlaceCount();
if (playerdata.getBlockPlaceCount() > plugin.nukeMonitorCountPlace)
if (playerdata.getBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
{
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
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()));
TFM_Util.autoEject(p, "You are placing blocks too fast.");
event.setCancelled(true);
return;
}
@ -162,7 +140,7 @@ public class TFM_BlockListener extends BlockListener
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
{
if (plugin.allowLavaPlace)
if (TotalFreedomMod.allowLavaPlace)
{
log.info(String.format("%s placed lava @ %s",
p.getName(),
@ -184,7 +162,7 @@ public class TFM_BlockListener extends BlockListener
}
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",
p.getName(),
@ -206,7 +184,7 @@ public class TFM_BlockListener extends BlockListener
}
else if (is.getType() == Material.FIRE)
{
if (plugin.allowFirePlace)
if (TotalFreedomMod.allowFirePlace)
{
log.info(String.format("%s placed fire @ %s",
p.getName(),
@ -228,7 +206,7 @@ public class TFM_BlockListener extends BlockListener
}
else if (is.getType() == Material.TNT)
{
if (plugin.allowExplosions)
if (TotalFreedomMod.allowExplosions)
{
log.info(String.format("%s placed TNT @ %s",
p.getName(),

View File

@ -18,7 +18,7 @@ public class TFM_EntityListener extends EntityListener
@Override
public void onEntityExplode(EntityExplodeEvent event)
{
if (!plugin.allowExplosions)
if (!TotalFreedomMod.allowExplosions)
{
event.setCancelled(true);
return;
@ -30,19 +30,19 @@ public class TFM_EntityListener extends EntityListener
@Override
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if (!plugin.allowExplosions)
if (!TotalFreedomMod.allowExplosions)
{
event.setCancelled(true);
return;
}
event.setRadius((float) plugin.explosiveRadius);
event.setRadius((float) TotalFreedomMod.explosiveRadius);
}
@Override
public void onEntityCombust(EntityCombustEvent event)
{
if (!plugin.allowFireSpread)
if (!TotalFreedomMod.allowFireSpread)
{
event.setCancelled(true);
return;
@ -57,7 +57,7 @@ public class TFM_EntityListener extends EntityListener
Player p = (Player) event.getEntity();
if (p != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
if (playerdata.getForcedDeath())
{
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);
return;

View File

@ -58,7 +58,7 @@ public class TFM_PlayerListener extends PlayerListener
{
if (material == Material.STICK)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.mobThrowerEnabled())
{
Location player_pos = player.getLocation();
@ -73,7 +73,7 @@ public class TFM_PlayerListener extends PlayerListener
}
else if (material == Material.SULPHUR)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.isMP44Armed())
{
@ -96,10 +96,10 @@ public class TFM_PlayerListener extends PlayerListener
public void onPlayerMove(PlayerMoveEvent event)
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
boolean do_freeze = false;
if (plugin.allPlayersFrozen)
if (TotalFreedomMod.allPlayersFrozen)
{
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())
{
TFM_LandmineData landmine = landmines.next();
@ -203,15 +203,13 @@ public class TFM_PlayerListener extends PlayerListener
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
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 chat.", ChatColor.RED);
TFM_Util.autoEject(p, "No Spamming");
playerdata.resetMsgCount();
event.setCancelled(true);
@ -225,15 +223,13 @@ public class TFM_PlayerListener extends PlayerListener
String command = event.getMessage();
Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
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);
TFM_Util.autoEject(p, "No Spamming");
playerdata.resetMsgCount();
TFM_Util.wipeDropEntities(true);
@ -242,7 +238,7 @@ public class TFM_PlayerListener extends PlayerListener
return;
}
if (plugin.preprocessLogEnabled)
if (TotalFreedomMod.preprocessLogEnabled)
{
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)
{
p.kickPlayer("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 evil commands.", ChatColor.RED);
TFM_Util.autoEject(p, "That command is prohibited.");
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
@ -299,7 +294,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (plugin.autoEntityWipe)
if (TotalFreedomMod.autoEntityWipe)
{
if (event.getPlayer().getWorld().getEntities().size() > 750)
{
@ -315,7 +310,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerKick(PlayerKickEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
playerdata.disarmMP44();
if (playerdata.isCaged())
{
@ -327,7 +322,7 @@ public class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerQuit(PlayerQuitEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
playerdata.disarmMP44();
if (playerdata.isCaged())
{

View File

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

View File

@ -18,18 +18,18 @@ public class TFM_Heartbeat implements Runnable
{
for (Player p : Bukkit.getOnlinePlayers())
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.resetMsgCount();
playerdata.resetBlockDestroyCount();
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
{
@ -46,7 +46,7 @@ public class TFM_Heartbeat implements Runnable
}
}
if (plugin.disableWeather)
if (TotalFreedomMod.disableWeather)
{
for (World world : Bukkit.getWorlds())
{

View File

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

View File

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

View File

@ -24,6 +24,7 @@ import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -36,6 +37,28 @@ import org.bukkit.entity.*;
public class TFM_Util
{
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()
{
@ -371,20 +394,6 @@ public class TFM_Util
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)
{
@ -420,7 +429,7 @@ public class TFM_Util
copy(kid, zout);
zout.closeEntry();
}
if (verbose)
{
sender.sendMessage("Zipping: " + name);
@ -435,7 +444,7 @@ public class TFM_Util
}
public static void unzip(File zipfile, File directory) throws IOException
{
{
ZipFile zfile = new ZipFile(zipfile);
Enumeration<? extends ZipEntry> entries = zfile.entries();
while (entries.hasMoreElements())
@ -501,19 +510,74 @@ public class TFM_Util
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());
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.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
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 String CONFIG_FILE = "config.yml";
public static final String SUPERADMIN_FILE = "superadmin.yml";
private static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
private static final String COMMAND_PREFIX = "Command_";
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 Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
public List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
public boolean allPlayersFrozen = false;
public static boolean allPlayersFrozen = false;
@Override
public void onEnable()
@ -122,24 +117,24 @@ public class TotalFreedomMod extends JavaPlugin
return true;
}
public boolean allowFirePlace = false;
public Boolean allowFireSpread = false;
public Boolean allowLavaDamage = false;
public boolean allowLavaPlace = false;
public boolean allowWaterPlace = false;
public Boolean allowExplosions = false;
public double explosiveRadius = 4.0D;
public boolean autoEntityWipe = true;
public boolean nukeMonitor = true;
public int nukeMonitorCountBreak = 100;
public int nukeMonitorCountPlace = 25;
public double nukeMonitorRange = 10.0D;
public int freecamTriggerCount = 10;
public Boolean preprocessLogEnabled = true;
public Boolean disableNight = true;
public Boolean disableWeather = true;
public boolean landminesEnabled = false;
public boolean mp44Enabled = false;
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 double explosiveRadius = 4.0D;
public static boolean autoEntityWipe = true;
public static boolean nukeMonitor = true;
public static int nukeMonitorCountBreak = 100;
public static int nukeMonitorCountPlace = 25;
public static double nukeMonitorRange = 10.0D;
public static int freecamTriggerCount = 10;
public static Boolean preprocessLogEnabled = true;
public static Boolean disableNight = true;
public static Boolean disableWeather = true;
public static boolean landminesEnabled = false;
public static boolean mp44Enabled = false;
public void loadMainConfig()
{