Beispiel #1
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);
   }
 }
Beispiel #2
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")));
   }
 }
 @Command(
     aliases = "blacksmith",
     usage = "status",
     desc = "view the status of your in-hand item",
     modifiers = "status",
     min = 1,
     max = 1)
 @CommandPermissions("blacksmith.use.status")
 public static void cost(CommandContext args, Player player, HumanNPC npc) {
   ItemStack item = player.getItemInHand();
   String repairType = "";
   if (InventoryUtils.isArmor(item)) {
     repairType = "armorrepair";
   } else if (InventoryUtils.isTool(item)) {
     repairType = "toolrepair";
   }
   if (repairType.isEmpty()) {
     Messaging.sendError(
         player, MessageUtils.getMaterialName(item.getTypeId()) + " is not a repairable item.");
     return;
   }
   if (EconomyManager.useEconPlugin()) {
     double price = BlacksmithManager.getBlacksmithPrice(player, repairType);
     player.sendMessage(
         ChatColor.GREEN
             + "Item: "
             + StringUtils.wrap(MessageUtils.getMaterialName(item.getTypeId())));
     player.sendMessage(
         ChatColor.GREEN + "Cost: " + StringUtils.wrap(EconomyManager.format(price)));
     player.sendMessage(
         ChatColor.GREEN
             + "Durability Remaining: "
             + StringUtils.wrap(
                 Material.getMaterial(item.getTypeId()).getMaxDurability()
                     - item.getDurability()));
   } else {
     Messaging.sendError(player, "This server is not using an economy system.");
   }
 }