예제 #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);
   }
 }
예제 #2
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);
 }
예제 #3
0
  @CommandRequirements()
  @Command(
      aliases = "npc",
      usage = "create [name] (text)",
      desc = "create an NPC",
      modifiers = "create",
      min = 2)
  @CommandPermissions("basic.create")
  public static void create(CommandContext args, Player player, HumanNPC npc) {
    if (!PermissionManager.canCreate(player)) {
      player.sendMessage(MessageUtils.reachedNPCLimitMessage);
      return;
    }
    ArrayDeque<String> texts = new ArrayDeque<String>();
    String firstArg = args.getString(1);
    if (args.argsLength() >= 3) {
      texts.add(args.getJoinedStrings(2));
    }
    if (firstArg.length() > 16) {
      player.sendMessage(
          ChatColor.RED + "The name of this NPC will be truncated - max name length is 16.");
      firstArg = args.getString(1).substring(0, 16);
    }
    if (Economy.useEconPlugin()) {
      if (Economy.hasEnough(player, UtilityProperties.getPrice("basic.creation"))) {
        double paid = Economy.pay(player, UtilityProperties.getPrice("basic.creation"));
        if (paid > 0) {
          player.sendMessage(
              MessageUtils.getPaidMessage(
                  player, "basic", "basic.creation", firstArg.replace("/", " "), false));
        }
      } else {
        player.sendMessage(MessageUtils.getNoMoneyMessage(player, "basic.creation"));
        return;
      }
    }
    int UID =
        NPCManager.register(
            firstArg, player.getLocation(), player.getName(), NPCCreateReason.COMMAND);
    NPCDataManager.setText(UID, texts);

    HumanNPC created = NPCManager.get(UID);
    created.getNPCData().setOwner(player.getName());
    Messaging.send(player, created, Settings.getString("CreationMessage"));

    NPCDataManager.selectNPC(player, NPCManager.get(UID));
    Messaging.send(player, created, Settings.getString("SelectionMessage"));
  }
예제 #4
0
 @Override
 public void onLeftClick(Player player, HumanNPC npc) {
   if (PermissionManager.hasPermission(player, "citizens.wizard.use.interact")) {
     if (UtilityProperties.isHoldingTool("WizardInteractItem", player)) {
       String msg = ChatColor.GREEN.toString();
       switch (mode) {
         case TELEPORT:
           if (locations.size() > 0) {
             cycle();
             msg += "Location set to " + StringUtils.wrap(getCurrentLocationName());
           } else {
             msg += ChatColor.RED + npc.getName() + " has no locations.";
           }
           break;
         case SPAWN:
           cycle();
           msg += "Mob to spawn set to " + StringUtils.wrap(StringUtils.format(mob));
           break;
         case TIME:
           cycle();
           msg += "Time setting set to " + StringUtils.wrap(time);
           break;
         case WEATHER:
           return;
         default:
           msg = ChatColor.RED + "No valid mode selected.";
       }
       player.sendMessage(msg);
     }
   } else {
     player.sendMessage(MessageUtils.noPermissionsMessage);
   }
 }
예제 #5
0
 @CommandRequirements()
 @Command(
     aliases = "citizens",
     usage = "debug",
     desc = "toggle debug mode for Citizens",
     modifiers = "debug",
     min = 1,
     max = 1)
 @ServerCommand()
 @CommandPermissions("admin.debug")
 public static void debug(CommandContext args, CommandSender sender, HumanNPC npc) {
   boolean debug = Settings.getBoolean("DebugMode");
   UtilityProperties.getConfig().setRaw("general.debug-mode", !debug);
   debug = !debug;
   if (debug) {
     Messaging.log("Debug mode is now on.");
     if (sender instanceof Player) {
       Messaging.send(sender, npc, "Debug mode is now " + ChatColor.GREEN + "on");
     }
   } else {
     Messaging.log("Debug mode is now off.");
     if (sender instanceof Player) {
       Messaging.send(sender, npc, "Debug mode is now " + ChatColor.RED + "off");
     }
   }
 }
예제 #6
0
 @Override
 public void onDeath() {
   ItemStack item = UtilityProperties.getRandomDrop(Settings.getString("EvilDrops"));
   if (item == null) return;
   this.getEntity().getWorld().dropItemNaturally(this.getLocation(), item);
 }