diff options
Diffstat (limited to 'src/main/java/com/MylesAndMore')
3 files changed, 20 insertions, 15 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/PluginManager.java b/src/main/java/com/MylesAndMore/tumble/PluginManager.java index 57e7c5c..29993c8 100644 --- a/src/main/java/com/MylesAndMore/tumble/PluginManager.java +++ b/src/main/java/com/MylesAndMore/tumble/PluginManager.java @@ -3,14 +3,25 @@ package com.MylesAndMore.tumble;  import com.onarandombox.MultiverseCore.MultiverseCore;  import com.onarandombox.MultiverseCore.api.MVWorldManager;  import org.bukkit.Bukkit; +import org.bukkit.entity.Player;  import org.bukkit.plugin.Plugin; +import java.util.List; +  public class PluginManager {      // Tumble plugin      public static Plugin getPlugin() {          return Bukkit.getServer().getPluginManager().getPlugin("tumble");      } +    // Tumble static methods +    public static String getPermissionMessage() { return PluginManager.getPlugin().getConfig().getString("permissionMessage"); } +    public static String getGameWorld() { return PluginManager.getPlugin().getConfig().getString("gameWorld"); } +    public static String getLobbyWorld() { return PluginManager.getPlugin().getConfig().getString("lobbyWorld"); } +    public static List<Player> getPlayersInGame() { return Bukkit.getServer().getWorld(PluginManager.getGameWorld()).getPlayers(); } +    public static List<Player> getPlayersInLobby() { return Bukkit.getServer().getWorld(PluginManager.getLobbyWorld()).getPlayers(); } + +      // Multiverse plugin      public static MultiverseCore getMV() { return (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core"); }      // Multiverse worldManager diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java index 1f0084c..6a78233 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java @@ -67,7 +67,7 @@ public class SetWorldConfig implements CommandExecutor {              }              // Feedback for if sender has no perms              else { -                sender.sendMessage(ChatColor.RED + PluginManager.getPlugin().getConfig().getString("permissionMessage")); +                sender.sendMessage(ChatColor.RED + PluginManager.getPermissionMessage());              }          }          // Feedback for if no args were entered diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 83fde65..602bfe2 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -11,26 +11,20 @@ import org.bukkit.entity.Player;  import java.util.List;  public class StartGame implements CommandExecutor { -    // Define game and lobby world vars because they get used often in this class -    String gameWorld = PluginManager.getPlugin().getConfig().getString("gameWorld"); -    String lobbyWorld = PluginManager.getPlugin().getConfig().getString("lobbyWorld"); -    // Define a method for getting players in the lobby because that also gets used a lot here -    public List<Player> getPlayersInLobby() { return Bukkit.getServer().getWorld(lobbyWorld).getPlayers(); } -      @Override      public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {          // Check if sender has perms to run command          if (sender.hasPermission("tumble.startgame")) {              // Check if there is a lobbyWorld specified in config -            if (lobbyWorld != null) { +            if (PluginManager.getLobbyWorld() != null) {                  // Check if there is more than one person in lobby -                if (getPlayersInLobby().size() > 0) { +                if (PluginManager.getPlayersInLobby().size() > 0) {                      // Check if there is a gameWorld specified in config -                    if (gameWorld != null) { +                    if (PluginManager.getGameWorld() != null) {                          sender.sendMessage("Checking world, this could take a few moments...");                          // Use multiverse to load game world                          // If the load was successful, start game -                        if (PluginManager.getMVWorldManager().loadWorld(gameWorld)) { +                        if (PluginManager.getMVWorldManager().loadWorld(PluginManager.getGameWorld())) {                              sender.sendMessage("Starting game, please wait.");                              // Generate the blocks in game world @@ -38,11 +32,11 @@ public class StartGame implements CommandExecutor {                              // While there are still players in the lobby, send them to the gameWorld                              // This is just a way of sending everybody in the lobby to the game -                            for (List<Player> playersInLobby = getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = getPlayersInLobby()) { +                            for (List<Player> playersInLobby = PluginManager.getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = PluginManager.getPlayersInLobby()) {                                  // Get a singular player from the player list                                  Player aPlayer = playersInLobby.get(0);                                  // Teleport that player to the spawn of the gameWorld -                                aPlayer.teleport(Bukkit.getWorld(gameWorld).getSpawnLocation()); +                                aPlayer.teleport(Bukkit.getWorld(PluginManager.getGameWorld()).getSpawnLocation());                              }                              // Give players game item (shovels/snowballs/etc.) @@ -54,7 +48,7 @@ public class StartGame implements CommandExecutor {                          // Note: this should not occur unless the config file was edited externally,                          // because the plugin prevents adding "worlds" that are not actually present to the config.                          else { -                            sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + gameWorld); +                            sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + PluginManager.getGameWorld());                              sender.sendMessage(ChatColor.RED + "Is the configuration file correct?");                          }                      } @@ -74,7 +68,7 @@ public class StartGame implements CommandExecutor {          }          // Feedback for if the sender has no perms          else { -            sender.sendMessage(ChatColor.RED + PluginManager.getPlugin().getConfig().getString("permissionMessage")); +            sender.sendMessage(ChatColor.RED + PluginManager.getPermissionMessage());          }          return true;      }  | 
