예제 #1
0
 @Override
 public void onRightClick(Player player) {
   if (!PermissionManager.canCreate(player)) {
     Messaging.sendError(
         player, "You cannot tame this Evil NPC because you have reached the NPC creation limit.");
     return;
   }
   if (player.getItemInHand().getTypeId() != Settings.getInt("EvilTameItem")) return;
   if (random.nextInt(100) <= Settings.getInt("EvilTameChance")) {
     InventoryUtils.decreaseItemInHand(player);
     isTame = true;
     CreatureTask.despawn(this, NPCRemoveReason.OTHER);
     NPCManager.register(
         npc.getName(), player.getLocation(), player.getName(), NPCCreateReason.RESPAWN);
     player.sendMessage(
         ChatColor.GREEN
             + "You have tamed "
             + StringUtils.wrap(npc.getName())
             + "! You can now toggle it to be any type.");
   } else {
     Messaging.send(
         player,
         this.npc,
         StringUtils.colourise(Settings.getString("ChatFormat").replace("%name%", npc.getName()))
             + ChatColor.WHITE
             + MessageUtils.getRandomMessage(Settings.getString("EvilFailedTameMessages")));
   }
 }
예제 #2
0
 @Override
 public void onRightClick(Player player, HumanNPC npc) {
   if (PermissionManager.hasPermission(player, "citizens.wizard.use.interact")) {
     if (UtilityProperties.isHoldingTool("WizardInteractItem", player)) {
       WizardManager.handleRightClick(player, npc, "wizard." + mode.toString());
     } else if (UtilityProperties.isHoldingTool("WizardManaRegenItem", player)) {
       String msg = StringUtils.wrap(npc.getName() + "'s");
       int mana = 0;
       if (mana + 10 < Settings.getInt("WizardMaxMana")) {
         mana = mana + 10;
         msg += " mana has been increased to " + StringUtils.wrap(mana) + ".";
       } else if (mana + 10 == Settings.getInt("WizardMaxMana")) {
         mana = Settings.getInt("WizardMaxMana");
         msg += " mana has been fully replenished.";
       } else {
         msg += " mana cannot be regenerated with that item any further.";
         return;
       }
       InventoryUtils.decreaseItemInHand(player);
       player.sendMessage(msg);
       this.mana = mana;
     }
   } else {
     player.sendMessage(MessageUtils.noPermissionsMessage);
   }
 }
예제 #3
0
 @Override
 public void onSpawn() {
   npc.getInventory()
       .setItemInHand(new ItemStack(weapons[this.random.nextInt(weapons.length)], 1));
   this.health = Settings.getInt("EvilHealth");
   super.onSpawn();
 }