A bit of tweaking

This commit is contained in:
Acrobot 2012-11-23 21:01:43 +01:00
parent 9c492ac031
commit 724cc4077c

View File

@ -1,5 +1,7 @@
package com.Acrobot.Breeze.Utils; package com.Acrobot.Breeze.Utils;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import info.somethingodd.bukkit.OddItem.OddItem; import info.somethingodd.bukkit.OddItem.OddItem;
import org.bukkit.CoalType; import org.bukkit.CoalType;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
@ -63,7 +65,7 @@ public class MaterialUtil {
return material; return material;
} }
name = name.replace(" ", "").toUpperCase(); name = name.replaceAll(" |_", "").toUpperCase();
short length = Short.MAX_VALUE; short length = Short.MAX_VALUE;
@ -125,7 +127,7 @@ public class MaterialUtil {
name.append('-').append(MaterialUtil.Enchantment.encodeEnchantment(itemStack)); name.append('-').append(MaterialUtil.Enchantment.encodeEnchantment(itemStack));
} }
return name.toString(); return StringUtil.capitalizeFirstLetter(name.toString(), '_');
} }
/** /**
@ -141,22 +143,19 @@ public class MaterialUtil {
return itemStack; return itemStack;
} }
String[] split = itemName.trim().split(":|-"); String[] split = Iterables.toArray(Splitter.onPattern(":|-").trimResults().split(itemName), String.class);
if (split.length == 0) {
return null;
}
Material material = getMaterial(split[0]); Material material = getMaterial(split[0]);
boolean onlyPartiallyChecked = false; boolean onlyPartiallyChecked = false;
if (material == null) { if (material == null) {
int index = split[0].indexOf(' '); if (!split[0].contains(" ")) {
if (index == -1) {
return null; return null;
} }
int index = split[0].indexOf(' ');
material = getMaterial(split[0].substring(index + 1)); material = getMaterial(split[0].substring(index + 1));
if (material == null) { if (material == null) {