Example #1
0
 // Handle the right-clicking of a wizard
 public static void handleRightClick(Player player, HumanNPC npc, String op) {
   Wizard wizard = npc.getType("wizard");
   String econMsg = "";
   if (EconomyManager.useEconPlugin()) {
     if (EconomyManager.hasEnough(player, UtilityProperties.getPrice(op))) {
       double paid = EconomyManager.pay(player, UtilityProperties.getPrice(op));
       if (paid > 0) {
         econMsg = ChatColor.GREEN + "Paid " + StringUtils.wrap(EconomyManager.format(paid)) + ":";
       }
     } else {
       player.sendMessage(MessageUtils.getNoMoneyMessage(player, op));
       return;
     }
   }
   String msg = StringUtils.wrap(npc.getStrippedName());
   if (op.equals("wizard.teleport")) {
     msg += " teleported you to " + StringUtils.wrap(wizard.getCurrentLocationName()) + ".";
     if (!teleportPlayer(player, npc)) {
       return;
     }
   } else if (op.equals("wizard.spawnmob")) {
     msg +=
         " spawned a "
             + StringUtils.wrap(wizard.getMob().name().toLowerCase().replace("_", " "))
             + ".";
     if (!spawnMob(player, npc)) {
       return;
     }
   } else if (op.equals("wizard.changetime")) {
     msg += " changed the time to " + StringUtils.wrap(wizard.getTime()) + ".";
     if (!changeTime(player, npc)) {
       return;
     }
   } else if (op.equals("wizard.togglestorm")) {
     msg +=
         " toggled a thunderstorm in the world "
             + StringUtils.wrap(player.getWorld().getName())
             + ".";
     if (!toggleStorm(player, npc)) {
       return;
     }
   } else if (op.equals("wizard.executecommand")) {
     msg += " executed the command " + StringUtils.wrap("/" + wizard.getCommand()) + ".";
     if (!executeCommand(player, npc)) {
       return;
     }
     if (!player.performCommand(wizard.getCommand())) {
       return;
     }
   }
   if (EconomyManager.useEconPlugin()) {
     player.sendMessage(econMsg);
   }
   player.sendMessage(msg);
 }
Example #2
0
 @Override
 public void onPluginDisable(PluginDisableEvent event) {
   if (this.methods != null && this.methods.hasMethod()) {
     Boolean check = this.methods.checkDisabled(event.getPlugin());
     if (check) {
       Messaging.log("Payment method disabled.");
     }
     EconomyManager.setServerEconomyEnabled(false);
   }
 }
 @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.");
   }
 }
Example #4
0
 @Override
 public void onPluginEnable(PluginEnableEvent event) {
   if (!this.methods.hasMethod()) {
     if (this.methods.setMethod(event.getPlugin())) {
       Citizens.setMethod(this.methods.getMethod());
       EconomyManager.setServerEconomyEnabled(true);
       Messaging.log(
           "Payment method found ("
               + methods.getMethod().getName()
               + " version: "
               + methods.getMethod().getVersion()
               + ")");
     }
   }
 }