示例#1
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = (Player) sender;
    if (!(args.length == 0)) {
      p.sendMessage(ChatColor.RED + "Invalid Command.");
      p.sendMessage(ChatColor.GRAY + "Usage: /toggletrade");
      p.sendMessage(ChatColor.GRAY + "Description: Enables / Disables recieving trade requests.");
      return true;
    }

    if (PlayerManager.getPlayerModel(p).getToggleList().contains("trade")) {
      List<String> ltoggle_list = PlayerManager.getPlayerModel(p).getToggleList();
      ltoggle_list.remove("trade");
      PlayerManager.getPlayerModel(p).setToggleList(ltoggle_list);
      p.sendMessage(ChatColor.GREEN + "Trade - " + ChatColor.BOLD + "ENABLED");
      return true;
    }

    if (!PlayerManager.getPlayerModel(p).getToggleList().contains("trade")) {
      List<String> ltoggle_list = PlayerManager.getPlayerModel(p).getToggleList();
      ltoggle_list.add("trade");
      PlayerManager.getPlayerModel(p).setToggleList(ltoggle_list);
      p.sendMessage(ChatColor.RED + "Trade - " + ChatColor.BOLD + "DISABLED");
      return true;
    }
    return true;
  }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    final Player p = (Player) sender;

    if (cmd.getName().equalsIgnoreCase("crypt")) {
      if (p != null) {
        if (!(p.isOp())) {
          return true;
        }
      }

      return true;
    }

    if (!(args.length == 0)) {
      p.sendMessage(ChatColor.RED + "Invalid Command.");
      p.sendMessage(ChatColor.GRAY + "Usage: /toggleglobal");
      p.sendMessage(
          ChatColor.GRAY
              + "Description: Enables / Disables sending and recieving global messages.");
      return true;
    }

    if (PlayerManager.getPlayerModel(p).getToggleList().contains("global")) {
      List<String> ltoggle_list = PlayerManager.getPlayerModel(p).getToggleList();
      ltoggle_list.remove("global");
      PlayerManager.getPlayerModel(p).setToggleList(ltoggle_list);
      p.sendMessage(ChatColor.GREEN + "Global Chat - " + ChatColor.BOLD + "ENABLED");
      return true;
    }

    if (!PlayerManager.getPlayerModel(p).getToggleList().contains("global")) {
      List<String> ltoggle_list = PlayerManager.getPlayerModel(p).getToggleList();
      ltoggle_list.add("global");
      PlayerManager.getPlayerModel(p).setToggleList(ltoggle_list);
      p.sendMessage(ChatColor.RED + "Global Chat - " + ChatColor.BOLD + "DISABLED");
      return true;
    }
    return true;
  }