bukkit/src/main/java/org/bukkit/World.java

404 lines
13 KiB
Java
Raw Normal View History

package org.bukkit;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.bukkit.entity.Creature;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemDrop;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.PoweredMinecart;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
/**
2011-02-19 22:47:23 +00:00
* Represents a world, which may contain entities, chunks and blocks
*/
public interface World {
2011-01-03 02:59:16 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Block} at the given coordinates
2011-01-03 02:59:16 +00:00
*
* @param x X-coordinate of the block
* @param y Y-coordinate of the block
* @param z Z-coordinate of the block
2011-02-19 22:47:23 +00:00
* @return Block at the given coordinates
* @see #getBlockTypeIdAt(int, int, int) Returns the current type ID of the block
2011-01-03 02:59:16 +00:00
*/
public Block getBlockAt(int x, int y, int z);
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Block} at the given {@link Location}
*
* @param location Location of the block
* @return Block at the given location
2011-02-19 22:47:23 +00:00
* @see #getBlockTypeIdAt(org.bukkit.Location) Returns the current type ID of the block
*/
public Block getBlockAt(Location location);
/**
2011-02-19 22:47:23 +00:00
* Gets the block type ID at the given coordinates
*
* @param x X-coordinate of the block
* @param y Y-coordinate of the block
* @param z Z-coordinate of the block
2011-02-19 22:47:23 +00:00
* @return Type ID of the block at the given coordinates
* @see #getBlockAt(int, int, int) Returns a live Block object at the given location
*/
public int getBlockTypeIdAt(int x, int y, int z);
/**
2011-02-19 22:47:23 +00:00
* Gets the block type ID at the given {@link Location}
*
* @param location Location of the block
2011-02-19 22:47:23 +00:00
* @return Type ID of the block at the given location
* @see #getBlockAt(org.bukkit.Location) Returns a live Block object at the given location
*/
public int getBlockTypeIdAt(Location location);
2011-01-04 05:57:56 +08:00
/**
2011-02-19 22:47:23 +00:00
* Gets the highest non-air coordinate at the given coordinates
*
2011-01-04 05:57:56 +08:00
* @param x X-coordinate of the blocks
* @param z Z-coordinate of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Gets the highest non-air coordinate at the given {@link Location}
*
* @param location Location of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(Location location);
2011-01-03 02:59:16 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Chunk} at the given coordinates
2011-01-03 02:59:16 +00:00
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
2011-02-19 22:47:23 +00:00
* @return Chunk at the given coordinates
2011-01-03 02:59:16 +00:00
*/
public Chunk getChunkAt(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Chunk} at the given {@link Location}
*
* @param location Location of the chunk
* @return Chunk at the given location
*/
public Chunk getChunkAt(Location location);
2011-01-03 02:59:16 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Chunk} that contains the given {@link Block}
2011-01-03 02:59:16 +00:00
*
2011-02-19 22:47:23 +00:00
* @param block Block to get the containing chunk from
* @return The chunk that contains the given block
2011-01-03 02:59:16 +00:00
*/
public Chunk getChunkAt(Block block);
2011-01-03 02:59:16 +00:00
/**
2011-02-19 22:47:23 +00:00
* Checks if the specified {@link Chunk} is loaded
2011-01-03 02:59:16 +00:00
*
2011-02-19 22:47:23 +00:00
* @param chunk The chunk to check
2011-01-03 02:59:16 +00:00
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(Chunk chunk);
2011-01-21 04:58:20 +08:00
2011-02-04 20:11:20 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets an array of all loaded {@link Chunk}s
2011-02-04 20:11:20 +00:00
*
2011-02-19 22:47:23 +00:00
* @return Chunk[] containing all loaded chunks
2011-02-04 20:11:20 +00:00
*/
public Chunk[] getLoadedChunks();
2011-01-21 04:58:20 +08:00
/**
2011-02-19 22:47:23 +00:00
* Loads the specified {@link Chunk}
2011-01-21 04:58:20 +08:00
*
2011-02-19 22:47:23 +00:00
* @param chunk The chunk to load
2011-01-21 04:58:20 +08:00
*/
public void loadChunk(Chunk chunk);
/**
2011-02-19 22:47:23 +00:00
* Checks if the {@link Chunk} at the specified coordinates is loaded
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Loads the {@link Chunk} at the specified coordinates
*
* If the chunk does not exist, it will be generated.
* This method is analogous to {@link #loadChunk(int, int, boolean)} where generate is true.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
*/
public void loadChunk(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Loads the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
2011-02-19 22:47:23 +00:00
* @param generate Whether or not to generate a chunk if it doesn't already exist
* @return true if the chunk has loaded successfully, otherwise false
*/
public boolean loadChunk(int x, int z, boolean generate);
/**
2011-02-19 22:47:23 +00:00
* Safely unloads and saves the {@link Chunk} at the specified coordinates
*
* This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where safe and saveis true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
2011-02-19 22:47:23 +00:00
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Safely unloads and optionally saves the {@link Chunk} at the specified coordinates
*
* This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where save is true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
2011-02-19 22:47:23 +00:00
* @param save Whether or not to save the chunk
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save);
/**
2011-02-19 22:47:23 +00:00
* Unloads and optionally saves the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are nearby
2011-02-19 22:47:23 +00:00
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save, boolean safe);
/**
2011-02-19 22:47:23 +00:00
* Safely queues the {@link Chunk} at the specified coordinates for unloading
*
* This method is analogous to {@link #unloadChunkRequest(int, int, boolean)} where safe is true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
2011-02-19 22:47:23 +00:00
* @return true is the queue attempt was successful, otherwise false
*/
public boolean unloadChunkRequest(int x, int z);
/**
2011-02-19 22:47:23 +00:00
* Queues the {@link Chunk} at the specified coordinates for unloading
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
*/
public boolean unloadChunkRequest(int x, int z, boolean safe);
/**
2011-02-19 22:47:23 +00:00
* Drops an item at the specified {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
2011-02-19 22:47:23 +00:00
public ItemDrop dropItem(Location location, ItemStack item);
/**
2011-02-19 22:47:23 +00:00
* Drops an item at the specified {@link Location} with a random offset
*
2011-02-19 22:47:23 +00:00
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
2011-02-19 22:47:23 +00:00
public ItemDrop dropItemNaturally(Location location, ItemStack item);
/**
2011-02-19 22:47:23 +00:00
* Creates an {@link Arrow} entity at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the arrow
* @param velocity Velocity to shoot the arrow in
* @param speed Speed of the arrow. A recommend speed is 0.6
* @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method
*/
2011-02-19 22:47:23 +00:00
public Arrow spawnArrow(Location location, Vector velocity, float speed, float spread);
/**
2011-02-19 22:47:23 +00:00
* Creates a tree at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the tree
* @param type Type of the tree to create
* @return true if the tree was created successfully, otherwise false
*/
2011-02-19 22:47:23 +00:00
public boolean generateTree(Location location, TreeType type);
/**
2011-02-19 22:47:23 +00:00
* Creates a tree at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the tree
* @param type Type of the tree to create
* @param delegate A class to call for each block changed as a result of this method
* @return true if the tree was created successfully, otherwise false
*/
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
/**
2011-02-19 22:47:23 +00:00
* Creates a regular passenger minecart at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the minecart
* @return Minecart created as a result of this method
*/
2011-02-19 22:47:23 +00:00
public Minecart spawnMinecart(Location location);
/**
2011-02-19 22:47:23 +00:00
* Creates a storage minecart at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the minecart
* @return StorageMinecart created as a result of this method
*/
public StorageMinecart spawnStorageMinecart(Location loc);
/**
2011-02-19 22:47:23 +00:00
* Creates a powered minecart at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the minecart
* @return PoweredMinecart created as a result of this method
*/
public PoweredMinecart spawnPoweredMinecart(Location loc);
2011-01-07 13:59:30 -08:00
/**
2011-02-19 22:47:23 +00:00
* Creates a boat at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param location Location to spawn the boat
* @return Boat created as a result of this method
2011-01-07 13:59:30 -08:00
*/
public Boat spawnBoat(Location loc);
/**
2011-02-19 22:47:23 +00:00
* Creates a creature at the given {@link Location}
*
2011-02-19 22:47:23 +00:00
* @param loc The location to spawn the creature
* @param type The creature to spawn
* @return Resulting Creature of this method, or null if it was unsuccessful
*/
2011-02-19 22:47:23 +00:00
public Creature spawnCreature(Location loc, CreatureType type);
/**
2011-02-19 22:47:23 +00:00
* Get a list of all entities in this World
*
2011-02-19 22:47:23 +00:00
* @return A List of all Entities currently residing in this world
*/
public List<Entity> getEntities();
/**
2011-02-19 22:47:23 +00:00
* Get a list of all living entities in this World
*
2011-02-19 22:47:23 +00:00
* @return A List of all LivingEntities currently residing in this world
*/
public List<LivingEntity> getLivingEntities();
2011-01-08 02:29:42 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets the unique name of this world
2011-01-08 02:29:42 +00:00
*
* @return Name of this world
*/
public String getName();
/**
2011-02-19 22:47:23 +00:00
* Gets a semi-unique identifier for this world.
*
* While it is highly unlikely that this may be shared with another World,
* it is not guaranteed to be unique
2011-01-08 02:29:42 +00:00
*
* @return Id of this world
*/
public long getId();
/**
2011-02-19 22:47:23 +00:00
* Gets the default spawn {@link Location} of this world
*
* @return The spawn location of this world
*/
public Location getSpawnLocation();
2011-02-01 14:53:26 +00:00
/**
2011-02-19 22:47:23 +00:00
* Gets the relative in-game time of this world.
*
* The relative time is analogous to hours * 1000
2011-02-01 14:53:26 +00:00
*
2011-02-19 22:47:23 +00:00
* @return The current relative time
* @see #getFullTime() Returns an absolute time of this world
2011-02-01 14:53:26 +00:00
*/
public long getTime();
/**
2011-02-19 22:47:23 +00:00
* Sets the relative in-game time on the server.
*
* The relative time is analogous to hours * 1000
* <br /><br />
2011-02-01 14:53:26 +00:00
* Note that setting the relative time below the current relative time will
* actually move the clock forward a day. If you require to rewind time, please
* see setFullTime
*
* @param time The new relative time to set the in-game time to (in hours*1000)
2011-02-19 22:47:23 +00:00
* @see #setFullTime(long) Sets the absolute time of this world
2011-02-01 14:53:26 +00:00
*/
public void setTime(long time);
/**
2011-02-19 22:47:23 +00:00
* Gets the full in-game time on this world
2011-02-01 14:53:26 +00:00
*
2011-02-19 22:47:23 +00:00
* @return The current absolute time
* @see #getTime() Returns a relative time of this world
2011-02-01 14:53:26 +00:00
*/
public long getFullTime();
/**
2011-02-19 22:47:23 +00:00
* Sets the in-game time on the server
* <br /><br />
2011-02-01 14:53:26 +00:00
* Note that this sets the full time of the world, which may cause adverse
* effects such as breaking redstone clocks and any scheduled events
*
2011-02-19 22:47:23 +00:00
* @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world
2011-02-01 14:53:26 +00:00
*/
public void setFullTime(long time);
/**
2011-02-19 22:47:23 +00:00
* Gets the {@link Environment} type of this world
*
* @return This worlds Environment type
*/
public Environment getEnvironment();
/**
* Represents various map environment types that a world may be
*/
public enum Environment {
/**
* Represents the "normal"/"surface world" map
*/
NORMAL,
/**
* Represents a nether based map
*/
NETHER
}
}