java - ShapedRecipe with Lore? -
i'm writing craftbukkit plugin server. couldn't find how check if ingredient item has lore
shapedrecipe packedice = new shapedrecipe(new itemstack(material.packed_ice)); packedice.shape(new string[]{"aba","bcb","aba"}).setingredient('a', material.prismarine_shard).setingredient('b', material.gold_block).setingredient('c', material.snow_ball); bukkit.getserver().addrecipe(packedice);
instead of shapedrecipe packedice = new shapedrecipe(new itemstack(material.packed_ice));
need bit more code:
itemstack = new itemstack(material.packed_ice); itemmeta m = i.getitemmeta(); m.setdisplayname("customdisplayname") list<string> l = new arraylist<string>(); l.add("line 1"); l.add("line 2"); m.setlore(l); i.setitemmeta(m); shapedrecipe packedice = new shapedrecipe(i);
hope helps
//edit: sorry missunderstod first, check if item in upper right corner has lore "line1"
:
@eventhandler public void oncraft(craftitemevent e) { shapedrecipe packedice = yourrecipe; if(e.getinventory().getsize() == 10 && e.getinventory().getresult().equals(packedice.getresult())) { if(e.getrawslot() == 0) { itemstack upleft = e.getinventory().getitem(1); if(upleft != null && upleft.hasitemmeta() && upleft.getitemmeta().haslore()) { list<string> l = upleft.getitemmeta().getlore(); if(!l.get(0).equals("line 1")) { e.setcancelled(true); } } } } }
Comments
Post a Comment