@Override public void onRightClick(Player player, HumanNPC npc) { if (Permission.canUse(player, npc, getType())) { WizardNPC wizard = npc.getToggleable("wizard"); if (player.getItemInHand().getTypeId() == Constants.wizardInteractItem) { WizardMode mode = wizard.getMode(); switch (mode) { case TELEPORT: if (wizard.getNumberOfLocations() > 0) { WizardManager.buy(player, npc, Operation.WIZARD_TELEPORT); } break; case SPAWN: WizardManager.buy(player, npc, Operation.WIZARD_SPAWNMOB); break; case TIME: WizardManager.buy(player, npc, Operation.WIZARD_CHANGETIME); break; case WEATHER: WizardManager.buy(player, npc, Operation.WIZARD_TOGGLESTORM); break; default: player.sendMessage(ChatColor.RED + "No valid mode selected."); break; } } else if (player.getItemInHand().getTypeId() == Constants.wizardManaRegenItem) { String msg = StringUtils.wrap(npc.getStrippedName() + "'s"); int mana = 0; if (wizard.getMana() + 10 < Constants.maxWizardMana) { mana = wizard.getMana() + 10; msg += " mana has been increased to " + StringUtils.wrap(mana) + "."; } else if (wizard.getMana() + 10 == Constants.maxWizardMana) { mana = Constants.maxWizardMana; msg += " mana has been fully replenished."; } else { msg += " mana cannot be regenerated with that item any further."; return; } InventoryUtils.decreaseItemInHand( player, Material.getMaterial(Constants.wizardManaRegenItem)); player.sendMessage(msg); wizard.setMana(mana); } } else { player.sendMessage(MessageUtils.noPermissionsMessage); } }
@Override public void onLeftClick(Player player, HumanNPC npc) { if (Permission.canUse(player, npc, getType())) { if (player.getItemInHand().getTypeId() == Constants.wizardInteractItem) { WizardNPC wizard = npc.getToggleable("wizard"); WizardMode mode = wizard.getMode(); String msg = ChatColor.GREEN + ""; switch (mode) { case TELEPORT: if (wizard.getNumberOfLocations() > 0) { wizard.cycle(npc, WizardMode.TELEPORT); msg += "Location set to " + StringUtils.wrap(wizard.getCurrentLocationName()); } else { msg += ChatColor.RED + npc.getStrippedName() + " has no locations."; } break; case SPAWN: wizard.cycle(npc, WizardMode.SPAWN); msg += "Mob to spawn set to " + StringUtils.wrap(wizard.getMob().name().toLowerCase().replace("_", " ")); break; case TIME: wizard.cycle(npc, WizardMode.TIME); msg += "Time setting set to " + StringUtils.wrap(wizard.getTime()); break; case WEATHER: return; default: msg = ChatColor.RED + "No valid mode selected."; break; } player.sendMessage(msg); } } else { player.sendMessage(MessageUtils.noPermissionsMessage); } }
private void sendLeaveMessage() { switch (mode) { case INFINITE: case NORMAL: player.sendMessage(ChatColor.GOLD + "-------------------------------"); break; case STOCK: player.sendMessage( ChatColor.GOLD + "Stocking of " + StringUtils.wrap(npc.getStrippedName(), ChatColor.GOLD) + " finished."); break; } }
private void sendJoinMessage() { switch (mode) { case INFINITE: case NORMAL: player.sendMessage(ChatColor.GREEN + "Transaction log"); player.sendMessage(ChatColor.GOLD + "-------------------------------"); break; case STOCK: player.sendMessage( ChatColor.GOLD + "Stocking of " + StringUtils.wrap(npc.getStrippedName(), ChatColor.GOLD) + " started."); break; } }
private Stockable getStockable(ItemStack item, String keyword, boolean selling) { // durability needs to be reset to 0 for tools / weapons / armor short durability = item.getDurability(); if (isTool(item.getTypeId())) { durability = 0; } TraderNPC trader = npc.getToggleable("trader"); if (!trader.isStocked(item.getTypeId(), durability, selling)) { player.sendMessage( StringUtils.wrap(MessageUtils.getItemName(item.getTypeId()), ChatColor.RED) + " isn't being " + keyword + " here."); return null; } return trader.getStockable(item.getTypeId(), durability, selling); }