mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Changing over to new config API.
This commit is contained in:
parent
112382893d
commit
b8d5e2f974
@ -26,7 +26,7 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar
|
|||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\github\\Bukkit\\target\\bukkit-0.0.1-SNAPSHOT.jar
|
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\github\\bukkit-0.0.1-SNAPSHOT.jar
|
||||||
file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
|
file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
|
@ -337,11 +337,11 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
sender.sendMessage("Nuke monitor is disabled.");
|
sender.sendMessage("Nuke monitor is disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalFreedomMod.CONFIG.load();
|
plugin.reloadConfig();
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor", plugin.nukeMonitor);
|
plugin.getConfig().set("nuke_monitor", plugin.nukeMonitor);
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_range", plugin.nukeMonitorRange);
|
plugin.getConfig().set("nuke_monitor_range", plugin.nukeMonitorRange);
|
||||||
TotalFreedomMod.CONFIG.setProperty("nuke_monitor_count", plugin.nukeMonitorCountBreak);
|
plugin.getConfig().set("nuke_monitor_count", plugin.nukeMonitorCountBreak);
|
||||||
TotalFreedomMod.CONFIG.save();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -370,9 +370,9 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
|||||||
sender.sendMessage("Command preprocess logging is now disabled.");
|
sender.sendMessage("Command preprocess logging is now disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalFreedomMod.CONFIG.load();
|
plugin.reloadConfig();
|
||||||
TotalFreedomMod.CONFIG.setProperty("preprocess_log", plugin.preprocessLogEnabled);
|
plugin.getConfig().set("preprocess_log", plugin.preprocessLogEnabled);
|
||||||
TotalFreedomMod.CONFIG.save();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -19,7 +24,6 @@ import org.bukkit.entity.*;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
|
|
||||||
public class TotalFreedomMod extends JavaPlugin
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
@ -31,7 +35,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
protected static Configuration CONFIG;
|
|
||||||
public List<String> superadmins = new ArrayList<String>();
|
public List<String> superadmins = new ArrayList<String>();
|
||||||
public List<String> superadmin_ips = new ArrayList<String>();
|
public List<String> superadmin_ips = new ArrayList<String>();
|
||||||
public Boolean allowExplosions = false;
|
public Boolean allowExplosions = false;
|
||||||
@ -48,9 +51,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public Boolean preprocessLogEnabled = false;
|
public Boolean preprocessLogEnabled = false;
|
||||||
public int freecamTriggerCount = 10;
|
public int freecamTriggerCount = 10;
|
||||||
|
|
||||||
public boolean allPlayersFrozen = false;
|
|
||||||
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
|
||||||
|
|
||||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||||
|
|
||||||
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
||||||
@ -58,6 +58,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||||
|
|
||||||
|
public boolean allPlayersFrozen = false;
|
||||||
|
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||||
|
|
||||||
private TFM_Cmds_OP OPCommands = new TFM_Cmds_OP(this);
|
private TFM_Cmds_OP OPCommands = new TFM_Cmds_OP(this);
|
||||||
private TFM_Cmds_Override OverrideCommands = new TFM_Cmds_Override(this);
|
private TFM_Cmds_Override OverrideCommands = new TFM_Cmds_Override(this);
|
||||||
private TFM_Cmds_General GeneralCommands = new TFM_Cmds_General(this);
|
private TFM_Cmds_General GeneralCommands = new TFM_Cmds_General(this);
|
||||||
@ -67,7 +70,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
CONFIG = getConfiguration();
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
registerEventHandlers();
|
registerEventHandlers();
|
||||||
@ -217,49 +219,105 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
private void loadConfig()
|
private void loadConfig()
|
||||||
{
|
{
|
||||||
File configfile = new File("plugins/TotalFreedomMod/config.yml");
|
createDefaultConfiguration("config.yml");
|
||||||
if (!configfile.exists())
|
|
||||||
|
reloadConfig();
|
||||||
|
|
||||||
|
allowExplosions = getConfig().getBoolean("allow_explosions", false);
|
||||||
|
allowFirePlace = getConfig().getBoolean("allow_fire_place", false);
|
||||||
|
allowFireSpread = getConfig().getBoolean("allow_fire_spread", false);
|
||||||
|
allowLavaDamage = getConfig().getBoolean("allow_lava_damage", false);
|
||||||
|
allowLavaPlace = getConfig().getBoolean("allow_lava_place", false);
|
||||||
|
allowWaterPlace = getConfig().getBoolean("allow_water_place", false);
|
||||||
|
autoEntityWipe = getConfig().getBoolean("auto_wipe", true);
|
||||||
|
explosiveRadius = getConfig().getDouble("explosiveRadius", 4.0D);
|
||||||
|
nukeMonitor = getConfig().getBoolean("nuke_monitor", true);
|
||||||
|
nukeMonitorCountBreak = getConfig().getInt("nuke_monitor_count", 100);
|
||||||
|
nukeMonitorRange = getConfig().getDouble("nuke_monitor_range", 10.0D);
|
||||||
|
preprocessLogEnabled = getConfig().getBoolean("preprocess_log", true);
|
||||||
|
freecamTriggerCount = getConfig().getInt("freecam_trigger_count", 10);
|
||||||
|
|
||||||
|
superadmins = (List<String>) getConfig().getList("superadmins", null);
|
||||||
|
if (superadmins == null)
|
||||||
{
|
{
|
||||||
log.log(Level.INFO, "[Total Freedom Mod] - Generating default config file (plugins/TotalFreedomMod/config.yml)...");
|
superadmins = new ArrayList<String>();
|
||||||
CONFIG.setProperty("superadmins", new String[]
|
superadmins.add("Madgeek1450");
|
||||||
{
|
superadmins.add("markbyron");
|
||||||
"Madgeek1450", "markbyron"
|
}
|
||||||
});
|
|
||||||
CONFIG.setProperty("superadmin_ips", new String[]
|
superadmin_ips = (List<String>) getConfig().getList("superadmin_ips", null);
|
||||||
{
|
if (superadmin_ips == null)
|
||||||
"0.0.0.0"
|
{
|
||||||
});
|
superadmin_ips = new ArrayList<String>();
|
||||||
CONFIG.setProperty("allow_explosions", false);
|
}
|
||||||
CONFIG.setProperty("allow_fire_place", false);
|
}
|
||||||
CONFIG.setProperty("allow_fire_spread", false);
|
|
||||||
CONFIG.setProperty("allow_lava_damage", false);
|
private void createDefaultConfiguration(String name)
|
||||||
CONFIG.setProperty("allow_lava_place", false);
|
{
|
||||||
CONFIG.setProperty("allow_water_place", false);
|
File actual = new File(getDataFolder(), name);
|
||||||
CONFIG.setProperty("auto_wipe", false);
|
if (!actual.exists())
|
||||||
CONFIG.setProperty("explosiveRadius", 4.0D);
|
{
|
||||||
CONFIG.setProperty("nuke_monitor", true);
|
InputStream input = null;
|
||||||
CONFIG.setProperty("nuke_monitor_count", 40);
|
try
|
||||||
CONFIG.setProperty("nuke_monitor_range", 10.0D);
|
{
|
||||||
CONFIG.setProperty("preprocess_log", false);
|
JarFile file = new JarFile(getFile());
|
||||||
CONFIG.setProperty("freecam_trigger_count", 10);
|
ZipEntry copy = file.getEntry("src/" + name);
|
||||||
CONFIG.save();
|
if (copy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
input = file.getInputStream(copy);
|
||||||
|
}
|
||||||
|
catch (IOException ioex)
|
||||||
|
{
|
||||||
|
log.severe("[TotalFreedomMod]: Unable to read default configuration: " + name);
|
||||||
|
}
|
||||||
|
if (input != null)
|
||||||
|
{
|
||||||
|
FileOutputStream output = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
output = new FileOutputStream(actual);
|
||||||
|
byte[] buf = new byte[8192];
|
||||||
|
int length = 0;
|
||||||
|
while ((length = input.read(buf)) > 0)
|
||||||
|
{
|
||||||
|
output.write(buf, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("[TotalFreedomMod]: Default configuration file written: " + name);
|
||||||
|
}
|
||||||
|
catch (IOException ioex)
|
||||||
|
{
|
||||||
|
log.severe("[TotalFreedomMod]: Unable to write default configuration: " + name);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (input != null)
|
||||||
|
{
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException ioex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (output != null)
|
||||||
|
{
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException ioex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CONFIG.load();
|
|
||||||
superadmins = CONFIG.getStringList("superadmins", null);
|
|
||||||
superadmin_ips = CONFIG.getStringList("superadmin_ips", null);
|
|
||||||
allowExplosions = CONFIG.getBoolean("allow_explosions", false);
|
|
||||||
allowFirePlace = CONFIG.getBoolean("allow_fire_place", false);
|
|
||||||
allowFireSpread = CONFIG.getBoolean("allow_fire_spread", false);
|
|
||||||
allowLavaDamage = CONFIG.getBoolean("allow_lava_damage", false);
|
|
||||||
allowLavaPlace = CONFIG.getBoolean("allow_lava_place", false);
|
|
||||||
allowWaterPlace = CONFIG.getBoolean("allow_water_place", false);
|
|
||||||
autoEntityWipe = CONFIG.getBoolean("auto_wipe", false);
|
|
||||||
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0D);
|
|
||||||
nukeMonitor = CONFIG.getBoolean("nuke_monitor", true);
|
|
||||||
nukeMonitorCountBreak = CONFIG.getInt("nuke_monitor_count", 40);
|
|
||||||
nukeMonitorRange = CONFIG.getDouble("nuke_monitor_range", 10.0D);
|
|
||||||
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", false);
|
|
||||||
freecamTriggerCount = CONFIG.getInt("freecam_trigger_count", 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEventHandlers()
|
private void registerEventHandlers()
|
||||||
|
Loading…
Reference in New Issue
Block a user