2011-09-20 02:52:08 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod;
|
|
|
|
|
2011-09-26 15:26:52 +00:00
|
|
|
import java.io.File;
|
2012-12-06 11:01:51 +00:00
|
|
|
import java.io.IOException;
|
2012-03-09 19:01:04 +00:00
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.*;
|
2011-10-19 00:37:00 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
2013-04-10 02:05:24 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
2013-07-30 01:09:20 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.Listener.*;
|
2012-11-24 01:22:52 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2012-09-15 17:01:43 +00:00
|
|
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
2011-09-20 02:52:08 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
2012-03-06 19:25:22 +00:00
|
|
|
import org.bukkit.Server;
|
2012-09-20 03:17:10 +00:00
|
|
|
import org.bukkit.World;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-10-12 19:33:31 +00:00
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2011-10-13 23:07:52 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2011-09-23 03:22:10 +00:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
2011-09-20 02:52:08 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2013-07-27 21:49:25 +00:00
|
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import org.bukkit.scheduler.BukkitTask;
|
2012-12-08 01:01:52 +00:00
|
|
|
import org.mcstats.Metrics;
|
2011-09-20 02:52:08 +00:00
|
|
|
|
|
|
|
public class TotalFreedomMod extends JavaPlugin
|
|
|
|
{
|
2012-12-02 17:05:54 +00:00
|
|
|
public static final Server server = Bukkit.getServer();
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-10-10 12:09:19 +00:00
|
|
|
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
2013-08-09 15:08:16 +00:00
|
|
|
public static final long SERVICE_CHECKER_RATE = 120L;
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-10-12 22:45:43 +00:00
|
|
|
public static final String CONFIG_FILE = "config.yml";
|
2011-10-19 02:52:32 +00:00
|
|
|
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
2012-09-18 14:40:48 +00:00
|
|
|
public static final String PERMBAN_FILE = "permban.yml";
|
2012-11-03 19:03:38 +00:00
|
|
|
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
|
2012-11-05 03:44:24 +00:00
|
|
|
public static final String SAVED_FLAGS_FILE = "savedflags.dat";
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-11-08 00:29:33 +00:00
|
|
|
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
|
|
|
public static final String COMMAND_PREFIX = "Command_";
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-10-02 16:15:16 +00:00
|
|
|
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
|
|
|
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
|
|
|
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
|
|
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
2011-10-16 06:00:37 +00:00
|
|
|
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-11-08 00:29:33 +00:00
|
|
|
public static boolean allPlayersFrozen = false;
|
2013-07-27 21:49:25 +00:00
|
|
|
public static BukkitTask freezePurgeTask = null;
|
|
|
|
public static BukkitTask mutePurgeTask = null;
|
2013-08-12 18:47:36 +00:00
|
|
|
public static boolean lockdownEnabled = false;
|
2011-11-28 22:44:51 +00:00
|
|
|
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2012-09-14 22:49:44 +00:00
|
|
|
public static String pluginVersion = "";
|
|
|
|
public static String buildNumber = "";
|
|
|
|
public static String buildDate = "";
|
2012-09-15 17:01:43 +00:00
|
|
|
public static String pluginName = "";
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2012-09-14 22:49:44 +00:00
|
|
|
public static TotalFreedomMod plugin = null;
|
2012-11-13 01:42:30 +00:00
|
|
|
public static File plugin_file = null;
|
2012-09-14 22:49:44 +00:00
|
|
|
|
2011-10-02 16:15:16 +00:00
|
|
|
@Override
|
|
|
|
public void onEnable()
|
|
|
|
{
|
2012-09-14 22:49:44 +00:00
|
|
|
TotalFreedomMod.plugin = this;
|
2012-11-13 01:42:30 +00:00
|
|
|
TotalFreedomMod.plugin_file = getFile();
|
2012-09-15 18:05:48 +00:00
|
|
|
|
2012-09-15 17:01:43 +00:00
|
|
|
TotalFreedomMod.pluginName = this.getDescription().getName();
|
2012-09-14 22:49:44 +00:00
|
|
|
|
2012-03-09 19:01:04 +00:00
|
|
|
setAppProperties();
|
2012-09-18 21:25:37 +00:00
|
|
|
|
2011-10-19 02:52:32 +00:00
|
|
|
loadMainConfig();
|
|
|
|
loadSuperadminConfig();
|
2012-09-18 14:40:48 +00:00
|
|
|
loadPermbanConfig();
|
2011-10-30 19:27:06 +00:00
|
|
|
|
2012-03-09 19:01:04 +00:00
|
|
|
TFM_UserList.getInstance(this);
|
|
|
|
|
2011-10-02 16:15:16 +00:00
|
|
|
registerEventHandlers();
|
2011-10-30 19:27:06 +00:00
|
|
|
|
2012-03-06 19:25:22 +00:00
|
|
|
if (generateFlatlands)
|
|
|
|
{
|
2012-11-05 03:44:24 +00:00
|
|
|
TFM_Util.wipeFlatlandsIfFlagged();
|
2012-03-06 19:25:22 +00:00
|
|
|
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
|
|
|
}
|
2012-09-20 03:17:10 +00:00
|
|
|
|
2013-08-13 01:33:21 +00:00
|
|
|
TFM_AdminWorld.getInstance().getAdminWorld();
|
2013-08-12 16:38:46 +00:00
|
|
|
|
2012-09-20 03:17:10 +00:00
|
|
|
if (disableWeather)
|
|
|
|
{
|
|
|
|
for (World world : server.getWorlds())
|
|
|
|
{
|
|
|
|
world.setThundering(false);
|
|
|
|
world.setStorm(false);
|
|
|
|
world.setThunderDuration(0);
|
|
|
|
world.setThunderDuration(0);
|
|
|
|
}
|
|
|
|
}
|
2012-11-03 19:03:38 +00:00
|
|
|
|
2013-07-30 01:09:20 +00:00
|
|
|
// Initialize game rules
|
|
|
|
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !disableNight, false);
|
|
|
|
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, allowFireSpread, 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_TILE_DROPS, 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.commitGameRules();
|
|
|
|
|
2012-11-03 19:03:38 +00:00
|
|
|
if (TotalFreedomMod.protectedAreasEnabled)
|
|
|
|
{
|
|
|
|
TFM_ProtectedArea.loadProtectedAreas();
|
|
|
|
TFM_ProtectedArea.autoAddSpawnpoints();
|
|
|
|
}
|
2012-12-02 17:05:54 +00:00
|
|
|
|
|
|
|
TFM_Util.deleteFolder(new File("./_deleteme"));
|
|
|
|
|
2013-07-27 21:49:25 +00:00
|
|
|
File[] coreDumps = new File(".").listFiles(new java.io.FileFilter()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean accept(File file)
|
|
|
|
{
|
|
|
|
return file.getName().startsWith("java.core");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
for (File dump : coreDumps)
|
|
|
|
{
|
|
|
|
TFM_Log.info("Removing core dump file: " + dump.getName());
|
|
|
|
dump.delete();
|
|
|
|
}
|
|
|
|
|
2013-07-01 08:04:43 +00:00
|
|
|
// Heartbeat
|
2013-07-27 21:49:25 +00:00
|
|
|
new TFM_Heartbeat(this).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
2012-12-02 17:05:54 +00:00
|
|
|
|
2012-12-06 11:01:51 +00:00
|
|
|
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
2012-12-08 01:01:52 +00:00
|
|
|
try
|
|
|
|
{
|
2012-12-06 11:01:51 +00:00
|
|
|
Metrics metrics = new Metrics(plugin);
|
|
|
|
metrics.start();
|
2012-12-08 01:01:52 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (IOException ex)
|
2012-12-08 01:01:52 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
2012-12-06 11:01:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 01:46:29 +00:00
|
|
|
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
2013-07-20 20:06:46 +00:00
|
|
|
|
2013-08-09 15:08:16 +00:00
|
|
|
TFM_ServiceChecker.getInstance().getUpdateRunnable().runTaskTimerAsynchronously(plugin, 40L, SERVICE_CHECKER_RATE * 20L);
|
|
|
|
|
2013-07-27 21:49:25 +00:00
|
|
|
new BukkitRunnable()
|
2013-07-20 20:06:46 +00:00
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
TFM_CommandLoader.getInstance().scan();
|
2013-07-22 02:48:34 +00:00
|
|
|
TFM_CommandBlockerNew.getInstance().parseBlockingRules();
|
2013-07-20 20:06:46 +00:00
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
}.runTaskLater(this, 20L);
|
2011-10-02 16:15:16 +00:00
|
|
|
}
|
2011-09-26 15:26:52 +00:00
|
|
|
|
2011-10-02 16:15:16 +00:00
|
|
|
@Override
|
|
|
|
public void onDisable()
|
|
|
|
{
|
2012-03-06 19:25:22 +00:00
|
|
|
server.getScheduler().cancelTasks(this);
|
2013-07-13 10:49:53 +00:00
|
|
|
TFM_Log.info("Plugin disabled");
|
2011-10-12 22:45:43 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Player sender_p = null;
|
|
|
|
boolean senderIsConsole = false;
|
|
|
|
if (sender instanceof Player)
|
|
|
|
{
|
|
|
|
sender_p = (Player) sender;
|
2012-09-15 17:01:43 +00:00
|
|
|
TFM_Log.info(String.format("[PLAYER_COMMAND] %s(%s): /%s %s",
|
2011-10-19 00:37:00 +00:00
|
|
|
sender_p.getName(),
|
|
|
|
ChatColor.stripColor(sender_p.getDisplayName()),
|
|
|
|
commandLabel,
|
2012-11-24 01:22:52 +00:00
|
|
|
StringUtils.join(args, " ")), true);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
senderIsConsole = true;
|
2012-09-15 17:01:43 +00:00
|
|
|
TFM_Log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s",
|
2011-10-19 00:37:00 +00:00
|
|
|
sender.getName(),
|
|
|
|
commandLabel,
|
2012-11-24 01:22:52 +00:00
|
|
|
StringUtils.join(args, " ")), true);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TFM_Command dispatcher;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
2013-07-11 18:51:08 +00:00
|
|
|
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
|
2013-04-08 21:59:04 +00:00
|
|
|
dispatcher.setup(this, sender, dispatcher.getClass());
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Command not loaded: " + cmd.getName() + "\n" + ExceptionUtils.getStackTrace(ex));
|
2011-10-19 00:37:00 +00:00
|
|
|
sender.sendMessage(ChatColor.RED + "Command Error: Command not loaded: " + cmd.getName());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2013-04-08 21:59:04 +00:00
|
|
|
if (dispatcher.senderHasPermission())
|
2012-11-23 03:48:28 +00:00
|
|
|
{
|
|
|
|
return dispatcher.run(sender, sender_p, cmd, commandLabel, args, senderIsConsole);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2011-10-30 19:27:06 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Throwable ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Command Error: " + commandLabel + "\n" + ExceptionUtils.getStackTrace(ex));
|
2011-10-19 00:37:00 +00:00
|
|
|
sender.sendMessage(ChatColor.RED + "Unknown Command Error.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2011-11-08 00:29:33 +00:00
|
|
|
public static boolean allowFirePlace = false;
|
2013-07-29 00:50:57 +00:00
|
|
|
public static boolean allowFireSpread = false;
|
|
|
|
public static boolean allowLavaDamage = false;
|
2011-11-08 00:29:33 +00:00
|
|
|
public static boolean allowLavaPlace = false;
|
|
|
|
public static boolean allowWaterPlace = false;
|
2013-07-29 00:50:57 +00:00
|
|
|
public static boolean allowExplosions = false;
|
2013-06-23 13:17:12 +00:00
|
|
|
public static boolean allowFliudSpread = false;
|
|
|
|
public static boolean allowTntMinecarts = false;
|
2011-11-08 00:29:33 +00:00
|
|
|
public static double explosiveRadius = 4.0D;
|
2013-07-04 20:46:51 +00:00
|
|
|
public static List<String> blockedCommands = new ArrayList<String>();
|
2011-11-08 00:29:33 +00:00
|
|
|
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;
|
2013-07-29 00:50:57 +00:00
|
|
|
public static boolean preprocessLogEnabled = true;
|
|
|
|
public static boolean disableNight = true;
|
|
|
|
public static boolean disableWeather = true;
|
2011-11-08 00:29:33 +00:00
|
|
|
public static boolean landminesEnabled = false;
|
|
|
|
public static boolean mp44Enabled = false;
|
2011-11-21 04:31:29 +00:00
|
|
|
public static boolean mobLimiterEnabled = true;
|
|
|
|
public static int mobLimiterMax = 50;
|
2011-11-28 22:44:51 +00:00
|
|
|
public static boolean mobLimiterDisableDragon = true;
|
|
|
|
public static boolean mobLimiterDisableGhast = true;
|
|
|
|
public static boolean mobLimiterDisableSlime = true;
|
|
|
|
public static boolean mobLimiterDisableGiant = true;
|
2011-11-29 05:41:47 +00:00
|
|
|
public static boolean tossmobEnabled = false;
|
2012-03-06 19:25:22 +00:00
|
|
|
public static boolean generateFlatlands = true;
|
|
|
|
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
|
2012-09-15 21:00:44 +00:00
|
|
|
public static boolean adminOnlyMode = false;
|
2012-11-03 19:03:38 +00:00
|
|
|
public static boolean protectedAreasEnabled = true;
|
|
|
|
public static boolean autoProtectSpawnpoints = true;
|
|
|
|
public static double autoProtectRadius = 25.0D;
|
2012-12-02 17:05:54 +00:00
|
|
|
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
|
2013-03-19 10:06:31 +00:00
|
|
|
public static boolean twitterbotEnabled = false;
|
2013-08-04 18:48:50 +00:00
|
|
|
public static String twitterbotURL = "";
|
2013-03-19 10:06:31 +00:00
|
|
|
public static String twitterbotSecret = "";
|
2013-07-11 18:51:08 +00:00
|
|
|
public static boolean petProtectEnabled = true;
|
2013-07-27 21:49:25 +00:00
|
|
|
public static String logsRegisterPassword = "";
|
|
|
|
public static String logsRegisterURL = "";
|
2013-08-04 18:48:50 +00:00
|
|
|
public static String serviceCheckerURL = "http://status.mojang.com/check";
|
2011-10-12 22:45:43 +00:00
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
public static void loadMainConfig()
|
2011-10-02 16:15:16 +00:00
|
|
|
{
|
2012-09-20 20:35:00 +00:00
|
|
|
try
|
|
|
|
{
|
2012-12-02 17:05:54 +00:00
|
|
|
TFM_Util.createDefaultConfiguration(CONFIG_FILE, plugin_file);
|
|
|
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), CONFIG_FILE));
|
2012-09-20 20:35:00 +00:00
|
|
|
|
|
|
|
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);
|
2013-06-23 13:17:12 +00:00
|
|
|
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
|
2012-09-20 20:35:00 +00:00
|
|
|
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
|
2013-07-04 20:46:51 +00:00
|
|
|
blockedCommands = config.getStringList("blocked_commands");
|
2012-09-20 20:35:00 +00:00
|
|
|
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);
|
2012-11-03 19:03:38 +00:00
|
|
|
protectedAreasEnabled = config.getBoolean("protected_areas_enabled", protectedAreasEnabled);
|
|
|
|
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
|
|
|
|
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
|
2012-12-02 17:05:54 +00:00
|
|
|
host_sender_names = config.getStringList("host_sender_names");
|
2013-07-04 20:46:51 +00:00
|
|
|
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
2013-08-04 18:48:50 +00:00
|
|
|
twitterbotURL = config.getString("twitterbot_url", twitterbotURL);
|
2013-07-04 20:46:51 +00:00
|
|
|
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
|
2013-07-11 18:51:08 +00:00
|
|
|
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
|
2013-07-27 21:49:25 +00:00
|
|
|
logsRegisterPassword = config.getString("logs_register_password", logsRegisterPassword);
|
|
|
|
logsRegisterURL = config.getString("logs_register_url", logsRegisterURL);
|
2013-08-04 18:48:50 +00:00
|
|
|
serviceCheckerURL = config.getString("service_checker_url", serviceCheckerURL);
|
2012-09-20 20:35:00 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-09-20 20:35:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Error loading main config: " + ex.getMessage());
|
2012-09-20 20:35:00 +00:00
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
}
|
2012-09-18 21:25:37 +00:00
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
public static void loadSuperadminConfig()
|
2011-10-19 02:52:32 +00:00
|
|
|
{
|
2012-09-20 20:35:00 +00:00
|
|
|
try
|
2011-10-16 06:00:37 +00:00
|
|
|
{
|
2012-11-18 03:57:24 +00:00
|
|
|
TFM_SuperadminList.backupSavedList();
|
2012-11-13 01:42:30 +00:00
|
|
|
TFM_SuperadminList.loadSuperadminList();
|
2011-10-16 06:00:37 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-09-20 20:35:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
|
2012-09-20 20:35:00 +00:00
|
|
|
}
|
2012-09-18 14:40:48 +00:00
|
|
|
}
|
2013-07-11 01:46:29 +00:00
|
|
|
//
|
2012-09-18 14:40:48 +00:00
|
|
|
public static List<String> permbanned_players = new ArrayList<String>();
|
|
|
|
public static List<String> permbanned_ips = new ArrayList<String>();
|
2012-09-18 21:25:37 +00:00
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
public static void loadPermbanConfig()
|
2012-09-18 14:40:48 +00:00
|
|
|
{
|
2012-09-20 20:35:00 +00:00
|
|
|
try
|
2012-09-18 14:40:48 +00:00
|
|
|
{
|
2012-12-02 17:05:54 +00:00
|
|
|
TFM_Util.createDefaultConfiguration(PERMBAN_FILE, plugin_file);
|
|
|
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), PERMBAN_FILE));
|
2012-09-18 14:40:48 +00:00
|
|
|
|
2012-09-20 20:35:00 +00:00
|
|
|
permbanned_players = new ArrayList<String>();
|
|
|
|
permbanned_ips = new ArrayList<String>();
|
|
|
|
|
|
|
|
for (String user : config.getKeys(false))
|
2012-09-18 14:40:48 +00:00
|
|
|
{
|
2012-09-20 20:35:00 +00:00
|
|
|
permbanned_players.add(user.toLowerCase().trim());
|
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
List<String> user_ips = config.getStringList(user);
|
2012-09-20 20:35:00 +00:00
|
|
|
for (String ip : user_ips)
|
2012-09-18 14:40:48 +00:00
|
|
|
{
|
2012-09-20 20:35:00 +00:00
|
|
|
ip = ip.toLowerCase().trim();
|
|
|
|
if (!permbanned_ips.contains(ip))
|
|
|
|
{
|
|
|
|
permbanned_ips.add(ip);
|
|
|
|
}
|
2012-09-18 14:40:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-09-20 20:35:00 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe("Error loading permban list: " + ex.getMessage());
|
2012-09-20 20:35:00 +00:00
|
|
|
}
|
2011-10-12 18:13:10 +00:00
|
|
|
}
|
2011-10-30 19:27:06 +00:00
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
private static void registerEventHandlers()
|
2011-10-02 16:15:16 +00:00
|
|
|
{
|
2012-03-06 19:25:22 +00:00
|
|
|
PluginManager pm = server.getPluginManager();
|
|
|
|
|
2012-09-16 12:11:33 +00:00
|
|
|
pm.registerEvents(new TFM_EntityListener(), plugin);
|
|
|
|
pm.registerEvents(new TFM_BlockListener(), plugin);
|
|
|
|
pm.registerEvents(new TFM_PlayerListener(), plugin);
|
|
|
|
pm.registerEvents(new TFM_WeatherListener(), plugin);
|
2013-07-22 02:48:34 +00:00
|
|
|
pm.registerEvents(new TFM_ServerListener(), plugin);
|
2011-10-02 16:15:16 +00:00
|
|
|
}
|
2012-03-09 19:01:04 +00:00
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
private static void setAppProperties()
|
2012-03-09 19:01:04 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
InputStream in;
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
2012-12-02 17:05:54 +00:00
|
|
|
in = plugin.getClass().getResourceAsStream("/appinfo.properties");
|
2012-03-09 19:01:04 +00:00
|
|
|
props.load(in);
|
|
|
|
in.close();
|
|
|
|
|
2012-07-22 23:15:00 +00:00
|
|
|
TotalFreedomMod.pluginVersion = props.getProperty("program.VERSION");
|
|
|
|
TotalFreedomMod.buildNumber = props.getProperty("program.BUILDNUM");
|
|
|
|
TotalFreedomMod.buildDate = props.getProperty("program.BUILDDATE");
|
2012-03-09 19:01:04 +00:00
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (Exception ex)
|
2012-03-09 19:01:04 +00:00
|
|
|
{
|
2013-08-14 13:28:19 +00:00
|
|
|
TFM_Log.severe(ex);
|
2012-03-09 19:01:04 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-20 02:52:08 +00:00
|
|
|
}
|