Package org.bukkit

Examples of org.bukkit.Location


       
        try {
          String homePlayerForSQL = homePlayerName.toLowerCase();
          String foundPlayerName = "";
          Integer numHomes = 0;
          Location l = null;
          ResultSet res;
         
          if (multiHomesEnabled) {
            // if multiple homes are enabled, we check for a home in player's current world
            res = SQLManager.query_res("SELECT * FROM " + SQLManager.prefix + "homes WHERE (player_name = ? OR player_name LIKE ?) AND world_name = ? LIMIT 2", homePlayerForSQL, homePlayerForSQL + "%", player.getWorld().getName());
          } else {
            // multiple homes disabled, we check for player's home anywhere
            res = SQLManager.query_res("SELECT * FROM " + SQLManager.prefix + "homes WHERE (player_name = ? OR player_name LIKE ?) LIMIT 2", homePlayerForSQL, homePlayerForSQL + "%");
          }

          while (res.next()) {
            numHomes++;
            foundPlayerName = res.getString("player_name");
            res.getString("allowed_players");
            Boolean noPlayers = res.wasNull();
            // check if player is allowed to go to this home
            if (!Permissions.checkPermEx(player, "cex.bypassinvite") && !res.getBoolean("is_public") && !res.getString("player_name").equals(sender.getName()) && (noPlayers || (!noPlayers && !res.getString("allowed_players").equals(pName) && !res.getString("allowed_players").contains("," + pName) && !res.getString("allowed_players").contains(pName + ",")))) {
              // player is not allowed in
              LogHelper.showWarning("homeNotAllowed" + (multiHomesEnabled ? "#####homeInCurrentWorld" : ""), sender);
              return true;
            }

            // assemble location for the home
            l = new Location(CommandsEX.plugin.getServer().getWorld(res.getString("world_name")), res.getDouble("x"), res.getDouble("y"), res.getDouble("z"), (float) res.getDouble("yaw"), (float) res.getDouble("pitch"));
            if (l.getWorld() == null){
              LogHelper.showInfo("homeWorldNotExist", sender, ChatColor.RED);
              return true;
            }
           
            // if the name matches exactly what we've been looking for, adjust numHomes and break the loop
View Full Code Here


        entity1.setFallDistance(-999999999999F);
        // required for task, has to be final
        final int newExplosionStrength = explosionStrength;
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Runnable() {
          public void run() {
            final Location loc = entity1.getLocation();
            entity1.remove();
            loc.getWorld().createExplosion(loc, newExplosionStrength);
          }
        }, 20L);
      }

      }
View Full Code Here

            Integer lastJoinTime = Utils.getUnixTimestamp(o.getLastPlayed());
           
            // compare last join time with our requested number of days to past
            if ((stamp - lastJoinTime) >= daysInSeconds) {
              // match found, teleport player
              Teleportation.delayedTeleport(player, new Location(CommandsEX.plugin.getServer().getWorld(res.getString("world_name")), res.getInt("x"), res.getInt("y"), res.getInt("z"), (float) res.getDouble("yaw"), (float) res.getDouble("pitch")) );
              // tell player where he is
              LogHelper.showInfo("homeWelcomeTo#####[" + Nicknames.getNick(res.getString("player_name")) + "#####homePlayersHome", sender);
              res.close();
              return true;
            }
View Full Code Here

        if (Handler_tntkamikaze.explodingPlayers.contains(p.getName()) && p.getGameMode() != GameMode.CREATIVE && !Common.godPlayers.contains(p.getName())){
          // remove TNT from player's inventory
            p.getInventory().remove(Material.TNT);

            // create explosion in the world where the player is
            Location l = this.p.getLocation();
            this.p.playEffect(l, Effect.EXTINGUISH, 0);
            p.getWorld().createExplosion(l, 4F);

            // check if we should insta-kill the player
            if (CommandsEX.getConf().getBoolean("kamikazeInstaKill")) {
View Full Code Here

      ResultSet rs = SQLManager.query_res("SELECT * FROM " + SQLManager.prefix + "spawns");
      // add all worlds that are in the database to the inDatabase list
      try {
        while (rs.next()){
          if (Bukkit.getWorld(rs.getString("world_name")) != null){
            worldSpawns.put(rs.getString("world_name"), new Location(Bukkit.getWorld(rs.getString("world_name")), rs.getDouble("x"), rs.getDouble("y"), rs.getDouble("z"), rs.getFloat("yaw"), rs.getFloat("pitch")));
          }
        }
       
        rs.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
     
      // load each worlds current spawn point if they have not already been added to the database
      for (World w : Bukkit.getWorlds()){
        if (!worldSpawns.containsKey(w.getName())){
          Location spawn = w.getSpawnLocation();
          worldSpawns.put(w.getName(), spawn);
        }
      }
     
      if (CommandsEX.getConf().getBoolean("perWorldSpawn")){
        // set the default world if it has not already been set
        if (!CommandsEX.getConf().contains("globalSpawnWorld")){
          CommandsEX.getConf().set("globalSpawnWorld", Bukkit.getWorlds().get(0).getName());
          CommandsEX.plugin.saveConfig();
        }
      } else {
        // if the world in the config does not exist
        if (!CommandsEX.getConf().contains("globalSpawnWorld")){
          LogHelper.logDebug("globalSpawnWorld in config.yml does not exist, setting to default");
          CommandsEX.getConf().set("globalSpawnWorld", Bukkit.getWorlds().get(0).getName());
        }
      }
     
      for (String s : worldSpawns.keySet()){
        if (Bukkit.getWorlds().contains(s)){
          // add all worlds in the database to the worldSpawns hashmap
          World w = Bukkit.getWorld(s);
          ResultSet res = SQLManager.query_res("SELECT world_name, x, y, z, yaw, pitch FROM " + SQLManager.prefix + "spawns WHERE world_name = ?", s);
         
          try {
            worldSpawns.put(s, new Location(w, res.getDouble("x"), res.getDouble("y"), res.getDouble("z"), res.getFloat("yaw"), res.getFloat("pitch")));
            res.close();
          } catch (SQLException e) {
            e.printStackTrace();
          }
        }
View Full Code Here

  public static Boolean setSpawn(CommandSender sender, String[] args, String command, String alias) {
    // so far, this is a very simple function that will be expanded to allow random spawns and similar features
   
    Player player = (Player)sender;
    if (!Utils.checkCommandSpam(player, "spawn-set")) {
      Location loc = player.getLocation();
      World world = player.getWorld();
 
      if (!CommandsEX.getConf().getBoolean("perWorldSpawn")){
        CommandsEX.getConf().set("globalSpawnWorld", world.getName());
      }

      if (worldSpawns.containsKey(world.getName())){
        worldSpawns.remove(world.getName());
      }
     
      worldSpawns.put(world.getName(), loc);
     
      if (!CommandsEX.sqlEnabled){
        world.setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
      }
     
      if (CommandsEX.getConf().getBoolean("perWorldSpawn")){
        LogHelper.showInfo("spawnSetWorld", sender);
      } else {
View Full Code Here

      // add or update spawns that are in the hashmap
      for (String w : worldSpawns.keySet()){
        ResultSet rs = SQLManager.query_res("SELECT world_name FROM " + SQLManager.prefix + "spawns WHERE world_name = ?", w);
       
        try {
          Location loc = worldSpawns.get(w);
         
          if (!rs.next()){
            SQLManager.query("INSERT " + (SQLManager.sqlType.equals("mysql") ? "" : "OR REPLACE ") + "INTO " + SQLManager.prefix + "spawns (world_name, x, y, z, yaw, pitch) SELECT ? AS world_name, ? AS x, ? AS y, ? AS z, ? AS yaw, ? AS pitch", w, loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
          } else {
            SQLManager.query("UPDATE " + SQLManager.prefix + "spawns SET world_name = ?, x = ?, y = ?, z = ?, yaw = ?, pitch = ?", w, loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
          }
         
          rs.close();
        } catch (SQLException e) {
          e.printStackTrace();
View Full Code Here

    if (function == null || function.equalsIgnoreCase("god")) { LogHelper.showInfo("pinfoGod#####[" + ChatColor.GOLD + (Common.godPlayers.contains(target.getName()) ? "#####pinfoOn" : "#####pinfoOff"), sender, ChatColor.GRAY); }
    if (function == null || function.equalsIgnoreCase("inv") || function.equalsIgnoreCase("invisible")) { LogHelper.showInfo("pinfoInv#####[" + ChatColor.GOLD + (Common.invisiblePlayers.contains(target.getName()) ? "#####pinfoOn" : "#####pinfoOff"), sender, ChatColor.GRAY); }
   
    if (function == null || function.equalsIgnoreCase("coords") || function.equalsIgnoreCase("coordinates") || function.equalsIgnoreCase("world")){ LogHelper.showInfo("pinfoWorld#####[" + ChatColor.GOLD + target.getLocation().getWorld().getName(), sender, ChatColor.GRAY); }
    if (function == null || function.equalsIgnoreCase("coords")) {
      Location loc = target.getLocation();
      LogHelper.showInfo("pinfoX#####[" + ChatColor.GOLD + loc.getX() + ChatColor.GRAY + "#####pinfoY#####[" + ChatColor.GOLD + loc.getY() + ChatColor.GRAY + "#####pinfoZ#####[" + loc.getZ(), sender, ChatColor.GRAY);
    }
    if (function == null || function.equalsIgnoreCase("potions")) {
      ArrayList<String> potions = new ArrayList<String>();
      for (PotionEffect pot : target.getActivePotionEffects()){
        String time = Utils.convertToHHMMSS(pot.getDuration() / 20, true);
View Full Code Here

  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (PlayerHelper.checkIsPlayer(sender)) {
      Player player = (Player)sender;
     
      if (!Utils.checkCommandSpam(player, "chunk") && Permissions.checkPerms(player, "cex.chunk.refresh")) {
        Location loc = player.getLocation();
        World w = player.getWorld();
        Chunk lastChunk = w.getChunkAt(loc);
        Chunk currentChunk = w.getChunkAt(loc);
       
        // first regenerate player's chunk
        w.refreshChunk((int) loc.getX(), (int) loc.getZ());
       
        // regenerate left
        while (lastChunk.equals(currentChunk)) {
          loc.setX(loc.getX() + 10);
          currentChunk = w.getChunkAt(loc);
        }
        lastChunk = currentChunk;
        w.refreshChunk((int) loc.getX(), (int) loc.getZ());
        loc = player.getLocation();
       
        // regenerate right
        while (lastChunk.equals(currentChunk)) {
          loc.setX(loc.getX() - 10);
          currentChunk = w.getChunkAt(loc);
        }
        lastChunk = currentChunk;
        w.refreshChunk((int) loc.getX(), (int) loc.getZ());
        loc = player.getLocation();
       
        // regenerate in front of player
        while (lastChunk.equals(currentChunk)) {
          loc.setZ(loc.getZ() + 10);
          currentChunk = w.getChunkAt(loc);
        }
        lastChunk = currentChunk;
        w.refreshChunk((int) loc.getX(), (int) loc.getZ());
        loc = player.getLocation();
       
        // regenerate behind the player
        while (lastChunk.equals(currentChunk)) {
          loc.setZ(loc.getZ() - 10);
          currentChunk = w.getChunkAt(loc);
        }
        lastChunk = currentChunk;
        w.refreshChunk((int) loc.getX(), (int) loc.getZ());
        loc = player.getLocation();
       
        // all done :)
        LogHelper.showInfo("chunksRegenerated", sender);
      }
View Full Code Here

          } catch (SQLException e){
              e.printStackTrace();
              return false;
          }

          Location l = player.getLocation();
          l.setWorld(player.getWorld());
          if (createWarp((createForOther ? args[2] : pName), args[1], ((args.length > 2) && args[2].equals("public")) ? true : false,  l)) {
            // warp successfuly created
            LogHelper.showInfo("warpCreated#####[" + args[1], sender);

            if (createForOther) {
View Full Code Here

TOP

Related Classes of org.bukkit.Location

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.