@Override public boolean doPowerSign( PowerSigns plugin, Block signBlock, String action, Matcher argsm, Boolean isOn) { Sign signState = (Sign) signBlock.getState(); BlockFace signDir = PowerSigns.getSignDirection(signBlock); Vector dir = PowerSigns.strToVector(argsm.group(1), signDir); Block invBlock = signBlock.getRelative(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ()); Inventory inventory; BlockState state = invBlock.getState(); if (state instanceof InventoryHolder) inventory = ((InventoryHolder) state).getInventory(); else return plugin.debugFail("bad inv:" + invBlock.getType().toString() + " " + dir.toString()); Material[] materials = PowerSigns.getMaterials(signState.getLine(1)); int count = 0; for (Material material : materials) count += PowerSigns.inventoryCount(inventory, material); signState.setLine(2, Integer.toString(count)); plugin.updateSignState(signState); return true; }
public static void register() { InvCountSignPlugin iosp = new InvCountSignPlugin(); PowerSigns.register("invcount", "(s|(fblrud)+)", iosp); }