Exemple #1
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (!(sender instanceof Player)) {
     sender.sendMessage("�rro> �omente jogadores podem executar este comando!");
     return true;
   }
   Player player = (Player) sender;
   if (cmd.getName().equalsIgnoreCase("tp")) {
     if (!player.hasPermission("hg.mod")) {
       player.sendMessage("Voc� n鉶 tem permissao para fazer isso!");
       return true;
     }
     if (args.length == 0) {
       player.sendMessage("Use /tp [player] para ir at� um player!");
       player.sendMessage("Use /s [player] para puxar um player at� voc�!");
       return true;
     }
     if (args.length == 1) {
       Player target = Bukkit.getPlayerExact(args[0]);
       if ((target == null) || (!(target instanceof Player))) {
         player.sendMessage("�Jogador n鉶 encontrado!");
         return true;
       }
       player.teleport(target);
       player.sendMessage("�Teleportado para " + target.getName());
       return true;
     }
     if (args.length > 1) {
       player.sendMessage("�Use /tp [player] para ir at� um player!");
       player.sendMessage("� Use /s [player] para puxar um player at� voc�!");
       return true;
     }
   } else if (cmd.getName().equalsIgnoreCase("s")) {
     if (!player.hasPermission("hg.mod")) {
       player.sendMessage("�Voc� n鉶 tem permissao para fazer isso!");
       return true;
     }
     if (args.length == 0) {
       player.sendMessage("�Use /tp [player] para ir at� um player!");
       player.sendMessage("�Use /s [player] para puxar um player at� voc�!");
       return true;
     }
     if (args.length == 1) {
       Player target = Bukkit.getPlayerExact(args[0]);
       if ((target == null) || (!(target instanceof Player))) {
         player.sendMessage("�Jogador n鉶 encontrado!");
         return true;
       }
       target.teleport(player);
       player.sendMessage("�Voc� puxou -> " + target.getName());
       return true;
     }
     if (args.length > 1) {
       player.sendMessage("Use /tp [player] para ir at� um player!");
       player.sendMessage("Use /s [player] para puxar um player at� voc�!");
       return true;
     }
   }
   return false;
 }
Exemple #2
0
 // returns the Player if online
 public static Player getPlayerfromString(String name) {
   if (useUUID) {
     try {
       return Bukkit.getPlayer(UUID.fromString(name));
     } catch (Exception e) {
       return Bukkit.getPlayerExact(name);
     }
   }
   return Bukkit.getPlayerExact(name);
 }
 @Override
 @Localized({
   "CRAZYCHATS.CHANNEL.CHANGED $Channel$",
   "CRAZYCHATS.COMMAND.CHANNEL.PRIVATE.TARGET.REMOVED $Players$"
 })
 public void command(final Player player, final String[] args) throws CrazyException {
   final ChatPlayerData data = plugin.getPlayerData(player);
   final PrivateChannel channel = data.getPrivateChannel();
   final Set<Player> targets = channel.getTargets(null);
   if (args.length == 0) throw new CrazyCommandUsageException("<Player...>");
   else {
     final List<Player> targetList = new ArrayList<Player>();
     for (final String arg : args) {
       final Player target = Bukkit.getPlayerExact(arg);
       if (target == null || !player.canSee(target))
         throw new CrazyCommandNoSuchException("Player", arg);
       targetList.add(target);
     }
     targets.removeAll(targetList);
     if (data.getCurrentChannel() != channel) {
       data.setCurrentChannel(channel);
       plugin.sendLocaleMessage("CHANNEL.CHANGED", player, channel.getName());
     }
     plugin.sendLocaleMessage(
         "COMMAND.CHANNEL.PRIVATE.TARGET.REMOVED",
         player,
         ChatHelper.listingString(OfflinePlayerParamitrisable.getPlayerNames(targetList)));
   }
 }
  public void createDuel(Player p1, Player p2, String mode) {
    Duel duel = new Duel(this.plugin, p1.getName(), p2.getName(), mode);

    this.invites.removeAll(p1.getName());
    this.invites.removeAll(p2.getName());

    p1.getInventory().clear();
    p2.getInventory().clear();

    p1.updateInventory();
    p2.updateInventory();

    p1.setHealth(20.0D);
    p2.setHealth(20.0D);

    this.duels.add(duel);
    duel.setTaskID(Bukkit.getScheduler().scheduleSyncRepeatingTask(this.plugin, duel, 0L, 10L));
    for (String s : ovo) {
      Player p = Bukkit.getPlayerExact(s);
      if ((!p.getName().equals(p1.getName())) && (!p.getName().equals(p2.getName()))) {
        p1.hidePlayer(p);
        p2.hidePlayer(p);
      }
    }
  }
  @Override
  public void doCommand(RemoteController plugin, ClientConnection connection, int pid, String arg) {
    try {
      if (connection.isAuthorized()) {
        String[] args = arg.split(":", 3);
        String playername = args[0];
        int num = Integer.parseInt(args[1]);
        String[] itemdata = args[2].split(":");

        Player player = Bukkit.getPlayerExact(playername);
        if (player != null) {
          Material material = Material.matchMaterial(itemdata[0]);
          if (material != null) {
            short data = 0;
            if (itemdata.length != 1) {
              data = Short.parseShort(itemdata[1]);
            }
            player.getInventory().addItem(new ItemStack(material, num, data));
            connection.send("SUCCESS", pid, "");
          } else {
            connection.send("ERROR", pid, "NO_ITEM");
          }
        } else {
          connection.send("ERROR", pid, "NO_PLAYER");
        }
      } else {
        connection.send("ERROR", pid, "NOT_AUTH");
      }
    } catch (Exception e) {
      plugin.getLogger().severe("An error has occurred in CommandGive!");
      connection.send("ERROR", pid, "EXCEPTION:" + e.toString());
      e.printStackTrace();
    }
  }
  @Override
  public String getListName(String senderId) {
    if (senderId == null) return null;

    // Try Our Map
    String ret = this.idToListName.get(senderId);

    // Try Bukkit
    if (ret == null) {
      Player player = Bukkit.getPlayerExact(senderId);
      if (player != null) {
        ret = player.getPlayerListName();
      }
    }

    // Try Fixed Id
    if (ret == null) {
      ret = Mixin.tryFix(senderId);
    }

    // Ensure Colored
    if (ChatColor.stripColor(ret).equals(ret)) {
      ret = DEFAULT_COLOR.toString() + ret;
    }

    return ret;
  }
 private boolean confirmCmd(CommandSender sender, String args[]) {
   if (args.length > 1) return false;
   if (!(sender instanceof Player)) {
     sender.sendMessage("Command cannot be used at console");
     return true;
   }
   Player player = (Player) sender;
   Player broadcaster;
   if (args.length == 1) {
     broadcaster = Bukkit.getPlayerExact(args[0]);
     if (broadcaster == null) {
       sender.sendMessage("No such player " + args[0]);
       return true;
     }
   } else {
     broadcaster = broadcastman.getQuickConfirmPlayer(player);
     if (broadcaster == null) {
       sender.sendMessage("Nobody has requested to broadcast to you");
       return true;
     }
   }
   if (broadcastman.confirmBroadcast(broadcaster, player)) {
     player.sendMessage("You will now receive broadcasts from " + broadcaster.getDisplayName());
   } else {
     player.sendMessage(broadcaster.getDisplayName() + " does not wish to broadcast to you");
   }
   return true;
 }
 private boolean broadcastCmd(CommandSender sender, String args[]) {
   if (args.length != 1) return false;
   if (!(sender instanceof Player)) {
     sender.sendMessage("Command cannot be used at console");
     return true;
   }
   Player player = (Player) sender;
   Player receiver = Bukkit.getPlayerExact(args[0]);
   if (receiver == null) {
     sender.sendMessage("No such player " + args[0]);
     return true;
   } else if (receiver == player) {
     sender.sendMessage("You cannot broadcast to yourself!");
     return true;
   } else if (!pearls.isImprisoned(player)) {
     sender.sendMessage("You are not imprisoned!");
     return true;
   }
   if (broadcastman.addBroadcast(player, receiver)) {
     sender.sendMessage("You will broadcast pplocate information to " + receiver.getDisplayName());
     receiver.sendMessage(
         "Type /ppconfirm to receive pplocate broadcasts from " + player.getDisplayName());
   } else {
     sender.sendMessage("You are already broadcasting to " + receiver.getDisplayName());
   }
   return true;
 }
  private boolean party(CommandSender sender, String[] args) {
    if (!(sender instanceof Player)) {
      return true;
    }
    Player player = (Player) sender;

    Party party = plugin.parties.get(player.getName().toLowerCase());
    if (party == null) {
      player.sendMessage("You are not in a party.");
    } else {
      String list = "";
      Set<String> members = party.getMembers();
      for (String s : members) {
        Player p = Bukkit.getPlayerExact(s);
        if (p != null) {
          if (list.isEmpty()) {
            list += p.getDisplayName();
          } else {
            list += ", " + p.getDisplayName();
          }
        }
      }
      player.sendMessage("Party members: " + list);
    }

    return true;
  }
Exemple #10
0
  public static void sendToLocation(
      final ParticleEffect effect,
      final Location location,
      final float offsetX,
      final float offsetY,
      final float offsetZ,
      final float speed,
      final int count)
      throws Exception {
    // Hive.log.info(effect.name + " @ " + location.toString());
    Object packet = null;
    try {
      packet = createPacket(effect, location, offsetX, offsetY, offsetZ, speed, count);
    } catch (Exception e) {
      e.printStackTrace();
    }
    double radius = 32D;

    for (String s : MonsterMechanics.player_locations.keySet()) {
      if (Bukkit.getPlayerExact(s) != null) {
        Player pl = Main.plugin.getServer().getPlayer(s);
        if (pl.getWorld().getName().equalsIgnoreCase(location.getWorld().getName())
            && pl.getLocation().toVector().distanceSquared(location.toVector())
                <= Math.pow(radius, 2)) {
          try {
            sendPacket(pl, packet);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }
Exemple #11
0
  public void clearSpecs() {

    for (int a = 0; a < spectators.size(); a = 0) {
      removeSpectator(Bukkit.getPlayerExact(spectators.get(0)));
    }
    spectators.clear();
    nextspec.clear();
  }
 public void sendMessage(String message) {
   for (String name : members) {
     Player player = Bukkit.getPlayerExact(name);
     if (player != null && player.isValid()) {
       player.sendMessage(CoopPlugin.chatColor + message);
     }
   }
 }
Exemple #13
0
 public static Player findPlayerExact(String name) {
   if (name == null) return null;
   Player lastPlayer = Bukkit.getPlayerExact(name);
   if (lastPlayer != null) return lastPlayer;
   if (Defaults.DEBUG_VIRTUAL) {
     return VirtualPlayers.getPlayer(name);
   }
   return null;
 }
 public boolean banWithReason(String name, String reason) {
   try {
     Bukkit.getOfflinePlayer(name).setBanned(true);
     Bukkit.getPlayerExact(name).kickPlayer(reason);
     return true;
   } catch (Exception e) {
     return false;
   }
 }
 public List<Player> getMembers() {
   List<Player> players = new ArrayList<Player>();
   for (String name : members) {
     Player p = Bukkit.getPlayerExact(name);
     if (p != null) {
       players.add(p);
     }
   }
   return players;
 }
Exemple #16
0
 @Override
 public void run() {
   Iterator<Entry<String, Integer>> it = players.entrySet().iterator();
   while (it.hasNext()) {
     Map.Entry<String, Integer> pairs = (Map.Entry<String, Integer>) it.next();
     String playerName = pairs.getKey();
     if (Bukkit.getPlayerExact(playerName) == null) {
       players.remove(playerName);
     }
     it.remove();
   }
 }
  @Override
  public void setListName(String senderId, String listName) {
    if (listName == null) {
      this.idToListName.remove(senderId);
    } else {
      this.idToListName.put(senderId, listName);
    }

    Player player = Bukkit.getPlayerExact(senderId);
    if (player == null) return;
    player.setPlayerListName(this.getListName(senderId));
  }
Exemple #18
0
 @SuppressWarnings("deprecation")
 public boolean isKnownPlayer(String playerName) {
   if (Bukkit.getPlayerExact(playerName) != null) {
     return true;
   }
   for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
     if (offlinePlayer.getName().equalsIgnoreCase(playerName)) {
       return true;
     }
   }
   return false;
 }
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   if (sender.hasPermission("bukkit.command.teleportall")) {
     Player p = Bukkit.getPlayerExact(sender.getName());
     if (args.length > 0) {
       p = Bukkit.getPlayer(args[0]);
     }
     if (p == null) {
       sender.sendMessage(ChatColor.BLUE + "Player not found");
       return true;
     }
     for (Player player : Bukkit.getOnlinePlayers()) player.teleport(p);
   } else sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
   return true;
 }
 public boolean acceptDuel(Player p1, String s) {
   if (this.invites.containsInvited(p1.getName())) {
     Player c = Bukkit.getPlayerExact(this.invites.getInviter(p1.getName()));
     c.sendMessage(
         ChatColor.GOLD
             + p1.getName()
             + " � accept� votre invitation pour un training "
             + ChatColor.AQUA
             + s
             + ChatColor.GOLD
             + "!");
     createDuel(c, p1, s);
     return true;
   }
   return false;
 }
Exemple #21
0
  @Override
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;
    if ((args.length < 2) || (args.length > 4)) {
      sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
      return false;
    }

    Player player = Bukkit.getPlayerExact(args[0]);

    if (player != null) {
      Material material = Material.matchMaterial(args[1]);

      if (material != null) {
        Command.broadcastCommandMessage(
            sender,
            "Giving " + player.getName() + " some " + material.getId() + " (" + material + ")");

        int amount = 1;
        short data = 0;

        if (args.length >= 3) {
          try {
            amount = Integer.parseInt(args[2]);
          } catch (NumberFormatException ex) {
          }

          if (amount < 1) amount = 1;
          if (amount > 64) amount = 64;
          if (args.length >= 4) {
            try {
              data = Short.parseShort(args[3]);
            } catch (NumberFormatException ex) {
            }
          }
        }

        player.getInventory().addItem(new ItemStack(material, amount, data));
      } else {
        sender.sendMessage("There's no item called " + args[1]);
      }
    } else {
      sender.sendMessage("Can't find user " + args[0]);
    }

    return true;
  }
Exemple #22
0
  @Override
  public boolean execute(CommandSender sender, String[] args) {
    if (args.length <= 2) {
      LocalWeather.printPlayerList(
          sender, args.length == 2 && args[1].matches("\\d+") ? Integer.parseInt(args[1]) : 1);
    } else {

      String playerName = args[1];
      if (!isKnownPlayer(playerName)) {
        return M.WTH_UNKNOWNPLAYER.print(playerName);
      }

      @SuppressWarnings("deprecation")
      Player player = Bukkit.getPlayerExact(playerName);

      switch (args[2].toLowerCase()) {
        case "rain":
        case "storm":
          LocalWeather.setPlayerRain(player, true);
          M.WTH_PLAYERWEATHER.print(sender, playerName, M.RAIN);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_SET.print(player, M.RAIN);
          }
          break;
        case "sun":
        case "clear":
          LocalWeather.setPlayerRain(player, false);
          M.WTH_PLAYERWEATHER.print(sender, playerName, M.CLEAR);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_SET.print(player, M.CLEAR);
          }
          break;
        case "remove":
        case "delete":
          LocalWeather.clearPlayerRain(player);
          M.WTH_PLAYERWEATHERREMOVED.print(sender, playerName);
          if (player != null && !player.equals(sender)) {
            M.MY_WEATHER_REMOVED.print(player);
          }
          break;
        default:
          M.WTH_UNKNOWNWEATHER.print(sender, args[2]);
          break;
      }
    }
    return true;
  }
 private boolean imprisonCmd(CommandSender sender, String args[]) {
   if (args.length != 1) return false;
   if (!(sender instanceof Player)) {
     sender.sendMessage("imprison cannot be used at the console");
     return true;
   }
   if (pearlman.imprisonPlayer(args[0], (Player) sender)) {
     sender.sendMessage("You imprisoned " + args[0]);
     Player player = Bukkit.getPlayerExact(args[0]);
     if (player != null) {
       player.setHealth(0);
     }
   } else {
     sender.sendMessage("You failed to imprison " + args[0]);
   }
   return true;
 }
 private boolean silenceCmd(CommandSender sender, String args[]) {
   if (args.length != 1) return false;
   if (!(sender instanceof Player)) {
     sender.sendMessage("Command cannot be used at console");
     return true;
   }
   Player player = (Player) sender;
   Player broadcaster = Bukkit.getPlayerExact(args[0]);
   if (broadcaster == null) {
     sender.sendMessage("No such player " + args[0]);
     return true;
   }
   if (broadcastman.silenceBroadcast(player, broadcaster)) {
     player.sendMessage(
         "You will no longer receive broadcasts from " + broadcaster.getDisplayName());
   } else {
     player.sendMessage(broadcaster.getDisplayName() + " is not broadcasting to you");
   }
   return true;
 }
Exemple #25
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (!(sender instanceof Player)) {
     sender.sendMessage("Apenas jogadores podem executar esse comando!");
     return true;
   }
   Player player = (Player) sender;
   if (cmd.getName().equalsIgnoreCase("fake")) {
     if (!player.hasPermission("hg.mod")) {
       return true;
     }
     if (args.length == 0) {
       player.sendMessage("§cUse /fake [jogador]");
       return true;
     }
     if (args.length == 1) {
       Player target = Bukkit.getPlayerExact(args[0]);
     }
   }
   return false;
 }
  public void endDuel(Player p1) {
    Player p2 = this.duels.getOpponent(p1.getName());
    this.plugin.clearPlayer(p2);
    p2.getInventory().setItem(0, GameListener.soup);
    p2.getInventory().setHeldItemSlot(0);
    p2.getInventory().setItem(1, GameListener.vanilla1);
    p2.getInventory().setItem(2, GameListener.vanilla2);

    /** BLASTFIGHT ADD */
    p2.getInventory().setItem(4, GameListener.cheat);
    p2.getInventory().setItem(6, GameListener.soup2);
    p2.getInventory().setItem(7, GameListener.vanilla3);
    p2.getInventory().setItem(8, GameListener.vanilla4);
    p2.getInventory().setItem(3, GameListener.ranked);
    p2.getInventory().setItem(5, GameListener.rankedcheat);

    /** BLASTFIGHT ADD */
    p2.setHealth(20.0D);

    p2.sendMessage(
        ChatColor.GOLD
            + ">>> Vous avez gagn� le combat face � "
            + ChatColor.AQUA
            + p1.getName()
            + "!");
    p1.sendMessage(
        ChatColor.RED
            + ">>> Vous avez perdu le combat face � "
            + ChatColor.AQUA
            + p2.getName()
            + "!");

    this.duels.remove(p1.getName());
    for (String s : ovo) {
      if ((!s.equals(p1.getName())) && (!s.equals(p2.getName()))) {
        Player cP = Bukkit.getPlayerExact(s);
        p1.showPlayer(cP);
        p2.showPlayer(cP);
      }
    }
  }
Exemple #27
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   if (sender.hasPermission("bukkit.command.enchant")) {
     Player p = Bukkit.getPlayerExact(sender.getName());
     if (args.length == 0) {
       List<String> names = new ArrayList<String>();
       for (Enchantment enchant : Enchantment.values()) names.add(enchant.getName().toUpperCase());
       sender.sendMessage(
           ChatColor.GREEN
               + "Enchants: |"
               + ChatColor.RED
               + StringUtils.join(names, ChatColor.GREEN + "|  |" + ChatColor.RED)
               + ChatColor.GREEN
               + "|");
     } else {
       Enchantment enchant = Enchantment.getByName(args[0].toUpperCase());
       if (enchant == null) {
         for (Enchantment enchantment : Enchantment.values())
           if (enchantment.getName().equalsIgnoreCase(args[0])) enchant = enchantment;
         if (enchant == null) {
           sender.sendMessage(ChatColor.GREEN + "Enchant: " + args[0] + " - Not found");
           return true;
         }
       }
       int level = enchant.getMaxLevel();
       if (args.length > 1) {
         if (lib.isNumeric(args[1])) level = Integer.parseInt(args[1]);
       }
       if (p.getItemInHand() != null && p.getItemInHand().getType() != Material.AIR) {
         p.getItemInHand().addUnsafeEnchantment(enchant, level);
         p.sendMessage(
             ChatColor.GREEN
                 + "Item enchanted with "
                 + enchant.getName()
                 + " with level "
                 + level);
         updateEnchants(p.getItemInHand());
       } else p.sendMessage(ChatColor.GREEN + "Unable to enchant item");
     }
   } else sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
   return true;
 }
Exemple #28
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("give") && sender instanceof Player) {
      Player player = Bukkit.getPlayerExact(args[0]);
      Player p = (Player) sender;
      String user = Configuration.getString("settings.mysql.user");
      String pass = Configuration.getString("settings.mysql.pass");
      String url = "jdbc:mysql://localhost:3306/Fiery";
      String v = Configuration.getString("money.iscalled");
      boolean t = Configuration.getBoolean("money.isenabled");
      int cost = Configuration.getInt("commandcharge.give");
      int balance;

      try {
        Connection conn = DriverManager.getConnection(url, user, pass);
        Statement select = conn.createStatement();
        ResultSet rs =
            select.executeQuery("SELECT balance FROM money WHERE p_name ='" + p.getName() + "'");
        while (rs.next()) {
          balance = rs.getInt("balance");
          int nbalance;

          if (t && cost > 0 && cost < balance) {

            if (player != null) {
              Material material = Material.matchMaterial(args[1]);

              if (material != null) {
                int amount = 1;
                if (args.length >= 3) {

                  try {
                    amount = Integer.parseInt(args[2]);
                  } catch (NumberFormatException ex) {
                  }
                  if (amount < 1) amount = 1;
                  if (amount > 64) amount = 64;
                }

                player.getInventory().addItem(new ItemStack(material, amount));
                Command.broadcastCommandMessage(
                    sender, "Giving  " + player.getName() + "  " + args[2] + "  " + material);
                Command.broadcastCommandMessage(
                    player, sender.getName() + "  gave you  " + args[2] + "  " + material);
                nbalance = balance - cost;
                Statement select0 = conn.createStatement();
                select0.executeUpdate(
                    "UPDATE money SET balance = '"
                        + nbalance
                        + "'WHERE p_name ='"
                        + p.getName()
                        + "'");
                p.sendMessage(
                    "You have been charged "
                        + cost
                        + " "
                        + v
                        + " - your new balance is "
                        + nbalance
                        + " "
                        + v
                        + "");
                return true;

              } else {
                sender.sendMessage("There's no item called " + args[1]);
                return true;
              }

            } else {
              sender.sendMessage("Can't find user " + args[0]);
            }
            return true;
          }

          if (cost < 1) {
            if (player != null) {
              Material material = Material.matchMaterial(args[1]);

              if (material != null) {
                int amount = 1;
                if (args.length >= 3) {

                  try {
                    amount = Integer.parseInt(args[2]);
                  } catch (NumberFormatException ex) {
                  }
                  if (amount < 1) amount = 1;
                  if (amount > 64) amount = 64;
                }

                player.getInventory().addItem(new ItemStack(material, amount));
                Command.broadcastCommandMessage(
                    sender, "Giving  " + player.getName() + "  " + args[2] + "  " + material);
                Command.broadcastCommandMessage(
                    player, sender.getName() + "  gave you  " + args[2] + "  " + material);

              } else {
                sender.sendMessage("There's no item called " + args[1]);
              }
              return true;

            } else {
              sender.sendMessage("Can't find user " + args[0]);
            }
          } else {
            if (player != null) {
              Material material = Material.matchMaterial(args[1]);

              if (material != null) {
                int amount = 1;
                if (args.length >= 3) {

                  try {
                    amount = Integer.parseInt(args[2]);
                  } catch (NumberFormatException ex) {
                  }
                  if (amount < 1) amount = 1;
                  if (amount > 64) amount = 64;
                }

                player.getInventory().addItem(new ItemStack(material, amount));
                Command.broadcastCommandMessage(
                    sender, "Giving  " + player.getName() + "  " + args[2] + "  " + material);
                Command.broadcastCommandMessage(
                    player, sender.getName() + "  gave you  " + args[2] + "  " + material);

              } else {
                sender.sendMessage("There's no item called " + args[1]);
              }

            } else {
              sender.sendMessage("Can't find user " + args[0]);
            }
            return true;
          }
        }
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
    }
    return false;
  }
 /**
  * Cast the command sender to the player.
  *
  * @param sender CommandSender
  * @return A casted player from a command sender.
  */
 public Player castToPlayer(CommandSender sender) {
   return Bukkit.getPlayerExact(sender.getName());
 }
  public void unload() {
    final Player player = Bukkit.getPlayerExact(name);

    if (player == null) {
      final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(name);
      PVPArena.instance.getAgm().disconnect(aPlayer.getArena(), aPlayer);
      return;
    }
    debug.i("restoring PlayerState of " + name, player);

    player.setFireTicks(fireticks);
    player.setFoodLevel(foodlevel);
    player.setGameMode(GameMode.getByValue(gamemode));

    final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(player.getName());
    player.setFoodLevel(foodlevel);
    if (player.getMaxHealth() != maxhealth) {
      final double newHealth = player.getMaxHealth() * health / maxhealth;
      if (newHealth > player.getMaxHealth()) {
        player.setHealth(player.getMaxHealth());
      } else {
        player.setHealth(newHealth);
      }

    } else {
      player.setHealth(health);
    }
    player.setSaturation(saturation);
    player.setGameMode(GameMode.getByValue(gamemode));
    player.setLevel(explevel);
    player.setExp(experience);
    player.setExhaustion(exhaustion);
    player.setFallDistance(0);
    player.setVelocity(new Vector());
    if (aPlayer.getArena() != null
        && aPlayer.getArena().getArenaConfig().getBoolean(CFG.CHAT_COLORNICK)) {
      player.setDisplayName(displayname);
    }

    if (aPlayer.getArena() != null) {

      ArenaModuleManager.unload(aPlayer.getArena(), player);
      PVPArena.instance.getAgm().unload(aPlayer.getArena(), player);
    }

    removeEffects(player);
    player.addPotionEffects(potionEffects);

    aPlayer.setTelePass(false);
    player.setFireTicks(fireticks);

    if (aPlayer.getArena() != null) {
      player.setNoDamageTicks(
          aPlayer.getArena().getArenaConfig().getInt(CFG.TIME_TELEPORTPROTECT) * 20);
    }
    player.resetPlayerTime();
    if (flying && !player.getAllowFlight()) {
      player.setAllowFlight(true);
    }
    player.setFlying(flying);
  }