Fix powertools with new config format.

This commit is contained in:
KHobbits 2012-02-22 00:10:13 +00:00
parent 46f05ee92f
commit 945ba6f8ab

View file

@ -94,8 +94,9 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getHomes() private Map<String, Object> _getHomes()
{ {
if (config.isConfigurationSection("homes")) { if (config.isConfigurationSection("homes"))
return config.getConfigurationSection("homes").getValues(false); {
return config.getConfigurationSection("homes").getValues(false);
} }
return new HashMap<String, Object>(); return new HashMap<String, Object>();
} }
@ -228,22 +229,15 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("unlimited", unlimited); config.setProperty("unlimited", unlimited);
config.save(); config.save();
} }
private Map<Integer, Object> powertools; private Map<String, Object> powertools;
@SuppressWarnings("unchecked") private Map<String, Object> _getPowertools()
private Map<Integer, Object> _getPowertools()
{ {
Object o = config.getProperty("powertools"); if (config.isConfigurationSection("powertools"))
if (o instanceof Map)
{ {
return (Map<Integer, Object>)o; return config.getConfigurationSection("powertools").getValues(false);
} }
else return new HashMap<String, Object>();
{
return new HashMap<Integer, Object>();
}
} }
public void clearAllPowertools() public void clearAllPowertools()
@ -255,23 +249,23 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getPowertool(ItemStack stack) public List<String> getPowertool(ItemStack stack)
{ {
return (List<String>)powertools.get(stack.getTypeId()); return (List<String>)powertools.get("" + stack.getTypeId());
} }
public List<String> getPowertool(int id) public List<String> getPowertool(int id)
{ {
return (List<String>)powertools.get(id); return (List<String>)powertools.get("" + id);
} }
public void setPowertool(ItemStack stack, List<String> commandList) public void setPowertool(ItemStack stack, List<String> commandList)
{ {
if (commandList == null || commandList.isEmpty()) if (commandList == null || commandList.isEmpty())
{ {
powertools.remove(stack.getTypeId()); powertools.remove("" + stack.getTypeId());
} }
else else
{ {
powertools.put(stack.getTypeId(), commandList); powertools.put("" + stack.getTypeId(), commandList);
} }
config.setProperty("powertools", powertools); config.setProperty("powertools", powertools);
config.save(); config.save();
@ -732,7 +726,6 @@ public abstract class UserData extends PlayerExtension implements IConf
return ret; return ret;
} }
private boolean newplayer; private boolean newplayer;
private String geolocation; private String geolocation;
private String _getGeoLocation() private String _getGeoLocation()