Class World

java.lang.Object
com.welcome234.pluginsystem.World

public class World extends Object
Represents the world, containing the blocks, time, biomes and chunks.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Biome
    getBiome​(int x, boolean endDimension)
    Gets the current biome for the specified coordinate and dimension.
    static Block
    getBlock​(int x, int y, boolean endDimension)
    Gets the current block for the specified coordinate and dimension.
    static Chunk
    getBlockChunk​(int x, int y, boolean endDimension)
    Gets the chunk for the specified block coordinates and dimension.
    static Chunk
    getChunk​(int chunkX, boolean endDimension)
    Gets the chunk for the specified coordinate and dimension.
    static boolean
    Gets if the end boss was defeated
    getLoadedChunks​(boolean endDimension)
    Gets the loaded chunks for the specified dimension.
    static int
    Gets the maximum height of the world
    static int
    Gets the minimum height of the world
    static long
    Gets the seed of the world
    static String
    getSign​(int x, int y, boolean endDimension)
    Gets the sign text for the specified coordinate and dimension.
    static int
    Gets the X position spawn point of the world
    static double
    Gets the current world time in ticks.
    static boolean
    inBuildableArea​(int x)
    Deprecated.
    Worlds are now infinite, this now always returns true
    static boolean
    isChunkLoaded​(int chunkX, boolean endDimension)
    Gets if the chunk is loaded for the specified coordinate and dimension.
    static boolean
    Get if the current weather is rain
    static void
    loadChunk​(int chunkX, boolean endDimension)
    Loads the chunk for the specified coordinate and dimension.
    static void
    Saves the world to the disk
    static void
    setBiome​(int x, boolean endDimension, Biome biome)
    Sets the current biome for the specified coordinate and dimension.
    static void
    setBlock​(int x, int y, boolean endDimension, Block block)
    Sets the current block for the specified coordinate and dimension.
    static void
    setEndBossDefeated​(boolean defeated)
    Sets whether the end boss is defeated
    static void
    setExitPortalActive​(boolean active)
    Sets whether the exit portal in the end is active
    static void
    setRaining​(boolean raining)
    Sets whether if it currently raining
    static void
    setSign​(int x, int y, boolean endDimension, String message)
    Sets the sign text for the specified coordinate and dimension.
    static void
    setSpawn​(int x)
    Sets the X position spawn point of the world
    static void
    setTime​(double ticks)
    Sets the world time in ticks.
    static void
    unloadChunk​(int chunkX, boolean endDimension)
    Unloads the chunk for the specified coordinate and dimension.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getMaximumHeight

      public static int getMaximumHeight()
      Gets the maximum height of the world
      Returns:
      Maximum height in blocks
    • getMinimumHeight

      public static int getMinimumHeight()
      Gets the minimum height of the world
      Returns:
      Minimum height in blocks
    • inBuildableArea

      @Deprecated public static boolean inBuildableArea(int x)
      Deprecated.
      Worlds are now infinite, this now always returns true
      Checks if the position is in buildable area of the world.
      Parameters:
      x - X-coordinate of the world
      Returns:
      Whether in buildable area
    • setBlock

      public static void setBlock(int x, int y, boolean endDimension, Block block)
      Sets the current block for the specified coordinate and dimension.

      If the chunk containing the block is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this block
      y - Y-coordinate of this block
      endDimension - Dimension of this block (false = Overworld, true = End)
      block - Block type to set
      Throws:
      IllegalArgumentException - if block position is outside world height bounds
      IllegalArgumentException - if block is null
    • getBlock

      public static Block getBlock(int x, int y, boolean endDimension)
      Gets the current block for the specified coordinate and dimension.

      If the chunk containing the block is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this block
      y - Y-coordinate of this block
      endDimension - Dimension of this block (false = Overworld, true = End)
      Returns:
      Block type for this position
      Throws:
      IllegalArgumentException - if block position is outside world height bounds
    • setSign

      public static void setSign(int x, int y, boolean endDimension, String message)
      Sets the sign text for the specified coordinate and dimension.

      If the chunk containing the sign is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this sign
      y - Y-coordinate of this sign
      endDimension - Dimension of this sign (false = Overworld, true = End)
      message - Sign message to set
      Throws:
      IllegalArgumentException - if the block is not a sign
      IllegalArgumentException - if block position is outside world height bounds
      IllegalArgumentException - if message is null
    • getSign

      public static String getSign(int x, int y, boolean endDimension)
      Gets the sign text for the specified coordinate and dimension.

      If the chunk containing the sign is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this sign
      y - Y-coordinate of this sign
      endDimension - Dimension of this sign (false = Overworld, true = End)
      Returns:
      Sign message on this sign
      Throws:
      IllegalArgumentException - if the block is not a sign
      IllegalArgumentException - if block position is outside world height bounds
    • setBiome

      public static void setBiome(int x, boolean endDimension, Biome biome)
      Sets the current biome for the specified coordinate and dimension.

      Biomes changes only update after a players chunk reloads.

      If the chunk containing the biome is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this biome
      endDimension - Dimension of this biome (false = Overworld, true = End)
      biome - Biome type to set
      Throws:
      IllegalArgumentException - if biome is null
    • getBiome

      public static Biome getBiome(int x, boolean endDimension)
      Gets the current biome for the specified coordinate and dimension.

      If the chunk containing the biome is not loaded, it will be automatically loaded when calling this.

      Parameters:
      x - X-coordinate of this block
      endDimension - Dimension of this biome (false = Overworld, true = End)
      Returns:
      Biome type for this position
    • getLoadedChunks

      public static ArrayList<Chunk> getLoadedChunks(boolean endDimension)
      Gets the loaded chunks for the specified dimension.
      Parameters:
      endDimension - Dimension of the chunks (false = Overworld, true = End)
      Returns:
      Array list of chunks
    • isChunkLoaded

      public static boolean isChunkLoaded(int chunkX, boolean endDimension)
      Gets if the chunk is loaded for the specified coordinate and dimension.
      Parameters:
      chunkX - X-coordinate of the chunk
      endDimension - Dimension of the chunk (false = Overworld, true = End)
      Returns:
      Whether chunk is loaded
    • getChunk

      public static Chunk getChunk(int chunkX, boolean endDimension)
      Gets the chunk for the specified coordinate and dimension.
      Parameters:
      chunkX - X-coordinate of the chunk
      endDimension - Dimension of the chunk (false = Overworld, true = End)
      Returns:
      Chunk instance
    • getBlockChunk

      public static Chunk getBlockChunk(int x, int y, boolean endDimension)
      Gets the chunk for the specified block coordinates and dimension.
      Parameters:
      x - Block X-coordinate
      y - Block Y-coordinate
      endDimension - Dimension of the chunk (false = Overworld, true = End)
      Returns:
      Chunk instance
      Throws:
      IllegalArgumentException - if block position is outside world height bounds
    • loadChunk

      public static void loadChunk(int chunkX, boolean endDimension)
      Loads the chunk for the specified coordinate and dimension.

      The chunk will remain always loaded until unloaded by a plugin

      Parameters:
      chunkX - X-coordinate of the chunk
      endDimension - Dimension of the chunk (false = Overworld, true = End)
    • unloadChunk

      public static void unloadChunk(int chunkX, boolean endDimension)
      Unloads the chunk for the specified coordinate and dimension.
      Parameters:
      chunkX - X-coordinate of the chunk
      endDimension - Dimension of the chunk (false = Overworld, true = End)
      Throws:
      IllegalStateException - if chunk is not loaded
    • setRaining

      public static void setRaining(boolean raining)
      Sets whether if it currently raining
      Parameters:
      raining - Whether it is raining
    • isRaining

      public static boolean isRaining()
      Get if the current weather is rain
      Returns:
      Whether it is raining
    • setTime

      public static void setTime(double ticks)
      Sets the world time in ticks.
      Parameters:
      ticks - Time in ticks
    • getTime

      public static double getTime()
      Gets the current world time in ticks.
      Returns:
      Time in ticks
    • getSeed

      public static long getSeed()
      Gets the seed of the world
      Returns:
      World seed
    • getEndBossDefeated

      public static boolean getEndBossDefeated()
      Gets if the end boss was defeated
      Returns:
      Whether defeated
    • setEndBossDefeated

      public static void setEndBossDefeated(boolean defeated)
      Sets whether the end boss is defeated
      Parameters:
      defeated - Whether defeated
    • getSpawn

      public static int getSpawn()
      Gets the X position spawn point of the world
      Returns:
      World spawn point
    • setSpawn

      public static void setSpawn(int x)
      Sets the X position spawn point of the world
      Parameters:
      x - Spawn X-coordinate
    • setExitPortalActive

      public static void setExitPortalActive(boolean active)
      Sets whether the exit portal in the end is active

      If the chunk containing the exit portal is not loaded, it will be automatically loaded when calling this.

      Parameters:
      active - Whether active
    • save

      public static void save()
      Saves the world to the disk