diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/MylesAndMore/tumble/Main.java | 2 | ||||
-rw-r--r-- | src/main/java/com/MylesAndMore/tumble/WorldManager.java | 5 | ||||
-rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java | 62 | ||||
-rw-r--r-- | src/main/resources/config.yml | 7 | ||||
-rw-r--r-- | src/main/resources/plugin.yml | 16 |
5 files changed, 87 insertions, 5 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/Main.java b/src/main/java/com/MylesAndMore/tumble/Main.java index 4228e16..27fadb2 100644 --- a/src/main/java/com/MylesAndMore/tumble/Main.java +++ b/src/main/java/com/MylesAndMore/tumble/Main.java @@ -2,6 +2,7 @@ package com.MylesAndMore.tumble; import com.MylesAndMore.tumble.commands.ReloadCommand; import com.MylesAndMore.tumble.api.Metrics; +import com.MylesAndMore.tumble.commands.SetWorldConfig; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin{ @@ -11,6 +12,7 @@ public class Main extends JavaPlugin{ getServer().getPluginManager().registerEvents(new EventListener(), this); // Register commands this.getCommand("reload").setExecutor(new ReloadCommand()); + this.getCommand("setworld").setExecutor(new SetWorldConfig()); // Save the default config file (packaged in the JAR) this.saveDefaultConfig(); diff --git a/src/main/java/com/MylesAndMore/tumble/WorldManager.java b/src/main/java/com/MylesAndMore/tumble/WorldManager.java new file mode 100644 index 0000000..be660b4 --- /dev/null +++ b/src/main/java/com/MylesAndMore/tumble/WorldManager.java @@ -0,0 +1,5 @@ +package com.MylesAndMore.tumble; + +public class WorldManager { + +} diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java new file mode 100644 index 0000000..8406253 --- /dev/null +++ b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java @@ -0,0 +1,62 @@ +package com.MylesAndMore.tumble.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; + +import java.util.Objects; + +public class SetWorldConfig implements CommandExecutor { + Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("tumble"); + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + // Initialize vars for their respective command arguments + String world = args[0]; + String worldType = args[1]; + // Catch for null arguments + if (args.length > 0) { + // Check if the world type is lobby + if (Objects.equals(worldType, "lobby")) { + // Check if the world is actually a world on the server + if (Bukkit.getWorld(world) != null) { + // Set the specified value of the world in the config under lobbyWorld + plugin.getConfig().set("lobbyWorld", world); + // Save said config + plugin.saveConfig(); + // Feedback + sender.sendMessage(ChatColor.GREEN + "Lobby world successfully linked: " + ChatColor.GRAY + world); + sender.sendMessage(ChatColor.GREEN + "Run /tumble:reload for the changes to take effect."); + } + // Feedback for if the world doesn't exist + else { + sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + world); + } + } + // Check if the world type is game + else if (Objects.equals(args[1], "game")) { + if (Bukkit.getWorld(world) != null) { + plugin.getConfig().set("gameWorld", world); + plugin.saveConfig(); + sender.sendMessage(ChatColor.GREEN + "Game world successfully linked: " + ChatColor.GRAY + world); + sender.sendMessage(ChatColor.GREEN + "Run /tumble:reload for the changes to take effect."); + } + else { + sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + world); + } + } + // Feedback for if lobby or game wasn't entered + else { + sender.sendMessage(ChatColor.RED + "Allowed world types are " + ChatColor.GRAY + "lobby " + ChatColor.RED + "and " + ChatColor.GRAY + "game" + ChatColor.RED + "."); + } + } + // Feedback for if no args were entered + else { + sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.GRAY + "/tumble:setworld <world> lobby|game"); + } + return true; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 232f4a7..d9b51ae 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,4 +3,9 @@ hideJoinLeaveMessages: true # Customize the message that displays when the player does not have permission to execute a command from this plugin -permissionMessage: You do not have permission to perform this command!
\ No newline at end of file +permissionMessage: You do not have permission to perform this command! + +# This tells the plugin which worlds it should use as the lobby/game worlds +# Do NOT change unless you know what you're doing!! +lobbyWorld: +gameWorld:
\ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 28423cf..f5c06e3 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,10 +10,18 @@ depend: - Multiverse-Core commands: reload: - description: Base constructor for /tumble commands - usage: /tumble <command> - permission: tumble + description: Reloads the plugin's config. + usage: /tumble:reload + permission: reload + setworld: + description: Sets a world on the server as a lobby/game world. + usage: /tumble:setworld <world> lobby|game + permission: setworld + aliases: [set-world] permissions: reload: description: Allows you to reload the plugin's config. - default: false
\ No newline at end of file + default: op + setworld: + description: Allows you to set a world on the server as a lobby/game world. + default: op |