2011-03-30 14:54:37 +01:00
|
|
|
package org.bukkit;
|
|
|
|
|
2011-11-25 03:46:47 +00:00
|
|
|
import java.io.File;
|
2011-07-23 23:18:58 -04:00
|
|
|
import java.util.Iterator;
|
2011-08-18 12:55:25 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2011-09-03 01:59:08 +01:00
|
|
|
import java.util.Set;
|
2011-08-18 12:55:25 +01:00
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.logging.Logger;
|
2012-01-30 21:32:48 +01:00
|
|
|
|
2011-08-18 12:55:25 +01:00
|
|
|
import org.bukkit.command.CommandSender;
|
2011-09-24 23:11:01 +01:00
|
|
|
import org.bukkit.command.ConsoleCommandSender;
|
2011-08-18 12:55:25 +01:00
|
|
|
import org.bukkit.command.PluginCommand;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-07-23 23:18:58 -04:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2012-02-29 13:32:33 -05:00
|
|
|
import org.bukkit.event.inventory.InventoryType;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
|
|
|
import org.bukkit.inventory.InventoryHolder;
|
2011-08-18 12:55:25 +01:00
|
|
|
import org.bukkit.inventory.Recipe;
|
|
|
|
import org.bukkit.map.MapView;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.ServicesManager;
|
2012-01-13 08:51:10 +00:00
|
|
|
import org.bukkit.plugin.messaging.Messenger;
|
2011-08-18 12:55:25 +01:00
|
|
|
import org.bukkit.scheduler.BukkitScheduler;
|
|
|
|
|
2012-01-30 21:32:48 +01:00
|
|
|
import com.avaje.ebean.config.ServerConfig;
|
|
|
|
|
2011-03-30 14:54:37 +01:00
|
|
|
/**
|
|
|
|
* Represents the Bukkit core, for version and Server singleton handling
|
|
|
|
*/
|
|
|
|
public final class Bukkit {
|
|
|
|
private static Server server;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Static class cannot be initialized.
|
|
|
|
*/
|
2011-05-14 23:22:54 +02:00
|
|
|
private Bukkit() {}
|
2011-03-30 14:54:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current {@link Server} singleton
|
|
|
|
*
|
|
|
|
* @return Server instance being ran
|
|
|
|
*/
|
|
|
|
public static Server getServer() {
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to set the {@link Server} singleton.
|
2012-01-15 14:37:30 +01:00
|
|
|
* <p />
|
2011-03-30 14:54:37 +01:00
|
|
|
* This cannot be done if the Server is already set.
|
|
|
|
*
|
|
|
|
* @param server Server instance
|
|
|
|
*/
|
|
|
|
public static void setServer(Server server) {
|
|
|
|
if (Bukkit.server != null) {
|
2011-04-01 16:04:43 +01:00
|
|
|
throw new UnsupportedOperationException("Cannot redefine singleton Server");
|
2011-03-30 14:54:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Bukkit.server = server;
|
2011-10-31 04:01:56 +00:00
|
|
|
server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
|
2011-03-30 14:54:37 +01:00
|
|
|
}
|
2011-08-18 12:55:25 +01:00
|
|
|
|
|
|
|
public static String getName() {
|
|
|
|
return server.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getVersion() {
|
|
|
|
return server.getVersion();
|
|
|
|
}
|
|
|
|
|
2011-10-31 04:01:56 +00:00
|
|
|
public static String getBukkitVersion() {
|
|
|
|
return server.getBukkitVersion();
|
|
|
|
}
|
|
|
|
|
2011-08-18 12:55:25 +01:00
|
|
|
public static Player[] getOnlinePlayers() {
|
|
|
|
return server.getOnlinePlayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getMaxPlayers() {
|
|
|
|
return server.getMaxPlayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getPort() {
|
|
|
|
return server.getPort();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getViewDistance() {
|
|
|
|
return server.getViewDistance();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getIp() {
|
|
|
|
return server.getIp();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getServerName() {
|
|
|
|
return server.getServerName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getServerId() {
|
|
|
|
return server.getServerId();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean getAllowNether() {
|
|
|
|
return server.getAllowNether();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean hasWhitelist() {
|
|
|
|
return server.hasWhitelist();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int broadcastMessage(String message) {
|
|
|
|
return server.broadcastMessage(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getUpdateFolder() {
|
|
|
|
return server.getUpdateFolder();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Player getPlayer(String name) {
|
|
|
|
return server.getPlayer(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<Player> matchPlayer(String name) {
|
|
|
|
return server.matchPlayer(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static PluginManager getPluginManager() {
|
|
|
|
return server.getPluginManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BukkitScheduler getScheduler() {
|
|
|
|
return server.getScheduler();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ServicesManager getServicesManager() {
|
|
|
|
return server.getServicesManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<World> getWorlds() {
|
|
|
|
return server.getWorlds();
|
|
|
|
}
|
|
|
|
|
2011-09-25 01:04:43 +01:00
|
|
|
public static World createWorld(WorldCreator options) {
|
|
|
|
return server.createWorld(options);
|
|
|
|
}
|
|
|
|
|
2011-08-18 12:55:25 +01:00
|
|
|
public static boolean unloadWorld(String name, boolean save) {
|
|
|
|
return server.unloadWorld(name, save);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean unloadWorld(World world, boolean save) {
|
|
|
|
return server.unloadWorld(world, save);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static World getWorld(String name) {
|
|
|
|
return server.getWorld(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static World getWorld(UUID uid) {
|
|
|
|
return server.getWorld(uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MapView getMap(short id) {
|
|
|
|
return server.getMap(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MapView createMap(World world) {
|
|
|
|
return server.createMap(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void reload() {
|
|
|
|
server.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Logger getLogger() {
|
|
|
|
return server.getLogger();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static PluginCommand getPluginCommand(String name) {
|
|
|
|
return server.getPluginCommand(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void savePlayers() {
|
|
|
|
server.savePlayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean dispatchCommand(CommandSender sender, String commandLine) {
|
|
|
|
return server.dispatchCommand(sender, commandLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void configureDbConfig(ServerConfig config) {
|
|
|
|
server.configureDbConfig(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean addRecipe(Recipe recipe) {
|
|
|
|
return server.addRecipe(recipe);
|
|
|
|
}
|
|
|
|
|
2012-02-25 12:39:10 -05:00
|
|
|
public static List<Recipe> getRecipesFor(ItemStack result) {
|
2011-07-23 23:18:58 -04:00
|
|
|
return server.getRecipesFor(result);
|
|
|
|
}
|
|
|
|
|
2012-02-25 12:39:10 -05:00
|
|
|
public static Iterator<Recipe> recipeIterator() {
|
2011-07-23 23:18:58 -04:00
|
|
|
return server.recipeIterator();
|
|
|
|
}
|
|
|
|
|
2012-02-25 12:39:10 -05:00
|
|
|
public static void clearRecipes() {
|
2011-07-23 23:18:58 -04:00
|
|
|
server.clearRecipes();
|
|
|
|
}
|
|
|
|
|
2012-02-25 12:39:10 -05:00
|
|
|
public static void resetRecipes() {
|
2011-07-23 23:18:58 -04:00
|
|
|
server.resetRecipes();
|
|
|
|
}
|
|
|
|
|
2011-08-18 12:55:25 +01:00
|
|
|
public static Map<String, String[]> getCommandAliases() {
|
|
|
|
return server.getCommandAliases();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getSpawnRadius() {
|
|
|
|
return server.getSpawnRadius();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setSpawnRadius(int value) {
|
|
|
|
server.setSpawnRadius(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean getOnlineMode() {
|
|
|
|
return server.getOnlineMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean getAllowFlight() {
|
|
|
|
return server.getAllowFlight();
|
|
|
|
}
|
2011-09-02 20:18:10 +01:00
|
|
|
|
|
|
|
public static void shutdown() {
|
|
|
|
server.shutdown();
|
|
|
|
}
|
2011-09-02 22:21:26 +01:00
|
|
|
|
2011-09-03 00:41:22 +01:00
|
|
|
public static int broadcast(String message, String permission) {
|
2011-09-02 22:21:26 +01:00
|
|
|
return server.broadcast(message, permission);
|
|
|
|
}
|
2011-09-03 00:41:22 +01:00
|
|
|
|
|
|
|
public static OfflinePlayer getOfflinePlayer(String name) {
|
|
|
|
return server.getOfflinePlayer(name);
|
|
|
|
}
|
2011-09-03 01:59:08 +01:00
|
|
|
|
2011-09-03 04:37:23 +01:00
|
|
|
public static Player getPlayerExact(String name) {
|
|
|
|
return server.getPlayerExact(name);
|
|
|
|
}
|
|
|
|
|
2011-09-03 01:59:08 +01:00
|
|
|
public static Set<String> getIPBans() {
|
|
|
|
return server.getIPBans();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void banIP(String address) {
|
|
|
|
server.banIP(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void unbanIP(String address) {
|
|
|
|
server.unbanIP(address);
|
|
|
|
}
|
2011-12-25 16:02:30 +01:00
|
|
|
|
2011-09-03 02:21:08 +01:00
|
|
|
public static Set<OfflinePlayer> getBannedPlayers() {
|
2011-09-03 02:13:37 +01:00
|
|
|
return server.getBannedPlayers();
|
|
|
|
}
|
2011-09-03 04:37:23 +01:00
|
|
|
|
|
|
|
public static void setWhitelist(boolean value) {
|
|
|
|
server.setWhitelist(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Set<OfflinePlayer> getWhitelistedPlayers() {
|
|
|
|
return server.getWhitelistedPlayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void reloadWhitelist() {
|
|
|
|
server.reloadWhitelist();
|
|
|
|
}
|
2011-09-24 23:11:01 +01:00
|
|
|
|
|
|
|
public static ConsoleCommandSender getConsoleSender() {
|
|
|
|
return server.getConsoleSender();
|
|
|
|
}
|
2011-09-25 03:27:44 +01:00
|
|
|
|
|
|
|
public static Set<OfflinePlayer> getOperators() {
|
|
|
|
return server.getOperators();
|
|
|
|
}
|
2011-11-25 03:46:47 +00:00
|
|
|
|
|
|
|
public static File getWorldContainer() {
|
|
|
|
return server.getWorldContainer();
|
|
|
|
}
|
2012-01-13 08:51:10 +00:00
|
|
|
|
|
|
|
public static Messenger getMessenger() {
|
|
|
|
return server.getMessenger();
|
|
|
|
}
|
2012-02-25 12:39:10 -05:00
|
|
|
|
|
|
|
public static boolean getAllowEnd() {
|
|
|
|
return server.getAllowEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static File getUpdateFolderFile() {
|
|
|
|
return server.getUpdateFolderFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getTicksPerAnimalSpawns() {
|
|
|
|
return server.getTicksPerAnimalSpawns();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int getTicksPerMonsterSpawns() {
|
|
|
|
return server.getTicksPerMonsterSpawns();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean useExactLoginLocation() {
|
|
|
|
return server.useExactLoginLocation();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static GameMode getDefaultGameMode() {
|
|
|
|
return server.getDefaultGameMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setDefaultGameMode(GameMode mode) {
|
|
|
|
server.setDefaultGameMode(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static OfflinePlayer[] getOfflinePlayers() {
|
|
|
|
return server.getOfflinePlayers();
|
|
|
|
}
|
2012-02-29 13:32:33 -05:00
|
|
|
|
|
|
|
public static Inventory createInventory(InventoryHolder owner, InventoryType type) {
|
|
|
|
return server.createInventory(owner, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Inventory createInventory(InventoryHolder owner, int size) {
|
|
|
|
return server.createInventory(owner, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Inventory createInventory(InventoryHolder owner, int size, String title) {
|
|
|
|
return server.createInventory(owner, size, title);
|
|
|
|
}
|
2011-03-30 14:54:37 +01:00
|
|
|
}
|