1
0
mirror of https://e.coding.net/circlecloud/ProtectItem.git synced 2024-12-27 20:48:51 +00:00

fix getname null and fix a bug...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-10-24 18:09:56 +08:00
parent 6be962b13a
commit 2b515ca77d
2 changed files with 6 additions and 3 deletions

View File

@ -19,11 +19,11 @@ public class ProtectItem extends JavaPlugin {
public boolean actionCheck(final Player p, final ItemStack i, final ActionType action) { public boolean actionCheck(final Player p, final ItemStack i, final ActionType action) {
if (itemManager.canAction(i, action)) { if (itemManager.canAction(i, action)) {
return true; return false;
} else if (itemManager.hasActionPerm(p, i, action)) { } else if (itemManager.hasActionPerm(p, i, action)) {
return true; return false;
} }
return false; return true;
} }
public ItemManager getItemManager() { public ItemManager getItemManager() {

View File

@ -65,6 +65,9 @@ public class ItemManager {
} }
public String getItemName(final ItemStack i) { public String getItemName(final ItemStack i) {
if (i == null || i.getType() == Material.AIR) {
return "";
}
final int dur = i.getDurability(); final int dur = i.getDurability();
final String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : ""; final String dura = i.getMaxStackSize() != 1 ? dur != 0 ? "_" + dur : "" : "";
return (i.getType().name() + dura).toLowerCase(); return (i.getType().name() + dura).toLowerCase();