aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/MylesAndMore/tumble/Main.java2
-rw-r--r--src/main/java/com/MylesAndMore/tumble/commands/StartGame.java56
-rw-r--r--src/main/resources/plugin.yml8
3 files changed, 66 insertions, 0 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/Main.java b/src/main/java/com/MylesAndMore/tumble/Main.java
index 27fadb2..30c8141 100644
--- a/src/main/java/com/MylesAndMore/tumble/Main.java
+++ b/src/main/java/com/MylesAndMore/tumble/Main.java
@@ -3,6 +3,7 @@ package com.MylesAndMore.tumble;
import com.MylesAndMore.tumble.commands.ReloadCommand;
import com.MylesAndMore.tumble.api.Metrics;
import com.MylesAndMore.tumble.commands.SetWorldConfig;
+import com.MylesAndMore.tumble.commands.StartGame;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin{
@@ -13,6 +14,7 @@ public class Main extends JavaPlugin{
// Register commands
this.getCommand("reload").setExecutor(new ReloadCommand());
this.getCommand("setworld").setExecutor(new SetWorldConfig());
+ this.getCommand("startgame").setExecutor(new StartGame());
// Save the default config file (packaged in the JAR)
this.saveDefaultConfig();
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
new file mode 100644
index 0000000..feec5b4
--- /dev/null
+++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
@@ -0,0 +1,56 @@
+package com.MylesAndMore.tumble.commands;
+
+import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.api.MVWorldManager;
+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;
+
+public class StartGame implements CommandExecutor {
+ // Define tumble instances
+ Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("tumble");
+ String gameWorld = plugin.getConfig().getString("gameWorld");
+
+ // Define multiverse instances
+ MultiverseCore mv = (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core");
+ MVWorldManager mvWorldManager = mv.getMVWorldManager();
+
+ @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 more than one person online
+ if (Bukkit.getOnlinePlayers().size() > 1) {
+ sender.sendMessage("Starting game...");
+ // Use multiverse to load game world
+ boolean includeLoaded = false;
+ boolean worldLoaded = (mvWorldManager.hasUnloadedWorld(gameWorld, includeLoaded));
+ if (worldLoaded) {
+ mvWorldManager.loadWorld(gameWorld);
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + gameWorld);
+ sender.sendMessage(ChatColor.RED + "Is the configuration file correct?");
+ }
+ // Generate the blocks in game world
+
+ // Move all players in lobby to the game world
+
+ // Give players game item (shovels/snowballs/etc.)
+
+ }
+ // Feedback for if there is only one person online
+ else {
+ sender.sendMessage(ChatColor.RED + "You can't start a game with yourself!");
+ }
+ }
+ // Feedback for if the sender has no perms
+ else {
+ sender.sendMessage(ChatColor.RED + plugin.getConfig().getString("permissionMessage"));
+ }
+ return true;
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index f5c06e3..71cc531 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -18,6 +18,11 @@ commands:
usage: /tumble:setworld <world> lobby|game
permission: setworld
aliases: [set-world]
+ startgame:
+ description: Force starts a Tumble match.
+ usage: /tumble:startgame
+ permission: startgame
+ aliases: [start-game]
permissions:
reload:
description: Allows you to reload the plugin's config.
@@ -25,3 +30,6 @@ permissions:
setworld:
description: Allows you to set a world on the server as a lobby/game world.
default: op
+ startgame:
+ description: Allows you to start a Tumble match.
+ default: op