Package org.bukkit.entity

Examples of org.bukkit.entity.Player


   * @return
   */
  public static Boolean jail(CommandSender sender, String[] args, String command, String alias, Boolean... omitMessage) {
    Boolean showMessages = (omitMessage.length == 0);
    // check if requested player is online
    Player p = Bukkit.getServer().getPlayer(args[0]);
    Boolean isOnline = false;
    String pName = "";
    if (p != null) {
      pName = p.getName();
      isOnline = true;
    } else {
      pName = args[0];
    }

    // check if requested player is jailed
    if ((jailedPlayers.size() > 0) && jailedPlayers.containsKey(pName)) {
      // unfreeze player and teleport him back to his previous location
      Location l = jailedPlayers.get(pName);
      jailedPlayers.remove(pName);
      Common.freeze(sender, args, command, alias, true);
     
      // teleport player back
      if (isOnline) {
        try {Handler_savebackposition.omittedPlayers.add(pName);} catch (Throwable e) {}
        Teleportation.delayedTeleport(p, l);
      }

      // inform the command sender and the player
      if (showMessages) {
        LogHelper.showInfo("[" + Nicknames.getNick(pName) + " #####jailsPlayerUnJailed", sender);
        if (isOnline) {
          LogHelper.showInfo("jailsEndMessage", p);
        }
      }
     
      return true;
    }

    // we are trying to jail a player
    String worldName = "";
    if (!isOnline) {
      // requested player not found
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    } else {
      worldName = p.getWorld().getName();
      // check if we have a jail location set for this world
      if (!jailPlaces.containsKey(worldName)) {
        LogHelper.showWarning("jailsNoJailInWorld", sender);
        return true;
      }
    }

    // insert player's name into jailed players' list
    jailedPlayers.put(pName, p.getLocation());

    // set a random position within the jail area
    Location jailPoint = jailPlaces.get(worldName);
    Integer jailArea = CommandsEX.getConf().getInt("jailArea");
    Integer halfJailArea = Math.round(jailArea / 2);
View Full Code Here


   * @param alias
   * @return
   */
  public static Boolean setjail(CommandSender sender, String[] args, String command, String alias) {
    // first of all, save the jail location locally
    Player p = (Player) sender;
    Location l = p.getLocation();
    jailPlaces.put(p.getWorld().getName(), l);
   
    // now see if we can put the location inside a database
    if (CommandsEX.sqlEnabled) {
      try {
        SQLManager.query("INSERT " + (SQLManager.sqlType.equals("mysql") ? "" : "OR REPLACE ") + "INTO " + SQLManager.prefix + "jails (world_name, x, y, z) VALUES (?, ?, ?, ?)" + (SQLManager.sqlType.equals("mysql") ? " ON DUPLICATE KEY UPDATE x = VALUES(x), y = VALUES(y), z = VALUES(z)" : ""), p.getWorld().getName(), l.getX(), l.getY(), l.getZ());
      } catch (Throwable e) {
        LogHelper.logSevere("[CommandsEX] " + _("dbWriteError", ""));
        LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
      }
    }
View Full Code Here

   * @return
   */
  public static Boolean unmute(CommandSender sender, String[] args, String command, String alias) {
    // make online player's name lookup, making this command case-insensitive,
    // fallback to case-sensitive argument from the player if the lookup fails
    Player p = Bukkit.getPlayer(args[0]);
    String pName = args[0];
    if (p != null) {
      pName = p.getName();
    }

    // check if requested player is muted
    if (mutedPlayers.containsKey(pName)) {
      // remove player's unmute timer as well, if set
View Full Code Here

   * @param args
   * @return
   */
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (PlayerHelper.checkIsPlayer(sender)) {
      Player player = (Player)sender;

      if (args.length > 0) {
        if (Permissions.checkPerms(player, "cex.tpdeny")) {
          // get player object (if online)
          Player tpaPlayer = Bukkit.getServer().getPlayer(args[0]);
         
          // check if there is a TPA or TPAHERE request for the given players combination
          String id = args[0] + "#####" + player.getName();
          if (Teleportation.tpaallRequests.contains(id)){
            Teleportation.tpaallRequests.remove(id);
View Full Code Here

   * @return
   */
 
  public static Boolean run(CommandSender sender, String alias, String[] args) {
   
    Player target = null;
    GameMode toGM = null;
   
    if (args.length == 0){
      if (!(sender instanceof Player)){
        Commands.showCommandHelpAndUsage(sender, "cex_gm", alias);
        return true;
      }
     
      target = (Player) sender;
    }
   
    if (args.length > 3){
      Commands.showCommandHelpAndUsage(sender, "cex_gm", alias);
      return true;
    }
   
    if (args.length == 1){
      toGM = matchGM(args[0]);
      if (toGM == null){
        if (!sender.hasPermission("cex.gamemode.others")){
          LogHelper.showInfo("gamemodeOthersNoPerm", sender, ChatColor.RED);
          return true;
        }
       
        target = Bukkit.getPlayer(args[0]);
       
        if (target == null){
          LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
          return true;
        }
      } else {
        if (!(sender instanceof Player)){
          Commands.showCommandHelpAndUsage(sender, "cex_gm", alias);
          return true;
        }
       
        target = (Player) sender;
      }
    }
   
    if (args.length == 2){
      if (!sender.hasPermission("cex.gamemode.others")){
        LogHelper.showInfo("gamemodeOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      target = Bukkit.getPlayer(args[0]);
      if (target == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return true;
      }
     
      toGM = matchGM(args[1]);
      if (toGM == null){
        LogHelper.showInfo("gamemodeInvalid", sender, ChatColor.RED);
        return true;
      }
    }
   
    if (toGM == null){
      if (target.getGameMode() == GameMode.SURVIVAL){
        toGM = GameMode.CREATIVE;
      } else {
        toGM = GameMode.SURVIVAL;
      }
    }
   
   
    target.setGameMode(toGM);
    if (sender != target){
      LogHelper.showInfo("gamemodeToSender#####[" + Nicknames.getNick(target.getName()) + " #####to#####[" + Utils.userFriendlyNames(toGM.name()), sender, ChatColor.AQUA);
      LogHelper.showInfo("gamemodeNotify#####[" + Nicknames.getNick(sender.getName()) + " #####to#####[" + Utils.userFriendlyNames(toGM.name()), target, ChatColor.AQUA);
    } else {
      LogHelper.showInfo("gamemodeSelf#####[" + Utils.userFriendlyNames(toGM.name()), sender, ChatColor.AQUA);
    }
   
View Full Code Here

        Commands.showCommandHelpAndUsage(sender, "cex_fireball", alias);
        return true;
      }
    }
   
    Player player = (Player) sender;
    Location eye = player.getEyeLocation().add(0.5, 0.5, 0.5);
    Vector v = eye.getDirection().multiply(2);
    Fireball entity = player.getWorld().spawn(eye.add(v.getX(), v.getY(), v.getZ()), (!smallFireball ? Fireball.class : SmallFireball.class));
    entity.setShooter(player);
    entity.setVelocity(eye.getDirection().multiply(2));
   
    LogHelper.showInfo("fireballSuccess", sender);
    return true;
View Full Code Here

   
    if (!PlayerHelper.checkIsPlayer(sender)){
      return true;
    }

    Player player = (Player) sender;

    if (Utils.checkCommandSpam(player, "cex_spawner")){
      return true;
    }

    ArrayList<String> list = new ArrayList<String>();
    // For each entity, check if the entity is alive and spawnable
    // If it then add it to the list
    for (EntityType entity : EntityType.values()){
      if (entity.isAlive() && entity.isSpawnable()){
        list.add(entity.getName().replaceAll(" ", ""));
      }
    }
   
    if (args.length == 0){
      LogHelper.showInfo("spawnerList#####[" + Utils.userFriendlyNames(Utils.implode(list, ", ")), sender, ChatColor.AQUA);
      return true;
    }

    if (args.length == 1){
      Block block = player.getTargetBlock(null, 30);
      if (block.getType() == Material.MOB_SPAWNER){
        String entityType = args[0];
        // Get the entity from the string
        EntityType entity = EntityType.fromName(entityType);
        // If the entity is not null and the list contains the entity
View Full Code Here

   * @param args
   * @return
   */
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (PlayerHelper.checkIsPlayer(sender)) {
      Player player = (Player)sender;

            if (CombatTag.isInCombat(player)){
                LogHelper.showWarning("combatTagCannotDo", player);
                return true;
            }
View Full Code Here

    if (args.length == 0 || args.length > 2 || (args.length == 1 && !(sender instanceof Player))){
      Commands.showCommandHelpAndUsage(sender, "cex_nickname", alias);
      return true;
    }
   
    Player target;
    String nickTo;
   
    if (args.length == 1){
      target = (Player) sender;
      nickTo = args[0];
    } else {
      if (!sender.hasPermission("cex.nickname.others")){
        LogHelper.showInfo("nickOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      target = Bukkit.getPlayer(args[0]);
      if (target == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return true;
      }
     
      nickTo = args[1];
    }
   
    // if nickto = reset then reset their nickname to default
    if (nickTo.equalsIgnoreCase("reset")){
      resetNick(target);
     
      if (!sender.equals(target)){
        LogHelper.showInfo("nickResetConfirm#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA);
        LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) + " #####nickResetNotify", target, ChatColor.AQUA);
      } else {
        LogHelper.showInfo("nickResetSelf", sender, ChatColor.AQUA);
      }
     
      return true;
    }
   
    if (!setNick(target.getName(), nickTo)){
      LogHelper.showWarning("nickAlreadyExists", sender);
      return true;
    }
   
    if (!sender.equals(target)){
      LogHelper.showInfo("nickConfirm#####[" + Nicknames.getNick(target.getName()) + " #####nickSetTo#####[" + Utils.replaceChatColors(nickTo), sender, ChatColor.AQUA);
      LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) + " #####nickNotify#####[" + Utils.replaceChatColors(nickTo), target, ChatColor.AQUA);
    } else {
      LogHelper.showInfo("nickSelf#####[" + Utils.replaceChatColors(nickTo), sender, ChatColor.AQUA);
    }
   
View Full Code Here

    if (!validCommand){
      Commands.showCommandHelpAndUsage(sender, "cex_xp", alias);
      return true;
    }

    Player target;
    String function;
    String amount;
    int amountint = 0;

    if ((args.length == 3 && !args[1].equalsIgnoreCase("view")) || (args.length == 2 && args[1].equalsIgnoreCase("view"))){
      target = Bukkit.getPlayer(args[0]);
      function = args[1];
    } else {
      if (sender instanceof Player){
        target = ((Player) sender);
      } else {
        Commands.showCommandHelpAndUsage(sender, "cex_xp", alias);
        return true;
      }
      function = args[0];
    }

    if (target == null){
      LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
      return true;
    }

    if (!function.equalsIgnoreCase("view") && !function.equalsIgnoreCase("set") && !function.equalsIgnoreCase("add") && !function.equalsIgnoreCase("take")){
      Commands.showCommandHelpAndUsage(sender, "cex_xp", alias);
      return true;
    }

    // If the function is not view then try to convert the string to an integer
    // If the string is not an integer then tell the sender and stop the code
    if (!function.equalsIgnoreCase("view")){
      if (args.length == 2){
        amount = args[1];
      } else {
        amount = args[2];
      }

      try {
        amountint = Integer.valueOf(amount);
      } catch (Exception e){
        LogHelper.showInfo("xpNotNumeric", sender, ChatColor.RED);
        return true;
      }
    }

    ExperienceManager expman = new ExperienceManager(target);
    // We manually define the maximum amount of XP a player can have before their experience bar disappears
    int xpMax = 99999999;
    // Very simple view function to show how much XP a player has
    if (function.equalsIgnoreCase("view")){
      if (!sender.hasPermission("cex.xp.view")){
        LogHelper.showInfo("xpViewNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.view.others")){
        LogHelper.showInfo("xpViewOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(target.getName()) + " #####xpHas#####[" : "xpViewSelf#####[") + expman.getCurrentExp() + " #####xpExperience", sender, ChatColor.AQUA);
      return true;
    }

    // Set function to set a players XP
    if (function.equalsIgnoreCase("set")){
      if (!sender.hasPermission("cex.xp.set")){
        LogHelper.showInfo("xpSetNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.set.others")){
        LogHelper.showInfo("xpSetOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      boolean overLimit = false;
      // See if the amount the player defined is over the limit
      if (amountint > xpMax){ overLimit = true; }
      // Check if it is over the limit, if it is set it to the maximum amount of XP otherwise set it to the amount the player defined
      expman.setExp((overLimit ? xpMax : amountint));
      // If the amount is over the limit, notify the sender
      if (overLimit) { LogHelper.showInfo("xpCouldNotAddAll", sender, ChatColor.RED); }
      // Send a message to the target with the actual amount of XP that was set
      if (sender != target) { LogHelper.showInfo("xpSet#####[" + Nicknames.getNick(target.getName()) " #####xpTo#####[" + (overLimit ? xpMax : amountint), sender, ChatColor.AQUA); }
      // Send a success message to the target with the actual amount of XP that was set
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(sender.getName()) + " #####xpSetMsgToTarget1#####[" : "xpSetMsgToTarget2#####[") + (overLimit ? xpMax : amountint), target, ChatColor.AQUA);
    }

    // Add function to add to a players current experience
    if (function.equalsIgnoreCase("add")){
      if (!sender.hasPermission("cex.xp.add")){
        LogHelper.showInfo("xpAddNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.add.others")){
        LogHelper.showInfo("xpAddOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      boolean overLimit = false;
      int oldXP = expman.getCurrentExp();
      // Determine whether adding this amount of XP would go over the limit
      if (expman.getCurrentExp() + amountint > xpMax) { overLimit = true; }
      // If it is over the limit, then set their XP to maximum
      // Otherwise add the XP normally
      if (overLimit){
        expman.setExp(xpMax);
        LogHelper.showInfo("xpCouldNotAddAll", sender, ChatColor.RED);
      } else {
        expman.changeExp(amountint);
      }
      // Send a success message to the target with the actual amount of XP that was added
      if (sender != target) { LogHelper.showInfo("xpAdded#####[" + (overLimit ? xpMax - oldXP : amountint) + " #####xpExperience#####[ #####xpTo#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA); }
      // Send a success message to the sender with the actual amount of XP that was added
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(sender.getName()) + " #####xpAddedGave1#####[" : "xpAddedGave2#####[") + (overLimit ? xpMax - oldXP : amountint) + " #####xpExperience", target, ChatColor.AQUA);
    }

    // Take function to take XP from a player
    if (function.equalsIgnoreCase("take")){
      if (!sender.hasPermission("cex.xp.take")){
        LogHelper.showInfo("xpTakeNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      if (sender != target && !sender.hasPermission("cex.xp.take.others")){
        LogHelper.showInfo("xpTakeOthersNoPerm", sender, ChatColor.RED);
        return true;
      }
     
      // Check if the player has the amount needed
      boolean hasXP = expman.hasExp(amountint);
      int oldXP = expman.getCurrentExp();
      // If the player has the XP, then take the amount the user defined
      // If not then take as much as we can
      expman.changeExp(-(hasXP ? amountint : expman.getCurrentExp()));
      // Send a message to sender saying the target didn't have that amount
      if (!hasXP) { LogHelper.showInfo("xpNotEnough", sender, ChatColor.RED); }
      // Alert the target that some of his XP has been stolen and the actual amount of XP taken
      if (sender != target) { LogHelper.showInfo("xpTaken#####[" + (hasXP ? amountint : oldXP) + " #####xpExperience#####[ #####xpFrom#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA); }
      // Send a message to the sender with the actual amount of XP taken
      LogHelper.showInfo((sender != target ? "[" + Nicknames.getNick(sender.getName()) + " #####xpTakenTook1#####[" : "xpTakenTook2#####[") + (hasXP ? amountint : oldXP) + " #####xpExperience", target, ChatColor.AQUA);
    }
    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.