From 2d112edee51f974d265048a6dab3ca629694d502 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sat, 8 Oct 2011 11:42:35 -0600 Subject: [PATCH] Start writing the Core API --- .../MultiverseCore/MultiverseCore.java | 12 +-- .../onarandombox/MultiverseCore/api/Core.java | 87 +++++++++++++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/api/Core.java diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 04d44971..3e69abb1 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore; import com.fernferret.allpay.AllPay; import com.fernferret.allpay.GenericBank; +import com.onarandombox.MultiverseCore.api.Core; import com.onarandombox.MultiverseCore.api.MVPlugin; import com.onarandombox.MultiverseCore.commands.*; import com.onarandombox.MultiverseCore.configuration.DefaultConfig; @@ -42,7 +43,7 @@ import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; -public class MultiverseCore extends JavaPlugin implements MVPlugin { +public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { public static boolean outdatedPluginFound = false; private static int Protocol = 1; @@ -64,6 +65,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin { } + @Override public int getProtocolVersion() { return MultiverseCore.Protocol; } @@ -356,13 +358,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin { log(Level.INFO, "- Disabled"); } - /** - * Grab the players session if one exists, otherwise create a session then return it. - * - * @param player - * - * @return - */ + @Override public MVPlayerSession getPlayerSession(Player player) { if (this.playerSessions.containsKey(player.getName())) { return this.playerSessions.get(player.getName()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/Core.java b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java new file mode 100644 index 00000000..6de23f19 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/api/Core.java @@ -0,0 +1,87 @@ +/****************************************************************************** + * Multiverse 2 Copyright (c) the Multiverse Team 2011. * + * Multiverse 2 is licensed under the BSD License. * + * For more information please check the README.md file included * + * with this project. * + ******************************************************************************/ + +package com.onarandombox.MultiverseCore.api; + +import com.fernferret.allpay.GenericBank; +import com.onarandombox.MultiverseCore.utils.MVMessaging; +import com.onarandombox.MultiverseCore.utils.MVPermissions; +import com.onarandombox.MultiverseCore.utils.MVPlayerSession; +import com.onarandombox.MultiverseCore.utils.SafeTTeleporter; +import com.pneumaticraft.commandhandler.CommandHandler; +import org.bukkit.entity.Player; +import org.bukkit.util.config.Configuration; + +/** + * Multiverse 2 Core API + *

+ * This api contains a bunch of useful things you can get out of Multiverse in general! + */ +public interface Core { + /** + * Gets the Multiverse config file. + * + * @return The Multiverse config file. + */ + public Configuration getConfig(); + + /** + * Gets the Banking system that Multiverse-Core has hooked into. + * + * @return A {@link GenericBank} that can be used for payments. + */ + public GenericBank getBank(); + + /** + * Reloads the Multiverse Configuration files: + * worlds.yml and config.yml. + */ + public void loadConfigs(); + + /** + * Gets the Multiverse message system. This allows you to send messages + * to users at specified intervals. + * + * @return The loaded {@link MVMessaging}. + */ + public MVMessaging getMessaging(); + + /** + * Gets the {@link MVPlayerSession} for the given player. + * This will also create a player session if one does not exist + * for a player. + * + * @param player The player's session to grab. + * + * @return The corresponding {@link MVPlayerSession}. + */ + public MVPlayerSession getPlayerSession(Player player); + + /** + * Gets the instantiated Safe-T-Teleporter for performing + * safe teleports. + * + * @return A non-null {@link SafeTTeleporter}. + */ + public SafeTTeleporter getTeleporter(); + + /** + * Multiverse uses an advanced permissions setup, this object + * simplifies getting/setting permissions. + * + * @return A non-null {@link MVPermissions}. + */ + public MVPermissions getMVPerms(); + + /** + * Multiverse uses {@link CommandHandler} to make adding and using commands + * a piece of cake. + * + * @return A non-null {@link CommandHandler}. + */ + public CommandHandler getCommandHandler(); +}