mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +01:00
[trunk] metadata support in itemsdb.java, allows worth commands with metadata
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1364 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
bd5b8eacd0
commit
31f5802611
@ -89,14 +89,25 @@ public class ItemDb
|
||||
|
||||
public static ItemStack get(String id) throws Exception
|
||||
{
|
||||
int itemid = getUnsafe(id);
|
||||
int itemid;
|
||||
short metaData =0;
|
||||
if(id.matches("^\\d+:\\d+$"))
|
||||
{
|
||||
itemid = getUnsafe(id.split(":")[0]);
|
||||
metaData = (short)getUnsafe(id.split(":")[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemid = getUnsafe(id);
|
||||
}
|
||||
|
||||
Material mat = Material.getMaterial(itemid);
|
||||
if (mat == null) {
|
||||
throw new Exception("Unknown item id: "+itemid);
|
||||
}
|
||||
ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
|
||||
retval.setDurability(durabilities.containsKey(id.toLowerCase()) ? durabilities.get(id.toLowerCase()) : 0);
|
||||
retval.setDurability(metaData !=0 ? metaData :(durabilities.containsKey(id.toLowerCase()) ? durabilities.get(id.toLowerCase()) : 0));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ public class Commandworth extends EssentialsCommand
|
||||
user.charge(this);
|
||||
user.sendMessage("§7Stack of "
|
||||
+ is.getType().toString().toLowerCase().replace("_", "")
|
||||
+ (is.getDurability() !=0 ? " with metadata of "+ String.valueOf(is.getDurability()) : "")
|
||||
+ " worth §c" + Util.formatCurrency(worth*amount) + "§7 ("
|
||||
+ amount + " item(s) at " + Util.formatCurrency(worth) + " each)");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user