[trunk] case insensitive items from items csv when using /item and /give

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1198 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
ementalo 2011-04-15 21:11:41 +00:00
parent 77ad27a6ff
commit d3b6534396

View File

@ -65,8 +65,8 @@ public class ItemDb
int numeric = Integer.parseInt(parts[1]); int numeric = Integer.parseInt(parts[1]);
durabilities.put(parts[0], parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0); durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0], numeric); items.put(parts[0].toLowerCase(), numeric);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -81,7 +81,7 @@ public class ItemDb
} }
public static ItemStack get(String id, int quantity) throws Exception { public static ItemStack get(String id, int quantity) throws Exception {
ItemStack retval = get(id); ItemStack retval = get(id.toLowerCase());
retval.setAmount(quantity); retval.setAmount(quantity);
return retval; return retval;
} }
@ -90,7 +90,7 @@ public class ItemDb
{ {
ItemStack retval = new ItemStack(getUnsafe(id)); ItemStack retval = new ItemStack(getUnsafe(id));
retval.setAmount(Essentials.getSettings().getDefaultStackSize()); retval.setAmount(Essentials.getSettings().getDefaultStackSize());
retval.setDurability(durabilities.containsKey(id) ? durabilities.get(id) : 0); retval.setDurability(durabilities.containsKey(id.toLowerCase()) ? durabilities.get(id.toLowerCase()) : 0);
if (items.containsValue(retval.getTypeId()) || true) return retval; if (items.containsValue(retval.getTypeId()) || true) return retval;
throw new Exception("Unknown item numeric: " + retval); throw new Exception("Unknown item numeric: " + retval);
} }
@ -103,7 +103,7 @@ public class ItemDb
} }
catch (NumberFormatException ex) catch (NumberFormatException ex)
{ {
if (items.containsKey(id)) return items.get(id); if (items.containsKey(id.toLowerCase())) return items.get(id.toLowerCase());
throw new Exception("Unknown item name: " + id); throw new Exception("Unknown item name: " + id);
} }
} }