@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 void onComplete() {
    PlayerInfo.getPlayerInfo(player).addUndoAction(backup);

    String confirmMessage = "";
    switch (this.effectMode) {
      case THAW:
        confirmMessage = "thaw";
        break;
      case FREEZE:
        confirmMessage = "freeze";
        break;
      case SNOW:
        confirmMessage = "snow";
        break;
      case TILL:
        confirmMessage = "till";
        break;
      case UNTILL:
        confirmMessage = "untill";
        break;
    }
    OutputHandler.chatConfirmation(
        player, Localization.format("message.wc." + confirmMessage + "Confirm", this.changed));
  }
Пример #3
0
  @Override
  public void processCommandPlayer(EntityPlayer sender, String[] args) {
    if (args.length == 0) throw new WrongUsageException("command.auth.usage");

    boolean hasAdmin =
        APIRegistry.perms.checkPermAllowed(
            new PermQueryPlayer(sender, getCommandPerm() + ".admin"));

    // one arg? must be help.
    if (args.length == 1) {
      if (args[0].equalsIgnoreCase("help")) {
        OutputHandler.chatConfirmation(sender, " - /auth register <password>");
        OutputHandler.chatConfirmation(sender, " - /auth login <password>");
        OutputHandler.chatConfirmation(
            sender, " - /auth changepass <oldpass> <newpass>  - changes your password");

        if (!hasAdmin) return;

        OutputHandler.chatConfirmation(
            sender, " - /auth kick <player>  - forces the player to login again");
        OutputHandler.chatConfirmation(
            sender, " - /auth setpass <player> <password>  - sets the players password");
        OutputHandler.chatConfirmation(
            sender, " - /auth unregister <player>  - forces the player to register again");
        return;
      } else throw new WrongUsageException("command.auth.usage");
    }

    // 2 args? seconds needs to be the player.
    if (args.length == 2) {
      // parse login
      if (args[0].equalsIgnoreCase("login")) {
        PlayerPassData data = PlayerPassData.getData(sender.username);
        if (data == null) {
          OutputHandler.chatError(
              sender, Localization.format("message.auth.error.notregisterred", sender.username));
          return;
        }

        String pass = ModuleAuth.encrypt(args[1]);

        // login worked
        if (data.password.equals(pass)) {
          ModuleAuth.unLogged.remove(sender.username);
          OutputHandler.chatConfirmation(sender, Localization.get("command.auth.login.success"));
        } else {
          OutputHandler.chatError(sender, Localization.get("command.auth.login.fail"));
        }

        return;

      }
      // parse register
      else if (args[0].equalsIgnoreCase("register")) {
        if (PlayerPassData.getData(sender.username) != null) {
          OutputHandler.chatError(
              sender, Localization.format("message.auth.error.yesregisterred", sender.username));
          return;
        }

        if (ModuleAuth.isEnabled() && !ModuleAuth.allowOfflineReg) {
          OutputHandler.chatError(sender, Localization.format("message.auth.error.disabledreg"));
          return;
        }

        String pass = ModuleAuth.encrypt(args[1]);
        PlayerPassData.registerData(sender.username, pass);
        ModuleAuth.unRegistered.remove(sender.username);
        OutputHandler.chatConfirmation(sender, Localization.get("command.auth.register.success"));
        return;
      }

      // stop if unlogged.
      if (ModuleAuth.unLogged.contains(sender.username)) {
        OutputHandler.chatError(sender, Localization.get("message.auth.needlogin"));
        return;
      } else if (ModuleAuth.unRegistered.contains(sender.username)) {
        OutputHandler.chatError(sender, Localization.get("message.auth.needregister"));
        return;
      }

      // check for players.. all the rest of these should be greated than 1.
      String name = args[1];
      boolean isLogged = true;

      // check if the player is logged.
      EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);
      if (player == null) {
        OutputHandler.chatWarning(
            sender, "A player of that name is not on the server. Doing the action anyways.");
        isLogged = false;
      }

      // parse ./auth kick
      if (args[0].equalsIgnoreCase("kick")) {
        if (!hasAdmin) throw new PermissionDeniedException();
        else if (!isLogged) throw new PlayerNotFoundException();
        else {
          ModuleAuth.unLogged.add(name);
          OutputHandler.chatConfirmation(
              sender, Localization.format("command.auth.kick.user", name));
          OutputHandler.chatWarning(player, Localization.get("command.auth.kick.target"));
          return;
        }
      }
      // parse ./auth setpass
      else if (args[0].equalsIgnoreCase("setPass")) {
        if (!hasAdmin) throw new PermissionDeniedException();

        throw new WrongUsageException("command.auth.usage.setpass");
      }

      // parse ./auth unregister
      else if (args[0].equalsIgnoreCase("unregister")) {
        if (!hasAdmin) throw new PermissionDeniedException();

        if (PlayerPassData.getData(name) == null)
          throw new WrongUsageException("message.auth.error.notregisterred", name);

        PlayerPassData.deleteData(name);
        OutputHandler.chatConfirmation(
            sender, Localization.format("command.auth.unregister", name));
        return;
      }

      // ERROR! :D
      else throw new WrongUsageException("command.auth.usage");
    }
    // 3 args? must be a comtmand - player - pass
    else if (args.length == 3) {
      if (ModuleAuth.unLogged.contains(sender.username)) {
        OutputHandler.chatError(sender, Localization.get("message.auth.needlogin"));
        return;
      } else if (ModuleAuth.unRegistered.contains(sender.username)) {
        OutputHandler.chatError(sender, Localization.get("message.auth.needregister"));
        return;
      }

      // parse changePass
      if (args[0].equalsIgnoreCase("changepass")) {
        PlayerPassData data = PlayerPassData.getData(sender.username);
        String oldpass = ModuleAuth.encrypt(args[1]);
        String newPass = ModuleAuth.encrypt(args[2]);

        if (args[1].equals(args[2])) {
          OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.same"));
          return;
        }

        if (!data.password.equals(oldpass)) {
          OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.wrongpass"));
          return;
        }

        data.password = newPass;
        data.save();

        OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.success"));
        return;
      }

      // check for players.. all the rest of these should be greated than 1.
      String name = args[1];
      // check if the player is logged.
      EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);
      if (player == null) {
        OutputHandler.chatWarning(
            sender, "A player of that name is not on the server. Doing the action anyways.");
      }

      // pasre setPass
      if (args[0].equalsIgnoreCase("setPass")) {
        if (!hasAdmin) throw new PermissionDeniedException();

        PlayerPassData data = PlayerPassData.getData(name);
        String encrypted = ModuleAuth.encrypt(args[2]);

        if (data == null) {
          PlayerPassData.registerData(name, encrypted);
        } else {
          data.password = encrypted;
          data.save();
        }
        OutputHandler.chatConfirmation(sender, Localization.format("command.auth.setPass", name));
      }
    }
  }
  private void execute(ICommandSender sender, String[] args) {
    /*
     * No world, Status update.
     */
    if (args.length == 0) {
      // Header
      String header = "--- Fillers active ---";
      sender.sendChatToPlayer(header);
      // Actual info
      for (Integer world : map.keySet()) {
        sender.sendChatToPlayer(world + ": " + map.get(world).getStatus());
      }
      // Footer
      StringBuilder footer = new StringBuilder();
      for (int i = 3; i < header.length(); i++) {
        footer.append("-");
      }
      sender.sendChatToPlayer(footer.toString());
      return;
    }

    /*
     * Get the world
     */
    WorldServer world = null;
    if (FunctionHelper.isNumeric(args[0])) {
      world = DimensionManager.getWorld(parseInt(sender, args[0]));
    } else if ((args[0].equalsIgnoreCase("here") || args[0].equalsIgnoreCase("world"))
        && sender instanceof EntityPlayer) {
      world = (WorldServer) ((EntityPlayer) sender).worldObj;
    }

    if (world == null) {
      OutputHandler.chatError(sender, args[0] + " is not an ID of a loaded world.");
      return;
    }

    if (args.length == 1) {
      if (map.containsKey(world.provider.dimensionId)) {
        OutputHandler.chatConfirmation(sender, map.get(world.provider.dimensionId).getStatus());
      } else {
        OutputHandler.chatError(sender, "There is no filler running for that world.");
      }
    } else {
      if (args[1].equalsIgnoreCase("start")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          map.put(world.provider.dimensionId, new TickTaskFill(world, sender, true));
        } else {
          OutputHandler.chatError(sender, "Filler already running for that world!");
        }
      } else if (args[1].equalsIgnoreCase("stop")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          OutputHandler.chatError(sender, "There is no filler running for that world.");
        } else {
          map.get(world.provider.dimensionId).stop();
        }
      } else if (args[1].equalsIgnoreCase("reset")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          map.put(world.provider.dimensionId, new TickTaskFill(world, sender, false));
        } else {
          OutputHandler.chatError(sender, "Filler already running for that world!");
        }
      } else if (args[1].equalsIgnoreCase("speed")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          OutputHandler.chatError(sender, "There is no filler running for that world.");
        } else {
          if (args.length != 3) {
            OutputHandler.chatConfirmation(
                sender, "Current speed: " + map.get(world.provider.dimensionId));
          } else {
            map.get(world.provider.dimensionId).speed(parseIntWithMin(sender, args[2], 0));
            if (map.get(world.provider.dimensionId).source != sender) {
              OutputHandler.chatError(sender, "Changed speed to " + args[2]);
            }
          }
        }
      }
    }
  }