Package org.bukkit

Examples of org.bukkit.World


    if (matches.size() < 1){
      LogHelper.showWarning("invalidWorld", sender);
      return true;
    }
   
    World world = matches.get(0);
   
    // teleport
    Teleportation.delayedTeleport(target, Spawning.getWorldSpawn(world));
   
    if (sender == target){
      LogHelper.showInfo("tpWorldSelf#####[" + world.getName(), sender);
    } else {
      LogHelper.showInfo("tpLocSuccess#####[" + Nicknames.getNick(target.getName()) + " #####to#####[" + world.getName(), sender);
      LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) + " #####tpWorldOtherNotify#####[" + world.getName(), target);
    }
   
    return true;
  }
View Full Code Here


           
            // get some variables from the CSV file
            String homeName = 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("Home for " + ownerName + " 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);

              // 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...");
View Full Code Here

    if (sender instanceof Player && Utils.checkCommandSpam((Player) sender, "cex_time")){
      return true;
    }
   
    String function = "";
    World cWorld = (sender instanceof Player ? ((Player) sender).getWorld() : Bukkit.getWorlds().get(0));
    World w = null;
    long move = 0L;
   
    if (args.length == 0){
      Commands.showCommandHelpAndUsage(sender, "cex_time", alias);
      return true;
    }
   
    if (args.length > 0){
      function = args[0];
     
      if (function.equalsIgnoreCase("view")){
        if (args.length == 2){
          List<World> matches = ClosestMatches.intellWorld(args[1], cWorld);
          if (matches.size() == 0){
            LogHelper.showWarning("invalidWorld", sender);
            return true;
          }
         
          w = matches.get(0);
        } else if (args.length == 1){
          w = cWorld;
        } else {
          Commands.showCommandHelpAndUsage(sender, "cex_time", alias);
          return true;
        }
      } else {
        if (args.length == 3){
          List<World> matches = ClosestMatches.intellWorld(args[2], cWorld);
          if (matches.size() == 0){
            LogHelper.showWarning("invalidWorld", sender);
            return true;
          }
         
          w = matches.get(0);
        } else if (args.length == 2){
          w = cWorld;
        } else {
          Commands.showCommandHelpAndUsage(sender, "cex_time", alias);
          return true;
        }
      }
    }
   
    if (w == null){
      LogHelper.showWarning("invalidWorld", sender);
      return true;
    }
   
    if (function.equalsIgnoreCase("view")){
      LogHelper.showInfo("timeCurrentTime1#####[" + Utils.parseTime(w.getTime()) + " #####timeCurrentTime2#####[" + w.getName(), sender);
      return true;
    } else if (function.equalsIgnoreCase("add")){
      if (Permissions.checkPerms(sender, "cex.time.set")){
        if (args.length == 2 || args.length == 3){
          if (!args[1].matches(CommandsEX.intRegex)){
            LogHelper.showWarning("timeAddOnlyWorksWithNumbers", sender);
            return true;
          }
         
          move = Long.parseLong(args[1]);
        }
       
        w.setTime(w.getTime() + move);
      } else {
        return true;
      }
    } else if (function.equalsIgnoreCase("set")){
      if (Permissions.checkPerms(sender, "cex.time.set")){
        if (args[1].equalsIgnoreCase("dawn") || args[1].equalsIgnoreCase("day")){
          move = 0L;
        } else if (args[1].equalsIgnoreCase("morning")){
          move = 2500L;
        } else if (args[1].equalsIgnoreCase("noon")){
          move = 6000L;
        } else if (args[1].equalsIgnoreCase("evening")){
          move = 11000L;
        } else if (args[1].equalsIgnoreCase("night")){
          move = 15000L;
        } else if (args[1].matches(CommandsEX.intRegex)){
          move = Long.parseLong(args[1]);
        } else {
          LogHelper.showWarning("timeInvalidStringValue", sender);
          return true;
        }

        w.setTime(move);
      } else {
        return true;
      }
    } else {
      Commands.showCommandHelpAndUsage(sender, "cex_time", alias);
      return true;
    }

    // tell the player and anyone with permission to see what happened
    LogHelper.showInfo("timeChanged#####[" + Utils.parseTime(w.getTime()) + " #####timeOr#####[" + w.getTime() + " #####timeTicks" + (!cWorld.equals(w) ? "#####in#####[ " + w.getName() : ""), sender);
    for (Player player : Bukkit.getOnlinePlayers()) {
      if (!player.equals(sender) && Permissions.checkPermEx(player, "cex.time.notify")) {
        LogHelper.showInfo("timeChangedBy1#####[" + w.getName() + " #####timeChangedBy2#####[" + Nicknames.getNick(sender.getName()), player);
      }
    }
    return true;
  }
View Full Code Here

      }
     
      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();
          }
        }
      }
     
      // save the database when the server is shutdown
      CommandsEX.onDisableFunctions.add("com.github.zathrus_writer.commandsex.helpers.Spawning#####onDisable");
    } else {
      for (World w : Bukkit.getWorlds()){
        worldSpawns.put(w.getName(), w.getSpawnLocation());
      }
    }
  }
View Full Code Here

    // 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

     
      if (input.contains("overworld")){
        toWorld = wBase;
      }
     
      World toSend = Bukkit.getWorld(toWorld);
      if (toSend != null){
        matches.add(toSend);
      }
    }
   
View Full Code Here

    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

   * Code taken from HomeSpawnPlus, which uses "codename_B's excellent BananaChunk plugin's code,
   * which this forces Bukkit to refresh the chunk the player is teleporting into"
   * @param l
   */
  public static void refreshMapChunk(Location l) {
    World world = l.getWorld();
      Chunk chunk = world.getChunkAt(l);
      int chunkx = chunk.getX();
      int chunkz = chunk.getZ();
      world.refreshChunk(chunkx, chunkz);
  }
View Full Code Here

   * If global spawn is enabled, this is the world players should be teleported to
   * @param world The world to set the global spawn to
   */
 
  public static void setGlobalSpawnWorld(String world){
    World w = Bukkit.getWorld(world);
   
    if (w == null){
      LogHelper.logDebug("Plugin tried to set default spawn world to " + world + " but that world does not exist");
      return;
    }
View Full Code Here

  public static Boolean run(CommandSender sender, String alias, String[] args){
    if (sender instanceof Player && Utils.checkCommandSpam((Player) sender, "cex_seed")){
      return true;
    }
   
    World world = null;

    if (args.length > 1){
      Commands.showCommandHelpAndUsage(sender, "cex_seed", alias);
      return true;
    }

    if (args.length == 0){
      if (sender instanceof Player){
        Player player = (Player) sender;
        world = player.getWorld();
      } else {
        Commands.showCommandHelpAndUsage(sender, "cex_seed", alias);
        return true;
      }
    } else {
      if (sender instanceof Player){
        List<World> matches = ClosestMatches.intellWorld(args[0], ((Player) sender).getWorld());
        if (matches.size() > 0){
          world = matches.get(0);
        }
      } else {
        Commands.showCommandHelpAndUsage(sender, "cex_seed", alias);
        return true;
      }
    }

    if (world == null){
      List<String> worldNames = new ArrayList<String>();
      for (World w : Bukkit.getWorlds()){
        worldNames.add(w.getName());
      }
      LogHelper.showInfo("invalidWorld", sender, ChatColor.RED);
      LogHelper.showInfo("seedInvalidWorldList#####[" + ChatColor.GOLD
          + Utils.implode(worldNames, ChatColor.AQUA + ", " + ChatColor.GOLD), sender);
      return true;
    }

    LogHelper.showInfo("seedShow#####[" + ChatColor.GOLD + world.getName() + ChatColor.AQUA + " #####is#####["
        + ChatColor.GOLD + world.getSeed(), sender);
    return true;
  }
View Full Code Here

TOP

Related Classes of org.bukkit.World

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.