Package org.bukkit.entity

Examples of org.bukkit.entity.Player


   * @param e
   */
 
  @EventHandler (priority = EventPriority.LOW)
  public void slapPlayerQuit(PlayerQuitEvent e){
    Player p = e.getPlayer();
    if (slappedPlayers.contains(p.getName())){
      p.teleport(slappedLastLocations.get(p.getName()), PlayerTeleportEvent.TeleportCause.PLUGIN);
     
      slappedLastLocations.remove(p.getName());
      slappedPlayers.remove(p.getName());
    }
  }
View Full Code Here


      e.setJoinMessage("");
    }
   
    // make all invisible players invisible to our joining player as well
    for (String p : Common.invisiblePlayers) {
      Player player = Bukkit.getPlayer(p);
      if (player != null) {
        e.getPlayer().hidePlayer(player);
        // Hide the player from the player list
      }
    }
   
    if ((Common.frozenPlayers.size() > 0) && Common.frozenPlayers.contains(e.getPlayer().getName())) {
      // if the player is frozen, remind them
      Player p = e.getPlayer();
      LogHelper.showInfo("freezeYouAreFrozen1", p);
      LogHelper.showInfo("freezeYouAreFrozen2", p);
    }
  }
View Full Code Here

 
  @EventHandler(priority = EventPriority.NORMAL)
  public void checkDamage(EntityDamageEvent e) {
    if (!e.getEntityType().equals(EntityType.PLAYER)) return;

    Player p = (Player)e.getEntity();
    String pName = p.getName();
    if ((Common.godPlayers.size() > 0) && Common.godPlayers.contains(pName)) {
      e.setCancelled(true);
    }
   
    if ((Common.slappedPlayers.size() > 0) && Common.slappedPlayers.contains(pName)) {
      if (slappedUnslapTasks.containsKey(pName)){
        // remove UnSlap task for this player
        Bukkit.getServer().getScheduler().cancelTask(slappedUnslapTasks.get(pName));
        slappedUnslapTasks.remove(pName);
      }
     
      if (CommandsEX.getConf().getBoolean("slapPreventDamage", true)) {
        e.setCancelled(true);
      }
     
      // restore player's original position
      p.teleport(slappedLastLocations.get(pName), PlayerTeleportEvent.TeleportCause.PLUGIN);
     
      // remove records
      slappedPlayers.remove(pName);
      slappedLastLocations.remove(pName);
View Full Code Here

    }
  }
 
  @EventHandler (priority = EventPriority.LOW, ignoreCancelled = true)
  public void onPlayerDeath(PlayerDeathEvent e){
    Player player = (Player) e.getEntity();
    // If the player is invisible, don't show their death message
    if (Common.invisiblePlayers.contains(player.getName())){
      e.setDeathMessage("");
    }
  }
View Full Code Here

   *
   * @return  the Player object
   * @throws IllegalStateException if the player is no longer online
   */
  public Player getPlayer() {
    Player p = Bukkit.getPlayer(playerName);
    if (p == null) {
      throw new IllegalStateException("Player " + playerName + " is not online");
    }
    return p;
  }
View Full Code Here

  private void setExp(int base, int amt) {
    int xp = base + amt;
    if (xp < 0) xp = 0;

    Player player = getPlayer();
    int curLvl = player.getLevel();
    int newLvl = getLevelForExp(xp);
    if (curLvl != newLvl) {
      player.setLevel(newLvl);
    }

    float pct = ((float)(xp - getXpForLevel(newLvl)) / (float)xpRequiredForNextLevel[newLvl]);
    player.setExp(pct);
  }
View Full Code Here

   * Get the player's current XP total.
   *
   * @return  the player's total XP
   */
  public int getCurrentExp() {
    Player player = getPlayer();
    int lvl = player.getLevel();
    int cur = getXpForLevel(lvl) + (int) Math.round(xpRequiredForNextLevel[lvl] * player.getExp());
    return cur;
  }
View Full Code Here

   * @param alias
   * @return
   */
  public static void give(CommandSender sender, String[] args, Boolean suppressWarnings) {
    Boolean forOtherPlayer = false;
    Player player;
    Player sendingPlayer = (Player) sender;
    if (args.length > 1) {
      // we're giving a kit to another player
      player = Bukkit.getServer().getPlayer(args[1]);
     
      if (player == null) {
View Full Code Here

   * @param e
   * @return
   */
  @EventHandler(priority = EventPriority.LOWEST)
  public void giveInitialKits(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    if (player.hasPlayedBefore()) return;

    FileConfiguration f = CommandsEX.getConf();
    ConfigurationSection kitConfigGroups = f.getConfigurationSection("kits");
    if (kitConfigGroups == null) return;
   
View Full Code Here

   */
 
  public static void giveItem(CommandSender sender, String[] args, String function, String alias){

    if (sender instanceof Player){
      Player player = (Player) sender;
      if (Utils.checkCommandSpam(player, "cex_" + function)){
        return;
      }
    }

    if ((function.equals("give") ? args.length < 2 || args.length > 4 : args.length < 1 || args.length > 3)){
      Commands.showCommandHelpAndUsage(sender, "cex_" + function, alias);
      return;
    }

    Player target;

    if (function.equals("give")){
      target = Bukkit.getPlayer(args[0]);

      if (target == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return;
      }
    } else {
      if (!(sender instanceof Player)){
        Commands.showCommandHelpAndUsage(sender, "cex_" + function, alias);
        return;
      }

      target = (Player) sender;
    }
   
    String itemArg = (function.equals("give") ? args[1] : args[0]);
    String amountArg = (function.equals("give") ? (args.length > 2 ? args[2] : null) : (args.length > 1 ? args[1] : null));
    String damageArg = (function.equals("give") ? (args.length > 3 ? args[3] : null) : (args.length > 2 ? args[2] : null));
   
    if (itemArg.contains(":") && damageArg != null){
      Commands.showCommandHelpAndUsage(sender, "cex_" + function, alias);
      return;
    }
   
    List<String> listArgs = new ArrayList<String>();
    if (itemArg != null){ listArgs.add(itemArg); }
    if (amountArg != null){ listArgs.add(amountArg); }
    if (damageArg != null){ listArgs.add(damageArg); }
   
    ItemStack stack = ItemStackParser.parse(listArgs.toArray(new String[]{}), sender);
    if (stack == null){ return; }
    target.getInventory().addItem(stack);

    Material item = stack.getType();
    int amount = stack.getAmount();
    short damage = stack.getDurability();
   
    // Messages will be different if the player spawned the item for himself, or someone else
    if (sender != target){
      LogHelper.showInfo("itemYouGave#####[" + Nicknames.getNick(target.getName()) + " " + amount + " " + Utils.userFriendlyNames(item.name()) + (damage != 0 ? " (" + damage + ")": ""), sender, ChatColor.AQUA);
      LogHelper.showInfo("itemGiveSuccess#####[" + amount + " " + Utils.userFriendlyNames(item.name()) + (damage != 0 ? " (" + damage + ")": "") + " #####itemFrom#####[" + Nicknames.getNick(sender.getName()), target, ChatColor.AQUA);
    } else {
      LogHelper.showInfo("itemGiveSuccess#####[" + amount + " " + Utils.userFriendlyNames(item.name()) + (damage != 0 ? " (" + damage + ")": ""), sender, ChatColor.AQUA);
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.