summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java53
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Join.java2
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java2
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java18
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java45
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java55
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java21
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Start.java2
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java2
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java9
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java5
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java5
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java20
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java46
14 files changed, 153 insertions, 132 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
index 61d0c46..2ca998e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
@@ -2,11 +2,10 @@ package net.tylermurphy.hideAndSeek.command;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
-import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@@ -18,7 +17,7 @@ import java.util.Map;
import java.util.function.Consumer;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Debug implements ICommand {
@@ -26,41 +25,43 @@ public class Debug implements ICommand {
private Inventory debugMenu;
public void execute(Player sender, String[] args) {
- if(debugMenu == null) createMenu();
+ if(args.length < 1) args = new String[]{""};
+ if(debugMenu == null) createMenu(args[0]);
sender.openInventory(debugMenu);
}
- private void createMenu(){
+ private void createMenu(String mapname){
+ net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(mapname);
debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
+ if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addHider(player);
- PlayerLoader.loadHider(player, Main.getInstance().getGame().getGameWorld());
+ PlayerLoader.loadHider(player, Main.getInstance().getGame().getCurrentMap());
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
+ if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSeeker(player);
- PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getGameWorld());
+ PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getCurrentMap());
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
+ if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSpectator(player);
- PlayerLoader.loadSpectator(player, Main.getInstance().getGame().getGameWorld());
+ PlayerLoader.loadSpectator(player, Main.getInstance().getGame().getCurrentMap());
}));
debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
Main.getInstance().getBoard().remove(player);
PlayerLoader.unloadPlayer(player);
- player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
+ player.teleport(exitPosition);
}));
debugMenu.setItem(4, createOption(4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
@@ -68,14 +69,30 @@ public class Debug implements ICommand {
}
}));
debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
+ if(map == null) {
+ player.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
+ if(map.getSpawn().getWorld() == null) map.getWorldLoader().loadMap();
+ }
+ player.teleport(map.getSpawn());
+ }));
+ debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
+ if(map == null) {
+ player.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ player.teleport(map.getLobby());
+ }));
+ debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition)));
+ debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
+ if(map == null) {
+ player.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
}
- player.teleport(new Location(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
+ PlayerLoader.openBlockHuntPicker(player, map);
}));
- debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(), lobbyPosition.getY(), lobbyPosition.getZ()))));
- debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()))));
- debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, PlayerLoader::openBlockHuntPicker));
debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
}
@@ -100,7 +117,7 @@ public class Debug implements ICommand {
}
public String getUsage() {
- return "";
+ return "<*map>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
index 941cec0..cf8944e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
@@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
index 092ff50..fee7ca8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
@@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
index 1e66395..4758666 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
@@ -20,8 +20,9 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@@ -42,21 +43,26 @@ public class SaveMap implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
- World world = Bukkit.getServer().getWorld(spawnWorld);
+ World world = map.getSpawn().getWorld();
if (world == null) {
- throw new RuntimeException("Unable to get world: " + spawnWorld);
+ throw new RuntimeException("Unable to get spawn world");
}
world.save();
BukkitRunnable runnable = new BukkitRunnable() {
public void run() {
sender.sendMessage(
- Main.getInstance().getGame().getWorldLoader().save()
+ map.getWorldLoader().save()
);
runningBackup = false;
}
@@ -70,7 +76,7 @@ public class SaveMap implements ICommand {
}
public String getUsage() {
- return "";
+ return "<map>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
index b456e6a..08a8c87 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
@@ -20,6 +20,8 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@@ -34,16 +36,21 @@ public class SetBorder implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if (spawnPosition == null) {
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
if (args.length < 3) {
- worldBorderEnabled = false;
+ map.setWorldBorderData(0, 0, 0, 0, 0);
addToConfig("worldBorder.enabled",false);
saveConfig();
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
- Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
+ Main.getInstance().getGame().getCurrentMap().getWorldBorder().resetWorldBorder();
return;
}
int num,delay,change;
@@ -67,28 +74,16 @@ public class SetBorder implements ICommand {
sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
return;
}
- Vector vec = new Vector();
- vec.setX(sender.getLocation().getBlockX());
- vec.setY(0);
- vec.setZ(sender.getLocation().getBlockZ());
- if (spawnPosition.distance(vec) > 100) {
- sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
- return;
- }
- worldBorderPosition = vec;
- worldBorderSize = num;
- worldBorderDelay = delay;
- worldBorderChange = change;
- worldBorderEnabled = true;
- addToConfig("worldBorder.x", worldBorderPosition.getBlockX());
- addToConfig("worldBorder.z", worldBorderPosition.getBlockZ());
- addToConfig("worldBorder.delay", worldBorderDelay);
- addToConfig("worldBorder.size", worldBorderSize);
- addToConfig("worldBorder.enabled", true);
- addToConfig("worldBorder.move", worldBorderChange);
+ map.setWorldBorderData(
+ sender.getLocation().getBlockX(),
+ sender.getLocation().getBlockZ(),
+ num,
+ delay,
+ change
+ );
+ Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
- saveConfig();
- Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
+ map.getWorldBorder().resetWorldBorder();
}
public String getLabel() {
@@ -96,7 +91,7 @@ public class SetBorder implements ICommand {
}
public String getUsage() {
- return "<size> <delay> <move>";
+ return "<map> <size> <delay> <move>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
index 434e4a6..c22e3a6 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
@@ -20,6 +20,8 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
@@ -33,11 +35,16 @@ public class SetBounds implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if (spawnPosition == null) {
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
- if (!sender.getWorld().getName().equals(spawnWorld)) {
+ if (!sender.getWorld().getName().equals(map.getSpawn().getWorld().getName())) {
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
return;
}
@@ -46,37 +53,35 @@ public class SetBounds implements ICommand {
return;
}
boolean first = true;
- if (saveMinX != 0 && saveMinZ != 0 && saveMaxX != 0 && saveMaxZ != 0) {
- saveMinX = 0; saveMinZ= 0; saveMaxX = 0; saveMaxZ = 0;
+ int bxs = map.getBoundsMin().getBlockX();
+ int bzs = map.getBoundsMin().getBlockZ();
+ int bxl = map.getBoundsMax().getBlockX();
+ int bzl = map.getBoundsMax().getBlockZ();
+ if (bxs != 0 && bzs != 0 && bxl != 0 && bzl != 0) {
+ bxs = bzs = bxl = bzl = 0;
}
- if (saveMaxX == 0) {
- addToConfig("bounds.max.x", sender.getLocation().getBlockX());
- saveMaxX = sender.getLocation().getBlockX();
- } else if (saveMaxX < sender.getLocation().getBlockX()) {
+ if (bxl == 0) {
+ bxl = sender.getLocation().getBlockX();
+ } else if (map.getBoundsMax().getX() < sender.getLocation().getBlockX()) {
first = false;
- addToConfig("bounds.max.x", sender.getLocation().getBlockX());
- addToConfig("bounds.min.x", saveMaxX);
- saveMinX = saveMaxX;
- saveMaxX = sender.getLocation().getBlockX();
+ bxs = bxl;
+ bxl = sender.getLocation().getBlockX();
} else {
first = false;
- addToConfig("bounds.min.x", sender.getLocation().getBlockX());
- saveMinX = sender.getLocation().getBlockX();
+ bxs = sender.getLocation().getBlockX();
}
- if (saveMaxZ == 0) {
- addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
- saveMaxZ = sender.getLocation().getBlockZ();
- } else if (saveMaxZ < sender.getLocation().getBlockZ()) {
+ if (bzl == 0) {
+ bzl = sender.getLocation().getBlockZ();
+ } else if (map.getBoundsMax().getX() < sender.getLocation().getBlockZ()) {
first = false;
- addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
- addToConfig("bounds.min.z", saveMaxZ);
- saveMinZ = saveMaxZ;
- saveMaxZ = sender.getLocation().getBlockZ();
+ bzs = bzl;
+ bzl = sender.getLocation().getBlockZ();
} else {
first = false;
- addToConfig("bounds.min.z", sender.getLocation().getBlockZ());
- saveMinZ = sender.getLocation().getBlockZ();
+ bzs = sender.getLocation().getBlockZ();
}
+ map.setBoundMin(bxs, bzs);
+ map.setBoundMax(bxl, bzl);
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
saveConfig();
}
@@ -86,7 +91,7 @@ public class SetBounds implements ICommand {
}
public String getUsage() {
- return "";
+ return "<map>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
index e961188..ef052aa 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
@@ -20,6 +20,8 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.io.File;
@@ -33,16 +35,20 @@ public class Setup implements ICommand {
String msg = message("SETUP").toString();
int count = 0;
-
- if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_GAME");
count++;
}
- if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
+ if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_LOBBY");
count++;
}
- if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0) {
+ if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
count++;
}
@@ -50,12 +56,13 @@ public class Setup implements ICommand {
msg = msg + "\n" + message("SETUP_EXIT");
count++;
}
- if (saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) {
+ if (map.getBoundsMin().getBlockX() == 0 || map.getBoundsMin().getBlockZ() == 0 ||
+ map.getBoundsMax().getBlockX() == 0 || map.getBoundsMax().getBlockX() == 0) {
msg = msg + "\n" + message("SETUP_BOUNDS");
count++;
}
if (mapSaveEnabled) {
- File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + Main.getInstance().getGame().getGameWorld());
+ File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + map.getSpawn().getWorld().getName());
if (!destenation.exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
count++;
@@ -73,7 +80,7 @@ public class Setup implements ICommand {
}
public String getUsage() {
- return "";
+ return "<map>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
index 18bcbba..2d847d5 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
@@ -34,7 +34,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Start implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
index 9280b53..22ab3fb 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
@@ -30,7 +30,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Stop implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
index 93c0d8c..a616297 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
@@ -28,9 +28,14 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetExitLocation implements ICommand {
public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.EXIT, vector -> {
+ LocationUtils.setLocation(sender, Locations.EXIT, args[0], map -> {
+ addToConfig("exit.x", sender.getLocation().getBlockX());
+ addToConfig("exit.y", sender.getLocation().getBlockY());
+ addToConfig("exit.z", sender.getLocation().getBlockZ());
+ addToConfig("exit.world", sender.getLocation().getWorld().getName());
+ exitPosition = sender.getLocation();
exitWorld = sender.getLocation().getWorld().getName();
- exitPosition = vector;
+ saveConfig();
});
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
index eb228f9..4eb5462 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
@@ -29,9 +29,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetLobbyLocation implements ICommand {
public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.LOBBY, vector -> {
- lobbyWorld = sender.getLocation().getWorld().getName();
- lobbyPosition = vector;
+ LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
+ map.setLobby(sender.getLocation());
});
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
index c6c3ccb..59bec64 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
@@ -10,9 +10,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetSeekerLobbyLocation implements ICommand {
public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.SEEKER, vector -> {
- seekerLobbyWorld = sender.getLocation().getWorld().getName();
- seekerLobbyPosition = vector;
+ LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
+ map.setSeekerLobby(sender.getLocation());
});
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
index 5ecfb8d..12ac232 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
@@ -19,11 +19,11 @@
package net.tylermurphy.hideAndSeek.command.location;
-import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.ICommand;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import org.bukkit.entity.Player;
+import org.bukkit.util.Vector;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@@ -31,19 +31,19 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetSpawnLocation implements ICommand {
public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.GAME, vector -> {
- if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) {
+ LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> {
+
+ if (map.isWorldBorderEnabled() &&
+ new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
throw new RuntimeException("World border not enabled or not in valid position!");
}
- if (!sender.getLocation().getWorld().getName().equals(spawnWorld)) {
- Main.getInstance().getGame().getWorldLoader().unloadMap();
- Main.getInstance().getGame().getWorldLoader().setNewMap(sender.getLocation().getWorld().getName());
- }
+ map.setSpawn(sender.getLocation());
- spawnWorld = sender.getLocation().getWorld().getName();
- spawnPosition = vector;
+ if (!sender.getLocation().getWorld().getName().equals(map.getSpawn().getWorld().getName()) && mapSaveEnabled) {
+ map.getWorldLoader().unloadMap();
+ }
});
}
@@ -52,7 +52,7 @@ public class SetSpawnLocation implements ICommand {
}
public String getUsage() {
- return "";
+ return "<map>";
}
public String getDescription() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java
index 50d1776..2655805 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java
@@ -1,12 +1,11 @@
package net.tylermurphy.hideAndSeek.command.location.util;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Location;
-import org.bukkit.World;
import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
@@ -18,42 +17,31 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
*/
public class LocationUtils {
- /**
- * Provides a vector for a player
- * @param player the player to create the vector for
- * @return the vector
- */
- private static @Nullable Vector vector(Player player) {
+ public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer<Map> consumer) {
+
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
- return null;
+ return;
}
if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
- return null;
+ return;
}
- Location loc = player.getLocation();
- return new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
- }
-
- public static void setLocation(Player player, Locations place, @Nullable Consumer<Vector> consumer) {
- Vector vec = vector(player);
-
- World world = player.getLocation().getWorld();
- if(world == null) {
- throw new RuntimeException("Unable to get world: " + spawnWorld);
+ Map map = null;
+ if(mapName != null) {
+ map = Maps.getMap(mapName);
+ if (map == null) {
+ player.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
}
- consumer.accept(vec);
-
+ consumer.accept(map);
+ if(map != null)
+ Maps.setMap(mapName, map);
player.sendMessage(messagePrefix + message(place.message()));
- addToConfig(place.path("x"), vec.getX());
- addToConfig(place.path("y"), vec.getY());
- addToConfig(place.path("z"), vec.getZ());
- addToConfig(place.path("world"), player.getLocation().getWorld().getName());
- saveConfig();
}
} \ No newline at end of file