geforkt von Mirrors/Paper
Made Server a singleton, accessible by Bukkit.getServer().
By: Dinnerbone <dinnerbone@dinnerbone.com>
Dieser Commit ist enthalten in:
Ursprung
9d24880b0e
Commit
41bcf14b27
39
paper-api/src/main/java/org/bukkit/Bukkit.java
Normale Datei
39
paper-api/src/main/java/org/bukkit/Bukkit.java
Normale Datei
@ -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;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren