mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-05 16:49:39 +00:00
Made Server a singleton, accessible by Bukkit.getServer().
This commit is contained in:
parent
9c1210e312
commit
a6b67158dc
1 changed files with 39 additions and 0 deletions
39
src/main/java/org/bukkit/Bukkit.java
Normal file
39
src/main/java/org/bukkit/Bukkit.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
package org.bukkit;
|
||||
|
||||
/**
|
||||
* Represents the Bukkit core, for version and Server singleton handling
|
||||
*/
|
||||
public final class Bukkit {
|
||||
private static Server server;
|
||||
|
||||
/**
|
||||
* Static class cannot be initialized.
|
||||
*/
|
||||
private Bukkit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current {@link Server} singleton
|
||||
*
|
||||
* @return Server instance being ran
|
||||
*/
|
||||
public static Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to set the {@link Server} singleton.
|
||||
*
|
||||
* This cannot be done if the Server is already set.
|
||||
*
|
||||
* @param server Server instance
|
||||
*/
|
||||
public static void setServer(Server server) {
|
||||
if (Bukkit.server != null) {
|
||||
throw new UnsupportedOperationException("Cannot redelcare singleton Server");
|
||||
}
|
||||
|
||||
Bukkit.server = server;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue