@Override
 public void processCommandPlayer(EntityPlayer sender, String[] args) {
   if (args.length == 0) {
     String msg = "";
     for (String warp : CommandDataManager.warps.keySet()) {
       msg = warp + ", " + msg;
     }
     sender.sendChatToPlayer(msg);
   } else if (args.length == 1) {
     if (CommandDataManager.warps.containsKey(args[0].toLowerCase())) {
       if (PermissionsAPI.checkPermAllowed(
           new PermQueryPlayer(sender, getCommandPerm() + "." + args[0].toLowerCase()))) {
         Warp warp = CommandDataManager.warps.get(args[0].toLowerCase());
         PlayerInfo playerInfo = PlayerInfo.getPlayerInfo(sender.username);
         playerInfo.back = new WarpPoint(sender);
         TeleportCenter.addToTpQue(warp.getPoint(), sender);
       } else {
         OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
     }
   } else if (args.length == 2) {
     if (PermissionsAPI.checkPermAllowed(
         new PermQueryPlayer(sender, getCommandPerm() + ".admin"))) {
       if (args[0].equalsIgnoreCase("set")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           OutputHandler.chatError(sender, Localization.get("command.warp.alreadyexists"));
         } else {
           CommandDataManager.addWarp(new Warp(args[1].toLowerCase(), new WarpPoint(sender)));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         }
       } else if (args[0].equalsIgnoreCase("del")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           CommandDataManager.removeWarp(CommandDataManager.warps.get(args[1]));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         } else {
           OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
         }
       } else {
         OutputHandler.chatError(
             sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
     }
   }
 }
 @Override
 public boolean canCommandSenderUseCommand(ICommandSender sender) {
   if (sender instanceof EntityPlayer)
     return PermissionsAPI.checkPermAllowed(
         new PermQueryPlayer((EntityPlayer) sender, "Minecraft.commands." + getCommandName()));
   else return true;
 }
예제 #3
0
  @Override
  public void processCommandPlayer(EntityPlayer sender, String[] args) {
    if (args.length >= 1) {
      if (!PermissionsAPI.checkPermAllowed(
          new PermQueryPlayer(sender, getCommandPerm() + ".others"))) {
        OutputHandler.chatError(sender, Localization.get(Localization.ERROR_NOPERMISSION));
        return;
      }
      EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
      if (player != null) {
        PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);

        PropQueryPlayerZone query =
            new PropQueryPlayerZone(
                player, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
        PermissionsAPI.getPermissionProp(query);

        String val = query.getStringValue();
        String[] split = val.split("[;_]");

        int dim = Integer.parseInt(split[0]);
        int x = Integer.parseInt(split[1]);
        int y = Integer.parseInt(split[2]);
        int z = Integer.parseInt(split[3]);

        WarpPoint point =
            new WarpPoint(dim, x + .5, y + 1, z + .5, player.cameraYaw, player.cameraPitch);

        // teleport
        FunctionHelper.setPlayer(player, point);
        player.sendChatToPlayer(Localization.get("command.spawn.done"));
        return;
      } else {
        OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
        return;
      }
    } else if (args.length == 0) {
      PropQueryPlayerZone query =
          new PropQueryPlayerZone(
              sender, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
      PermissionsAPI.getPermissionProp(query);

      String val = query.getStringValue();
      String[] split = val.split("[;_]");

      int dim = Integer.parseInt(split[0]);
      int x = Integer.parseInt(split[1]);
      int y = Integer.parseInt(split[2]);
      int z = Integer.parseInt(split[3]);

      WarpPoint spawn =
          new WarpPoint(dim, x + .5, y + 1, z + .5, sender.cameraYaw, sender.cameraPitch);
      PlayerInfo.getPlayerInfo(sender.username).back = new WarpPoint(sender);
      TeleportCenter.addToTpQue(spawn, sender);
      sender.sendChatToPlayer(Localization.get("command.spawn.done"));
    }
  }