Finish /config command.

Fix typo: ALLOW_FLIUD_SPREAD -> ALLOW_FLUID_SPREAD
This commit is contained in:
Steven Lawson 2013-09-07 22:51:12 -04:00
parent 549c5231e8
commit 18e4943216
7 changed files with 21 additions and 23 deletions

View File

@ -1,5 +1,5 @@
#Tue, 03 Sep 2013 20:25:31 -0400 #Sat, 07 Sep 2013 22:46:21 -0400
program.VERSION=3.2 program.VERSION=3.2
program.BUILDNUM=567 program.BUILDNUM=575
program.BUILDDATE=09/03/2013 08\:25 PM program.BUILDDATE=09/07/2013 10\:46 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Tue Sep 03 20:25:31 EDT 2013 #Sat Sep 07 22:46:21 EDT 2013
build.number=568 build.number=576

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Config;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry; 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;
@ -26,41 +25,40 @@ public class Command_config extends TFM_Command
return true; return true;
} }
boolean valueSet = false; Object newValue = null;
final String newValueString = args[1].trim(); final String newValueString = args[1].trim();
final Class<?> type = entry.getType(); final Class<?> type = entry.getType();
try try
{ {
if (type.isAssignableFrom(Integer.class)) if (type.isAssignableFrom(Integer.class))
{ {
entry.setInteger(new Integer(newValueString)); newValue = new Integer(newValueString);
valueSet = true; entry.setInteger((Integer) newValue);
} }
else if (type.isAssignableFrom(Double.class)) else if (type.isAssignableFrom(Double.class))
{ {
entry.setDouble(new Double(newValueString)); newValue = new Double(newValueString);
valueSet = true; entry.setDouble((Double) newValue);
} }
else if (type.isAssignableFrom(Boolean.class)) else if (type.isAssignableFrom(Boolean.class))
{ {
entry.setBoolean(Boolean.valueOf(newValueString)); newValue = Boolean.valueOf(newValueString);
valueSet = true; entry.setBoolean((Boolean) newValue);
} }
else if (type.isAssignableFrom(String.class)) else if (type.isAssignableFrom(String.class))
{ {
TFM_Config.getInstance().set(entry, newValueString, String.class); newValue = newValueString;
valueSet = true; entry.setString((String) newValue);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
} }
if (!valueSet) if (newValue != null)
{ {
sender.sendMessage(String.format("Set configuration entry \"%s\" to \"%s\" value \"%s\".", sender.sendMessage(String.format("Set configuration entry \"%s\" to \"%s\" value \"%s\".",
entry.toString(), type.getName(), newValueString)); entry.toString(), type.getName(), newValue.toString()));
} }
else else
{ {

View File

@ -17,7 +17,7 @@ public class Command_fluidspread extends TFM_Command
return false; return false;
} }
playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + "."); playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
return true; return true;
} }

View File

@ -267,7 +267,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 (!TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.getBoolean()) if (!TFM_ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{ {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -8,7 +8,7 @@ public enum TFM_ConfigEntry
ALLOW_EXPLOSIONS(Boolean.class, "allow_explosions"), ALLOW_EXPLOSIONS(Boolean.class, "allow_explosions"),
ALLOW_FIRE_PLACE(Boolean.class, "allow_fire_place"), ALLOW_FIRE_PLACE(Boolean.class, "allow_fire_place"),
ALLOW_FIRE_SPREAD(Boolean.class, "allow_fire_spread"), ALLOW_FIRE_SPREAD(Boolean.class, "allow_fire_spread"),
ALLOW_FLIUD_SPREAD(Boolean.class, "allow_fluid_spread"), ALLOW_FLUID_SPREAD(Boolean.class, "allow_fluid_spread"),
ALLOW_LAVA_DAMAGE(Boolean.class, "allow_lava_damage"), ALLOW_LAVA_DAMAGE(Boolean.class, "allow_lava_damage"),
ALLOW_LAVA_PLACE(Boolean.class, "allow_lava_place"), ALLOW_LAVA_PLACE(Boolean.class, "allow_lava_place"),
ALLOW_TNT_MINECARTS(Boolean.class, "allow_tnt_minecarts"), ALLOW_TNT_MINECARTS(Boolean.class, "allow_tnt_minecarts"),

View File

@ -246,7 +246,7 @@ public class TFM_FrontDoor
{ {
message = false; message = false;
} }
else if (TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.getBoolean()) else if (TFM_ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{ {
message = false; message = false;
} }
@ -257,7 +257,7 @@ public class TFM_FrontDoor
TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true); TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true); TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(true); TFM_ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true); TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
if (message) if (message)