Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 474 lines 14 kB view raw
1package org.bukkit; 2 3import com.avaje.ebean.config.ServerConfig; 4import org.bukkit.command.CommandSender; 5import org.bukkit.command.PluginCommand; 6import org.bukkit.entity.Player; 7import org.bukkit.generator.ChunkGenerator; 8import org.bukkit.inventory.Recipe; 9import org.bukkit.map.MapView; 10import org.bukkit.plugin.PluginManager; 11import org.bukkit.plugin.ServicesManager; 12import org.bukkit.scheduler.BukkitScheduler; 13 14import java.util.List; 15import java.util.Map; 16import java.util.Set; 17import java.util.UUID; 18import java.util.logging.Logger; 19 20/** 21 * Represents a server implementation 22 */ 23public interface Server { 24 25 26 /** 27 * Gets the name of this server game version 28 * 29 * @return server game version 30 */ 31 public String getGameVersion(); 32 33 /** 34 * Used for all administrative messages, such as an operator using a command. 35 * <p> 36 * For use in {@link #broadcast(java.lang.String, java.lang.String)} 37 */ 38 public static final String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin"; 39 40 /** 41 * Used for all announcement messages, such as informing users that a player has joined. 42 * <p> 43 * For use in {@link #broadcast(java.lang.String, java.lang.String)} 44 */ 45 public static final String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user"; 46 47 /** 48 * Gets the name of this server implementation 49 * 50 * @return name of this server implementation 51 */ 52 public String getName(); 53 54 /** 55 * Gets the name of this server environment 56 * 57 * @return name of this server environment 58 */ 59 public String getServerEnvironment(); 60 61 /** 62 * Gets the version string of Poseidon. 63 * 64 * @return version of Poseidon 65 */ 66 public String getPoseidonVersion(); 67 68 69 public String getPoseidonReleaseType(); 70 71 /** 72 * Gets the version string of this server enviroment. 73 * 74 * @return version of this server implementation 75 */ 76 public String getVersion(); 77 78 /** 79 * Gets a list of all currently logged in players 80 * 81 * @return An array of Players that are currently online 82 */ 83 public Player[] getOnlinePlayers(); 84 85 /** 86 * Get the maximum amount of players which can login to this server 87 * 88 * @return The amount of players this server allows 89 */ 90 public int getMaxPlayers(); 91 92 /** 93 * Get the game port that the server runs on 94 * 95 * @return The port number of this server 96 */ 97 public int getPort(); 98 99 /** 100 * Get the view distance from this server. 101 * 102 * @return The view distance from this server. 103 */ 104 public int getViewDistance(); 105 106 /** 107 * Get the IP that this server is bound to or empty string if not specified 108 * 109 * @return The IP string that this server is bound to, otherwise empty string 110 */ 111 public String getIp(); 112 113 /** 114 * Get the name of this server 115 * 116 * @return The name of this server 117 */ 118 public String getServerName(); 119 120 /** 121 * Get an ID of this server. The ID is a simple generally alphanumeric 122 * ID that can be used for uniquely identifying this server. 123 * 124 * @return The ID of this server 125 */ 126 public String getServerId(); 127 128 /** 129 * Gets whether this server allows the Nether or not. 130 * 131 * @return Whether this server allows the Nether or not. 132 */ 133 public boolean getAllowNether(); 134 135 /** 136 * Gets whether this server has a whitelist or not. 137 * 138 * @return Whether this server has a whitelist or not. 139 */ 140 public boolean hasWhitelist(); 141 142 /** 143 * Sets the whitelist on or off 144 * 145 * @param value true if whitelist is on, otherwise false 146 */ 147 public void setWhitelist(boolean value); 148 149 /** 150 * Gets a list of whitelisted players 151 * 152 * @return Set containing all whitelisted players 153 */ 154 public Set<OfflinePlayer> getWhitelistedPlayers(); 155 156 /** 157 * Reloads the whitelist from disk 158 */ 159 public void reloadWhitelist(); 160 161 /** 162 * Broadcast a message to all players. 163 * <p> 164 * This is the same as calling {@link #broadcast(java.lang.String, java.lang.String)} to {@link #BROADCAST_CHANNEL_USERS} 165 * 166 * @param message the message 167 * @return the number of players 168 */ 169 public int broadcastMessage(String message); 170 171 /** 172 * Gets the name of the update folder. The update folder is used to safely update 173 * plugins at the right moment on a plugin load. 174 * 175 * @return The name of the update folder 176 */ 177 public String getUpdateFolder(); 178 179 /** 180 * Gets a player object by the given username 181 * <p> 182 * This method may not return objects for offline players 183 * 184 * @param name Name to look up 185 * @return Player if it was found, otherwise null 186 */ 187 public Player getPlayer(String name); 188 189 //TODO: Javadoc 190 public Player getPlayer(UUID uuid); 191 192 /** 193 * Gets the player with the exact given name, case insensitive 194 * 195 * @param name Exact name of the player to retrieve 196 * @return Player object or null if not found 197 */ 198 public Player getPlayerExact(String name); 199 200 /** 201 * Attempts to match any players with the given name, and returns a list 202 * of all possibly matches 203 * <p> 204 * This list is not sorted in any particular order. If an exact match is found, 205 * the returned list will only contain a single result. 206 * 207 * @param name Name to match 208 * @return List of all possible players 209 */ 210 public List<Player> matchPlayer(String name); 211 212 /** 213 * Gets the PluginManager for interfacing with plugins 214 * 215 * @return PluginManager for this Server instance 216 */ 217 public PluginManager getPluginManager(); 218 219 /** 220 * Gets the Scheduler for managing scheduled events 221 * 222 * @return Scheduler for this Server instance 223 */ 224 public BukkitScheduler getScheduler(); 225 226 /** 227 * Gets a services manager 228 * 229 * @return Services manager 230 */ 231 public ServicesManager getServicesManager(); 232 233 /** 234 * Gets a list of all worlds on this server 235 * 236 * @return A list of worlds 237 */ 238 public List<World> getWorlds(); 239 240 /** 241 * Creates or loads a world with the given name. 242 * If the world is already loaded, it will just return the equivalent of 243 * getWorld(name) 244 * 245 * @param name Name of the world to load 246 * @param environment Environment type of the world 247 * @return Newly created or loaded World 248 */ 249 public World createWorld(String name, World.Environment environment); 250 251 /** 252 * Creates or loads a world with the given name. 253 * If the world is already loaded, it will just return the equivalent of 254 * getWorld(name) 255 * 256 * @param name Name of the world to load 257 * @param environment Environment type of the world 258 * @param seed Seed value to create the world with 259 * @return Newly created or loaded World 260 */ 261 public World createWorld(String name, World.Environment environment, long seed); 262 263 /** 264 * Creates or loads a world with the given name. 265 * If the world is already loaded, it will just return the equivalent of 266 * getWorld(name) 267 * 268 * @param name Name of the world to load 269 * @param environment Environment type of the world 270 * @param generator ChunkGenerator to use in the construction of the new world 271 * @return Newly created or loaded World 272 */ 273 public World createWorld(String name, World.Environment environment, ChunkGenerator generator); 274 275 /** 276 * Creates or loads a world with the given name. 277 * If the world is already loaded, it will just return the equivalent of 278 * getWorld(name) 279 * 280 * @param name Name of the world to load 281 * @param environment Environment type of the world 282 * @param seed Seed value to create the world with 283 * @param generator ChunkGenerator to use in the construction of the new world 284 * @return Newly created or loaded World 285 */ 286 public World createWorld(String name, World.Environment environment, long seed, ChunkGenerator generator); 287 288 /** 289 * Unloads a world with the given name. 290 * 291 * @param name Name of the world to unload 292 * @param save Whether to save the chunks before unloading. 293 * @return Whether the action was Successful 294 */ 295 public boolean unloadWorld(String name, boolean save); 296 297 /** 298 * Unloads the given world. 299 * 300 * @param world The world to unload 301 * @param save Whether to save the chunks before unloading. 302 * @return Whether the action was Successful 303 */ 304 public boolean unloadWorld(World world, boolean save); 305 306 /** 307 * Gets the world with the given name 308 * 309 * @param name Name of the world to retrieve 310 * @return World with the given name, or null if none exists 311 */ 312 public World getWorld(String name); 313 314 /** 315 * Gets the world from the given Unique ID 316 * 317 * @param uid Unique ID of the world to retrieve. 318 * @return World with the given Unique ID, or null if none exists. 319 */ 320 public World getWorld(UUID uid); 321 322 /** 323 * Gets the map from the given item ID. 324 * 325 * @param id ID of the map to get. 326 * @return The MapView if it exists, or null otherwise. 327 */ 328 public MapView getMap(short id); 329 330 /** 331 * Create a new map with an automatically assigned ID. 332 * 333 * @param world The world the map will belong to. 334 * @return The MapView just created. 335 */ 336 public MapView createMap(World world); 337 338 /** 339 * Reloads the server, refreshing settings and plugin information 340 */ 341 public void reload(); 342 343 /** 344 * Returns the primary logger associated with this server instance 345 * 346 * @return Logger associated with this server 347 */ 348 public Logger getLogger(); 349 350 /** 351 * Gets a {@link PluginCommand} with the given name or alias 352 * 353 * @param name Name of the command to retrieve 354 * @return PluginCommand if found, otherwise null 355 */ 356 public PluginCommand getPluginCommand(String name); 357 358 /** 359 * Writes loaded players to disk 360 */ 361 public void savePlayers(); 362 363 /** 364 * Dispatches a command on the server, and executes it if found. 365 * 366 * @param cmdLine command + arguments. Example: "test abc 123" 367 * @return targetFound returns false if no target is found. 368 * @throws CommandException Thrown when the executor for the given command fails with an unhandled exception 369 */ 370 public boolean dispatchCommand(CommandSender sender, String commandLine); 371 372 /** 373 * Populates a given {@link ServerConfig} with values attributes to this server 374 * 375 * @param config ServerConfig to populate 376 */ 377 public void configureDbConfig(ServerConfig config); 378 379 /** 380 * Adds a recipe to the crafting manager. 381 * 382 * @param recipe The recipe to add. 383 * @return True to indicate that the recipe was added. 384 */ 385 public boolean addRecipe(Recipe recipe); 386 387 /** 388 * Gets a list of command aliases defined in the server properties. 389 * 390 * @return Map of aliases to command names 391 */ 392 public Map<String, String[]> getCommandAliases(); 393 394 /** 395 * Gets the radius, in blocks, around each worlds spawn point to protect 396 * 397 * @return Spawn radius, or 0 if none 398 */ 399 public int getSpawnRadius(); 400 401 /** 402 * Sets the radius, in blocks, around each worlds spawn point to protect 403 * 404 * @param value New spawn radius, or 0 if none 405 */ 406 public void setSpawnRadius(int value); 407 408 /** 409 * Gets whether the Server is in online mode or not. 410 * 411 * @return Whether the server is in online mode. 412 */ 413 public boolean getOnlineMode(); 414 415 /** 416 * Gets whether this server allows flying or not. 417 * 418 * @return Whether this server allows flying or not. 419 */ 420 public boolean getAllowFlight(); 421 422 /** 423 * Shutdowns the server, stopping everything. 424 */ 425 public void shutdown(); 426 427 /** 428 * Broadcasts the specified message to every user with the given permission 429 * 430 * @param message Message to broadcast 431 * @param permission Permission the users must have to receive the broadcast 432 * @return Amount of users who received the message 433 */ 434 public int broadcast(String message, String permission); 435 436 /** 437 * Gets the player by the given name, regardless if they are offline or online. 438 * <p> 439 * This will return an object even if the player does not exist. To this method, all players will exist. 440 * 441 * @param name Name of the player to retrieve 442 * @return OfflinePlayer object 443 */ 444 public OfflinePlayer getOfflinePlayer(String name); 445 446 /** 447 * Gets a set containing all current IPs that are banned 448 * 449 * @return Set containing banned IP addresses 450 */ 451 public Set<String> getIPBans(); 452 453 /** 454 * Bans the specified address from the server 455 * 456 * @param address IP address to ban 457 */ 458 public void banIP(String address); 459 460 /** 461 * Unbans the specified address from the server 462 * 463 * @param address IP address to unban 464 */ 465 public void unbanIP(String address); 466 467 /** 468 * Gets a set containing all banned players 469 * 470 * @return Set containing banned players 471 */ 472 public Set<OfflinePlayer> getBannedPlayers(); 473 474}