Package org.bukkit

Examples of org.bukkit.Location


        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
View Full Code Here


              double z = Double.parseDouble(dataArray[5]);
              float yaw = Float.parseFloat(dataArray[6]);
              float pitch = Float.parseFloat(dataArray[7]);

              // construct the location
              Location l = new Location(world, x, y, z, yaw, pitch);

              // only convert to home if it is the players PRIMARY home as CommandsEX
              // otherwise we will try to convert it to a private warp
              if (homeName.equals(ownerName)){
                // This sets the players home, deleting all other homes IF allowMultiworldHomes is false
                Home.setHome(ownerName, l);
                // alert to console
                LogHelper.logInfo("Set home for " + ownerName + " successfully!");
              } else {
                LogHelper.logInfo("Home named " + homeName + " is not the primary home of " + ownerName);
                if (CommandsEX.loadedClasses.contains("Command_cex_warp")){
                  LogHelper.logInfo("Instead we will convert this home to a warp, owned by " + ownerName);
                  Warps.createWarp(ownerName, homeName, false, l);
                  LogHelper.logInfo("Successfully created private warp called " + homeName + " for " + ownerName);
                } else {
                  LogHelper.logInfo("Warps have not been enabled, therefore we cannot convert this home to a warp");
                }
              }
            }

            // Read next line of data
            dataRow = CSVFile.readLine();
          }
          // Close the file once all data has been read.
          CSVFile.close();

          // Copy CommandBookHomes.csv to the oldConversion folder, with a unique suffix
          Files.copy(cmdBkHomes, oldConversion);
          cmdBkHomes.delete();

          // alert to console
          LogHelper.logInfo("CommandBook Home Conversion Finished, CommandBookHomes.csv moved to old-conversions");
        } catch (FileNotFoundException e) {
          e.printStackTrace();// this should never be thrown as we check if the file exists above
        } catch (IOException e) {
          e.printStackTrace();
        }
      } else {
        // TODO move this to lang.properties
        LogHelper.logWarning("Cannot convert CommandBook warps because the SQL database is disabled");
        LogHelper.logWarning("Please enable it in the config");
      }
    }
   
    /**
     * Warp Importing
     */

    File cmdBkWarps = new File(plugin.getDataFolder() + "/convert/CommandBookWarps.csv");

    if (cmdBkWarps.exists()){
      if (CommandsEX.sqlEnabled){
        try {
          LogHelper.logInfo("Started CommandBook Warp Conversion");
          File oldConversion = new File(plugin.getDataFolder() + "/old-conversions/CommandBookWarps" + dateString + ".csv");
          // begin reading the CSV file
          BufferedReader CSVFile = new BufferedReader(new FileReader(cmdBkWarps.getAbsolutePath()));
          // Read the first line
          String dataRow = CSVFile.readLine();

          // run this, while there are more rows
          while (dataRow != null){
            // split the rows values into an array
            String[] dataArray = dataRow.split(",");

            // remove the first and last " on all arguments
            for (int i = 0; i < dataArray.length; i++){
              dataArray[i] = dataArray[i].substring(1, dataArray[i].length() - 1);
            }
           
            // get some variables from the CSV file
            String warpName = dataArray[0];
            String ownerName = dataArray[2];
            String worldName = dataArray[1];
            World world = Bukkit.getWorld(worldName);

            // if the world does not exist, don't continue
            if (world == null){
              LogHelper.logWarning("Warp named " + warpName + " could not be converted from CommandBook -> CommandsEX");
              LogHelper.logWarning("ERROR: World " + worldName + " does not exist, skipping...");
            } else {
              double x = Double.parseDouble(dataArray[3]);
              double y = Double.parseDouble(dataArray[4]);
              double z = Double.parseDouble(dataArray[5]);
              float yaw = Float.parseFloat(dataArray[6]);
              float pitch = Float.parseFloat(dataArray[7]);

              // construct the location
              Location l = new Location(world, x, y, z, yaw, pitch);

              // This creates the public warp
              Warps.createWarp(ownerName, warpName, true, l);
              // alert to console
              LogHelper.logInfo("Created warp " + warpName + " successfully!");
View Full Code Here

    // load per-world jails
    try {
      ResultSet res = SQLManager.query_res("SELECT * FROM " + SQLManager.prefix + "jails");
      while (res.next()) {
        // assemble and store location for the jail
        Location l = new Location(CommandsEX.plugin.getServer().getWorld(res.getString("world_name")), res.getDouble("x"), res.getDouble("y"), res.getDouble("z"));
        jailPlaces.put(res.getString("world_name"), l);
      }
      res.close();
    } catch (Throwable e) {
      // unable to load jail locations
View Full Code Here

    }

    // 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);
    Integer xMin = (int) (jailPoint.getX() - halfJailArea);
    Integer xMax = (int) (jailPoint.getX() + halfJailArea);
    Integer zMin = (int) (jailPoint.getZ() - halfJailArea);
    Integer zMax = (int) (jailPoint.getZ() + halfJailArea);
    jailPoint.setX(xMin + (int)(Math.random() * ((xMax - xMin) + 1)));
    jailPoint.setZ(zMin + (int)(Math.random() * ((zMax - zMin) + 1)));
   
    // teleport player to jail and freeze him upon teleportation
    try {Handler_savebackposition.omittedPlayers.add(pName);} catch (Throwable e) {}
    Teleportation.delayedTeleport(p, jailPoint, new DelayedFreeze(sender, args, command, alias, true));

View Full Code Here

   * @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 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

    LogHelper.showInfo("cannonCreated", sender);
    // 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);
    return true;
  }
View Full Code Here

        if (smited == null) {
          LogHelper.showWarning("invalidPlayer", sender);
          return true;
        }
       
        Location loc = smited.getLocation();
        // smite the player
        smited.getWorld().strikeLightningEffect(loc);
        // set last damage cause for custom death messages
        smited.setLastDamageCause(new EntityDamageEvent(smited, DamageCause.LIGHTNING, 20));
        smited.setHealth(0);
View Full Code Here

    Afk.resetPlayerIdleTime(e.getPlayer().getName());
  }
 
  @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
  public void onPlayerMove(PlayerMoveEvent e){
    Location from = e.getFrom();
    Location to = e.getTo();
   
    // don't reset their idle time for little movements
    if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ()){
      Afk.resetPlayerIdleTime(e.getPlayer().getName());
    }
  }
View Full Code Here

        String pName = player.getName();
        // check if the player has been on the server long enough
        Integer hTime = CommandsEX.getConf().getInt("homeQualifyTime");
        if (Permissions.checkPermEx(player, "cex.bypasshomequalify") || (CommandsEX.playTimes.containsKey(pName) && (CommandsEX.playTimes.get(pName) >= hTime))) {
          // all ok, let's save our home
          Location l = player.getLocation();
         
          // all done :-)
          if (setHome(pName, l)) {
            // home successfuly created
            LogHelper.showInfo("homeSetComplete#####[" + Nicknames.getNick(pName) + "!", sender);
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.