aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java')
-rw-r--r--src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java
index 505af0d..fe663f9 100644
--- a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java
+++ b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java
@@ -1,34 +1,36 @@
package com.MylesAndMore.tumble.commands;
+import com.MylesAndMore.tumble.PluginManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.World;
+import org.bukkit.WorldType;
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) {
+ if (args.length == 2) {
// Check if sender has perms to run command
- if (!sender.hasPermission("tumble.setworld")){
+ if (sender.hasPermission("tumble.setworld")){
+ // Initialize vars for their respective command arguments
+ String world = args[0];
+ String worldType = args[1];
// 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);
+ PluginManager.getPlugin().getConfig().set("lobbyWorld", world);
// Save said config
- plugin.saveConfig();
+ PluginManager.getPlugin().saveConfig();
+ // Add the world to the multiverse world manager
+ PluginManager.getWorldManager().addWorld(world, World.Environment.NORMAL, null, WorldType.FLAT, false, null);
// 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.");
@@ -41,8 +43,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) {
- plugin.getConfig().set("gameWorld", world);
- plugin.saveConfig();
+ PluginManager.getPlugin().getConfig().set("gameWorld", world);
+ PluginManager.getPlugin().saveConfig();
+ PluginManager.getWorldManager().addWorld(world, World.Environment.NORMAL, null, WorldType.FLAT, false, null);
sender.sendMessage(ChatColor.GREEN + "Game world successfully linked: " + ChatColor.GRAY + world);
sender.sendMessage(ChatColor.GREEN + "Run /tumble:reload for the changes to take effect.");
}
@@ -57,7 +60,7 @@ public class SetWorldConfig implements CommandExecutor {
}
// Feedback for if sender has no perms
else {
- sender.sendMessage(ChatColor.RED + plugin.getConfig().getString("permissionMessage"));
+ sender.sendMessage(ChatColor.RED + PluginManager.getPlugin().getConfig().getString("permissionMessage"));
}
}
// Feedback for if no args were entered