mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 21:22:09 +00: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
2 changed files with 14 additions and 2 deletions
|
@ -89,14 +89,25 @@ public class ItemDb
|
||||||
|
|
||||||
public static ItemStack get(String id) throws Exception
|
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);
|
Material mat = Material.getMaterial(itemid);
|
||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
throw new Exception("Unknown item id: "+itemid);
|
throw new Exception("Unknown item id: "+itemid);
|
||||||
}
|
}
|
||||||
ItemStack retval = new ItemStack(mat);
|
ItemStack retval = new ItemStack(mat);
|
||||||
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class Commandworth extends EssentialsCommand
|
||||||
user.charge(this);
|
user.charge(this);
|
||||||
user.sendMessage("§7Stack of "
|
user.sendMessage("§7Stack of "
|
||||||
+ is.getType().toString().toLowerCase().replace("_", "")
|
+ is.getType().toString().toLowerCase().replace("_", "")
|
||||||
|
+ (is.getDurability() !=0 ? " with metadata of "+ String.valueOf(is.getDurability()) : "")
|
||||||
+ " worth §c" + Util.formatCurrency(worth*amount) + "§7 ("
|
+ " worth §c" + Util.formatCurrency(worth*amount) + "§7 ("
|
||||||
+ amount + " item(s) at " + Util.formatCurrency(worth) + " each)");
|
+ amount + " item(s) at " + Util.formatCurrency(worth) + " each)");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue