Moved toggle commands (/firespread, /lavadmg, etc) to /toggle

This commit is contained in:
unknown 2014-04-23 16:23:50 +02:00
parent 8522570db5
commit 20b117a703
20 changed files with 270 additions and 513 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Apr 21 23:08:17 CEST 2014
build.number=787
#Wed Apr 23 16:22:40 CEST 2014
build.number=792

View File

@ -1,70 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandParameters(description = "Temporarily change config parameters.", usage = "/<command> <entry> <value>")
public class Command_config extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 2)
{
return false;
}
TFM_ConfigEntry entry = TFM_ConfigEntry.findConfigEntry(args[0]);
if (entry == null)
{
sender.sendMessage("Can't find configuration option: " + args[0]);
return true;
}
Object newValue = null;
final String newValueString = args[1].trim();
final Class<?> type = entry.getType();
try
{
if (type.isAssignableFrom(Integer.class))
{
newValue = new Integer(newValueString);
entry.setInteger((Integer) newValue);
}
else if (type.isAssignableFrom(Double.class))
{
newValue = new Double(newValueString);
entry.setDouble((Double) newValue);
}
else if (type.isAssignableFrom(Boolean.class))
{
newValue = Boolean.valueOf(newValueString);
entry.setBoolean((Boolean) newValue);
}
else if (type.isAssignableFrom(String.class))
{
newValue = newValueString;
entry.setString((String) newValue);
}
}
catch (Exception ex)
{
}
if (newValue != null)
{
sender.sendMessage(String.format("Set configuration entry \"%s\" to \"%s\" value \"%s\".",
entry.toString(), type.getName(), newValue.toString()));
}
else
{
sender.sendMessage("Could not parse value \"" + newValueString + "\" as type \"" + type.getName() + "\".");
}
return true;
}
}

View File

@ -1,25 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable auto entity wiper.", usage = "/<command> <on | off>")
public class Command_droptoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(sender.getName(),
(TFM_ConfigEntry.AUTO_ENTITY_WIPE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
+ " automatic entity wiping.", false);
return true;
}
}

View File

@ -1,42 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shortcut to enable/disable DisguiseCraft.", usage = "/<command>")
public class Command_dtoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft != null)
{
PluginManager pluginManager = plugin.getServer().getPluginManager();
boolean enabled = disguiseCraft.isEnabled();
if (enabled)
{
pluginManager.disablePlugin(disguiseCraft);
}
else
{
pluginManager.enablePlugin(disguiseCraft);
}
TFM_Util.adminAction(sender.getName(), (!enabled ? "Enabled" : "Disabled") + " DisguiseCraft.", true);
}
else
{
sender.sendMessage("DisguiseCraft is not installed on this server.");
}
return true;
}
}

View File

@ -1,47 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable explosives and set effect radius.", usage = "/<command> <on | off> [radius]")
public class Command_explosives extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
return false;
}
if (args.length == 2)
{
try
{
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
TFM_Util.playerMsg(sender, nfex.getMessage());
return true;
}
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
playerMsg("Explosives are now enabled, radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble() + " blocks.");
}
else
{
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(false);
playerMsg("Explosives are now disabled.");
}
return true;
}
}

View File

@ -1,33 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fire placement.", usage = "/<command> <on | off>")
public class Command_fireplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
playerMsg("Fire placement is now enabled.");
}
else
{
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(false);
playerMsg("Fire placement is now disabled.");
}
return true;
}
}

View File

@ -1,31 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fire spread.", usage = "/<command> <on | off>")
public class Command_firespread extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
boolean fireSpread = !args[0].equalsIgnoreCase("off");
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;
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable fluid spread.", usage = "/<command> <on | off>")
public class Command_fluidspread extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -50,12 +50,11 @@ public class Command_glist extends TFM_Command
else if (args.length == 2)
{
String username;
List<String> ips = new ArrayList<String>();
final List<String> ips = new ArrayList<String>();
try
{
Player player = getPlayer(args[1]);
final Player player = getPlayer(args[1]);
username = player.getName();
ips.add(player.getAddress().getAddress().getHostAddress());
}
@ -70,7 +69,7 @@ public class Command_glist extends TFM_Command
}
username = entry.getLastJoinName();
ips = entry.getIps();
ips.addAll(entry.getIps());
}
String mode = args[0].toLowerCase();

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable lava damage.", usage = "/<command> <on | off>")
public class Command_lavadmg extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava damage is now " + (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable lava placement.", usage = "/<command> <on | off>")
public class Command_lavaplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Lava placement is now " + (TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -1,57 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
public class Command_nonuke extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
if (args.length >= 2)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 3)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(true);
playerMsg("Nuke monitor is enabled.");
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
}
else
{
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
playerMsg("Nuke monitor is disabled.");
}
return true;
}
}

View File

@ -1,28 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable tamed pet protection.", usage = "/<command> <on | off>")
public class Command_petprotect extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
TFM_Util.adminAction(
sender.getName(),
"Tamed pet protection is now " + (TFM_ConfigEntry.PET_PROTECT_ENABLED.setBoolean(!TFM_Util.isStopCommand(args[0])) ? "enabled" : "disabled") + ".",
false);
return true;
}
}

View File

@ -1,35 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(
description = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
usage = "/<command> <on | off>")
public class Command_prelog extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(true);
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
}
else
{
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(false);
playerMsg("Command preprocess logging is now disabled.");
}
return true;
}
}

View File

@ -45,7 +45,7 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
TFM_AdminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperUUIDs(), ", "), ChatColor.YELLOW);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperNames(), ", "), ChatColor.YELLOW);
return true;
}

View File

@ -1,5 +1,11 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_BanManager;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PermbanList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -7,12 +13,42 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows information about TotalFreedomMod", usage = "/<command>")
@CommandParameters(description = "Shows information about TotalFreedomMod or reloads it", usage = "/<command> [reload]")
public class Command_tfm extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 1)
{
if (!args[0].equals("reload"))
{
return false;
}
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
}
TFM_AdminList.load();
TFM_PermbanList.load();
TFM_PlayerList.getInstance().load();
TFM_BanManager.getInstance().load();
TFM_CommandBlocker.getInstance().parseBlockingRules();
final String message = String.format("%s v%s.%s reloaded.",
TotalFreedomMod.pluginName,
TotalFreedomMod.pluginVersion,
TotalFreedomMod.buildNumber);
playerMsg(message);
TFM_Log.info(message);
return true;
}
playerMsg("TotalFreedomMod for 'Total Freedom', the original all-op server.", ChatColor.GOLD);
playerMsg(String.format("Version "
+ ChatColor.BLUE + "%s.%s" + ChatColor.GOLD + ", built "

View File

@ -0,0 +1,184 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler.TFM_GameRule;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Toggles TotalFreedomMod settings", usage = "/<command> [option] [value] [value]")
public class Command_toggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
playerMsg("Available toggles: ");
playerMsg("- waterplace");
playerMsg("- fireplace");
playerMsg("- lavaplace");
playerMsg("- fluidspread");
playerMsg("- lavadmg");
playerMsg("- firespread");
playerMsg("- prelog");
playerMsg("- petprotect");
playerMsg("- droptoggle");
playerMsg("- nonuke");
playerMsg("- explosives");
playerMsg("- disguisecraft");
return false;
}
if (args[0].equals("waterplace"))
{
toggle("Water placement is", TFM_ConfigEntry.ALLOW_WATER_PLACE);
return true;
}
if (args[0].equals("fireplace"))
{
toggle("Fire placement is", TFM_ConfigEntry.ALLOW_FIRE_PLACE);
return true;
}
if (args[0].equals("lavaplace"))
{
toggle("Lava placement is", TFM_ConfigEntry.ALLOW_LAVA_PLACE);
return true;
}
if (args[0].equals("fluidspread"))
{
toggle("Fire placement is", TFM_ConfigEntry.ALLOW_FLUID_SPREAD);
return true;
}
if (args[0].equals("lavadmg"))
{
toggle("Lava damage is", TFM_ConfigEntry.ALLOW_LAVA_DAMAGE);
return true;
}
if (args[0].equals("firespread"))
{
TFM_GameRuleHandler.setGameRule(TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean());
toggle("Fire spread is", TFM_ConfigEntry.ALLOW_FIRE_SPREAD);
return true;
}
if (args[0].equals("prelog"))
{
toggle("Command prelogging is", TFM_ConfigEntry.PREPROCESS_LOG_ENABLED);
return true;
}
if (args[0].equals("petprotect"))
{
toggle("Tamed pet protection is", TFM_ConfigEntry.PET_PROTECT_ENABLED);
return true;
}
if (args[0].equals("droptoggle"))
{
toggle("Automatic entity wiping is", TFM_ConfigEntry.AUTO_ENTITY_WIPE);
return true;
}
if (args[0].equals("nonuke"))
{
if (args.length >= 2)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 3)
{
try
{
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
}
catch (NumberFormatException nfex)
{
}
}
toggle("Nuke monitor is", TFM_ConfigEntry.NUKE_MONITOR);
if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
{
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
}
return true;
}
if (args[0].equals("explosives"))
{
if (args.length == 2)
{
try
{
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
}
catch (NumberFormatException ex)
{
TFM_Util.playerMsg(sender, ex.getMessage());
return true;
}
}
toggle("Explosions are", TFM_ConfigEntry.ALLOW_EXPLOSIONS);
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
playerMsg("Radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble());
}
return true;
}
if (args[0].equals("disguisecraft"))
{
final Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft == null)
{
playerMsg("DisguiseCraft is not installed on this server.");
return true;
}
boolean enabled = disguiseCraft.isEnabled();
TFM_Util.adminAction(sender.getName(), (enabled ? "disa" : "ena") + "bling DisguiseCraft", true);
if (enabled)
{
plugin.getServer().getPluginManager().disablePlugin(disguiseCraft);
}
else
{
plugin.getServer().getPluginManager().enablePlugin(disguiseCraft);
}
return true;
}
return false;
}
private void toggle(String name, TFM_ConfigEntry entry)
{
entry.setBoolean(!entry.getBoolean());
playerMsg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
}
}

View File

@ -1,24 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Enable/disable water placement.", usage = "/<command> <on | off>")
public class Command_waterplace extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
playerMsg("Water placement is now " + (TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true;
}
}

View File

@ -1,13 +1,11 @@
package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@ -23,7 +21,6 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.FileUtil;
@ -130,42 +127,7 @@ public class TFM_AdminList
// Parse old superadmins
if (config.isConfigurationSection("superadmins"))
{
TFM_Log.info("Old superadmin configuration found, parsing...");
final ConfigurationSection section = config.getConfigurationSection("superadmins");
int counter = 0;
int errors = 0;
for (String admin : config.getConfigurationSection("superadmins").getKeys(false))
{
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin);
if (player == null || player.getUniqueId() == null)
{
errors++;
TFM_Log.warning("Could not convert admin " + admin + ", UUID could not be found!");
continue;
}
final String uuid = player.getUniqueId().toString();
config.set("admins." + uuid + ".last_login_name", player.getName());
config.set("admins." + uuid + ".is_activated", section.getBoolean(admin + ".is_activated"));
config.set("admins." + uuid + ".is_telnet_admin", section.getBoolean(admin + ".is_telnet_admin"));
config.set("admins." + uuid + ".is_senior_admin", section.getBoolean(admin + ".is_senior_admin"));
config.set("admins." + uuid + ".last_login", section.getString(admin + ".last_login"));
config.set("admins." + uuid + ".custom_login_message", section.getString(admin + ".custom_login_message"));
config.set("admins." + uuid + ".console_aliases", section.getStringList(admin + ".console_aliases"));
config.set("admins." + uuid + ".ips", section.getStringList(admin + ".ips"));
counter++;
}
config.set("superadmins", null);
config.save();
TFM_Log.info(counter + " admins parsed, " + errors + " errors");
parseOldConfig(config);
}
if (!config.isConfigurationSection("admins"))
@ -249,6 +211,46 @@ public class TFM_AdminList
TFM_AdminWorld.getInstance().wipeAccessCache();
}
private static void parseOldConfig(TFM_Config config)
{
TFM_Log.info("Old superadmin configuration found, parsing...");
final ConfigurationSection section = config.getConfigurationSection("superadmins");
int counter = 0;
int errors = 0;
for (String admin : config.getConfigurationSection("superadmins").getKeys(false))
{
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin);
if (player == null || player.getUniqueId() == null)
{
errors++;
TFM_Log.warning("Could not convert admin " + admin + ", UUID could not be found!");
continue;
}
final String uuid = player.getUniqueId().toString();
config.set("admins." + uuid + ".last_login_name", player.getName());
config.set("admins." + uuid + ".is_activated", section.getBoolean(admin + ".is_activated"));
config.set("admins." + uuid + ".is_telnet_admin", section.getBoolean(admin + ".is_telnet_admin"));
config.set("admins." + uuid + ".is_senior_admin", section.getBoolean(admin + ".is_senior_admin"));
config.set("admins." + uuid + ".last_login", section.getString(admin + ".last_login"));
config.set("admins." + uuid + ".custom_login_message", section.getString(admin + ".custom_login_message"));
config.set("admins." + uuid + ".console_aliases", section.getStringList(admin + ".console_aliases"));
config.set("admins." + uuid + ".ips", section.getStringList(admin + ".ips"));
counter++;
}
config.set("superadmins", null);
config.save();
TFM_Log.info("Done! " + counter + " admins parsed, " + errors + " errors");
}
public static void save()
{
final TFM_Config config = new TFM_Config(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILE, true);

View File

@ -79,8 +79,8 @@ public class TotalFreedomMod extends JavaPlugin
@Override
public void onEnable()
{
TFM_Log.info("Starting " + pluginName + " v" + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber);
TFM_Log.info("Made by Madgeek1450 and DarthSalamon, Compiled " + buildDate + " by " + buildCreator);
TFM_Log.info("Made by Madgeek1450 and DarthSalamon");
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
final File[] coreDumps = new File(".").listFiles(new FileFilter()
{