Package org.bukkit.entity

Examples of org.bukkit.entity.Player


    if (nametags.containsKey(pName)){
      nametags.remove(pName);
    }
   
    nametags.put(pName, nametag);
    Player player = Bukkit.getPlayerExact(pName);
    if (player != null){
      org.kitteh.tag.TagAPI.refreshPlayer(player);
    }
  }
View Full Code Here


  public static void resetTag(String pName){
    if (nametags.containsKey(pName)){
      nametags.remove(pName);
    }
   
    Player player = Bukkit.getPlayerExact(pName);
    if (player != null){
      org.kitteh.tag.TagAPI.refreshPlayer(player);
    }
  }
View Full Code Here

      return true;
    }
   
    EntityType toSpawn = null;
    int explosionStrength = CommandsEX.getConf().getInt("CannonExplosionStrength");
    Player target = null;
    String type = null;
    String entity = null;
   
    if (args.length == 1 || args.length == 2){
      if (sender instanceof Player){
        target = (Player) sender;
        if (args[0].contains(":")){
          String[] data = args[0].split(":");
          entity = data[0];
          if (data.length == 2){ type = data[1]; }
        } else {
          entity = args[0];
        }
       
        List<EntityType> matches = ClosestMatches.spawnableEntity(entity);
        if (matches.size() > 0){
          toSpawn = matches.get(0);
        } else {
          LogHelper.showInfo("cannonInvalid", sender, ChatColor.RED);
          return true;
        }
      } else {
        Commands.showCommandHelpAndUsage(sender, "cex_cannon", alias);
        return true;
      }
    }
   
    if (args.length == 2){
      if (args[1].matches(CommandsEX.intRegex)){
        explosionStrength = Integer.valueOf(args[1]);
        if (explosionStrength > explosionStrengthLimit){
          LogHelper.showInfo("cannonLimit", sender, ChatColor.RED);
          explosionStrength = explosionStrengthLimit;
        }
      } else {
        LogHelper.showInfo("cannonInteger", sender, ChatColor.RED);
        return true;
      }
    }
   
    if (args.length == 3){
      target = Bukkit.getPlayer(args[0]);
      if (target == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return true;
      }
     
      if (args[1].contains(":")){
        String[] data = args[1].split(":");
        entity = data[0];
        if (data.length == 2){ type = data[1]; }
      } else {
        entity = args[1];
      }
     
      if (ClosestMatches.spawnableEntity(entity).size() > 0){
        List<EntityType> matches = ClosestMatches.spawnableEntity(entity);
        toSpawn = matches.get(0);
      } else {
        LogHelper.showInfo("cannonInvalid", sender, ChatColor.RED);
        return true;
      }
     
      if (args[2].matches(CommandsEX.intRegex)){
        explosionStrength = Integer.valueOf(args[2]);
        if (explosionStrength > explosionStrengthLimit){
          LogHelper.showInfo("cannonLimit", sender, ChatColor.RED);
          explosionStrength = explosionStrengthLimit;
        }
      } else {
        LogHelper.showInfo("cannonInteger", sender, ChatColor.RED);
        return true;
      }
    }
   
    DyeColor dye = null;

    try {
      for (DyeColor d : DyeColor.values()){
        String lower = d.name().toLowerCase();
        if (lower.equalsIgnoreCase(type)){
          dye = d;
        }
      }
    } catch (Exception e){

    }

    if (type != null){
      if (type.equalsIgnoreCase("fire")){
       
      } else if (type.equalsIgnoreCase("charged") || type.equalsIgnoreCase("powered") && toSpawn == EntityType.CREEPER){
        type = "charged";
      } else if (type.equalsIgnoreCase("baby") || type.equalsIgnoreCase("child") && (toSpawn == EntityType.PIG || toSpawn == EntityType.COW
          || toSpawn == EntityType.CHICKEN || toSpawn == EntityType.SHEEP || toSpawn == EntityType.OCELOT || toSpawn == EntityType.WOLF)){
        type = "baby";
      } else if (type.equalsIgnoreCase("tamed") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.OCELOT)){
       
      } else if (type.equalsIgnoreCase("angry") && (toSpawn == EntityType.WOLF || toSpawn == EntityType.PIG_ZOMBIE)){
       
      } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
       
      } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
       
      } else if (toSpawn == EntityType.DROPPED_ITEM && ClosestMatches.material(type).size() > 0){
        type = "item:" + type;
      } else if (toSpawn == EntityType.SHEEP && dye != null){
        // Correct, nothing to do here
      } else {
        LogHelper.showInfo("cannonInvalidType", sender, ChatColor.RED);
        return true;
      }
    }
   

    final Entity entity1;
   
    if (toSpawn == EntityType.DROPPED_ITEM){
      entity1 = target.getWorld().dropItem(target.getEyeLocation(), new ItemStack(ClosestMatches.material(type.split(":")[1].replaceFirst(":", "")).get(0)));
    } else {
      entity1 = target.getWorld().spawn(target.getEyeLocation(), toSpawn.getEntityClass());
    }
   
    if (toSpawn == EntityType.OCELOT){
      final Ocelot ocelot = (Ocelot) entity1;
      Random random = new Random();
      int i = random.nextInt(Ocelot.Type.values().length);
      ocelot.setCatType(Ocelot.Type.values()[i]);
    }
   
    if (type != null){
      if (type.equalsIgnoreCase("fire")){
        entity1.setFireTicks(40);
      } else if (type.equalsIgnoreCase("baby")){
        Ageable age = (Ageable) entity1;
        age.setBaby();
      } else if (type.equalsIgnoreCase("tamed")){
        Tameable tame = (Tameable) entity1;
        tame.setTamed(true);
      } else if (type.equalsIgnoreCase("angry")){
        if (toSpawn == EntityType.WOLF){
          Wolf wolf = (Wolf) entity1;
          wolf.setAngry(true);
        }
       
        if (toSpawn == EntityType.PIG_ZOMBIE){
          PigZombie pigzombie = (PigZombie) entity1;
          pigzombie.setAngry(true);
        }
      } else if (type.equalsIgnoreCase("charged")){
        Creeper creep = (Creeper) entity1;
        creep.setPowered(true);
      } else if (toSpawn == EntityType.ENDERMAN && ClosestMatches.material(type).size() > 0){
        Enderman enderman = (Enderman) entity1;
        enderman.setCarriedMaterial(new MaterialData(ClosestMatches.material(type).get(0)));
      } else if (toSpawn == EntityType.VILLAGER && ClosestMatches.villagerProfessions(type).size() > 0){
        Villager villager = (Villager) entity1;
        villager.setProfession(ClosestMatches.villagerProfessions(type).get(0));
      } else if (type.startsWith("item:") && toSpawn == EntityType.DROPPED_ITEM){

      } else if (dye != null){
        Sheep sheep = (Sheep) entity1;
        sheep.setColor(dye);
      }
    }
   
    entity1.setVelocity(target.getEyeLocation().getDirection().multiply(2));
    entity1.setFallDistance(-999999999999F);
    LogHelper.showInfo("cannonCreated", sender);
    // required for task, has to be final
    final int newExplosionStrength = explosionStrength;
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Runnable() {
View Full Code Here

      new Common();
    }

    Boolean showMessages = (omitMessage.length == 0);
    // check if requested player is online
    Player p = Bukkit.getServer().getPlayer(args[0]);
    String pName = "";
    if (p != null) {
      pName = p.getName();
    } else {
      pName = args[0];
    }
       
    // check if requested player is frozen
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean kick(CommandSender sender, String[] args, String command, String alias) {
    // check if requested player is online
    Player p = Bukkit.getServer().getPlayer(args[0]);
    String pName = "";
    String leaveReason = "";
    if (p == null) {
      // requested player not found
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    } else if (p.hasPermission("cex.bypass.kick")){
      LogHelper.showInfo("kickCannotKick", sender, ChatColor.RED);
      return true;
    } else {
      pName = p.getName();
    }
   
    // if we have more than 1 argument, build up the leave string
    if (args.length > 1) {
      for (Integer i = 1; i < args.length; i++) {
        leaveReason = leaveReason + " " + args[i];
      }
    }
   
    // kick player and tell everyone if set up in the config file
    p.kickPlayer(ChatColor.RED + (leaveReason.equals("") ? _("kickGenericReason", "") : leaveReason));
    if (!CommandsEX.getConf().getBoolean("silentKicks")) {
      CommandsEX.plugin.getServer().broadcastMessage(ChatColor.LIGHT_PURPLE + (!leaveReason.equals("") ? (Nicknames.getNick(pName) + " " + _("kickBeingKickedForMessage", "") + leaveReason) : Nicknames.getNick(pName) + " " + _("kickBeingKickedMessage", "")));
    }
   
    return true;
View Full Code Here

    if (plugin == null) {
      new Common();
    }

    // if we have a player to make god, check if he's online
    Player p;
    if (args.length > 0) {
      p = Bukkit.getServer().getPlayer(args[0]);

      if (p == null) {
        // requested player not found
        LogHelper.showWarning("invalidPlayer", sender);
        return true;
      }
    } else {
      p = (Player)sender;
    }
   
    String pName = p.getName();
    Boolean showMessages = (omitMessage.length == 0);
       
    // check if requested player is in god mode now
    if ((godPlayers.size() > 0) && godPlayers.contains(pName)) {
      // cancel god mode for the player
View Full Code Here

   */
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    // check if we have any parameters
    if (args.length > 0) {
     
      Player beingBanned = Bukkit.getServer().getPlayer(args[0]);
     
      // check permissions and roll it :)
      Boolean hasPerms = true;
      Boolean hasBypass = false;
      if (sender instanceof Player) {
        hasPerms = Permissions.checkPerms((Player)sender, "cex.ban");
       
        if (beingBanned != null) {
          hasBypass = Permissions.checkPerms((Player)beingBanned, "cex.bypass.ban");
        }
      }
     
      // permissions ok
      if (hasBypass) {
        LogHelper.showWarning("[" + beingBanned.getDisplayName() + " #####bansBanBypassMessage", sender);
        return true;
      }
      if (hasPerms) {
        ban(sender, args, "cex_ban", alias);
      }
View Full Code Here

    if (plugin == null) {
      new Common();
    }

    // if we have a player to make god, check if he's online
    Player target = Bukkit.getServer().getPlayer(args[0]);
    if (target == null) {
      // requested player not found
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    }
   
    String tName = target.getName();
    Boolean showMessages = (omitMessage.length == 0);

    // insert player's name into slapped players' list
    slappedPlayers.add(tName);
    // if we have only this player, activate event listeners, since they're not active yet
    if ((frozenPlayers.size() == 0) && (slappedPlayers.size() == 1) && (godPlayers.size() == 0) && (invisiblePlayers.size() == 0)) {
      CommandsEX.plugin.getServer().getPluginManager().registerEvents(Common.plugin, CommandsEX.plugin);
    }
   
    // now slap him! :)
    Integer slapHeight = CommandsEX.getConf().getInt("defaultSlapHeight", 20);
    if (args.length > 1) {
      try {
        slapHeight = Integer.parseInt(args[1]);
      } catch (Throwable e) {}
    }
   
    // store player's original position, so we can return him safely back (in case he's underground and another player slaps him to heavens)
    Location loc = target.getLocation();
    slappedLastLocations.put(tName, loc);
   
    target.setVelocity(new Vector(0, slapHeight, 0));
   
    // insure player's safe return home even if they fall into deep water and no damage is done
    slappedUnslapTasks.put(tName,  Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Unslap(target, tName), (20 * 25)));

    if (showMessages) {
      // inform both players
      if (!sender.getName().equalsIgnoreCase(target.getName())){
        LogHelper.showInfo("playerYouWereSlapped#####[" + Nicknames.getNick(sender.getName()), target, ChatColor.YELLOW);
      }

      // Only do this if the command was slap
      if (command.equalsIgnoreCase("slap")){
View Full Code Here

    if (plugin == null) {
      new Common();
    }

    Boolean showMessages = (omitMessage.length == 0);
    Player player = (Player) sender;
    String pName = player.getName();
    Boolean isInvisible = invisiblePlayers.contains(pName);
   
    // use VanishNoPacket to handle invisibility if found
    if (CommandsEX.vanishNoPacketPresent){
      try {
View Full Code Here

  public static Boolean run(CommandSender sender, String alias, String[] args){
    if (!PlayerHelper.checkIsPlayer(sender)){
      return true;
    }
   
    Player player = (Player) sender;
   
    if (Utils.checkCommandSpam(player, "cex_enderchest")){
      return true;
    }
   
    if (args.length > 1){
      Commands.showCommandHelpAndUsage(sender, "cex_enderchest", alias);
      return true;
    }
   
    Player target;
    if (args.length == 0){
      target = player;
    } else {
      target = Bukkit.getPlayer(args[0]);
     
      if (target == null){
        target = Utils.getOfflinePlayer(args[0]);
        if (target == null){
          LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
          return true;
        }
      }
    }
   
    if (player.equals(target)){
      LogHelper.showInfo("enderChestOpenSelf", sender);
    } else {
      if (player.hasPermission("cex.enderchest.others")){
        LogHelper.showInfo("enderChestOpen#####[" + Nicknames.getNick(target.getName()), sender);
      } else {
        LogHelper.showInfo("enderChestOtherNoPerm", sender, ChatColor.RED);
        return true;
      }
    }
   
    player.openInventory(target.getEnderChest());
   
    return true;
  }
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.