diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-30 14:54:37 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-04-01 16:09:23 +0100 |
commit | a6b67158dc49c71f46bd2da9b83254fd44655f14 (patch) | |
tree | 32f52eff2197d3a6d8c058c3c3fa2c7d62a1fc9d /src/main | |
parent | 9c1210e31246ebaac650db5ce3ce1c776ca54ba6 (diff) | |
download | bukkit-a6b67158dc49c71f46bd2da9b83254fd44655f14.tar bukkit-a6b67158dc49c71f46bd2da9b83254fd44655f14.tar.gz bukkit-a6b67158dc49c71f46bd2da9b83254fd44655f14.tar.lz bukkit-a6b67158dc49c71f46bd2da9b83254fd44655f14.tar.xz bukkit-a6b67158dc49c71f46bd2da9b83254fd44655f14.zip |
Made Server a singleton, accessible by Bukkit.getServer().
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/Bukkit.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java new file mode 100644 index 00000000..18c03f36 --- /dev/null +++ b/src/main/java/org/bukkit/Bukkit.java @@ -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; + } +} |