diff options
| author | Myles <mylesandmore9@gmail.com> | 2022-11-27 14:31:04 -0600 | 
|---|---|---|
| committer | Myles <mylesandmore9@gmail.com> | 2022-11-27 14:31:04 -0600 | 
| commit | 94899286c562537e8849ef37c1bce2ef543f4832 (patch) | |
| tree | 145d25bba20dd756756ab083901ed7061c512772 /src/main/java/com/MylesAndMore | |
| parent | 9c88a3a8aa0d0600dce16794e9c58f384da0142b (diff) | |
| download | Tumble-94899286c562537e8849ef37c1bce2ef543f4832.tar.gz Tumble-94899286c562537e8849ef37c1bce2ef543f4832.tar.bz2 Tumble-94899286c562537e8849ef37c1bce2ef543f4832.zip  | |
refactor: the PluginManager was too op, so we had to nerf it
it is now TumbleManager because I just realized bukkit already has something called PluginManager
Diffstat (limited to 'src/main/java/com/MylesAndMore')
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/EventListener.java | 10 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/Main.java | 4 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/TumbleManager.java (renamed from src/main/java/com/MylesAndMore/tumble/PluginManager.java) | 12 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java | 6 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java | 16 | ||||
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 18 | 
6 files changed, 33 insertions, 33 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/EventListener.java b/src/main/java/com/MylesAndMore/tumble/EventListener.java index c5ec8e5..1009ab3 100644 --- a/src/main/java/com/MylesAndMore/tumble/EventListener.java +++ b/src/main/java/com/MylesAndMore/tumble/EventListener.java @@ -12,15 +12,15 @@ public class EventListener implements Listener{          // On a PlayerJoinEvent, check if the config is set to hide the join/leave messages          // If true, null out the join message (which just makes it so that there is no message)          // If false, nothing will happen, and the default message will display -        if (PluginManager.getPlugin().getConfig().getBoolean("hideJoinLeaveMessages")) { +        if (TumbleManager.getPlugin().getConfig().getBoolean("hideJoinLeaveMessages")) {              event.setJoinMessage(null);          }          // If the gameWorld and lobbyWorld is not null, then check -        if (PluginManager.getPlugin().getConfig().getString("gameWorld") != null && PluginManager.getPlugin().getConfig().getString("lobbyWorld") != null) { +        if (TumbleManager.getPlugin().getConfig().getString("gameWorld") != null && TumbleManager.getPlugin().getConfig().getString("lobbyWorld") != null) {              // if the player joining is in the game world, then -            if (event.getPlayer().getWorld() == Bukkit.getWorld(PluginManager.getPlugin().getConfig().getString("gameWorld"))) { +            if (event.getPlayer().getWorld() == Bukkit.getWorld(TumbleManager.getPlugin().getConfig().getString("gameWorld"))) {                  // send them back to the lobby. -                event.getPlayer().teleport(Bukkit.getWorld(PluginManager.getPlugin().getConfig().getString("lobbyWorld")).getSpawnLocation()); +                event.getPlayer().teleport(Bukkit.getWorld(TumbleManager.getPlugin().getConfig().getString("lobbyWorld")).getSpawnLocation());              }          }      } @@ -30,7 +30,7 @@ public class EventListener implements Listener{          // On a PlayerQuitEvent, check if the config is set to hide the join/leave messages          // If true, null out the quit message (which just makes it so that there is no message)          // If false, nothing will happen, and the default message will display -        if (PluginManager.getPlugin().getConfig().getBoolean("hideJoinLeaveMessages")) { +        if (TumbleManager.getPlugin().getConfig().getBoolean("hideJoinLeaveMessages")) {              event.setQuitMessage(null);          }      } diff --git a/src/main/java/com/MylesAndMore/tumble/Main.java b/src/main/java/com/MylesAndMore/tumble/Main.java index 3761aca..ef360d9 100644 --- a/src/main/java/com/MylesAndMore/tumble/Main.java +++ b/src/main/java/com/MylesAndMore/tumble/Main.java @@ -24,11 +24,11 @@ public class Main extends JavaPlugin{          Metrics metrics = new Metrics(this, 16940);          // Check if worlds are null in config -        if (PluginManager.getPlugin().getConfig().getString("gameWorld") == null) { +        if (TumbleManager.getPlugin().getConfig().getString("gameWorld") == null) {              Bukkit.getServer().getLogger().warning("It appears you have not configured a game world for Tumble.");              Bukkit.getServer().getLogger().info("If this is your first time running the plugin, you may disregard this message.");          } -        if (PluginManager.getPlugin().getConfig().getString("lobbyWorld") == null) { +        if (TumbleManager.getPlugin().getConfig().getString("lobbyWorld") == null) {              Bukkit.getServer().getLogger().warning("It appears you have not configured a lobby world for Tumble.");              Bukkit.getServer().getLogger().info("If this is your first time running the plugin, you may disregard this message.");          } diff --git a/src/main/java/com/MylesAndMore/tumble/PluginManager.java b/src/main/java/com/MylesAndMore/tumble/TumbleManager.java index 29993c8..0b62494 100644 --- a/src/main/java/com/MylesAndMore/tumble/PluginManager.java +++ b/src/main/java/com/MylesAndMore/tumble/TumbleManager.java @@ -8,18 +8,18 @@ import org.bukkit.plugin.Plugin;  import java.util.List; -public class PluginManager { +public class TumbleManager {      // 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(); } +    public static String getPermissionMessage() { return TumbleManager.getPlugin().getConfig().getString("permissionMessage"); } +    public static String getGameWorld() { return TumbleManager.getPlugin().getConfig().getString("gameWorld"); } +    public static String getLobbyWorld() { return TumbleManager.getPlugin().getConfig().getString("lobbyWorld"); } +    public static List<Player> getPlayersInGame() { return Bukkit.getServer().getWorld(TumbleManager.getGameWorld()).getPlayers(); } +    public static List<Player> getPlayersInLobby() { return Bukkit.getServer().getWorld(TumbleManager.getLobbyWorld()).getPlayers(); }      // Multiverse plugin diff --git a/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java b/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java index 844241d..4ca26f4 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java @@ -1,6 +1,6 @@  package com.MylesAndMore.tumble.commands; -import com.MylesAndMore.tumble.PluginManager; +import com.MylesAndMore.tumble.TumbleManager;  import org.bukkit.ChatColor;  import org.bukkit.command.Command;  import org.bukkit.command.CommandExecutor; @@ -12,12 +12,12 @@ public class ReloadCommand implements CommandExecutor {          // Check if the sender has perms to run command          if (sender.hasPermission("tumble.reload")) {              // If sender does have permission, reload the plugin's config and display a confirmation message -            PluginManager.getPlugin().reloadConfig(); +            TumbleManager.getPlugin().reloadConfig();              sender.sendMessage(ChatColor.GREEN + "Tumble configuration reloaded successfully.");          }          else {              // If sender does not have permission, display them the permissionMessage from the config -            sender.sendMessage(ChatColor.RED + PluginManager.getPermissionMessage()); +            sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage());          }          return true;      } diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java index 6a78233..0a7696d 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java @@ -1,6 +1,6 @@  package com.MylesAndMore.tumble.commands; -import com.MylesAndMore.tumble.PluginManager; +import com.MylesAndMore.tumble.TumbleManager;  import org.bukkit.Bukkit;  import org.bukkit.ChatColor;  import org.bukkit.command.Command; @@ -24,11 +24,11 @@ public class SetWorldConfig implements CommandExecutor {                      // Check if the world is actually a world on the server                      if (Bukkit.getWorld(world) != null) {                          // Check if the world has already been configured -                        if (!Objects.equals(PluginManager.getPlugin().getConfig().getString("gameWorld"), world)) { +                        if (!Objects.equals(TumbleManager.getPlugin().getConfig().getString("gameWorld"), world)) {                              // Set the specified value of the world in the config under lobbyWorld -                            PluginManager.getPlugin().getConfig().set("lobbyWorld", world); +                            TumbleManager.getPlugin().getConfig().set("lobbyWorld", world);                              // Save said config -                            PluginManager.getPlugin().saveConfig(); +                            TumbleManager.getPlugin().saveConfig();                              // Feedback                              sender.sendMessage(ChatColor.GREEN + "Lobby world successfully linked: " + ChatColor.GRAY + world);                              sender.sendMessage(ChatColor.RED + "Please restart your server for the changes to take effect; reloading the plugin is insufficient!"); @@ -46,9 +46,9 @@ public class SetWorldConfig implements CommandExecutor {                  // Check if the world type is game                  else if (Objects.equals(args[1], "game")) {                      if (Bukkit.getWorld(world) != null) { -                        if (!Objects.equals(PluginManager.getPlugin().getConfig().getString("lobbyWorld"), world)) { -                            PluginManager.getPlugin().getConfig().set("gameWorld", world); -                            PluginManager.getPlugin().saveConfig(); +                        if (!Objects.equals(TumbleManager.getPlugin().getConfig().getString("lobbyWorld"), world)) { +                            TumbleManager.getPlugin().getConfig().set("gameWorld", world); +                            TumbleManager.getPlugin().saveConfig();                              sender.sendMessage(ChatColor.GREEN + "Game world successfully linked: " + ChatColor.GRAY + world);                              sender.sendMessage(ChatColor.RED + "Please restart your server for the changes to take effect; reloading the plugin is insufficient!");                          } @@ -67,7 +67,7 @@ public class SetWorldConfig implements CommandExecutor {              }              // Feedback for if sender has no perms              else { -                sender.sendMessage(ChatColor.RED + PluginManager.getPermissionMessage()); +                sender.sendMessage(ChatColor.RED + TumbleManager.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 602bfe2..4d4ff97 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -1,6 +1,6 @@  package com.MylesAndMore.tumble.commands; -import com.MylesAndMore.tumble.PluginManager; +import com.MylesAndMore.tumble.TumbleManager;  import org.bukkit.Bukkit;  import org.bukkit.ChatColor;  import org.bukkit.command.Command; @@ -16,15 +16,15 @@ public class StartGame implements CommandExecutor {          // Check if sender has perms to run command          if (sender.hasPermission("tumble.startgame")) {              // Check if there is a lobbyWorld specified in config -            if (PluginManager.getLobbyWorld() != null) { +            if (TumbleManager.getLobbyWorld() != null) {                  // Check if there is more than one person in lobby -                if (PluginManager.getPlayersInLobby().size() > 0) { +                if (TumbleManager.getPlayersInLobby().size() > 1) {                      // Check if there is a gameWorld specified in config -                    if (PluginManager.getGameWorld() != null) { +                    if (TumbleManager.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(PluginManager.getGameWorld())) { +                        if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) {                              sender.sendMessage("Starting game, please wait.");                              // Generate the blocks in game world @@ -32,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 = PluginManager.getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = PluginManager.getPlayersInLobby()) { +                            for (List<Player> playersInLobby = TumbleManager.getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = TumbleManager.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(PluginManager.getGameWorld()).getSpawnLocation()); +                                aPlayer.teleport(Bukkit.getWorld(TumbleManager.getGameWorld()).getSpawnLocation());                              }                              // Give players game item (shovels/snowballs/etc.) @@ -48,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 + PluginManager.getGameWorld()); +                            sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + TumbleManager.getGameWorld());                              sender.sendMessage(ChatColor.RED + "Is the configuration file correct?");                          }                      } @@ -68,7 +68,7 @@ public class StartGame implements CommandExecutor {          }          // Feedback for if the sender has no perms          else { -            sender.sendMessage(ChatColor.RED + PluginManager.getPermissionMessage()); +            sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage());          }          return true;      }  | 
