Esempio n. 1
0
  private boolean locationCommand(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!xAuthPermissions.has(player, "xauth.admin.location")) {
        xAuthMessages.send("admnPermission", player);
        return true;
      } else if (args.length < 2 || !(args[1].equals("set") || args[1].equals("remove"))) {
        xAuthMessages.send("admnLocUsage", player);
        return true;
      }

      String action = args[1];

      if (action.equals("set")) {
        dataManager.setTeleLocation(new TeleLocation(player.getLocation()));
        xAuthMessages.send("admnLocSetSuccess", player);
      } else {
        TeleLocation tLoc = dataManager.getTeleLocation(player.getWorld().getName());
        if (tLoc == null) {
          xAuthMessages.send("admnLocRmvNo", player);
          return true;
        }

        dataManager.removeTeleLocation(tLoc);
        xAuthMessages.send("admnLocRmvSuccess", player);
      }
    }

    return true;
  }
Esempio n. 2
0
  private boolean unregisterCommand(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!xAuthPermissions.has(player, "xauth.admin.unregister")) {
        xAuthMessages.send("admnPermission", player);
        return true;
      } else if (args.length < 2) {
        xAuthMessages.send("admnUnregUsage", player);
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.isRegistered()) {
        xAuthMessages.send("admnUnregRegistered", player, xPlayer.getPlayer());
        return true;
      }

      dataManager.deleteAccount(xPlayer);

      Player target = xPlayer.getPlayer();
      if (target != null) {
        if (xPlayer.mustRegister()) plugin.createGuest(xPlayer);
        xAuthMessages.send("admnUnregSuccessTgt", target);
      }

      xAuthMessages.send("admnUnregSuccessPlyr", player, target);
      xAuthLog.info(targetName + " has been unregistered by " + player.getName());
    } else if (sender instanceof ConsoleCommandSender) {
      if (args.length < 2) {
        xAuthLog.info("Correct Usage: xauth unregister <player>");
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.isRegistered()) {
        xAuthLog.info(targetName + " is not registered!");
        return true;
      }

      dataManager.deleteAccount(xPlayer);

      Player target = xPlayer.getPlayer();
      if (target != null) {
        if (xPlayer.mustRegister()) plugin.createGuest(xPlayer);
        target.sendMessage("You have been unregistered and logged out!");
      }

      xAuthLog.info(targetName + " has been unregistered!");
    }

    return true;
  }
Esempio n. 3
0
  private boolean registerCommand(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!xAuthPermissions.has(player, "xauth.admin.register")) {
        xAuthMessages.send("admnPermission", player);
        return true;
      } else if (args.length < 3) {
        xAuthMessages.send("admnRegUsage", player);
        return true;
      }

      String targetName = args[1];
      String password = args[2];
      String email = (args.length > 3 ? args[3] : null);
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (xPlayer.isRegistered()) {
        xAuthMessages.send("admnRegRegistered", player, xPlayer.getPlayer());
        return true;
      }

      Account account = new Account(targetName, Util.encrypt(password), email);
      xPlayer.setAccount(account);
      dataManager.saveAccount(account);

      xAuthMessages.send("admnRegSuccess", player, xPlayer.getPlayer());
      xAuthLog.info(player.getName() + " has registered an account for " + targetName);
    } else if (sender instanceof ConsoleCommandSender) {
      if (args.length < 3) {
        xAuthLog.info("Correct Usage: xauth register <player> <password> [email]");
        return true;
      }

      String targetName = args[1];
      String password = args[2];
      String email = (args.length > 3 ? args[3] : null);
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (xPlayer.isRegistered()) {
        xAuthLog.info(targetName + " is already registered!");
        return true;
      }

      Account account = new Account(targetName, Util.encrypt(password), email);
      xPlayer.setAccount(account);
      dataManager.saveAccount(account);

      xAuthLog.info("Account successfully created for: " + targetName);
    }

    return true;
  }
Esempio n. 4
0
  private boolean changePasswordCommand(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!xAuthPermissions.has(player, "xauth.admin.changepw")) {
        xAuthMessages.send("admnPermission", player);
        return true;
      } else if (args.length < 3) {
        xAuthMessages.send("admnCpwUsage", player);
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.isRegistered()) {
        xAuthMessages.send("admnCpwRegistered", player, xPlayer.getPlayer());
        return true;
      }

      Account targetAcc = xPlayer.getAccount();
      String newPassword = args[2];

      plugin.changePassword(targetAcc, newPassword);
      xAuthMessages.send("admnCpwSuccess", player, xPlayer.getPlayer());
      xAuthLog.info(player.getName() + " changed " + targetName + "'s password");
    } else if (sender instanceof ConsoleCommandSender) {
      if (args.length < 3) {
        xAuthLog.info("Correct Usage: xauth changepw <player> <new password>");
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.isRegistered()) {
        xAuthLog.info("This player is not registered!");
        return true;
      }

      Account targetAcc = xPlayer.getAccount();
      String newPassword = args[2];

      plugin.changePassword(targetAcc, newPassword);
      xAuthLog.info(targetName + "'s password has been changed");
    }

    return true;
  }
Esempio n. 5
0
  private boolean logoutCommand(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
      Player player = (Player) sender;

      if (!xAuthPermissions.has(player, "xauth.admin.logout")) {
        xAuthMessages.send("admnPermission", player);
        return true;
      } else if (args.length < 2) {
        xAuthMessages.send("admnLogoutUsage", player);
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.hasSession()) {
        xAuthMessages.send("admnLogoutLogged", player, xPlayer.getPlayer());
        return true;
      }

      plugin.createGuest(xPlayer);
      Player target = xPlayer.getPlayer();
      xAuthMessages.send("admnLogoutSuccess", player, target);
      if (target != null) xAuthMessages.send("logoutSuccess", target);
      xAuthLog.info(targetName + " was logged out by " + player.getName());
    } else if (sender instanceof ConsoleCommandSender) {
      if (args.length < 2) {
        xAuthLog.info("Correct Usage: xauth logout <player>");
        return true;
      }

      String targetName = args[1];
      xAuthPlayer xPlayer = dataManager.getPlayer(targetName);

      if (!xPlayer.hasSession()) {
        xAuthLog.info(targetName + " is not logged in!");
        return true;
      }

      plugin.createGuest(xPlayer);
      xAuthLog.info(targetName + " has been logged out");
      Player target = xPlayer.getPlayer();
      if (target != null) xAuthMessages.send("logoutSuccess", target);
    }

    return true;
  }