Merge branch 'master' into adminworld

This commit is contained in:
Steven Lawson 2013-08-20 20:51:23 -04:00
commit a3cf53f5b1
46 changed files with 956 additions and 799 deletions

View File

@ -1,5 +1,5 @@
#Wed, 14 Aug 2013 15:57:37 +0200 #Tue, 20 Aug 2013 20:43:47 -0400
program.VERSION=3.00 program.VERSION=3.1
program.BUILDNUM=459 program.BUILDNUM=472
program.BUILDDATE=08/14/2013 03\:57 PM program.BUILDDATE=08/20/2013 08\:43 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Wed Aug 14 15:57:37 CEST 2013 #Tue Aug 20 20:43:47 EDT 2013
build.number=460 build.number=473

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v3.00 Configuration # TotalFreedomMod v3.1 Configuration
# by Madgeek1450 and DarthSalamon # by Madgeek1450 and DarthSalamon
# Block placement prevention: # Block placement prevention:
@ -12,7 +12,7 @@ allow_tnt_minecarts: false
# Explosion management: # Explosion management:
allow_explosions: false allow_explosions: false
explosiveRadius: 4.0 explosive_radius: 4.0
# Blocked commands: # Blocked commands:
# #
@ -126,15 +126,15 @@ host_sender_names:
# TwitterBot - Used to allow superadmins to verify themselves using twitter # TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false twitterbot_enabled: false
twitterbot_url: twitterbot_url: ''
twitterbot_secret: twitterbot_secret: ''
# Pet Protect - Prevent tamed pets from being killed. # Pet Protect - Prevent tamed pets from being killed.
pet_protect_enabled: true pet_protect_enabled: true
# Logs Registration # Logs Registration
logs_register_password: logs_register_password: ''
logs_register_url: logs_register_url: ''
# Mojang service checker # Mojang service checker
service_checker_url: http://status.mojang.com/check service_checker_url: http://status.mojang.com/check

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,13 +21,13 @@ public class Command_adminmode extends TFM_Command
if (args[0].equalsIgnoreCase("off")) if (args[0].equalsIgnoreCase("off"))
{ {
TotalFreedomMod.adminOnlyMode = false; TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true); TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
return true; return true;
} }
else if (args[0].equalsIgnoreCase("on")) else if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.adminOnlyMode = true; TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true); TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,7 +18,7 @@ public class Command_droptoggle extends TFM_Command
return false; return false;
} }
TFM_Util.adminAction(sender.getName(), TFM_Util.adminAction(sender.getName(),
((TotalFreedomMod.autoEntityWipe = !args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled") (TFM_ConfigEntry.AUTO_ENTITY_WIPE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
+ " automatic entity wiping.", false); + " automatic entity wiping.", false);
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
{ {
try try
{ {
TotalFreedomMod.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))); TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -33,12 +33,12 @@ public class Command_explosives extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.allowExplosions = true; TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
playerMsg("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks."); playerMsg("Explosives are now enabled, radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble() + " blocks.");
} }
else else
{ {
TotalFreedomMod.allowExplosions = false; TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(false);
playerMsg("Explosives are now disabled."); playerMsg("Explosives are now disabled.");
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,12 +19,12 @@ public class Command_fireplace extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.allowFirePlace = true; TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
playerMsg("Fire placement is now enabled."); playerMsg("Fire placement is now enabled.");
} }
else else
{ {
TotalFreedomMod.allowFirePlace = false; TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(false);
playerMsg("Fire placement is now disabled."); playerMsg("Fire placement is now disabled.");
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler; import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,9 +18,13 @@ public class Command_firespread extends TFM_Command
return false; return false;
} }
playerMsg("Fire spread is now " + ((TotalFreedomMod.allowFireSpread = !args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + "."); boolean fireSpread = !args[0].equalsIgnoreCase("off");
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TotalFreedomMod.allowFireSpread); TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(fireSpread);
playerMsg("Fire spread is now " + (fireSpread ? "enabled" : "disabled") + ".");
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, fireSpread);
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ public class Command_flatlands 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 (TotalFreedomMod.generateFlatlands) if (TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean())
{ {
TFM_Util.gotoWorld(sender, "flatlands"); TFM_Util.gotoWorld(sender, "flatlands");
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_fluidspread extends TFM_Command
return false; return false;
} }
if (args[0].equalsIgnoreCase("on")) playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
{
TotalFreedomMod.allowFliudSpread = true;
playerMsg("Lava and water spread is now enabled.");
}
else
{
TotalFreedomMod.allowFliudSpread = false;
playerMsg("Lava and water spread is now disabled.");
}
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData; import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -17,11 +17,11 @@ public class Command_landmine 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 (!TotalFreedomMod.landminesEnabled) if (!TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean())
{ {
playerMsg("The landmine is currently disabled.", ChatColor.GREEN); playerMsg("The landmine is currently disabled.", ChatColor.GREEN);
} }
else if (!TotalFreedomMod.allowExplosions) else if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
playerMsg("Explosions are currently disabled.", ChatColor.GREEN); playerMsg("Explosions are currently disabled.", ChatColor.GREEN);
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_lavadmg extends TFM_Command
return false; return false;
} }
if (args[0].equalsIgnoreCase("on")) playerMsg("Lava damage is now " + (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
{
TotalFreedomMod.allowLavaDamage = true;
playerMsg("Lava damage is now enabled.");
}
else
{
TotalFreedomMod.allowLavaDamage = false;
playerMsg("Lava damage is now disabled.");
}
return true; return true;
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,16 +17,7 @@ public class Command_lavaplace extends TFM_Command
return false; return false;
} }
if (args[0].equalsIgnoreCase("on")) playerMsg("Lava placement is now " + (TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
{
TotalFreedomMod.allowLavaPlace = true;
playerMsg("Lava placement is now enabled.");
}
else
{
TotalFreedomMod.allowLavaPlace = false;
playerMsg("Lava placement is now disabled.");
}
return true; return true;
} }

View File

@ -9,6 +9,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
@ -46,12 +47,10 @@ public class Command_logs extends TFM_Command
public static void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode) public static void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
{ {
if (TotalFreedomMod.logsRegisterURL == null || TotalFreedomMod.logsRegisterPassword == null) final String logsRegisterURL = TFM_ConfigEntry.LOGS_REGISTER_URL.getString();
{ final String logsRegisterPassword = TFM_ConfigEntry.LOGS_REGISTER_PASSWORD.getString();
return;
}
if (TotalFreedomMod.logsRegisterPassword.isEmpty() || TotalFreedomMod.logsRegisterURL.isEmpty()) if (logsRegisterURL == null || logsRegisterPassword == null || logsRegisterURL.isEmpty() || logsRegisterPassword.isEmpty())
{ {
return; return;
} }
@ -68,9 +67,9 @@ public class Command_logs extends TFM_Command
sender.sendMessage(ChatColor.YELLOW + "Connecting..."); sender.sendMessage(ChatColor.YELLOW + "Connecting...");
} }
URL url = new URLBuilder(TotalFreedomMod.logsRegisterURL) URL url = new URLBuilder(logsRegisterURL)
.addQueryParameter("mode", mode.toString()) .addQueryParameter("mode", mode.toString())
.addQueryParameter("password", TotalFreedomMod.logsRegisterPassword) .addQueryParameter("password", logsRegisterPassword)
.addQueryParameter("name", targetName) .addQueryParameter("name", targetName)
.addQueryParameter("ip", targetIP) .addQueryParameter("ip", targetIP)
.getURL(); .getURL();

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler; import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -20,27 +20,27 @@ public class Command_moblimiter extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.mobLimiterEnabled = true; TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
} }
else if (args[0].equalsIgnoreCase("off")) else if (args[0].equalsIgnoreCase("off"))
{ {
TotalFreedomMod.mobLimiterEnabled = false; TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
} }
else if (args[0].equalsIgnoreCase("dragon")) else if (args[0].equalsIgnoreCase("dragon"))
{ {
TotalFreedomMod.mobLimiterDisableDragon = !TotalFreedomMod.mobLimiterDisableDragon; TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
} }
else if (args[0].equalsIgnoreCase("giant")) else if (args[0].equalsIgnoreCase("giant"))
{ {
TotalFreedomMod.mobLimiterDisableGiant = !TotalFreedomMod.mobLimiterDisableGiant; TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
} }
else if (args[0].equalsIgnoreCase("slime")) else if (args[0].equalsIgnoreCase("slime"))
{ {
TotalFreedomMod.mobLimiterDisableSlime = !TotalFreedomMod.mobLimiterDisableSlime; TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
} }
else if (args[0].equalsIgnoreCase("ghast")) else if (args[0].equalsIgnoreCase("ghast"))
{ {
TotalFreedomMod.mobLimiterDisableGhast = !TotalFreedomMod.mobLimiterDisableGhast; TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
} }
else else
{ {
@ -53,7 +53,7 @@ public class Command_moblimiter extends TFM_Command
{ {
try try
{ {
TotalFreedomMod.mobLimiterMax = Math.max(0, Math.min(2000, Integer.parseInt(args[1]))); TFM_ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -61,21 +61,21 @@ public class Command_moblimiter extends TFM_Command
} }
} }
if (TotalFreedomMod.mobLimiterEnabled) if (TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{ {
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TotalFreedomMod.mobLimiterMax + "."); sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TFM_ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
playerMsg("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + "."); playerMsg("Dragon: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + "."); playerMsg("Giant: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + "."); playerMsg("Slime: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + ".");
playerMsg("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + "."); playerMsg("Ghast: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean() ? "disabled" : "enabled") + ".");
} }
else else
{ {
playerMsg("Moblimiter is disabled. No mob restrictions are in effect."); playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
} }
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TotalFreedomMod.mobLimiterEnabled); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean());
return true; return true;
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -16,7 +16,7 @@ public class Command_mp44 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 (!TotalFreedomMod.mp44Enabled) if (!TFM_ConfigEntry.MP44_ENABLED.getBoolean())
{ {
playerMsg("The mp44 is currently disabled.", ChatColor.GREEN); playerMsg("The mp44 is currently disabled.", ChatColor.GREEN);
return true; return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,7 +21,7 @@ public class Command_nonuke extends TFM_Command
{ {
try try
{ {
TotalFreedomMod.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))); TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -32,7 +32,7 @@ public class Command_nonuke extends TFM_Command
{ {
try try
{ {
TotalFreedomMod.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2]))); TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
} }
catch (NumberFormatException nfex) catch (NumberFormatException nfex)
{ {
@ -41,14 +41,14 @@ public class Command_nonuke extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.nukeMonitor = true; TFM_ConfigEntry.NUKE_MONITOR.setBoolean(true);
playerMsg("Nuke monitor is enabled."); playerMsg("Nuke monitor is enabled.");
playerMsg("Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks."); playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds."); playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
} }
else else
{ {
TotalFreedomMod.nukeMonitor = false; TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
playerMsg("Nuke monitor is disabled."); playerMsg("Nuke monitor is disabled.");
} }

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,11 +18,9 @@ public class Command_petprotect extends TFM_Command
return false; return false;
} }
TotalFreedomMod.petProtectEnabled = !TFM_Util.isStopCommand(args[0]);
TFM_Util.adminAction( TFM_Util.adminAction(
sender.getName(), sender.getName(),
"Tamed pet protection is now " + (TotalFreedomMod.petProtectEnabled ? "enabled" : "disabled") + ".", "Tamed pet protection is now " + (TFM_ConfigEntry.PET_PROTECT_ENABLED.setBoolean(!TFM_Util.isStopCommand(args[0])) ? "enabled" : "disabled") + ".",
false); false);
return true; return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,12 +21,12 @@ public class Command_prelog extends TFM_Command
if (args[0].equalsIgnoreCase("on")) if (args[0].equalsIgnoreCase("on"))
{ {
TotalFreedomMod.preprocessLogEnabled = true; TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(true);
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log."); playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
} }
else else
{ {
TotalFreedomMod.preprocessLogEnabled = false; TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(false);
playerMsg("Command preprocess logging is now disabled."); playerMsg("Command preprocess logging is now disabled.");
} }

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea; import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -17,7 +17,7 @@ public class Command_protectarea 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 (!TotalFreedomMod.protectedAreasEnabled) if (!TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{ {
playerMsg("Protected areas are currently disabled in the TotalFreedomMod configuration."); playerMsg("Protected areas are currently disabled in the TotalFreedomMod configuration.");
return true; return true;

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin; import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler; import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
@ -150,13 +151,13 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true); TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(targetName); TFM_SuperadminList.removeSuperadmin(targetName);
if (!TotalFreedomMod.twitterbotEnabled) if (!TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
{ {
return true; return true;
} }
// Twitterbot // Twitterbot
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin); TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
String reply = twitterbot.delTwitter(targetName); String reply = twitterbot.delTwitter(targetName);
if ("ok".equals(reply)) if ("ok".equals(reply))
{ {

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea; import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,9 +20,9 @@ public class Command_setspawnworld extends TFM_Command
playerMsg("Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation())); playerMsg("Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation()));
if (TotalFreedomMod.protectedAreasEnabled && TotalFreedomMod.autoProtectSpawnpoints) if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean() && TFM_ConfigEntry.AUTO_PROTECT_SPAWNPOINTS.getBoolean())
{ {
TFM_ProtectedArea.addProtectedArea("spawn_" + sender_p.getWorld().getName(), pos, TotalFreedomMod.autoProtectRadius); TFM_ProtectedArea.addProtectedArea("spawn_" + sender_p.getWorld().getName(), pos, TFM_ConfigEntry.AUTO_PROTECT_RADIUS.getDouble());
} }
return true; return true;

View File

@ -1,8 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData; import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -19,7 +19,7 @@ public class Command_tossmob 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 (!TotalFreedomMod.tossmobEnabled) if (!TFM_ConfigEntry.TOSSMOB_ENABLED.getBoolean())
{ {
playerMsg("Tossmob is currently disabled."); playerMsg("Tossmob is currently disabled.");
return true; return true;

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler; import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -15,7 +16,7 @@ public class Command_twitter 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 (!TotalFreedomMod.twitterbotEnabled) if (!TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
{ {
TFM_Util.playerMsg(sender, "TwitterBot has been disabled in config.", ChatColor.RED); TFM_Util.playerMsg(sender, "TwitterBot has been disabled in config.", ChatColor.RED);
return true; return true;
@ -26,7 +27,7 @@ public class Command_twitter extends TFM_Command
return false; return false;
} }
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin); TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
if ("set".equals(args[0])) if ("set".equals(args[0]))
{ {

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,22 +12,12 @@ public class Command_waterplace 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 (args.length != 1) if (args.length != 1)
{ {
return false; return false;
} }
if (args[0].equalsIgnoreCase("on")) playerMsg("Water placement is now " + (TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
{
TotalFreedomMod.allowWaterPlace = true;
playerMsg("Water placement is now enabled.");
}
else
{
TotalFreedomMod.allowWaterPlace = false;
playerMsg("Water placement is now disabled.");
}
return true; return true;
} }

View File

@ -65,7 +65,6 @@ public class TFM_CommandLoader
Command existing = commandMap.getCommand(dynamicCommand.getName()); Command existing = commandMap.getCommand(dynamicCommand.getName());
if (existing != null) if (existing != null)
{ {
TFM_Log.info("Replacing command: " + existing.getName());
unregisterCommand(existing, commandMap); unregisterCommand(existing, commandMap);
} }

View File

@ -1,13 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_Heartbeat; import me.StevenLawson.TotalFreedomMod.*;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -23,7 +16,7 @@ public class TFM_BlockListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockBurn(BlockBurnEvent event) public void onBlockBurn(BlockBurnEvent event)
{ {
if (!TotalFreedomMod.allowFireSpread) if (!TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -32,7 +25,7 @@ public class TFM_BlockListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockIgnite(BlockIgniteEvent event) public void onBlockIgnite(BlockIgniteEvent event)
{ {
if (!TotalFreedomMod.allowFirePlace) if (!TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -44,25 +37,27 @@ public class TFM_BlockListener implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
Location block_pos = event.getBlock().getLocation(); Location block_pos = event.getBlock().getLocation();
if (TotalFreedomMod.nukeMonitor) if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
{ {
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
Location player_pos = player.getLocation(); Location player_pos = player.getLocation();
final double nukeMonitorRange = TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
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.distanceSquared(block_pos) > (TotalFreedomMod.nukeMonitorRange * TotalFreedomMod.nukeMonitorRange)) else if (player_pos.distanceSquared(block_pos) > (nukeMonitorRange * nukeMonitorRange))
{ {
out_of_range = true; out_of_range = true;
} }
if (out_of_range) if (out_of_range)
{ {
if (playerdata.incrementAndGetFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount) if (playerdata.incrementAndGetFreecamDestroyCount() > TFM_ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
{ {
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED); TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
TFM_Util.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server."); TFM_Util.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
@ -81,7 +76,7 @@ public class TFM_BlockListener implements Listener
} }
else else
{ {
if (playerdata.incrementAndGetBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak) if (playerdata.incrementAndGetBlockDestroyCount() > TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
{ {
TFM_Util.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED); TFM_Util.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
TFM_Util.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server."); TFM_Util.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
@ -94,7 +89,7 @@ public class TFM_BlockListener implements Listener
} }
} }
if (TotalFreedomMod.protectedAreasEnabled) if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{ {
if (!TFM_SuperadminList.isUserSuperadmin(player)) if (!TFM_SuperadminList.isUserSuperadmin(player))
{ {
@ -118,25 +113,27 @@ public class TFM_BlockListener implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
Location block_pos = event.getBlock().getLocation(); Location block_pos = event.getBlock().getLocation();
if (TotalFreedomMod.nukeMonitor) if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
{ {
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
Location player_pos = player.getLocation(); Location player_pos = player.getLocation();
double nukeMonitorRange = TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
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.distanceSquared(block_pos) > (TotalFreedomMod.nukeMonitorRange * TotalFreedomMod.nukeMonitorRange)) else if (player_pos.distanceSquared(block_pos) > (nukeMonitorRange * nukeMonitorRange))
{ {
out_of_range = true; out_of_range = true;
} }
if (out_of_range) if (out_of_range)
{ {
if (playerdata.incrementAndGetFreecamPlaceCount() > TotalFreedomMod.freecamTriggerCount) if (playerdata.incrementAndGetFreecamPlaceCount() > TFM_ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
{ {
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED); TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
TFM_Util.autoEject(player, "Freecam (extended range) block building is not permitted on this server."); TFM_Util.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
@ -155,7 +152,7 @@ public class TFM_BlockListener implements Listener
} }
else else
{ {
if (playerdata.incrementAndGetBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace) if (playerdata.incrementAndGetBlockPlaceCount() > TFM_ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
{ {
TFM_Util.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED); TFM_Util.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
TFM_Util.autoEject(player, "You are placing blocks too fast."); TFM_Util.autoEject(player, "You are placing blocks too fast.");
@ -168,7 +165,7 @@ public class TFM_BlockListener implements Listener
} }
} }
if (TotalFreedomMod.protectedAreasEnabled) if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{ {
if (!TFM_SuperadminList.isUserSuperadmin(player)) if (!TFM_SuperadminList.isUserSuperadmin(player))
{ {
@ -185,7 +182,7 @@ public class TFM_BlockListener implements Listener
case LAVA: case LAVA:
case STATIONARY_LAVA: case STATIONARY_LAVA:
{ {
if (TotalFreedomMod.allowLavaPlace) if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{ {
TFM_Log.info(String.format("%s placed lava @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation()))); TFM_Log.info(String.format("%s placed lava @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
@ -203,7 +200,7 @@ public class TFM_BlockListener implements Listener
case WATER: case WATER:
case STATIONARY_WATER: case STATIONARY_WATER:
{ {
if (TotalFreedomMod.allowWaterPlace) if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{ {
TFM_Log.info(String.format("%s placed water @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation()))); TFM_Log.info(String.format("%s placed water @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
@ -220,7 +217,7 @@ public class TFM_BlockListener implements Listener
} }
case FIRE: case FIRE:
{ {
if (TotalFreedomMod.allowFirePlace) if (TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{ {
TFM_Log.info(String.format("%s placed fire @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation()))); TFM_Log.info(String.format("%s placed fire @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
@ -237,7 +234,7 @@ public class TFM_BlockListener implements Listener
} }
case TNT: case TNT:
{ {
if (TotalFreedomMod.allowExplosions) if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
TFM_Log.info(String.format("%s placed TNT @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation()))); TFM_Log.info(String.format("%s placed TNT @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
@ -264,7 +261,7 @@ public class TFM_BlockListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(BlockFromToEvent event) public void onBlockFromTo(BlockFromToEvent event)
{ {
if (!TotalFreedomMod.allowFliudSpread) if (!TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -12,7 +12,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event) public void onEntityExplode(EntityExplodeEvent event)
{ {
if (!TotalFreedomMod.allowExplosions) if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -24,19 +24,19 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onExplosionPrime(ExplosionPrimeEvent event) public void onExplosionPrime(ExplosionPrimeEvent event)
{ {
if (!TotalFreedomMod.allowExplosions) if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
event.setRadius((float) TotalFreedomMod.explosiveRadius); event.setRadius((float) TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble().doubleValue());
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event) public void onEntityCombust(EntityCombustEvent event)
{ {
if (!TotalFreedomMod.allowExplosions) if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -49,7 +49,7 @@ public class TFM_EntityListener implements Listener
{ {
case LAVA: case LAVA:
{ {
if (!TotalFreedomMod.allowLavaDamage) if (!TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -57,7 +57,7 @@ public class TFM_EntityListener implements Listener
} }
} }
if (TotalFreedomMod.petProtectEnabled) if (TFM_ConfigEntry.PET_PROTECT_ENABLED.getBoolean())
{ {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof Tameable) if (entity instanceof Tameable)
@ -73,7 +73,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onCreatureSpawn(CreatureSpawnEvent event) public void onCreatureSpawn(CreatureSpawnEvent event)
{ {
if (TotalFreedomMod.mobLimiterEnabled) if (TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
{ {
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.EGG)) if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.EGG))
{ {
@ -85,7 +85,7 @@ public class TFM_EntityListener implements Listener
if (spawned instanceof EnderDragon) if (spawned instanceof EnderDragon)
{ {
if (TotalFreedomMod.mobLimiterDisableDragon) if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -93,7 +93,7 @@ public class TFM_EntityListener implements Listener
} }
else if (spawned instanceof Ghast) else if (spawned instanceof Ghast)
{ {
if (TotalFreedomMod.mobLimiterDisableGhast) if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -101,7 +101,7 @@ public class TFM_EntityListener implements Listener
} }
else if (spawned instanceof Slime) else if (spawned instanceof Slime)
{ {
if (TotalFreedomMod.mobLimiterDisableSlime) if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -109,7 +109,7 @@ public class TFM_EntityListener implements Listener
} }
else if (spawned instanceof Giant) else if (spawned instanceof Giant)
{ {
if (TotalFreedomMod.mobLimiterDisableGiant) if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -121,7 +121,9 @@ public class TFM_EntityListener implements Listener
return; return;
} }
if (TotalFreedomMod.mobLimiterMax > 0) int mobLimiterMax = TFM_ConfigEntry.MOB_LIMITER_MAX.getInteger().intValue();
if (mobLimiterMax > 0)
{ {
int mobcount = 0; int mobcount = 0;
@ -133,7 +135,7 @@ public class TFM_EntityListener implements Listener
} }
} }
if (mobcount > TotalFreedomMod.mobLimiterMax) if (mobcount > mobLimiterMax)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -144,7 +146,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) public void onEntityDeath(EntityDeathEvent event)
{ {
if (TotalFreedomMod.autoEntityWipe) if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{ {
event.setDroppedExp(0); event.setDroppedExp(0);
} }
@ -153,7 +155,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) public void onProjectileHit(ProjectileHitEvent event)
{ {
if (TotalFreedomMod.allowExplosions) if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (event.getEntityType() == EntityType.ARROW && entity.getShooter() instanceof Player) if (event.getEntityType() == EntityType.ARROW && entity.getShooter() instanceof Player)

View File

@ -46,7 +46,7 @@ public class TFM_PlayerListener implements Listener
{ {
case WATER_BUCKET: case WATER_BUCKET:
{ {
if (!TotalFreedomMod.allowWaterPlace) if (!TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled."); player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
@ -56,7 +56,7 @@ public class TFM_PlayerListener implements Listener
} }
case LAVA_BUCKET: case LAVA_BUCKET:
{ {
if (!TotalFreedomMod.allowLavaPlace) if (!TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{ {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled."); player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
@ -66,7 +66,7 @@ public class TFM_PlayerListener implements Listener
} }
case EXPLOSIVE_MINECART: case EXPLOSIVE_MINECART:
{ {
if (!TotalFreedomMod.allowTntMinecarts) if (!TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{ {
player.getInventory().clear(player.getInventory().getHeldItemSlot()); player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled."); player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
@ -118,7 +118,7 @@ public class TFM_PlayerListener implements Listener
} }
case BLAZE_ROD: case BLAZE_ROD:
{ {
if (TotalFreedomMod.allowExplosions) if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
if (TFM_SuperadminList.isSeniorAdmin(player, true)) if (TFM_SuperadminList.isSeniorAdmin(player, true))
{ {
@ -150,7 +150,7 @@ public class TFM_PlayerListener implements Listener
} }
case CARROT: case CARROT:
{ {
if (TotalFreedomMod.allowExplosions) if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
if (TFM_SuperadminList.isSeniorAdmin(player, true)) if (TFM_SuperadminList.isSeniorAdmin(player, true))
{ {
@ -341,7 +341,7 @@ public class TFM_PlayerListener implements Listener
TFM_Jumppads.getInstance().PlayerMoveEvent(event); TFM_Jumppads.getInstance().PlayerMoveEvent(event);
} }
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions) if (TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{ {
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator(); Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
while (landmines.hasNext()) while (landmines.hasNext())
@ -542,7 +542,7 @@ public class TFM_PlayerListener implements Listener
} }
} }
if (TotalFreedomMod.preprocessLogEnabled) if (TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.getBoolean())
{ {
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true); TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
} }
@ -550,7 +550,7 @@ public class TFM_PlayerListener implements Listener
command = command.toLowerCase().trim(); command = command.toLowerCase().trim();
// Blocked commands // Blocked commands
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(command, event.getPlayer())) if (TFM_CommandBlocker.getInstance().isCommandBlocked(command, event.getPlayer()))
{ {
// CommandBlocker handles messages and broadcasts // CommandBlocker handles messages and broadcasts
event.setCancelled(true); event.setCancelled(true);
@ -571,7 +571,7 @@ public class TFM_PlayerListener implements Listener
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
{ {
if (TotalFreedomMod.autoEntityWipe) if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{ {
if (event.getPlayer().getWorld().getEntities().size() > 750) if (event.getPlayer().getWorld().getEntities().size() > 750)
{ {
@ -661,7 +661,7 @@ public class TFM_PlayerListener implements Listener
} }
} }
if (TotalFreedomMod.adminOnlyMode) if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
new BukkitRunnable() new BukkitRunnable()
{ {

View File

@ -3,11 +3,11 @@ package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlockerNew; import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList; import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
@ -52,7 +52,7 @@ public class TFM_ServerListener implements Listener
topLevelCommand = topLevelCommand.toLowerCase().trim(); topLevelCommand = topLevelCommand.toLowerCase().trim();
// We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy: // We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy:
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false)) if (TFM_CommandBlocker.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
{ {
player.sendMessage(ChatColor.GRAY + "That command is blocked."); player.sendMessage(ChatColor.GRAY + "That command is blocked.");
event.setCancelled(true); event.setCancelled(true);
@ -64,7 +64,7 @@ public class TFM_ServerListener implements Listener
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onRemoteServerCommand(RemoteServerCommandEvent event) public void onRemoteServerCommand(RemoteServerCommandEvent event)
{ {
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender())) if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
{ {
event.setCommand(""); event.setCommand("");
} }
@ -73,7 +73,7 @@ public class TFM_ServerListener implements Listener
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onServerCommand(ServerCommandEvent event) public void onServerCommand(ServerCommandEvent event)
{ {
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender())) if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
{ {
event.setCommand(""); event.setCommand("");
} }
@ -88,7 +88,7 @@ public class TFM_ServerListener implements Listener
{ {
event.setMotd(ChatColor.RED + "You are banned."); event.setMotd(ChatColor.RED + "You are banned.");
} }
else if (TotalFreedomMod.adminOnlyMode) else if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.setMotd(ChatColor.RED + "Server is closed."); event.setMotd(ChatColor.RED + "Server is closed.");
} }

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -12,7 +12,7 @@ public class TFM_WeatherListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onThunderChange(ThunderChangeEvent event) public void onThunderChange(ThunderChangeEvent event)
{ {
if (event.toThunderState() && TotalFreedomMod.disableWeather) if (event.toThunderState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -22,7 +22,7 @@ public class TFM_WeatherListener implements Listener
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onWeatherChange(WeatherChangeEvent event) public void onWeatherChange(WeatherChangeEvent event)
{ {
if (event.toWeatherState() && TotalFreedomMod.disableWeather) if (event.toWeatherState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -19,7 +19,7 @@ public class TFM_AdminWorld
{ {
private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds
private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds
private static final String GENERATION_PARAMETERS = "16,stone,32,dirt,1,grass"; private static final String GENERATION_PARAMETERS = TFM_ConfigEntry.FLATLANDS_GENERATION_PARAMS.getString();
private static final String ADMINWORLD_NAME = "adminworld"; private static final String ADMINWORLD_NAME = "adminworld";
// //
private final Map<Player, Long> teleportCooldown = new HashMap<Player, Long>(); private final Map<Player, Long> teleportCooldown = new HashMap<Player, Long>();

View File

@ -1,5 +1,10 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader; import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -9,98 +14,148 @@ import org.bukkit.entity.Player;
public class TFM_CommandBlocker public class TFM_CommandBlocker
{ {
public static boolean isCommandBlocked(String usedcommand, CommandSender sender) private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
private TFM_CommandBlocker()
{ {
parseBlockingRules();
}
String name = sender.getName(); @SuppressWarnings("unchecked")
usedcommand = usedcommand.toLowerCase().trim(); public final void parseBlockingRules()
{
blockedCommands.clear();
for (String blocked_command : TotalFreedomMod.blockedCommands) CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
if (commandMap == null)
{ {
String[] parts = blocked_command.split(":"); TFM_Log.severe("Error loading commandMap.");
return;
}
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList();
for (String rawEntry : _blockedCommands)
{
String[] parts = rawEntry.split(":");
if (parts.length < 3 || parts.length > 4) if (parts.length < 3 || parts.length > 4)
{ {
continue; continue;
} }
if (!(usedcommand + " ").startsWith(parts[2] + " ")) CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
{ if (rank == null)
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
if (commandMap == null)
{
continue;
}
Command command = commandMap.getCommand(parts[2].replaceAll("/", ""));
if (command == null)
{
continue;
}
boolean block = false;
for (String alias : command.getAliases())
{
if (usedcommand.replaceAll("/", "").startsWith(alias))
{
block = true;
break;
}
}
if (!block)
{
continue;
}
}
if (SenderRank.hasPermissions(sender, parts[0]))
{ {
continue; continue;
} }
// Past this line indicates that the command is blocked. CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
if (action == null)
// Optional: Send a message
if (parts.length == 4)
{ {
if ("_".equals(parts[3])) continue;
}
String command = parts[2];
if (command == null || command.isEmpty())
{
continue;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{ {
sender.sendMessage(ChatColor.GRAY + "That command is blocked."); continue;
} }
else else
{ {
sender.sendMessage(ChatColor.GRAY + TFM_Util.colorise(parts[3])); command = command.toLowerCase().trim();
} }
} }
else
{
continue;
}
// Action String message = null;
if ("b".equals(parts[1])) if (parts.length == 4)
{ {
return true; message = parts[3];
} }
else if ("a".equals(parts[1]))
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
Command bukkitCommand = commandMap.getCommand(command);
if (bukkitCommand == null)
{ {
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops //TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
}
else
{
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
for (String alias : bukkitCommand.getAliases())
{ {
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + usedcommand); //TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED); blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
} }
return true;
}
else if ("u".equals(parts[1]))
{
sender.sendMessage("Unknown command. Type \"help\" for help.");
return true;
} }
}
}
public boolean isCommandBlocked(String command, CommandSender sender)
{
return isCommandBlocked(command, sender, true);
}
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
{
if (command == null || command.isEmpty())
{
return false; return false;
} }
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{
return false;
}
else
{
command = command.toLowerCase().trim();
}
}
else
{
return false;
}
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
if (blockedCommandEntry != null)
{
if (!blockedCommandEntry.getRank().hasPermission(sender))
{
if (doAction)
{
blockedCommandEntry.doActions(sender);
}
return true;
}
}
return false; return false;
} }
public enum SenderRank private static enum CommandBlockerRank
{ {
ANYONE("a", 0), ANYONE("a", 0),
OP("o", 1), OP("o", 1),
@ -108,57 +163,169 @@ public class TFM_CommandBlocker
TELNET("t", 3), TELNET("t", 3),
SENIOR("c", 4), SENIOR("c", 4),
NOBODY("n", 5); NOBODY("n", 5);
private String letter = "n"; private final String token;
private int rank = 5; private final int level;
SenderRank(String letter, int rank) private CommandBlockerRank(String token, int level)
{ {
this.letter = letter; this.token = token;
this.rank = rank; this.level = level;
} }
public static boolean hasPermissions(CommandSender sender, String letter) public String getToken()
{ {
return (getSenderRank(sender).rank >= getSenderRankByLetter(letter).rank); return this.token;
} }
public static SenderRank getSenderRank(CommandSender sender) public boolean hasPermission(CommandSender sender)
{ {
if (!(sender instanceof Player)) return getSenderRank(sender).level >= this.level;
}
public static CommandBlockerRank getSenderRank(CommandSender sender)
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
if (sender.isOp())
{
return OP;
}
return ANYONE;
}
else
{ {
if (TFM_SuperadminList.isSeniorAdmin(sender)) if (TFM_SuperadminList.isSeniorAdmin(sender))
{ {
return SenderRank.SENIOR; return SENIOR;
} }
else
if (!(sender instanceof Player))
{ {
return SenderRank.TELNET; return TELNET;
} }
}
if (TFM_SuperadminList.isUserSuperadmin(sender)) return SUPER;
{
return SenderRank.SUPER;
} }
if (sender.isOp())
{
return SenderRank.OP;
}
return SenderRank.ANYONE;
} }
public static SenderRank getSenderRankByLetter(String letter) public static CommandBlockerRank fromToken(String token)
{ {
for (SenderRank rank : SenderRank.values()) for (CommandBlockerRank rank : CommandBlockerRank.values())
{ {
if (letter.equals(rank.letter)) if (rank.getToken().equalsIgnoreCase(token))
{ {
return rank; return rank;
} }
} }
return SenderRank.NOBODY; return ANYONE;
} }
} }
private enum CommandBlockerAction
{
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token)
{
for (CommandBlockerAction action : CommandBlockerAction.values())
{
if (action.getToken().equalsIgnoreCase(token))
{
return action;
}
}
return null;
}
}
private static class TFM_CommandBlocker_BlockedCommandEntry
{
private final CommandBlockerRank rank;
private final CommandBlockerAction action;
private String command;
private final String message;
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this.rank = rank;
this.action = action;
this.command = command;
this.message = message;
}
public CommandBlockerAction getAction()
{
return this.action;
}
public String getCommand()
{
return this.command;
}
public String getMessage()
{
return this.message;
}
public CommandBlockerRank getRank()
{
return this.rank;
}
public void setCommand(String command)
{
this.command = command;
}
private void doActions(CommandSender sender)
{
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
String response;
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
{
response = "Unknown command. Type \"help\" for help.";
}
else if (this.message == null || "_".equals(this.message))
{
response = ChatColor.GRAY + "That command is blocked.";
}
else
{
response = ChatColor.GRAY + TFM_Util.colorise(this.message);
}
sender.sendMessage(response);
}
}
}
public static TFM_CommandBlocker getInstance()
{
return TFM_CommandBlockerNewHolder.INSTANCE;
}
private static class TFM_CommandBlockerNewHolder
{
private static final TFM_CommandBlocker INSTANCE = new TFM_CommandBlocker();
}
} }

View File

@ -1,328 +0,0 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TFM_CommandBlockerNew
{
private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
private TFM_CommandBlockerNew()
{
parseBlockingRules();
}
public final void parseBlockingRules()
{
blockedCommands.clear();
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
if (commandMap == null)
{
TFM_Log.severe("Error loading commandMap.");
return;
}
for (String rawEntry : TotalFreedomMod.blockedCommands)
{
String[] parts = rawEntry.split(":");
if (parts.length < 3 || parts.length > 4)
{
continue;
}
CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
if (rank == null)
{
continue;
}
CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
if (action == null)
{
continue;
}
String command = parts[2];
if (command == null || command.isEmpty())
{
continue;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{
continue;
}
else
{
command = command.toLowerCase().trim();
}
}
else
{
continue;
}
String message = null;
if (parts.length == 4)
{
message = parts[3];
}
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
Command bukkitCommand = commandMap.getCommand(command);
if (bukkitCommand == null)
{
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
}
else
{
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
for (String alias : bukkitCommand.getAliases())
{
//TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
}
}
}
}
public boolean isCommandBlocked(String command, CommandSender sender)
{
return isCommandBlocked(command, sender, true);
}
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
{
if (command == null || command.isEmpty())
{
return false;
}
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
if (matcher.find())
{
command = matcher.group(1);
if (command == null)
{
return false;
}
else
{
command = command.toLowerCase().trim();
}
}
else
{
return false;
}
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
if (blockedCommandEntry != null)
{
if (!blockedCommandEntry.getRank().hasPermission(sender))
{
if (doAction)
{
blockedCommandEntry.doActions(sender);
}
return true;
}
}
return false;
}
private static enum CommandBlockerRank
{
ANYONE("a", 0),
OP("o", 1),
SUPER("s", 2),
TELNET("t", 3),
SENIOR("c", 4),
NOBODY("n", 5);
private final String token;
private final int level;
private CommandBlockerRank(String token, int level)
{
this.token = token;
this.level = level;
}
public String getToken()
{
return this.token;
}
public boolean hasPermission(CommandSender sender)
{
return getSenderRank(sender).level >= this.level;
}
public static CommandBlockerRank getSenderRank(CommandSender sender)
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
if (sender.isOp())
{
return OP;
}
return ANYONE;
}
else
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
{
return SENIOR;
}
if (!(sender instanceof Player))
{
return TELNET;
}
return SUPER;
}
}
public static CommandBlockerRank fromToken(String token)
{
for (CommandBlockerRank rank : CommandBlockerRank.values())
{
if (rank.getToken().equalsIgnoreCase(token))
{
return rank;
}
}
return ANYONE;
}
}
private enum CommandBlockerAction
{
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
private final String token;
private CommandBlockerAction(String token)
{
this.token = token;
}
public String getToken()
{
return this.token;
}
public static CommandBlockerAction fromToken(String token)
{
for (CommandBlockerAction action : CommandBlockerAction.values())
{
if (action.getToken().equalsIgnoreCase(token))
{
return action;
}
}
return null;
}
}
private static class TFM_CommandBlocker_BlockedCommandEntry
{
private final CommandBlockerRank rank;
private final CommandBlockerAction action;
private String command;
private final String message;
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
{
this.rank = rank;
this.action = action;
this.command = command;
this.message = message;
}
public CommandBlockerAction getAction()
{
return this.action;
}
public String getCommand()
{
return this.command;
}
public String getMessage()
{
return this.message;
}
public CommandBlockerRank getRank()
{
return this.rank;
}
public void setCommand(String command)
{
this.command = command;
}
private void doActions(CommandSender sender)
{
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
{
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
}
else
{
String response;
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
{
response = "Unknown command. Type \"help\" for help.";
}
else if (this.message == null || "_".equals(this.message))
{
response = ChatColor.GRAY + "That command is blocked.";
}
else
{
response = ChatColor.GRAY + TFM_Util.colorise(this.message);
}
sender.sendMessage(response);
}
}
}
public static TFM_CommandBlockerNew getInstance()
{
return TFM_CommandBlockerNewHolder.INSTANCE;
}
private static class TFM_CommandBlockerNewHolder
{
private static final TFM_CommandBlockerNew INSTANCE = new TFM_CommandBlockerNew();
}
}

View File

@ -0,0 +1,293 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.EnumMap;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
public class TFM_Config
{
public static final String CONFIG_FILENAME = "config.yml";
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), CONFIG_FILENAME);
//
private final EnumMap<TFM_ConfigEntry, Object> configEntryMap = new EnumMap<TFM_ConfigEntry, Object>(TFM_ConfigEntry.class);
private TFM_Config()
{
try
{
try
{
InputStream defaultConfig = getDefaultConfig();
TFM_Config_DefaultsLoader defaultsLoader = new TFM_Config_DefaultsLoader(defaultConfig);
for (TFM_ConfigEntry entry : TFM_ConfigEntry.values())
{
configEntryMap.put(entry, defaultsLoader.get(entry.getConfigName()));
}
defaultConfig.close();
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
copyDefaultConfig(CONFIG_FILE);
load();
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public final void load()
{
try
{
YamlConfiguration config = new YamlConfiguration();
config.load(CONFIG_FILE);
for (TFM_ConfigEntry entry : TFM_ConfigEntry.values())
{
String path = entry.getConfigName();
if (config.contains(path))
{
Object value = config.get(path);
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
{
configEntryMap.put(entry, value);
}
else
{
TFM_Log.warning("Value for " + entry.getConfigName() + " is of type " + value.getClass().getSimpleName() + ". Needs to be " + entry.getType().getSimpleName() + ". Using default value.");
}
}
else
{
TFM_Log.warning("Missing configuration entry " + entry.getConfigName() + ". Using default value.");
}
}
}
catch (FileNotFoundException ex)
{
TFM_Log.severe(ex);
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
catch (InvalidConfigurationException ex)
{
TFM_Log.severe(ex);
}
}
public String getString(TFM_ConfigEntry entry)
{
try
{
return get(entry, String.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void setString(TFM_ConfigEntry entry, String value)
{
try
{
set(entry, value, String.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
}
public Double getDouble(TFM_ConfigEntry entry)
{
try
{
return get(entry, Double.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void setDouble(TFM_ConfigEntry entry, Double value)
{
try
{
set(entry, value, Double.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
}
public Boolean getBoolean(TFM_ConfigEntry entry)
{
try
{
return get(entry, Boolean.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void setBoolean(TFM_ConfigEntry entry, Boolean value)
{
try
{
set(entry, value, Boolean.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
}
public Integer getInteger(TFM_ConfigEntry entry)
{
try
{
return get(entry, Integer.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
return null;
}
public void setInteger(TFM_ConfigEntry entry, Integer value)
{
try
{
set(entry, value, Integer.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
}
public List getList(TFM_ConfigEntry entry)
{
try
{
return get(entry, List.class);
}
catch (IllegalArgumentException ex)
{
TFM_Log.severe(ex);
}
return null;
}
public <T> T get(TFM_ConfigEntry entry, Class<T> type) throws IllegalArgumentException
{
Object value = configEntryMap.get(entry);
try
{
return type.cast(value);
}
catch (ClassCastException ex)
{
throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
}
}
public <T> void set(TFM_ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
{
if (!type.isAssignableFrom(entry.getType()))
{
throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
}
if (value != null && !type.isAssignableFrom(value.getClass()))
{
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
}
configEntryMap.put(entry, value);
}
private static void copyDefaultConfig(File targetFile)
{
if (targetFile.exists())
{
return;
}
TFM_Log.info("Installing default configuration file template: " + targetFile.getPath());
try
{
InputStream defaultConfig = getDefaultConfig();
FileUtils.copyInputStreamToFile(getDefaultConfig(), targetFile);
defaultConfig.close();
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
}
private static InputStream getDefaultConfig()
{
return TotalFreedomMod.plugin.getResource(CONFIG_FILENAME);
}
private static class TFM_Config_DefaultsLoader
{
private YamlConfiguration defaults = null;
public TFM_Config_DefaultsLoader(InputStream defaultConfig)
{
try
{
defaults = new YamlConfiguration();
defaults.load(defaultConfig);
}
catch (IOException ex)
{
TFM_Log.severe(ex);
}
catch (InvalidConfigurationException ex)
{
TFM_Log.severe(ex);
}
}
public Object get(String path)
{
return defaults.get(path);
}
}
public static TFM_Config getInstance()
{
return TFM_ConfigHolder.INSTANCE;
}
private static class TFM_ConfigHolder
{
private static final TFM_Config INSTANCE = new TFM_Config();
}
}

View File

@ -0,0 +1,121 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.List;
public enum TFM_ConfigEntry
{
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
ALLOW_EXPLOSIONS(Boolean.class, "allow_explosions"),
ALLOW_FIRE_PLACE(Boolean.class, "allow_fire_place"),
ALLOW_FIRE_SPREAD(Boolean.class, "allow_fire_spread"),
ALLOW_FLIUD_SPREAD(Boolean.class, "allow_fluid_spread"),
ALLOW_LAVA_DAMAGE(Boolean.class, "allow_lava_damage"),
ALLOW_LAVA_PLACE(Boolean.class, "allow_lava_place"),
ALLOW_TNT_MINECARTS(Boolean.class, "allow_tnt_minecarts"),
ALLOW_WATER_PLACE(Boolean.class, "allow_water_place"),
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
AUTO_PROTECT_SPAWNPOINTS(Boolean.class, "auto_protect_spawnpoints"),
DISABLE_NIGHT(Boolean.class, "disable_night"),
DISABLE_WEATHER(Boolean.class, "disable_weather"),
GENERATE_FLATLANDS(Boolean.class, "generate_flatlands"),
LANDMINES_ENABLED(Boolean.class, "landmines_enabled"),
MOB_LIMITER_DISABLE_DRAGON(Boolean.class, "mob_limiter_disable_dragon"),
MOB_LIMITER_DISABLE_GHAST(Boolean.class, "mob_limiter_disable_ghast"),
MOB_LIMITER_DISABLE_GIANT(Boolean.class, "mob_limiter_disable_giant"),
MOB_LIMITER_DISABLE_SLIME(Boolean.class, "mob_limiter_disable_slime"),
MOB_LIMITER_ENABLED(Boolean.class, "mob_limiter_enabled"),
MP44_ENABLED(Boolean.class, "mp44_enabled"),
NUKE_MONITOR(Boolean.class, "nuke_monitor"),
PET_PROTECT_ENABLED(Boolean.class, "pet_protect_enabled"),
PREPROCESS_LOG_ENABLED(Boolean.class, "preprocess_log"),
PROTECTED_AREAS_ENABLED(Boolean.class, "protected_areas_enabled"),
TOSSMOB_ENABLED(Boolean.class, "tossmob_enabled"),
TWITTERBOT_ENABLED(Boolean.class, "twitterbot_enabled"),
//
AUTO_PROTECT_RADIUS(Double.class, "auto_protect_radius"),
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
NUKE_MONITOR_RANGE(Double.class, "nuke_monitor_range"),
//
FREECAM_TRIGGER_COUNT(Integer.class, "freecam_trigger_count"),
MOB_LIMITER_MAX(Integer.class, "mob_limiter_max"),
NUKE_MONITOR_COUNT_BREAK(Integer.class, "nuke_monitor_count_break"),
NUKE_MONITOR_COUNT_PLACE(Integer.class, "nuke_monitor_count_place"),
//
FLATLANDS_GENERATION_PARAMS(String.class, "flatlands_generation_params"),
LOGS_REGISTER_PASSWORD(String.class, "logs_register_password"),
LOGS_REGISTER_URL(String.class, "logs_register_url"),
SERVICE_CHECKER_URL(String.class, "service_checker_url"),
TWITTERBOT_SECRET(String.class, "twitterbot_secret"),
TWITTERBOT_URL(String.class, "twitterbot_url"),
//
BLOCKED_COMMANDS(List.class, "blocked_commands"),
HOST_SENDER_NAMES(List.class, "host_sender_names");
//
private final Class<?> type;
private final String configName;
private TFM_ConfigEntry(Class<?> type, String configName)
{
this.type = type;
this.configName = configName;
}
public Class<?> getType()
{
return type;
}
public String getConfigName()
{
return configName;
}
public String getString()
{
return TFM_Config.getInstance().getString(this);
}
public String setString(String value)
{
TFM_Config.getInstance().setString(this, value);
return value;
}
public Double getDouble()
{
return TFM_Config.getInstance().getDouble(this);
}
public Double setDouble(Double value)
{
TFM_Config.getInstance().setDouble(this, value);
return value;
}
public Boolean getBoolean()
{
return TFM_Config.getInstance().getBoolean(this);
}
public Boolean setBoolean(Boolean value)
{
TFM_Config.getInstance().setBoolean(this, value);
return value;
}
public Integer getInteger()
{
return TFM_Config.getInstance().getInteger(this);
}
public Integer setInteger(Integer value)
{
TFM_Config.getInstance().setInteger(this, value);
return value;
}
public List getList()
{
return TFM_Config.getInstance().getList(this);
}
}

View File

@ -35,12 +35,12 @@ public class TFM_Heartbeat extends BukkitRunnable
playerdata.resetBlockPlaceCount(); playerdata.resetBlockPlaceCount();
} }
if (TotalFreedomMod.autoEntityWipe) if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
{ {
TFM_Util.TFM_EntityWiper.wipeEntities(!TotalFreedomMod.allowExplosions, false); TFM_Util.TFM_EntityWiper.wipeEntities(!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
} }
if (TotalFreedomMod.disableWeather) if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{ {
for (World world : server.getWorlds()) for (World world : server.getWorlds())
{ {

View File

@ -6,50 +6,75 @@ import org.bukkit.Bukkit;
public class TFM_Log public class TFM_Log
{ {
private static final Logger logger = Bukkit.getLogger();
private TFM_Log() private TFM_Log()
{ {
throw new AssertionError(); throw new AssertionError();
} }
public static void info(Object... params)
{
prepareLogMessage(Level.INFO, params);
}
public static void warning(Object... params)
{
prepareLogMessage(Level.WARNING, params);
}
public static void severe(Object... params)
{
prepareLogMessage(Level.SEVERE, params);
}
private static void prepareLogMessage(Level level, Object... params)
{
if (params.length == 0)
{
return;
}
Object payload = params[0];
if (payload instanceof Throwable)
{
log(level, (Throwable) payload);
}
else
{
log(level, payload.toString(), params.length >= 2 && params[1] instanceof Boolean ? (Boolean) params[1] : false);
}
}
private static void log(Level level, String message, boolean raw) private static void log(Level level, String message, boolean raw)
{ {
logger.log(level, (raw ? "" : "[" + TotalFreedomMod.pluginName + "]: ") + message); LoggerType.getLogger(raw).log(level, message);
} }
public static void info(String message) private static void log(Level level, Throwable throwable)
{ {
TFM_Log.info(message, false); LoggerType.SERVER.getLogger().log(level, null, throwable);
} }
public static void info(String message, boolean raw) private static enum LoggerType
{ {
TFM_Log.log(Level.INFO, message, raw); SERVER(Bukkit.getLogger()),
} PLUGIN(TotalFreedomMod.plugin.getLogger());
//
private final Logger logger;
public static void warning(String message) private LoggerType(Logger logger)
{ {
TFM_Log.info(message, false); this.logger = logger;
} }
public static void warning(String message, boolean raw) public Logger getLogger()
{ {
TFM_Log.log(Level.WARNING, message, raw); return logger;
} }
public static void severe(String message) public static Logger getLogger(boolean getRawLogger)
{ {
TFM_Log.info(message, false); return (getRawLogger ? SERVER.getLogger() : PLUGIN.getLogger());
} }
public static void severe(String message, boolean raw)
{
TFM_Log.log(Level.SEVERE, message, raw);
}
public static void severe(Throwable ex)
{
logger.log(Level.SEVERE, null, ex);
} }
} }

View File

@ -115,11 +115,11 @@ public class TFM_ProtectedArea implements Serializable
public static void autoAddSpawnpoints() public static void autoAddSpawnpoints()
{ {
if (TotalFreedomMod.autoProtectSpawnpoints) if (TFM_ConfigEntry.AUTO_PROTECT_SPAWNPOINTS.getBoolean())
{ {
for (World world : Bukkit.getWorlds()) for (World world : Bukkit.getWorlds())
{ {
TFM_ProtectedArea.addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), TotalFreedomMod.autoProtectRadius); TFM_ProtectedArea.addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), TFM_ConfigEntry.AUTO_PROTECT_RADIUS.getDouble());
} }
} }
} }

View File

@ -247,7 +247,7 @@ public class TFM_ServerInterface
return; return;
} }
if (TotalFreedomMod.adminOnlyMode) if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
return; return;

View File

@ -40,9 +40,16 @@ public class TFM_ServiceChecker
@Override @Override
public void run() public void run()
{ {
final String serviceCheckerURL = TFM_ConfigEntry.SERVICE_CHECKER_URL.getString();
if (serviceCheckerURL == null || serviceCheckerURL.isEmpty())
{
return;
}
try try
{ {
URL mojang_status = new URL(TotalFreedomMod.serviceCheckerURL); URL mojang_status = new URL(serviceCheckerURL);
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream())); BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine()); JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
in.close(); in.close();
@ -90,7 +97,7 @@ public class TFM_ServiceChecker
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Error updating mojang services from " + TotalFreedomMod.serviceCheckerURL); TFM_Log.severe("Error updating mojang services from " + serviceCheckerURL);
TFM_Log.severe(ex); TFM_Log.severe(ex);
} }
} }

View File

@ -8,11 +8,8 @@ import org.apache.commons.lang.exception.ExceptionUtils;
public class TFM_TwitterHandler public class TFM_TwitterHandler
{ {
private TotalFreedomMod plugin; private TFM_TwitterHandler()
private TFM_TwitterHandler(TotalFreedomMod plugin)
{ {
this.plugin = plugin;
} }
public String getTwitter(String player) public String getTwitter(String player)
@ -47,24 +44,32 @@ public class TFM_TwitterHandler
private String request(String queryString) private String request(String queryString)
{ {
String line = "failed"; String line = "failed";
try
final String twitterbotURL = TFM_ConfigEntry.TWITTERBOT_URL.getString();
final String twitterbotSecret = TFM_ConfigEntry.TWITTERBOT_SECRET.getString();
if (twitterbotURL != null && twitterbotSecret != null && !twitterbotURL.isEmpty() && !twitterbotSecret.isEmpty())
{ {
URL getUrl = new URL(TotalFreedomMod.twitterbotURL + "?auth=" + TotalFreedomMod.twitterbotSecret + "&" + queryString); try
URLConnection urlConnection = getUrl.openConnection(); {
// Read the response URL getUrl = new URL(twitterbotURL + "?auth=" + twitterbotSecret + "&" + queryString);
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); URLConnection urlConnection = getUrl.openConnection();
line = in.readLine(); // Read the response
in.close(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
} line = in.readLine();
catch (Exception ex) in.close();
{ }
TFM_Log.severe(ExceptionUtils.getFullStackTrace(ex)); catch (Exception ex)
{
TFM_Log.severe(ExceptionUtils.getFullStackTrace(ex));
}
} }
return line; return line;
} }
public static TFM_TwitterHandler getInstance(TotalFreedomMod plugin) public static TFM_TwitterHandler getInstance()
{ {
return new TFM_TwitterHandler(plugin); return new TFM_TwitterHandler();
} }
} }

View File

@ -496,7 +496,7 @@ public class TFM_Util
public static void generateFlatlands() public static void generateFlatlands()
{ {
generateFlatlands(TotalFreedomMod.flatlandsGenerationParams); generateFlatlands(TFM_ConfigEntry.FLATLANDS_GENERATION_PARAMS.getString());
} }
public static void generateFlatlands(String genParams) public static void generateFlatlands(String genParams)
@ -791,9 +791,10 @@ public class TFM_Util
} }
} }
@SuppressWarnings("unchecked")
public static boolean isFromHostConsole(String sender_name) public static boolean isFromHostConsole(String sender_name)
{ {
return TotalFreedomMod.host_sender_names.contains(sender_name.toLowerCase()); return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getList()).contains(sender_name.toLowerCase());
} }
public static List<String> removeDuplicates(List<String> old_list) public static List<String> removeDuplicates(List<String> old_list)

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command; import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader; import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
import me.StevenLawson.TotalFreedomMod.Listener.*; import me.StevenLawson.TotalFreedomMod.Listener.*;
@ -26,12 +27,9 @@ import org.mcstats.Metrics;
public class TotalFreedomMod extends JavaPlugin public class TotalFreedomMod extends JavaPlugin
{ {
public static final Server server = Bukkit.getServer();
//
public static final long HEARTBEAT_RATE = 5L; //Seconds public static final long HEARTBEAT_RATE = 5L; //Seconds
public static final long SERVICE_CHECKER_RATE = 120L; public static final long SERVICE_CHECKER_RATE = 120L;
// //
public static final String CONFIG_FILE = "config.yml";
public static final String SUPERADMIN_FILE = "superadmin.yml"; public static final String SUPERADMIN_FILE = "superadmin.yml";
public static final String PERMBAN_FILE = "permban.yml"; public static final String PERMBAN_FILE = "permban.yml";
public static final String PROTECTED_AREA_FILE = "protectedareas.dat"; public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
@ -46,68 +44,71 @@ public class TotalFreedomMod extends JavaPlugin
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 static final Server server = Bukkit.getServer();
public static TotalFreedomMod plugin = null;
public static File plugin_file = null;
//
public static String pluginName = "";
public static String pluginVersion = "";
public static String buildNumber = "";
public static String buildDate = "";
//
public static boolean allPlayersFrozen = false; public static boolean allPlayersFrozen = false;
public static BukkitTask freezePurgeTask = null; public static BukkitTask freezePurgeTask = null;
public static BukkitTask mutePurgeTask = null; public static BukkitTask mutePurgeTask = null;
public static boolean lockdownEnabled = false; public static boolean lockdownEnabled = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>(); public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
// //
public static String pluginVersion = ""; public static List<String> permbanned_players = new ArrayList<String>();
public static String buildNumber = ""; public static List<String> permbanned_ips = new ArrayList<String>();
public static String buildDate = "";
public static String pluginName = "";
//
public static TotalFreedomMod plugin = null;
public static File plugin_file = null;
@Override @Override
public void onEnable() public void onEnable()
{ {
TotalFreedomMod.plugin = this; TotalFreedomMod.plugin = this;
TotalFreedomMod.plugin_file = getFile(); TotalFreedomMod.plugin_file = plugin.getFile();
TotalFreedomMod.pluginName = plugin.getDescription().getName();
TotalFreedomMod.pluginName = this.getDescription().getName();
setAppProperties(); setAppProperties();
loadMainConfig(); TFM_Log.info("Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
loadSuperadminConfig(); loadSuperadminConfig();
loadPermbanConfig(); loadPermbanConfig();
TFM_UserList.getInstance(this); TFM_UserList.getInstance(plugin);
registerEventHandlers(); registerEventHandlers();
if (generateFlatlands) if (TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean())
{ {
TFM_Util.wipeFlatlandsIfFlagged(); TFM_Util.wipeFlatlandsIfFlagged();
TFM_Util.generateFlatlands(flatlandsGenerationParams); TFM_Util.generateFlatlands(TFM_ConfigEntry.FLATLANDS_GENERATION_PARAMS.getString());
} }
TFM_AdminWorld.getInstance().getAdminWorld(); TFM_AdminWorld.getInstance().getAdminWorld();
if (disableWeather) if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{ {
for (World world : server.getWorlds()) for (World world : server.getWorlds())
{ {
world.setThundering(false); world.setThundering(false);
world.setStorm(false); world.setStorm(false);
world.setThunderDuration(0); world.setThunderDuration(0);
world.setThunderDuration(0);
} }
} }
// Initialize game rules // Initialize game rules
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !disableNight, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !TFM_ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, allowFireSpread, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !mobLimiterEnabled, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false);
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false); TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
TFM_GameRuleHandler.commitGameRules(); TFM_GameRuleHandler.commitGameRules();
if (TotalFreedomMod.protectedAreasEnabled) if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{ {
TFM_ProtectedArea.loadProtectedAreas(); TFM_ProtectedArea.loadProtectedAreas();
TFM_ProtectedArea.autoAddSpawnpoints(); TFM_ProtectedArea.autoAddSpawnpoints();
@ -131,7 +132,7 @@ public class TotalFreedomMod extends JavaPlugin
} }
// Heartbeat // Heartbeat
new TFM_Heartbeat(this).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); new TFM_Heartbeat(plugin).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
// metrics @ http://mcstats.org/plugin/TotalFreedomMod // metrics @ http://mcstats.org/plugin/TotalFreedomMod
try try
@ -144,8 +145,6 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage()); TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
} }
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
TFM_ServiceChecker.getInstance().getUpdateRunnable().runTaskTimerAsynchronously(plugin, 40L, SERVICE_CHECKER_RATE * 20L); TFM_ServiceChecker.getInstance().getUpdateRunnable().runTaskTimerAsynchronously(plugin, 40L, SERVICE_CHECKER_RATE * 20L);
new BukkitRunnable() new BukkitRunnable()
@ -154,16 +153,19 @@ public class TotalFreedomMod extends JavaPlugin
public void run() public void run()
{ {
TFM_CommandLoader.getInstance().scan(); TFM_CommandLoader.getInstance().scan();
TFM_CommandBlockerNew.getInstance().parseBlockingRules(); TFM_CommandBlocker.getInstance().parseBlockingRules();
} }
}.runTaskLater(this, 20L); }.runTaskLater(plugin, 20L);
TFM_Log.info("Plugin enabled.");
} }
@Override @Override
public void onDisable() public void onDisable()
{ {
server.getScheduler().cancelTasks(this); server.getScheduler().cancelTasks(plugin);
TFM_Log.info("Plugin disabled");
TFM_Log.info("Plugin disabled.");
} }
@Override @Override
@ -196,7 +198,7 @@ public class TotalFreedomMod extends JavaPlugin
{ {
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader(); ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance(); dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
dispatcher.setup(this, sender, dispatcher.getClass()); dispatcher.setup(plugin, sender, dispatcher.getClass());
} }
catch (Throwable ex) catch (Throwable ex)
{ {
@ -230,105 +232,6 @@ public class TotalFreedomMod extends JavaPlugin
return true; 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;
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 static boolean mobLimiterEnabled = true;
public static int mobLimiterMax = 50;
public static boolean mobLimiterDisableDragon = true;
public static boolean mobLimiterDisableGhast = true;
public static boolean mobLimiterDisableSlime = true;
public static boolean mobLimiterDisableGiant = true;
public static boolean tossmobEnabled = false;
public static boolean generateFlatlands = true;
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
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 = "";
public static String twitterbotSecret = "";
public static boolean petProtectEnabled = true;
public static String logsRegisterPassword = "";
public static String logsRegisterURL = "";
public static String serviceCheckerURL = "http://status.mojang.com/check";
public static void loadMainConfig()
{
try
{
TFM_Util.createDefaultConfiguration(CONFIG_FILE, plugin_file);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), CONFIG_FILE));
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
allowFireSpread = config.getBoolean("allow_fire_spread", allowFireSpread);
allowLavaDamage = config.getBoolean("allow_lava_damage", allowLavaDamage);
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);
nukeMonitorCountPlace = config.getInt("nuke_monitor_count_place", nukeMonitorCountPlace);
nukeMonitorRange = config.getDouble("nuke_monitor_range", nukeMonitorRange);
freecamTriggerCount = config.getInt("freecam_trigger_count", freecamTriggerCount);
preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled);
disableNight = config.getBoolean("disable_night", disableNight);
disableWeather = config.getBoolean("disable_weather", disableWeather);
landminesEnabled = config.getBoolean("landmines_enabled", landminesEnabled);
mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled);
mobLimiterEnabled = config.getBoolean("mob_limiter_enabled", mobLimiterEnabled);
mobLimiterMax = config.getInt("mob_limiter_max", mobLimiterMax);
mobLimiterDisableDragon = config.getBoolean("mob_limiter_disable_dragon", mobLimiterDisableDragon);
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant);
tossmobEnabled = config.getBoolean("tossmob_enabled", tossmobEnabled);
generateFlatlands = config.getBoolean("generate_flatlands", generateFlatlands);
flatlandsGenerationParams = config.getString("flatlands_generation_params", flatlandsGenerationParams);
allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread);
adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode);
protectedAreasEnabled = config.getBoolean("protected_areas_enabled", protectedAreasEnabled);
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", twitterbotEnabled);
twitterbotURL = config.getString("twitterbot_url", twitterbotURL);
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
logsRegisterPassword = config.getString("logs_register_password", logsRegisterPassword);
logsRegisterURL = config.getString("logs_register_url", logsRegisterURL);
serviceCheckerURL = config.getString("service_checker_url", serviceCheckerURL);
}
catch (Exception ex)
{
TFM_Log.severe("Error loading main config: " + ex.getMessage());
}
}
public static void loadSuperadminConfig() public static void loadSuperadminConfig()
{ {
@ -342,9 +245,6 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage()); 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>();
public static void loadPermbanConfig() public static void loadPermbanConfig()
{ {
@ -373,7 +273,8 @@ public class TotalFreedomMod extends JavaPlugin
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Error loading permban list: " + ex.getMessage()); TFM_Log.severe("Error loading permban list!");
TFM_Log.severe(ex);
} }
} }
@ -392,10 +293,10 @@ public class TotalFreedomMod extends JavaPlugin
{ {
try try
{ {
InputStream in; InputStream in = plugin.getResource("appinfo.properties");
Properties props = new Properties(); Properties props = new Properties();
in = plugin.getClass().getResourceAsStream("/appinfo.properties"); // in = plugin.getClass().getResourceAsStream("/appinfo.properties");
props.load(in); props.load(in);
in.close(); in.close();
@ -405,6 +306,7 @@ public class TotalFreedomMod extends JavaPlugin
} }
catch (Exception ex) catch (Exception ex)
{ {
TFM_Log.severe("Could not load App properties!");
TFM_Log.severe(ex); TFM_Log.severe(ex);
} }
} }

View File

@ -1,7 +1,7 @@
name: TotalFreedomMod name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 3.00 version: 3.1
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon] authors: [Madgeek1450, DarthSalamon]
# plugin.yml is no longer used to define commands. # plugin.yml is no longer used to define commands.