예제 #1
0
파일: VgTrade.java 프로젝트: Muson/vgTrade
  /**
   * @param player the player who sent the command
   * @param args the command arguments
   * @return whether the command was successful
   */
  private boolean doCommand(Player player, String[] args) {

    if (!player.hasPermission("vgtrade.trade")) {
      player.sendMessage(
          ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.UNABLE));
      return true;
    }

    if (args.length == 0) {
      // You must specify an option
      player.sendMessage(ChatColor.RED + languageManager.getString(LanguageManager.Strings.OPTION));

    } else if ("accept".equalsIgnoreCase(args[0]) || "decline".equalsIgnoreCase(args[0])) {

      manager.handleCommand(args[0], player);

    } else if ("ignore".equalsIgnoreCase(args[0])) {

      if (playersIgnoring.contains(player.getName())) {
        playersIgnoring.remove(player.getName());
        player.sendMessage(
            ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.NOTIGNORING));
      } else {
        playersIgnoring.add(player.getName());
        player.sendMessage(
            ChatColor.GREEN + LanguageManager.getString(LanguageManager.Strings.IGNORING));
      }

    } else {

      Player target;

      if ((target = getServer().getPlayer(args[0])) == null) {
        player.sendMessage(
            ChatColor.RED
                // The player you specified is not online
                + languageManager.getString(LanguageManager.Strings.ONLINE));
        return true;
      } else if (player.equals(target)) {
        player.sendMessage(
            ChatColor.RED
                // You can't trade with yourself!
                + languageManager.getString(LanguageManager.Strings.YOURSELF));
        return true;
      }

      if (!isBusy(player)) {
        requestTrade(player, target);
      } else {
        // Unable to trade with <target name>
        player.sendMessage(
            ChatColor.RED
                + LanguageManager.getString(LanguageManager.Strings.UNABLE)
                + " "
                + target.getName());
      }
    }
    return true;
  }
예제 #2
0
파일: VgTrade.java 프로젝트: Muson/vgTrade
 /**
  * Attempts to begin a trade for the two given players
  *
  * @param initiator The player who initiated the trade
  * @param target The target of the initiator
  */
 public void requestTrade(Player initiator, Player target) {
   if (playersIgnoring.contains(target.getName())) {
     initiator.sendMessage(
         ChatColor.RED
             + target.getName()
             + " "
             + LanguageManager.getString(LanguageManager.Strings.PLAYERIGNORING));
   } else if (config.canTrade(initiator, target)) {
     manager.begin(new TradePlayer(initiator), new TradePlayer(target));
   }
 }
예제 #3
0
파일: VgTrade.java 프로젝트: Muson/vgTrade
 @Override
 public void onDisable() {
   manager.terminateActiveTrades();
 }
예제 #4
0
파일: VgTrade.java 프로젝트: Muson/vgTrade
 /**
  * Checks if the player is currently involved in a trade or request
  *
  * @param player - the player to check
  * @return - if they are involved in a trade or request
  */
 public boolean isBusy(Player player) {
   return manager.isBusy((Player) player);
 }