aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/main/java/com/MylesAndMore/tumble/Main.java1
-rw-r--r--src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java79
-rw-r--r--src/main/resources/config.yml26
-rw-r--r--src/main/resources/plugin.yml10
5 files changed, 107 insertions, 15 deletions
diff --git a/README.md b/README.md
index 7ac10e1..97936bc 100644
--- a/README.md
+++ b/README.md
@@ -38,9 +38,9 @@ once this list is complete and all bugs are fixed, we *should* be ready for rele
## configuration/customization
-- [ ] add two configs where you can:
- - [ ] set if you want the game to auto-start
- - [ ] set the amt of players you want the game to auto-start at
+- [x] add two configs where you can:
+ - [x] set if you want the game to auto-start
+ - [x] set the amt of players you want the game to auto-start at
- [ ] program the auto-start (just add an if statement on the PlayerJoin listener to run the StartGame method on a certain amt of players in the config)
## etc
diff --git a/src/main/java/com/MylesAndMore/tumble/Main.java b/src/main/java/com/MylesAndMore/tumble/Main.java
index 04c8053..a35a519 100644
--- a/src/main/java/com/MylesAndMore/tumble/Main.java
+++ b/src/main/java/com/MylesAndMore/tumble/Main.java
@@ -15,6 +15,7 @@ public class Main extends JavaPlugin{
this.getCommand("link").setExecutor(new SetWorldConfig());
this.getCommand("start").setExecutor(new StartGame());
this.getCommand("winlocation").setExecutor(new SetWinnerLoc());
+ this.getCommand("autostart").setExecutor(new SetAutoStart());
// Save the default config file (packaged in the JAR)
this.saveDefaultConfig();
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java b/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java
new file mode 100644
index 0000000..d64573c
--- /dev/null
+++ b/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java
@@ -0,0 +1,79 @@
+package com.MylesAndMore.tumble.commands;
+
+import com.MylesAndMore.tumble.TumbleManager;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+import java.util.Objects;
+
+public class SetAutoStart implements CommandExecutor{
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ // Check if sender has perms to run command
+ if (sender.hasPermission("autostart")) {
+ // Check if game and lobby worlds are null
+ if (TumbleManager.getGameWorld() != null) {
+ if (TumbleManager.getLobbyWorld() != null) {
+ // Check the player # argument and parse it into an int
+ int args0 = 0;
+ try {
+ args0 = Integer.parseInt(args[0]);
+ } catch (NumberFormatException nfe){
+ sender.sendMessage(ChatColor.RED + "Player amount must be a valid number.");
+ } catch (Exception e){
+ sender.sendMessage(ChatColor.RED + "Invalid player amount.");
+ }
+ // Check the amount of args entered
+ if (args.length == 2) {
+ // PlayerAmount & enable/disable were entered
+ // Check if a playerAmount between 2-8 was entered
+ if ((args0 >= 2) && (args0 <= 8)) {
+ if (Objects.equals(args[1], "enable")) {
+ // Write values to the config
+ TumbleManager.getPlugin().getConfig().set("autoStart.players", args0);
+ TumbleManager.getPlugin().getConfig().set("autoStart.enabled", args[1]);
+ TumbleManager.getPlugin().saveConfig();
+ }
+ else if (Objects.equals(args[1], "disable")) {
+ TumbleManager.getPlugin().getConfig().set("autoStart.players", args0);
+ TumbleManager.getPlugin().getConfig().set("autoStart.enabled", args[1]);
+ TumbleManager.getPlugin().saveConfig();
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + "Please enter a player amount between two and eight!");
+ }
+ }
+ else if (args.length == 1) {
+ // Only PlayerAmount was entered
+ if ((args0 >= 2) && (args0 <= 8)) {
+ TumbleManager.getPlugin().getConfig().set("autoStart.players", args0);
+ TumbleManager.getPlugin().saveConfig();
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + "Please enter a player amount between two and eight!");
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + "Please link a lobby world first!");
+ }
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + "Please link a game world first!");
+ }
+ }
+ else {
+ sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage());
+ }
+ return true;
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 0f059f2..6c5e0a6 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -10,19 +10,23 @@ permissionMessage: You do not have permission to perform this command!
# Default is mixed
gameMode: mixed
+# Customize the auto start feature of Tumble
+# Defaults are disabled and two players
+# Players can be up to 8
+autoStart:
+ enabled: false
+ players: 2
+
# Customize the place that the winner is teleported after a game ends
-# This is an optional value
-# Default is nothing
-winnerTeleport:
- # These coordinates cannot be zero! The teleport will fail if any of them are.
- # Use something like 0.5 instead.
- x:
- y:
- z:
+# Keep in mind that these coordinates cannot be zero! The teleport will fail if any of them are; use something like 0.5 instead.
+# These are optional values--defaults are nothing
+winnerTeleport:
+ x:
+ y:
+ z:
# This tells the plugin which worlds it should use as the lobby/game worlds
# Do NOT change unless you know what you're doing!!
# Will be blank by default
-lobbyWorld:
-# Game world
-gameWorld: \ No newline at end of file
+lobbyWorld:
+gameWorld: \ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 7066a27..ac394bf 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -20,13 +20,18 @@ commands:
aliases: [linkworld, link-world]
start:
description: Force starts a Tumble match with an optional game type.
- usage: '§cUsage: /tumble:start [gametype]'
+ usage: '§cUsage: /tumble:start [gameType]'
permission: start
winlocation:
description: Links the location to teleport the winning player of a game.
usage: '§cUsage: /tumble:winlocation [x] [y] [z]'
permission: winlocation
aliases: [win-location, winloc, win-loc]
+ autostart:
+ description: Configures the auto start functions of Tumble.
+ usage: '§cUsage: /tumble:autostart <playerAmount> [enable|disable]'
+ permission: autostart
+ aliases: [auto-start]
permissions:
reload:
description: Allows you to reload the plugin's config.
@@ -40,3 +45,6 @@ permissions:
winlocation:
description: Allows you to link a win location.
default: op
+ autostart:
+ description: Allows you to set the autostart details of Tumble.
+ default: op