Exemplo n.º 1
0
 @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);
   }
 }
Exemplo n.º 2
0
 @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);
   }
 }