start adding multi map support
This commit is contained in:
parent
bdbb4a2c5c
commit
667a365e7b
32 changed files with 654 additions and 396 deletions
|
@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
board.removeBoard(player);
|
board.removeBoard(player);
|
||||||
PlayerLoader.unloadPlayer(player);
|
PlayerLoader.unloadPlayer(player);
|
||||||
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
if(!Objects.equals(exitWorld, ""))
|
||||||
|
player.teleport(exitPosition);
|
||||||
});
|
});
|
||||||
|
|
||||||
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
|
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
|
||||||
|
|
|
@ -2,11 +2,10 @@ package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
import com.cryptomorin.xseries.XMaterial;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
@ -18,7 +17,7 @@ import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
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 {
|
public class Debug implements ICommand {
|
||||||
|
|
||||||
|
@ -26,41 +25,43 @@ public class Debug implements ICommand {
|
||||||
private Inventory debugMenu;
|
private Inventory debugMenu;
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
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);
|
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 = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
|
||||||
debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
|
debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
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)
|
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
||||||
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
|
debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
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)
|
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
||||||
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
|
debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
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 -> {
|
debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
|
||||||
Main.getInstance().getBoard().remove(player);
|
Main.getInstance().getBoard().remove(player);
|
||||||
PlayerLoader.unloadPlayer(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 -> {
|
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){
|
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 -> {
|
debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
if(map == null) {
|
||||||
if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
|
player.sendMessage(errorPrefix + message("INVALID_MAP"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
player.teleport(new Location(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
if(mapSaveEnabled) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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)));
|
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() {
|
public String getUsage() {
|
||||||
return "";
|
return "<*map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
public class Join implements ICommand {
|
public class Join implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().isNotSetup()) {
|
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
public class Leave implements ICommand {
|
public class Leave implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().isNotSetup()) {
|
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
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 net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
@ -42,21 +43,26 @@ public class SaveMap implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
||||||
return;
|
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"));
|
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
|
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
|
||||||
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
|
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
|
||||||
World world = Bukkit.getServer().getWorld(spawnWorld);
|
World world = map.getSpawn().getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
throw new RuntimeException("Unable to get world: " + spawnWorld);
|
throw new RuntimeException("Unable to get spawn world");
|
||||||
}
|
}
|
||||||
world.save();
|
world.save();
|
||||||
BukkitRunnable runnable = new BukkitRunnable() {
|
BukkitRunnable runnable = new BukkitRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(
|
sender.sendMessage(
|
||||||
Main.getInstance().getGame().getWorldLoader().save()
|
map.getWorldLoader().save()
|
||||||
);
|
);
|
||||||
runningBackup = false;
|
runningBackup = false;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +76,7 @@ public class SaveMap implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
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 net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
@ -34,16 +36,21 @@ public class SetBorder implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
||||||
return;
|
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"));
|
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
worldBorderEnabled = false;
|
map.setWorldBorderData(0, 0, 0, 0, 0);
|
||||||
addToConfig("worldBorder.enabled",false);
|
addToConfig("worldBorder.enabled",false);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
|
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
|
||||||
Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
|
Main.getInstance().getGame().getCurrentMap().getWorldBorder().resetWorldBorder();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int num,delay,change;
|
int num,delay,change;
|
||||||
|
@ -67,28 +74,16 @@ public class SetBorder implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
|
sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vector vec = new Vector();
|
map.setWorldBorderData(
|
||||||
vec.setX(sender.getLocation().getBlockX());
|
sender.getLocation().getBlockX(),
|
||||||
vec.setY(0);
|
sender.getLocation().getBlockZ(),
|
||||||
vec.setZ(sender.getLocation().getBlockZ());
|
num,
|
||||||
if (spawnPosition.distance(vec) > 100) {
|
delay,
|
||||||
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
|
change
|
||||||
return;
|
);
|
||||||
}
|
Maps.setMap(map.getName(), map);
|
||||||
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);
|
|
||||||
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
|
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
|
||||||
saveConfig();
|
map.getWorldBorder().resetWorldBorder();
|
||||||
Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -96,7 +91,7 @@ public class SetBorder implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "<size> <delay> <move>";
|
return "<map> <size> <delay> <move>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
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 net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -33,11 +35,16 @@ public class SetBounds implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
||||||
return;
|
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"));
|
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!sender.getWorld().getName().equals(spawnWorld)) {
|
if (!sender.getWorld().getName().equals(map.getSpawn().getWorld().getName())) {
|
||||||
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
|
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,37 +53,35 @@ public class SetBounds implements ICommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
if (saveMinX != 0 && saveMinZ != 0 && saveMaxX != 0 && saveMaxZ != 0) {
|
int bxs = map.getBoundsMin().getBlockX();
|
||||||
saveMinX = 0; saveMinZ= 0; saveMaxX = 0; saveMaxZ = 0;
|
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) {
|
if (bxl == 0) {
|
||||||
addToConfig("bounds.max.x", sender.getLocation().getBlockX());
|
bxl = sender.getLocation().getBlockX();
|
||||||
saveMaxX = sender.getLocation().getBlockX();
|
} else if (map.getBoundsMax().getX() < sender.getLocation().getBlockX()) {
|
||||||
} else if (saveMaxX < sender.getLocation().getBlockX()) {
|
|
||||||
first = false;
|
first = false;
|
||||||
addToConfig("bounds.max.x", sender.getLocation().getBlockX());
|
bxs = bxl;
|
||||||
addToConfig("bounds.min.x", saveMaxX);
|
bxl = sender.getLocation().getBlockX();
|
||||||
saveMinX = saveMaxX;
|
|
||||||
saveMaxX = sender.getLocation().getBlockX();
|
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
addToConfig("bounds.min.x", sender.getLocation().getBlockX());
|
bxs = sender.getLocation().getBlockX();
|
||||||
saveMinX = sender.getLocation().getBlockX();
|
|
||||||
}
|
}
|
||||||
if (saveMaxZ == 0) {
|
if (bzl == 0) {
|
||||||
addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
|
bzl = sender.getLocation().getBlockZ();
|
||||||
saveMaxZ = sender.getLocation().getBlockZ();
|
} else if (map.getBoundsMax().getX() < sender.getLocation().getBlockZ()) {
|
||||||
} else if (saveMaxZ < sender.getLocation().getBlockZ()) {
|
|
||||||
first = false;
|
first = false;
|
||||||
addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
|
bzs = bzl;
|
||||||
addToConfig("bounds.min.z", saveMaxZ);
|
bzl = sender.getLocation().getBlockZ();
|
||||||
saveMinZ = saveMaxZ;
|
|
||||||
saveMaxZ = sender.getLocation().getBlockZ();
|
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
addToConfig("bounds.min.z", sender.getLocation().getBlockZ());
|
bzs = sender.getLocation().getBlockZ();
|
||||||
saveMinZ = sender.getLocation().getBlockZ();
|
|
||||||
}
|
}
|
||||||
|
map.setBoundMin(bxs, bzs);
|
||||||
|
map.setBoundMax(bxl, bzl);
|
||||||
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
|
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +91,7 @@ public class SetBounds implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -33,16 +35,20 @@ public class Setup implements ICommand {
|
||||||
|
|
||||||
String msg = message("SETUP").toString();
|
String msg = message("SETUP").toString();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
Map map = Maps.getMap(args[0]);
|
||||||
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 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");
|
msg = msg + "\n" + message("SETUP_GAME");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_LOBBY");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -50,12 +56,13 @@ public class Setup implements ICommand {
|
||||||
msg = msg + "\n" + message("SETUP_EXIT");
|
msg = msg + "\n" + message("SETUP_EXIT");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_BOUNDS");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (mapSaveEnabled) {
|
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()) {
|
if (!destenation.exists()) {
|
||||||
msg = msg + "\n" + message("SETUP_SAVEMAP");
|
msg = msg + "\n" + message("SETUP_SAVEMAP");
|
||||||
count++;
|
count++;
|
||||||
|
@ -73,7 +80,7 @@ public class Setup implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
public class Start implements ICommand {
|
public class Start implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().isNotSetup()) {
|
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
public class Stop implements ICommand {
|
public class Stop implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
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");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,14 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
public class SetExitLocation implements ICommand {
|
public class SetExitLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
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();
|
exitWorld = sender.getLocation().getWorld().getName();
|
||||||
exitPosition = vector;
|
saveConfig();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
public class SetLobbyLocation implements ICommand {
|
public class SetLobbyLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
LocationUtils.setLocation(sender, Locations.LOBBY, vector -> {
|
LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
|
||||||
lobbyWorld = sender.getLocation().getWorld().getName();
|
map.setLobby(sender.getLocation());
|
||||||
lobbyPosition = vector;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
public class SetSeekerLobbyLocation implements ICommand {
|
public class SetSeekerLobbyLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
LocationUtils.setLocation(sender, Locations.SEEKER, vector -> {
|
LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
|
||||||
seekerLobbyWorld = sender.getLocation().getWorld().getName();
|
map.setSeekerLobby(sender.getLocation());
|
||||||
seekerLobbyPosition = vector;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
|
|
||||||
package net.tylermurphy.hideAndSeek.command.location;
|
package net.tylermurphy.hideAndSeek.command.location;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
|
||||||
import net.tylermurphy.hideAndSeek.command.ICommand;
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
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 class SetSpawnLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
LocationUtils.setLocation(sender, Locations.GAME, vector -> {
|
LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> {
|
||||||
if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) {
|
|
||||||
|
if (map.isWorldBorderEnabled() &&
|
||||||
|
new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) {
|
||||||
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
|
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
|
||||||
throw new RuntimeException("World border not enabled or not in valid position!");
|
throw new RuntimeException("World border not enabled or not in valid position!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.getLocation().getWorld().getName().equals(spawnWorld)) {
|
map.setSpawn(sender.getLocation());
|
||||||
Main.getInstance().getGame().getWorldLoader().unloadMap();
|
|
||||||
Main.getInstance().getGame().getWorldLoader().setNewMap(sender.getLocation().getWorld().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
spawnWorld = sender.getLocation().getWorld().getName();
|
if (!sender.getLocation().getWorld().getName().equals(map.getSpawn().getWorld().getName()) && mapSaveEnabled) {
|
||||||
spawnPosition = vector;
|
map.getWorldLoader().unloadMap();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class SetSpawnLocation implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package net.tylermurphy.hideAndSeek.command.location.util;
|
package net.tylermurphy.hideAndSeek.command.location.util;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
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 net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@ -18,42 +17,31 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
*/
|
*/
|
||||||
public class LocationUtils {
|
public class LocationUtils {
|
||||||
|
|
||||||
/**
|
public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer<Map> consumer) {
|
||||||
* 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) {
|
|
||||||
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
|
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
|
||||||
player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
|
if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
|
||||||
player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
|
player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
Map map = null;
|
||||||
return new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
if(mapName != null) {
|
||||||
|
map = Maps.getMap(mapName);
|
||||||
|
if (map == null) {
|
||||||
|
player.sendMessage(errorPrefix + message("INVALID_MAP"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLocation(Player player, Locations place, @Nullable Consumer<Vector> consumer) {
|
consumer.accept(map);
|
||||||
Vector vec = vector(player);
|
if(map != null)
|
||||||
|
Maps.setMap(mapName, map);
|
||||||
World world = player.getLocation().getWorld();
|
|
||||||
if(world == null) {
|
|
||||||
throw new RuntimeException("Unable to get world: " + spawnWorld);
|
|
||||||
}
|
|
||||||
|
|
||||||
consumer.accept(vec);
|
|
||||||
|
|
||||||
player.sendMessage(messagePrefix + message(place.message()));
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,12 +24,13 @@ import com.cryptomorin.xseries.XMaterial;
|
||||||
import com.cryptomorin.xseries.XSound;
|
import com.cryptomorin.xseries.XSound;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
|
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -49,10 +50,6 @@ public class Config {
|
||||||
abortPrefix,
|
abortPrefix,
|
||||||
gameOverPrefix,
|
gameOverPrefix,
|
||||||
warningPrefix,
|
warningPrefix,
|
||||||
spawnWorld,
|
|
||||||
seekerLobbyWorld,
|
|
||||||
exitWorld,
|
|
||||||
lobbyWorld,
|
|
||||||
locale,
|
locale,
|
||||||
leaveServer,
|
leaveServer,
|
||||||
placeholderError,
|
placeholderError,
|
||||||
|
@ -62,20 +59,13 @@ public class Config {
|
||||||
databasePort,
|
databasePort,
|
||||||
databaseUser,
|
databaseUser,
|
||||||
databasePass,
|
databasePass,
|
||||||
databaseName;
|
databaseName,
|
||||||
|
exitWorld;
|
||||||
public static Vector
|
|
||||||
spawnPosition,
|
|
||||||
lobbyPosition,
|
|
||||||
exitPosition,
|
|
||||||
seekerLobbyPosition,
|
|
||||||
worldBorderPosition;
|
|
||||||
|
|
||||||
public static boolean
|
public static boolean
|
||||||
nameTagsVisible,
|
nameTagsVisible,
|
||||||
permissionsRequired,
|
permissionsRequired,
|
||||||
announceMessagesToNonPlayers,
|
announceMessagesToNonPlayers,
|
||||||
worldBorderEnabled,
|
|
||||||
tauntEnabled,
|
tauntEnabled,
|
||||||
tauntCountdown,
|
tauntCountdown,
|
||||||
tauntLast,
|
tauntLast,
|
||||||
|
@ -93,20 +83,11 @@ public class Config {
|
||||||
mapSaveEnabled,
|
mapSaveEnabled,
|
||||||
allowNaturalCauses,
|
allowNaturalCauses,
|
||||||
saveInventory,
|
saveInventory,
|
||||||
blockhuntEnabled,
|
|
||||||
delayedRespawn;
|
delayedRespawn;
|
||||||
|
|
||||||
public static int
|
public static int
|
||||||
minPlayers,
|
minPlayers,
|
||||||
worldBorderSize,
|
|
||||||
worldBorderDelay,
|
|
||||||
currentWorldborderSize,
|
|
||||||
worldBorderChange,
|
|
||||||
gameLength,
|
gameLength,
|
||||||
saveMinX,
|
|
||||||
saveMinZ,
|
|
||||||
saveMaxX,
|
|
||||||
saveMaxZ,
|
|
||||||
tauntDelay,
|
tauntDelay,
|
||||||
glowLength,
|
glowLength,
|
||||||
countdown,
|
countdown,
|
||||||
|
@ -132,9 +113,6 @@ public class Config {
|
||||||
blockedCommands,
|
blockedCommands,
|
||||||
blockedInteracts;
|
blockedInteracts;
|
||||||
|
|
||||||
public static List<Material>
|
|
||||||
blockhuntBlocks;
|
|
||||||
|
|
||||||
public static String
|
public static String
|
||||||
LOBBY_TITLE,
|
LOBBY_TITLE,
|
||||||
GAME_TITLE,
|
GAME_TITLE,
|
||||||
|
@ -167,56 +145,17 @@ public class Config {
|
||||||
public static CountdownDisplay
|
public static CountdownDisplay
|
||||||
countdownDisplay;
|
countdownDisplay;
|
||||||
|
|
||||||
|
public static Location
|
||||||
|
exitPosition;
|
||||||
|
|
||||||
public static void loadConfig() {
|
public static void loadConfig() {
|
||||||
|
|
||||||
config = ConfigManager.create("config.yml");
|
config = ConfigManager.create("config.yml");
|
||||||
config.saveConfig();
|
config.saveConfig();
|
||||||
ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
|
ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
|
||||||
|
|
||||||
//Spawn
|
|
||||||
spawnPosition = new Vector(
|
|
||||||
config.getDouble("spawns.game.x"),
|
|
||||||
Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.game.y"))),
|
|
||||||
config.getDouble("spawns.game.z")
|
|
||||||
);
|
|
||||||
spawnWorld = config.getString("spawns.game.world");
|
|
||||||
|
|
||||||
///Lobby
|
|
||||||
lobbyPosition = new Vector(
|
|
||||||
config.getDouble("spawns.lobby.x"),
|
|
||||||
Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.lobby.y"))),
|
|
||||||
config.getDouble("spawns.lobby.z")
|
|
||||||
);
|
|
||||||
lobbyWorld = config.getString("spawns.lobby.world");
|
|
||||||
|
|
||||||
///Seeker Lobby
|
|
||||||
seekerLobbyPosition = new Vector(
|
|
||||||
config.getDouble("spawns.seeker.x"),
|
|
||||||
Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.seeker.y"))),
|
|
||||||
config.getDouble("spawns.seeker.z")
|
|
||||||
);
|
|
||||||
seekerLobbyWorld = config.getString("spawns.seeker.world");
|
|
||||||
|
|
||||||
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
|
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
|
||||||
|
|
||||||
exitPosition = new Vector(
|
|
||||||
config.getDouble("spawns.exit.x"),
|
|
||||||
Math.max(Main.getInstance().supports(18) ? -64 : 0, Math.min(255, config.getDouble("spawns.exit.y"))),
|
|
||||||
config.getDouble("spawns.exit.z")
|
|
||||||
);
|
|
||||||
exitWorld = config.getString("spawns.exit.world");
|
|
||||||
|
|
||||||
//World border
|
|
||||||
worldBorderPosition = new Vector(
|
|
||||||
config.getInt("worldBorder.x"),
|
|
||||||
0,
|
|
||||||
config.getInt("worldBorder.z")
|
|
||||||
);
|
|
||||||
worldBorderSize = Math.max(100, config.getInt("worldBorder.size"));
|
|
||||||
worldBorderDelay = Math.max(1, config.getInt("worldBorder.delay"));
|
|
||||||
worldBorderEnabled = config.getBoolean("worldBorder.enabled");
|
|
||||||
worldBorderChange = config.getInt("worldBorder.moveAmount");
|
|
||||||
|
|
||||||
//Prefix
|
//Prefix
|
||||||
char SYMBOLE = '\u00A7';
|
char SYMBOLE = '\u00A7';
|
||||||
String SYMBOLE_STRING = String.valueOf(SYMBOLE);
|
String SYMBOLE_STRING = String.valueOf(SYMBOLE);
|
||||||
|
@ -229,11 +168,14 @@ public class Config {
|
||||||
gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
|
gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
|
||||||
warningPrefix = config.getString("prefix.warning").replace("&", SYMBOLE_STRING);
|
warningPrefix = config.getString("prefix.warning").replace("&", SYMBOLE_STRING);
|
||||||
|
|
||||||
//Map Bounds
|
// Locations
|
||||||
saveMinX = config.getInt("bounds.min.x");
|
exitPosition = new Location(
|
||||||
saveMinZ = config.getInt("bounds.min.z");
|
Bukkit.getWorld(config.getString("exit.world")),
|
||||||
saveMaxX = config.getInt("bounds.max.x");
|
config.getInt("exit.x"),
|
||||||
saveMaxZ = config.getInt("bounds.max.z");
|
config.getInt("exit.y"),
|
||||||
|
config.getInt("exit.z")
|
||||||
|
);
|
||||||
|
exitWorld = config.getString("exit.world");
|
||||||
mapSaveEnabled = config.getBoolean("mapSaveEnabled");
|
mapSaveEnabled = config.getBoolean("mapSaveEnabled");
|
||||||
|
|
||||||
//Taunt
|
//Taunt
|
||||||
|
@ -305,18 +247,6 @@ public class Config {
|
||||||
}
|
}
|
||||||
bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy");
|
bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy");
|
||||||
leaveServer = config.getString("leaveServer");
|
leaveServer = config.getString("leaveServer");
|
||||||
blockhuntEnabled = config.getBoolean("blockhunt.enabled") && Main.getInstance().supports(9);
|
|
||||||
blockhuntBlocks = new ArrayList<>();
|
|
||||||
tempInteracts = config.getStringList("blockhunt.blocks");
|
|
||||||
for(String id : tempInteracts) {
|
|
||||||
Optional<XMaterial> optional_mat = XMaterial.matchXMaterial(id);
|
|
||||||
if (optional_mat.isPresent()) {
|
|
||||||
Material mat = optional_mat.get().parseMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
blockhuntBlocks.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
solidifyTime = Math.max(20,config.getInt("blockhunt.solidifyTime"));
|
solidifyTime = Math.max(20,config.getInt("blockhunt.solidifyTime"));
|
||||||
|
|
||||||
//Leaderboard
|
//Leaderboard
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -188,6 +188,10 @@ public class ConfigManager {
|
||||||
config.set(path, defaultConfig.get(path));
|
config.set(path, defaultConfig.get(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAll() {
|
||||||
|
config = new YamlConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
public void resetFile(String newDefaultFilename) {
|
public void resetFile(String newDefaultFilename) {
|
||||||
this.defaultFilename = newDefaultFilename;
|
this.defaultFilename = newDefaultFilename;
|
||||||
|
|
||||||
|
@ -226,6 +230,14 @@ public class ConfigManager {
|
||||||
config.set(path, value);
|
config.set(path, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void overwriteConfig() {
|
||||||
|
try {
|
||||||
|
this.config.save(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void saveConfig() {
|
public void saveConfig() {
|
||||||
try {
|
try {
|
||||||
InputStream is = Main.getInstance().getResource(defaultFilename);
|
InputStream is = Main.getInstance().getResource(defaultFilename);
|
||||||
|
@ -233,7 +245,7 @@ public class ConfigManager {
|
||||||
throw new RuntimeException("Could not create input stream for "+defaultFilename);
|
throw new RuntimeException("Could not create input stream for "+defaultFilename);
|
||||||
}
|
}
|
||||||
StringBuilder textBuilder = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8));
|
StringBuilder textBuilder = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8));
|
||||||
Reader reader = new BufferedReader(new InputStreamReader(is, Charset.forName(StandardCharsets.UTF_8.name())));
|
Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||||
int c;
|
int c;
|
||||||
while((c = reader.read()) != -1) {
|
while((c = reader.read()) != -1) {
|
||||||
textBuilder.append((char) c);
|
textBuilder.append((char) c);
|
||||||
|
@ -285,7 +297,7 @@ public class ConfigManager {
|
||||||
yamlString = builder.toString();
|
yamlString = builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Writer fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
|
Writer fileWriter = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8));
|
||||||
fileWriter.write(yamlString);
|
fileWriter.write(yamlString);
|
||||||
fileWriter.close();
|
fileWriter.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
196
src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
Normal file
196
src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.configuration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.game.events.Border;
|
||||||
|
import net.tylermurphy.hideAndSeek.world.VoidGenerator;
|
||||||
|
import net.tylermurphy.hideAndSeek.world.WorldLoader;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
|
|
||||||
|
public class Map {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private Location
|
||||||
|
spawnPosition = new Location(null, 0, 0, 0),
|
||||||
|
lobbyPosition = new Location(null, 0, 0, 0),
|
||||||
|
seekerLobbyPosition = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
|
private String
|
||||||
|
gameWorldName;
|
||||||
|
|
||||||
|
private int
|
||||||
|
xBoundMin = 0,
|
||||||
|
zBoundMin = 0,
|
||||||
|
xBoundMax = 0,
|
||||||
|
zBoundMax = 0,
|
||||||
|
xWorldBorder = 0,
|
||||||
|
zWorldBorder = 0,
|
||||||
|
worldBorderSize = 0,
|
||||||
|
worldBorderDelay = 0,
|
||||||
|
worldBorderChange = 0;
|
||||||
|
|
||||||
|
private boolean
|
||||||
|
blockhunt;
|
||||||
|
|
||||||
|
private List<Material>
|
||||||
|
blockhuntBlocks;
|
||||||
|
|
||||||
|
private final Border
|
||||||
|
worldBorder;
|
||||||
|
|
||||||
|
private final WorldLoader
|
||||||
|
worldLoader;
|
||||||
|
|
||||||
|
public Map(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.worldBorder = new Border(this);
|
||||||
|
this.worldLoader = new WorldLoader(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawn(Location pos) {
|
||||||
|
this.spawnPosition = pos;
|
||||||
|
this.gameWorldName = pos.getWorld().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLobby(Location pos) {
|
||||||
|
this.lobbyPosition = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeekerLobby(Location pos) {
|
||||||
|
this.seekerLobbyPosition = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorldBorderData(int x, int z, int size, int delay, int move) {
|
||||||
|
if(size < 1) {
|
||||||
|
this.worldBorderSize = 0;
|
||||||
|
this.worldBorderDelay = 0;
|
||||||
|
this.worldBorderChange = 0;
|
||||||
|
this.xWorldBorder = 0;
|
||||||
|
this.zWorldBorder = 0;
|
||||||
|
this.worldBorder.resetWorldBorder();
|
||||||
|
} else {
|
||||||
|
this.worldBorderSize = size;
|
||||||
|
this.worldBorderDelay = delay;
|
||||||
|
this.worldBorderChange = move;
|
||||||
|
this.xWorldBorder = x;
|
||||||
|
this.zWorldBorder = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockhunt(boolean enabled, List<Material> blocks) {
|
||||||
|
this.blockhunt = enabled;
|
||||||
|
this.blockhuntBlocks = blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoundMin(int x, int z) {
|
||||||
|
this.xBoundMin = x;
|
||||||
|
this.zBoundMin = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoundMax(int x, int z) {
|
||||||
|
this.xBoundMax = x;
|
||||||
|
this.zBoundMax = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getSpawn() {
|
||||||
|
if(mapSaveEnabled)
|
||||||
|
spawnPosition.setWorld(Bukkit.getWorld("hs_"+gameWorldName));
|
||||||
|
else
|
||||||
|
spawnPosition.setWorld(Bukkit.getWorld(gameWorldName));
|
||||||
|
return spawnPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLobby() {
|
||||||
|
return lobbyPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getSeekerLobby() {
|
||||||
|
return seekerLobbyPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWorldBorderEnabled() {
|
||||||
|
return worldBorderSize > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getWorldBorderPos() {
|
||||||
|
return new Vector(
|
||||||
|
xWorldBorder,
|
||||||
|
0,
|
||||||
|
zWorldBorder
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getWorldBorderData() {
|
||||||
|
return new Vector(
|
||||||
|
worldBorderSize,
|
||||||
|
worldBorderDelay,
|
||||||
|
worldBorderChange
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Border getWorldBorder() {
|
||||||
|
return worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBlockHuntEnabled() {
|
||||||
|
return blockhunt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Material> getBlockHunt() {
|
||||||
|
return blockhuntBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getBoundsMin() {
|
||||||
|
return new Vector(
|
||||||
|
xBoundMin,
|
||||||
|
0,
|
||||||
|
zBoundMin
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getBoundsMax() {
|
||||||
|
return new Vector(
|
||||||
|
xBoundMax,
|
||||||
|
0,
|
||||||
|
zBoundMin
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldLoader getWorldLoader() {
|
||||||
|
return worldLoader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNotSetup() {
|
||||||
|
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true;
|
||||||
|
if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true;
|
||||||
|
if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true;
|
||||||
|
if (exitPosition.getWorld() == null) {
|
||||||
|
Bukkit.getServer().createWorld(new WorldCreator(exitWorld).generator(new VoidGenerator()));
|
||||||
|
World world = Bukkit.getServer().getWorld(exitWorld);
|
||||||
|
if(world == null) return true;
|
||||||
|
}
|
||||||
|
if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0) return true;
|
||||||
|
if (mapSaveEnabled) {
|
||||||
|
File destination = new File(Main.getInstance().getWorldContainer() + File.separator + spawnPosition.getWorld().getName());
|
||||||
|
if (!destination.exists()) return true;
|
||||||
|
}
|
||||||
|
if(isWorldBorderEnabled() &&
|
||||||
|
new Vector(spawnPosition.getX(), 0, spawnPosition.getZ()).distance(new Vector(xWorldBorder, 0, zWorldBorder)) > 100) return true;
|
||||||
|
return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpawnNotSetup() {
|
||||||
|
return spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
package net.tylermurphy.hideAndSeek.configuration;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.cryptomorin.xseries.XMaterial;
|
||||||
|
|
||||||
|
public class Maps {
|
||||||
|
|
||||||
|
private static final HashMap<String, Map> MAPS = new HashMap<>();
|
||||||
|
|
||||||
|
public static Map getMap(String name) {
|
||||||
|
return MAPS.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map getRandomMap() {
|
||||||
|
Optional<Map> map = MAPS.values().stream().skip(new Random().nextInt(MAPS.values().size())).findFirst();
|
||||||
|
if(map.isPresent()) return map.get();
|
||||||
|
setMap("default", new Map("default"));
|
||||||
|
return MAPS.get("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMap(String name, Map map) {
|
||||||
|
MAPS.put(name, map);
|
||||||
|
saveMaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Collection<Map> getAllMaps() {
|
||||||
|
return MAPS.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadMaps() {
|
||||||
|
|
||||||
|
ConfigManager manager = ConfigManager.create("maps.yml");
|
||||||
|
|
||||||
|
ConfigurationSection maps = manager.getConfigurationSection("maps");
|
||||||
|
if(maps == null) return;
|
||||||
|
Set<String> keys = maps.getKeys(false);
|
||||||
|
if(keys == null) return;
|
||||||
|
|
||||||
|
MAPS.clear();
|
||||||
|
for(String key : keys) {
|
||||||
|
System.out.println(key);
|
||||||
|
MAPS.put(key, parseMap(maps, key));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map parseMap(ConfigurationSection maps, String name) {
|
||||||
|
ConfigurationSection data = maps.getConfigurationSection(name);
|
||||||
|
if(data == null) return null;
|
||||||
|
Map map = new Map(name);
|
||||||
|
map.setSpawn(setSpawn(data, "game"));
|
||||||
|
map.setLobby(setSpawn(data, "lobby"));
|
||||||
|
map.setSeekerLobby(setSpawn(data, "seeker"));
|
||||||
|
map.setBoundMin(data.getInt("bounds.min.x"), data.getInt("bounds.min.z"));
|
||||||
|
map.setBoundMax(data.getInt("bounds.max.x"), data.getInt("bounds.max.z"));
|
||||||
|
map.setWorldBorderData(
|
||||||
|
data.getInt("worldborder.pos.x"),
|
||||||
|
data.getInt("worldborder.pos.z"),
|
||||||
|
data.getInt("worldborder.size"),
|
||||||
|
data.getInt("worldborder.delay"),
|
||||||
|
data.getInt("worldborder.change")
|
||||||
|
);
|
||||||
|
map.setBlockhunt(
|
||||||
|
data.getBoolean("blockhunt.enabled"),
|
||||||
|
data.getStringList("blockhunt.blocks")
|
||||||
|
.stream()
|
||||||
|
.map(XMaterial::matchXMaterial)
|
||||||
|
.filter(Optional::isPresent)
|
||||||
|
.map(e -> e.get().parseMaterial())
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Location setSpawn(ConfigurationSection data, String spawn) {
|
||||||
|
String worldName = data.getString("spawns."+spawn+".world");
|
||||||
|
if(worldName == null) return new Location(null, 0, 0, 0);
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if(world == null) return new Location(null, 0, 0, 0);
|
||||||
|
double x = data.getDouble("spawns."+spawn+".x");
|
||||||
|
double y = data.getDouble("spawns."+spawn+".y");
|
||||||
|
double z = data.getDouble("spawns."+spawn+".z");
|
||||||
|
return new Location(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveMaps() {
|
||||||
|
|
||||||
|
ConfigManager manager = ConfigManager.create("maps.yml");
|
||||||
|
ConfigurationSection maps = new YamlConfiguration();
|
||||||
|
|
||||||
|
for(Map map : MAPS.values()) {
|
||||||
|
ConfigurationSection data = new YamlConfiguration();
|
||||||
|
saveSpawn(data, map.getSpawn(), "game");
|
||||||
|
saveSpawn(data, map.getLobby(), "lobby");
|
||||||
|
saveSpawn(data, map.getSeekerLobby(), "seeker");
|
||||||
|
data.set("bounds.min.x", map.getBoundsMin().getX());
|
||||||
|
data.set("bounds.min.z", map.getBoundsMin().getZ());
|
||||||
|
data.set("bounds.max.x", map.getBoundsMax().getX());
|
||||||
|
data.set("bounds.max.z", map.getBoundsMax().getZ());
|
||||||
|
data.set("worldborder.pos.x", map.getWorldBorderPos().getX());
|
||||||
|
data.set("worldborder.pos.z", map.getWorldBorderPos().getZ());
|
||||||
|
data.set("worldborder.pos.size", map.getWorldBorderData().getX());
|
||||||
|
data.set("worldborder.pos.delay", map.getWorldBorderData().getY());
|
||||||
|
data.set("worldborder.pos.change", map.getWorldBorderData().getZ());
|
||||||
|
data.set("blockhunt.enabled", map.isBlockHuntEnabled());
|
||||||
|
data.set("blockhunt.blocks", map.getBlockHunt().stream().map(Material::name));
|
||||||
|
maps.set(map.getName(), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.set("maps", maps);
|
||||||
|
manager.overwriteConfig();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveSpawn(ConfigurationSection data, Location spawn, String name) {
|
||||||
|
if(spawn.getWorld() != null) {
|
||||||
|
data.set("spawns." + name + ".world", spawn.getWorld().getName());
|
||||||
|
} else {
|
||||||
|
data.set("spawns." + name + ".world", "world");
|
||||||
|
}
|
||||||
|
data.set("spawns.." + name + ".x", spawn.getX());
|
||||||
|
data.set("spawns.." + name + ".y", spawn.getY());
|
||||||
|
data.set("spawns.." + name + ".z", spawn.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -35,7 +35,6 @@ import java.util.stream.Collectors;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class Board {
|
public class Board {
|
||||||
|
|
||||||
private final List<String> Hider = new ArrayList<>(), Seeker = new ArrayList<>(), Spectator = new ArrayList<>();
|
private final List<String> Hider = new ArrayList<>(), Seeker = new ArrayList<>(), Spectator = new ArrayList<>();
|
||||||
|
@ -244,7 +243,7 @@ public class Board {
|
||||||
Status status = Main.getInstance().getGame().getStatus();
|
Status status = Main.getInstance().getGame().getStatus();
|
||||||
|
|
||||||
Taunt taunt = Main.getInstance().getGame().getTaunt();
|
Taunt taunt = Main.getInstance().getGame().getTaunt();
|
||||||
Border worldBorder = Main.getInstance().getGame().getBorder();
|
Border worldBorder = Main.getInstance().getGame().getCurrentMap().getWorldBorder();
|
||||||
Glow glow = Main.getInstance().getGame().getGlow();
|
Glow glow = Main.getInstance().getGame().getGlow();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -259,7 +258,7 @@ public class Board {
|
||||||
String value = getTeam(player);
|
String value = getTeam(player);
|
||||||
board.setLine(String.valueOf(i), line.replace("{TEAM}", value));
|
board.setLine(String.valueOf(i), line.replace("{TEAM}", value));
|
||||||
} else if (line.contains("{BORDER}")) {
|
} else if (line.contains("{BORDER}")) {
|
||||||
if (!worldBorderEnabled) continue;
|
if (!Main.getInstance().getGame().getCurrentMap().isWorldBorderEnabled()) continue;
|
||||||
if (worldBorder == null || status == Status.STARTING) {
|
if (worldBorder == null || status == Status.STARTING) {
|
||||||
board.setLine(String.valueOf(i), line.replace("{BORDER}", BORDER_COUNTING.replace("{AMOUNT}", "0")));
|
board.setLine(String.valueOf(i), line.replace("{BORDER}", BORDER_COUNTING.replace("{AMOUNT}", "0")));
|
||||||
} else if (!worldBorder.isRunning()) {
|
} else if (!worldBorder.isRunning()) {
|
||||||
|
|
|
@ -2,17 +2,17 @@ package net.tylermurphy.hideAndSeek.game;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Disguise;
|
import net.tylermurphy.hideAndSeek.game.util.Disguise;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Disguiser {
|
public class Disguiser {
|
||||||
|
|
||||||
private final Map<Player, Disguise> disguises;
|
private final HashMap<Player, Disguise> disguises;
|
||||||
|
|
||||||
public Disguiser(){
|
public Disguiser(){
|
||||||
this.disguises = new HashMap<>();
|
this.disguises = new HashMap<>();
|
||||||
|
@ -35,7 +35,7 @@ public class Disguiser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void check(){
|
public void check(){
|
||||||
for(Map.Entry<Player, Disguise> set : disguises.entrySet()){
|
for(HashMap.Entry<Player, Disguise> set : disguises.entrySet()){
|
||||||
Disguise disguise = set.getValue();
|
Disguise disguise = set.getValue();
|
||||||
Player player = set.getKey();
|
Player player = set.getKey();
|
||||||
if(!player.isOnline()) {
|
if(!player.isOnline()) {
|
||||||
|
@ -47,9 +47,9 @@ public class Disguiser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disguise(Player player, Material material){
|
public void disguise(Player player, Material material, Map map){
|
||||||
if(!blockhuntEnabled){
|
if(!map.isBlockHuntEnabled()){
|
||||||
player.sendMessage(errorPrefix + "Please enable blockhunt in config.yml to enable disguises. Blockhunt does not work on 1.8");
|
player.sendMessage(errorPrefix + "Please enable blockhunt in this map inside maps.yml to enable disguises. Blockhunt does not work on 1.8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(disguises.containsKey(player)){
|
if(disguises.containsKey(player)){
|
||||||
|
|
|
@ -24,18 +24,17 @@ import com.cryptomorin.xseries.messages.Titles;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.game.events.Border;
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.events.Glow;
|
import net.tylermurphy.hideAndSeek.game.events.Glow;
|
||||||
import net.tylermurphy.hideAndSeek.game.events.Taunt;
|
import net.tylermurphy.hideAndSeek.game.events.Taunt;
|
||||||
import net.tylermurphy.hideAndSeek.game.listener.RespawnHandler;
|
import net.tylermurphy.hideAndSeek.game.listener.RespawnHandler;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.*;
|
import net.tylermurphy.hideAndSeek.game.util.*;
|
||||||
import net.tylermurphy.hideAndSeek.world.WorldLoader;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -46,24 +45,25 @@ public class Game {
|
||||||
|
|
||||||
private final Taunt taunt;
|
private final Taunt taunt;
|
||||||
private final Glow glow;
|
private final Glow glow;
|
||||||
private final Border worldBorder;
|
|
||||||
private final WorldLoader worldLoader;
|
|
||||||
|
|
||||||
private final Board board;
|
private final Board board;
|
||||||
|
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
|
private Map currentMap;
|
||||||
|
|
||||||
private int gameTick;
|
private int gameTick;
|
||||||
private int lobbyTimer;
|
private int lobbyTimer;
|
||||||
private int startingTimer;
|
private int startingTimer;
|
||||||
private int gameTimer;
|
private int gameTimer;
|
||||||
private boolean hiderLeft;
|
private boolean hiderLeft;
|
||||||
|
|
||||||
public Game(Board board){
|
public Game(Board board) {
|
||||||
|
|
||||||
|
this.currentMap = Maps.getRandomMap();
|
||||||
|
|
||||||
this.taunt = new Taunt();
|
this.taunt = new Taunt();
|
||||||
this.glow = new Glow();
|
this.glow = new Glow();
|
||||||
this.worldBorder = new Border();
|
|
||||||
this.worldLoader = new WorldLoader(spawnWorld);
|
|
||||||
|
|
||||||
this.status = Status.STANDBY;
|
this.status = Status.STANDBY;
|
||||||
|
|
||||||
|
@ -92,18 +92,10 @@ public class Game {
|
||||||
return glow;
|
return glow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Border getBorder(){
|
|
||||||
return worldBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Taunt getTaunt(){
|
public Taunt getTaunt(){
|
||||||
return taunt;
|
return taunt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldLoader getWorldLoader(){
|
|
||||||
return worldLoader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
try {
|
try {
|
||||||
Optional<Player> rand = board.getPlayers().stream().skip(new Random().nextInt(board.size())).findFirst();
|
Optional<Player> rand = board.getPlayers().stream().skip(new Random().nextInt(board.size())).findFirst();
|
||||||
|
@ -115,17 +107,17 @@ public class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Player seeker) {
|
public void start(Player seeker) {
|
||||||
if (mapSaveEnabled) worldLoader.rollback();
|
if (mapSaveEnabled) currentMap.getWorldLoader().rollback();
|
||||||
board.reload();
|
board.reload();
|
||||||
board.addSeeker(seeker);
|
board.addSeeker(seeker);
|
||||||
PlayerLoader.loadSeeker(seeker, getGameWorld());
|
PlayerLoader.loadSeeker(seeker, currentMap);
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
if(board.isSeeker(player)) return;
|
if(board.isSeeker(player)) return;
|
||||||
board.addHider(player);
|
board.addHider(player);
|
||||||
PlayerLoader.loadHider(player, getGameWorld());
|
PlayerLoader.loadHider(player, currentMap);
|
||||||
});
|
});
|
||||||
board.getPlayers().forEach(board::createGameBoard);
|
board.getPlayers().forEach(board::createGameBoard);
|
||||||
worldBorder.resetWorldBorder(getGameWorld());
|
currentMap.getWorldBorder().resetWorldBorder();
|
||||||
if (gameLength > 0) gameTimer = gameLength;
|
if (gameLength > 0) gameTimer = gameLength;
|
||||||
status = Status.STARTING;
|
status = Status.STARTING;
|
||||||
startingTimer = 30;
|
startingTimer = 30;
|
||||||
|
@ -147,21 +139,21 @@ public class Game {
|
||||||
|
|
||||||
public void end() {
|
public void end() {
|
||||||
board.getPlayers().forEach(PlayerLoader::unloadPlayer);
|
board.getPlayers().forEach(PlayerLoader::unloadPlayer);
|
||||||
worldBorder.resetWorldBorder(getGameWorld());
|
currentMap.getWorldBorder().resetWorldBorder();
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
if (leaveOnEnd) {
|
if (leaveOnEnd) {
|
||||||
board.removeBoard(player);
|
board.removeBoard(player);
|
||||||
board.remove(player);
|
board.remove(player);
|
||||||
handleBungeeLeave(player);
|
handleBungeeLeave(player);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
player.teleport(currentMap.getLobby());
|
||||||
board.createLobbyBoard(player);
|
board.createLobbyBoard(player);
|
||||||
board.addHider(player);
|
board.addHider(player);
|
||||||
PlayerLoader.joinPlayer(player);
|
PlayerLoader.joinPlayer(player, currentMap);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RespawnHandler.temp_loc.clear();
|
RespawnHandler.temp_loc.clear();
|
||||||
if (mapSaveEnabled) worldLoader.unloadMap();
|
if (mapSaveEnabled) currentMap.getWorldLoader().unloadMap();
|
||||||
board.reloadLobbyBoards();
|
board.reloadLobbyBoards();
|
||||||
status = Status.ENDED;
|
status = Status.ENDED;
|
||||||
}
|
}
|
||||||
|
@ -172,14 +164,14 @@ public class Game {
|
||||||
ItemStack[] data = player.getInventory().getContents();
|
ItemStack[] data = player.getInventory().getContents();
|
||||||
Main.getInstance().getDatabase().getInventoryData().saveInventory(player.getUniqueId(), data);
|
Main.getInstance().getDatabase().getInventoryData().saveInventory(player.getUniqueId(), data);
|
||||||
}
|
}
|
||||||
PlayerLoader.joinPlayer(player);
|
PlayerLoader.joinPlayer(player, currentMap);
|
||||||
board.addHider(player);
|
board.addHider(player);
|
||||||
board.createLobbyBoard(player);
|
board.createLobbyBoard(player);
|
||||||
board.reloadLobbyBoards();
|
board.reloadLobbyBoards();
|
||||||
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
|
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
|
||||||
else broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
|
else broadcastMessage(messagePrefix + message("GAME_JOIN").addPlayer(player));
|
||||||
} else {
|
} else {
|
||||||
PlayerLoader.loadSpectator(player, getGameWorld());
|
PlayerLoader.loadSpectator(player, currentMap);
|
||||||
board.addSpectator(player);
|
board.addSpectator(player);
|
||||||
board.createGameBoard(player);
|
board.createGameBoard(player);
|
||||||
player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
|
player.sendMessage(messagePrefix + message("GAME_JOIN_SPECTATOR"));
|
||||||
|
@ -216,12 +208,12 @@ public class Game {
|
||||||
out.writeUTF(leaveServer);
|
out.writeUTF(leaveServer);
|
||||||
player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
player.teleport(exitPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
if (isNotSetup()) return;
|
if (currentMap.isNotSetup()) return;
|
||||||
if (status == Status.STANDBY) whileWaiting();
|
if (status == Status.STANDBY) whileWaiting();
|
||||||
else if (status == Status.STARTING) whileStarting();
|
else if (status == Status.STARTING) whileStarting();
|
||||||
else if (status == Status.PLAYING) whilePlaying();
|
else if (status == Status.PLAYING) whilePlaying();
|
||||||
|
@ -257,7 +249,7 @@ public class Game {
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
PlayerLoader.resetPlayer(player, board);
|
PlayerLoader.resetPlayer(player, board);
|
||||||
if(board.isSeeker(player)){
|
if(board.isSeeker(player)){
|
||||||
player.teleport(new Location(Bukkit.getWorld(getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(currentMap.getSpawn());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (startingTimer == 1){
|
} else if (startingTimer == 1){
|
||||||
|
@ -317,7 +309,7 @@ public class Game {
|
||||||
board.reloadGameBoards();
|
board.reloadGameBoards();
|
||||||
gameTimer--;
|
gameTimer--;
|
||||||
}
|
}
|
||||||
if (worldBorderEnabled) worldBorder.update();
|
if (currentMap.isWorldBorderEnabled()) currentMap.getWorldBorder().update();
|
||||||
if (tauntEnabled) taunt.update();
|
if (tauntEnabled) taunt.update();
|
||||||
if (glowEnabled || alwaysGlow) glow.update();
|
if (glowEnabled || alwaysGlow) glow.update();
|
||||||
}
|
}
|
||||||
|
@ -331,21 +323,17 @@ public class Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotSetup() {
|
public Map getCurrentMap() {
|
||||||
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return true;
|
return currentMap;
|
||||||
if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return true;
|
|
||||||
if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return true;
|
|
||||||
if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0) return true;
|
|
||||||
if (mapSaveEnabled) {
|
|
||||||
File destination = new File(Main.getInstance().getWorldContainer() + File.separator + getGameWorld());
|
|
||||||
if (!destination.exists()) return true;
|
|
||||||
}
|
|
||||||
return saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGameWorld() {
|
public void setCurrentMap(Map map) {
|
||||||
if (mapSaveEnabled) return "hideandseek_"+spawnWorld;
|
this.currentMap = map;
|
||||||
else return spawnWorld;
|
}
|
||||||
|
|
||||||
|
public World getGameWorld() {
|
||||||
|
if(currentMap == null || currentMap.getSpawn() == null) return null;
|
||||||
|
else return currentMap.getSpawn().getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkWinConditions() {
|
private void checkWinConditions() {
|
||||||
|
|
|
@ -23,9 +23,8 @@ import com.cryptomorin.xseries.messages.Titles;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Items;
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
import org.bukkit.Bukkit;
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -35,30 +34,29 @@ import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.lobbyPosition;
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class PlayerLoader {
|
public class PlayerLoader {
|
||||||
|
|
||||||
public static void loadHider(Player player, String gameWorld){
|
public static void loadHider(Player player, Map map){
|
||||||
player.teleport(new Location(Bukkit.getWorld(gameWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(map.getSpawn());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
||||||
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("HIDER_TEAM_NAME"), ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
|
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("HIDER_TEAM_NAME"), ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
|
||||||
if(blockhuntEnabled){
|
if(map.isBlockHuntEnabled()){
|
||||||
openBlockHuntPicker(player);
|
openBlockHuntPicker(player, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadSeeker(Player player, String gameWorld){
|
public static void loadSeeker(Player player, Map map){
|
||||||
player.teleport(new Location(Bukkit.getWorld(gameWorld), seekerLobbyPosition.getX(),seekerLobbyPosition.getY(),seekerLobbyPosition.getZ()));
|
player.teleport(map.getSeekerLobby());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("SEEKER_TEAM_NAME"), ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString());
|
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("SEEKER_TEAM_NAME"), ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadSpectator(Player player, String gameWorld){
|
public static void loadSpectator(Player player, Map map){
|
||||||
player.teleport(new Location(Bukkit.getWorld(gameWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
player.teleport(map.getSpawn());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
|
@ -115,8 +113,8 @@ public class PlayerLoader {
|
||||||
player.setFallDistance(0.0F);
|
player.setFallDistance(0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void joinPlayer(Player player){
|
public static void joinPlayer(Player player, Map map){
|
||||||
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(),lobbyPosition.getY(),lobbyPosition.getZ()));
|
player.teleport(map.getLobby());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start")))
|
if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start")))
|
||||||
player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
|
player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);
|
||||||
|
@ -143,11 +141,11 @@ public class PlayerLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openBlockHuntPicker(Player player){
|
public static void openBlockHuntPicker(Player player, Map map){
|
||||||
int slots = ((blockhuntBlocks.size()-1)/9)*9+9;
|
int slots = ((map.getBlockHunt().size()-1)/9)*9+9;
|
||||||
Inventory inventory = Main.getInstance().getServer().createInventory(null, slots, "Select a Block");
|
Inventory inventory = Main.getInstance().getServer().createInventory(null, slots, "Select a Block: " + map.getName());
|
||||||
for(int i=0;i<blockhuntBlocks.size();i++){
|
for(int i=0;i<map.getBlockHunt().size();i++){
|
||||||
inventory.setItem(i, new ItemStack(blockhuntBlocks.get(i)));
|
inventory.setItem(i, new ItemStack(map.getBlockHunt().get(i)));
|
||||||
}
|
}
|
||||||
player.openInventory(inventory);
|
player.openInventory(inventory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package net.tylermurphy.hideAndSeek.game.events;
|
package net.tylermurphy.hideAndSeek.game.events;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import org.bukkit.Bukkit;
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
@ -11,9 +10,13 @@ public class Border {
|
||||||
|
|
||||||
private int delay;
|
private int delay;
|
||||||
private boolean running;
|
private boolean running;
|
||||||
|
private final Map map;
|
||||||
|
private int currentSize;
|
||||||
|
|
||||||
public Border() {
|
public Border(Map map) {
|
||||||
delay = 60 * worldBorderDelay;
|
this.map = map;
|
||||||
|
this.delay = (int) (60 * map.getWorldBorderData().getY());
|
||||||
|
this.currentSize = (int) map.getWorldBorderData().getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
@ -21,7 +24,7 @@ public class Border {
|
||||||
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_WARN"));
|
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_WARN"));
|
||||||
} else if (delay == 0) {
|
} else if (delay == 0) {
|
||||||
if (running) {
|
if (running) {
|
||||||
delay = 60 * worldBorderDelay;
|
delay = (int) (60 * map.getWorldBorderData().getY());
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
else decreaseWorldBorder();
|
else decreaseWorldBorder();
|
||||||
|
@ -30,34 +33,30 @@ public class Border {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decreaseWorldBorder() {
|
private void decreaseWorldBorder() {
|
||||||
if (currentWorldborderSize == 100) return;
|
if (currentSize == 100) return;
|
||||||
int change = worldBorderChange;
|
int change = (int) map.getWorldBorderData().getZ();
|
||||||
if (currentWorldborderSize-worldBorderChange < 100) {
|
if (currentSize-change < 100) {
|
||||||
change = currentWorldborderSize-100;
|
change = currentSize-100;
|
||||||
}
|
}
|
||||||
running = true;
|
running = true;
|
||||||
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
|
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
|
||||||
currentWorldborderSize -= worldBorderChange;
|
currentSize -= map.getWorldBorderData().getZ();
|
||||||
World world = Bukkit.getWorld(Main.getInstance().getGame().getGameWorld());
|
org.bukkit.WorldBorder border = map.getSpawn().getWorld().getWorldBorder();
|
||||||
assert world != null;
|
|
||||||
org.bukkit.WorldBorder border = world.getWorldBorder();
|
|
||||||
border.setSize(border.getSize()-change,30);
|
border.setSize(border.getSize()-change,30);
|
||||||
delay = 30;
|
delay = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetWorldBorder(String worldName) {
|
public void resetWorldBorder() {
|
||||||
World world = Bukkit.getWorld(worldName);
|
org.bukkit.WorldBorder border = map.getSpawn().getWorld().getWorldBorder();
|
||||||
assert world != null;
|
if (map.isWorldBorderEnabled()) {
|
||||||
org.bukkit.WorldBorder border = world.getWorldBorder();
|
border.setSize(map.getWorldBorderData().getX());
|
||||||
if (worldBorderEnabled) {
|
border.setCenter(map.getWorldBorderPos().getX(), map.getWorldBorderPos().getY());
|
||||||
border.setSize(worldBorderSize);
|
currentSize = (int) map.getWorldBorderData().getX();
|
||||||
border.setCenter(worldBorderPosition.getX(), worldBorderPosition.getZ());
|
|
||||||
currentWorldborderSize = worldBorderSize;
|
|
||||||
} else {
|
} else {
|
||||||
border.setSize(30000000);
|
border.setSize(30000000);
|
||||||
border.setCenter(0, 0);
|
border.setCenter(0, 0);
|
||||||
}
|
}
|
||||||
delay = 60 * worldBorderDelay;
|
delay = (int) (60 * map.getWorldBorderData().getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDelay() {
|
public int getDelay() {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import net.tylermurphy.hideAndSeek.game.Game;
|
||||||
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -18,7 +17,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.spawnPosition;
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class DamageHandler implements Listener {
|
public class DamageHandler implements Listener {
|
||||||
|
@ -32,8 +30,8 @@ public class DamageHandler implements Listener {
|
||||||
// Define variables
|
// Define variables
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
// If no spawn position, we won't be able to manage their death :o
|
// If map is not setup we won't be able to process on it :o
|
||||||
if (spawnPosition == null) { return; }
|
if (game.getCurrentMap().isNotSetup()) { return; }
|
||||||
// If there is an attacker, find them
|
// If there is an attacker, find them
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
if (((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
if (((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
||||||
|
@ -73,9 +71,9 @@ public class DamageHandler implements Listener {
|
||||||
if (board.isSpectator(player)) {
|
if (board.isSpectator(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (Main.getInstance().supports(18) && player.getLocation().getBlockY() < -64) {
|
if (Main.getInstance().supports(18) && player.getLocation().getBlockY() < -64) {
|
||||||
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(game.getCurrentMap().getSpawn());
|
||||||
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
|
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
|
||||||
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(game.getCurrentMap().getSpawn());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,15 +96,15 @@ public class DamageHandler implements Listener {
|
||||||
Main.getInstance().getDisguiser().reveal(player);
|
Main.getInstance().getDisguiser().reveal(player);
|
||||||
// Teleport player to seeker spawn
|
// Teleport player to seeker spawn
|
||||||
if(delayedRespawn){
|
if(delayedRespawn){
|
||||||
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), seekerLobbyPosition.getX(), seekerLobbyPosition.getY(), seekerLobbyPosition.getZ()));
|
player.teleport(game.getCurrentMap().getSeekerLobby());
|
||||||
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
|
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
||||||
if(game.getStatus() == Status.PLAYING){
|
if(game.getStatus() == Status.PLAYING){
|
||||||
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(game.getCurrentMap().getSpawn());
|
||||||
}
|
}
|
||||||
}, delayedRespawnDelay * 20L);
|
}, delayedRespawnDelay * 20L);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(new Location(Bukkit.getWorld(game.getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
|
player.teleport(game.getCurrentMap().getSpawn());
|
||||||
}
|
}
|
||||||
// Add leaderboard stats
|
// Add leaderboard stats
|
||||||
board.addDeath(player.getUniqueId());
|
board.addDeath(player.getUniqueId());
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class InteractHandler implements Listener {
|
||||||
|
|
||||||
if (temp.isSimilar(lobbyStartItem) && event.getPlayer().hasPermission("hideandseek.start")) {
|
if (temp.isSimilar(lobbyStartItem) && event.getPlayer().hasPermission("hideandseek.start")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (Main.getInstance().getGame().isNotSetup()) {
|
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
||||||
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
|
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
import com.cryptomorin.xseries.XMaterial;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.command.Debug;
|
import net.tylermurphy.hideAndSeek.command.Debug;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -79,17 +81,22 @@ public class InventoryHandler implements Listener {
|
||||||
|
|
||||||
private void checkForBlockHuntMenu(InventoryClickEvent event){
|
private void checkForBlockHuntMenu(InventoryClickEvent event){
|
||||||
boolean test;
|
boolean test;
|
||||||
|
String mapName;
|
||||||
if(Main.getInstance().supports(14)){
|
if(Main.getInstance().supports(14)){
|
||||||
test = event.getView().getTitle().equals("Select a Block");
|
test = event.getView().getTitle().startsWith("Select a Block: ");
|
||||||
|
mapName = event.getView().getTitle().substring("Select a Block: ".length());
|
||||||
} else {
|
} else {
|
||||||
test = event.getInventory().getName().equals("Select a Block");
|
test = event.getInventory().getName().startsWith("Select a Block: ");
|
||||||
|
mapName = event.getInventory().getName().substring("Select a Block: ".length());
|
||||||
}
|
}
|
||||||
if(!test) return;
|
if(!test) return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Material mat = blockhuntBlocks.get(event.getRawSlot());
|
Map map = Maps.getMap(mapName);
|
||||||
|
if(map == null) return;
|
||||||
|
Material mat = map.getBlockHunt().get(event.getRawSlot());
|
||||||
if(mat == null) return;
|
if(mat == null) return;
|
||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
Main.getInstance().getDisguiser().disguise(player, mat);
|
Main.getInstance().getDisguiser().disguise(player, mat, map);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,17 +104,22 @@ public class InventoryHandler implements Listener {
|
||||||
public void onInventoryClose(InventoryCloseEvent event){
|
public void onInventoryClose(InventoryCloseEvent event){
|
||||||
if (!(event.getPlayer() instanceof Player)) return;
|
if (!(event.getPlayer() instanceof Player)) return;
|
||||||
boolean test;
|
boolean test;
|
||||||
|
String mapName;
|
||||||
if(Main.getInstance().supports(14)){
|
if(Main.getInstance().supports(14)){
|
||||||
test = event.getView().getTitle().equals("Select a Block");
|
test = event.getView().getTitle().startsWith("Select a Block: ");
|
||||||
|
mapName = event.getView().getTitle().substring("Select a Block: ".length());
|
||||||
} else {
|
} else {
|
||||||
test = event.getInventory().getName().equals("Select a Block");
|
test = event.getInventory().getName().startsWith("Select a Block: ");
|
||||||
|
mapName = event.getInventory().getName().substring("Select a Block: ".length());
|
||||||
}
|
}
|
||||||
if(!test) return;
|
if(!test) return;
|
||||||
Material mat = blockhuntBlocks.get(0);
|
Map map = Maps.getMap(mapName);
|
||||||
|
if(map == null) return;
|
||||||
|
Material mat = map.getBlockHunt().get(0);
|
||||||
if(mat == null) return;
|
if(mat == null) return;
|
||||||
Player player = (Player) event.getPlayer();
|
Player player = (Player) event.getPlayer();
|
||||||
if(Main.getInstance().getDisguiser().disguised(player)) return;
|
if(Main.getInstance().getDisguiser().disguised(player)) return;
|
||||||
Main.getInstance().getDisguiser().disguise(player, mat);
|
Main.getInstance().getDisguiser().disguise(player, mat, map);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Items;
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -17,8 +15,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
|
|
||||||
|
|
||||||
public class JoinLeaveHandler implements Listener {
|
public class JoinLeaveHandler implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
@ -28,20 +24,20 @@ public class JoinLeaveHandler implements Listener {
|
||||||
}
|
}
|
||||||
Main.getInstance().getBoard().remove(event.getPlayer());
|
Main.getInstance().getBoard().remove(event.getPlayer());
|
||||||
removeItems(event.getPlayer());
|
removeItems(event.getPlayer());
|
||||||
if (Main.getInstance().getGame().isNotSetup()) return;
|
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) return;
|
||||||
if (autoJoin) {
|
if (autoJoin) {
|
||||||
Main.getInstance().getGame().join(event.getPlayer());
|
Main.getInstance().getGame().join(event.getPlayer());
|
||||||
} else if (teleportToExit) {
|
} else if (teleportToExit) {
|
||||||
if (event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld()) || event.getPlayer().getWorld().getName().equals(lobbyWorld)) {
|
if (event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName()) || event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getLobby().getWorld().getName())) {
|
||||||
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
event.getPlayer().teleport(exitPosition);
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) {
|
if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) {
|
||||||
if (Main.getInstance().getGame().getStatus() != Status.STANDBY && Main.getInstance().getGame().getStatus() != Status.ENDING) {
|
if (Main.getInstance().getGame().getStatus() != Status.STANDBY && Main.getInstance().getGame().getStatus() != Status.ENDING) {
|
||||||
Main.getInstance().getGame().join(event.getPlayer());
|
Main.getInstance().getGame().join(event.getPlayer());
|
||||||
} else {
|
} else {
|
||||||
event.getPlayer().teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
|
event.getPlayer().teleport(exitPosition);
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.game.listener;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
import net.tylermurphy.hideAndSeek.game.listener.events.PlayerJumpEvent;
|
import net.tylermurphy.hideAndSeek.game.listener.events.PlayerJumpEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -12,9 +13,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.saveMaxZ;
|
|
||||||
|
|
||||||
public class MovementHandler implements Listener {
|
public class MovementHandler implements Listener {
|
||||||
|
|
||||||
private final Set<UUID> prevPlayersOnGround = Sets.newHashSet();
|
private final Set<UUID> prevPlayersOnGround = Sets.newHashSet();
|
||||||
|
@ -51,10 +49,11 @@ public class MovementHandler implements Listener {
|
||||||
|
|
||||||
private void checkBounds(PlayerMoveEvent event){
|
private void checkBounds(PlayerMoveEvent event){
|
||||||
if (!Main.getInstance().getBoard().contains(event.getPlayer())) return;
|
if (!Main.getInstance().getBoard().contains(event.getPlayer())) return;
|
||||||
if (!event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) return;
|
if (!event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) return;
|
||||||
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) return;
|
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) return;
|
||||||
if (event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
|
if (event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
|
||||||
if (event.getTo().getBlockX() < saveMinX || event.getTo().getBlockX() > saveMaxX || event.getTo().getBlockZ() < saveMinZ || event.getTo().getBlockZ() > saveMaxZ) {
|
Map map = Main.getInstance().getGame().getCurrentMap();
|
||||||
|
if (event.getTo().getBlockX() < map.getBoundsMin().getBlockX() || event.getTo().getBlockX() > map.getBoundsMax().getBlockX() || event.getTo().getBlockZ() < map.getBoundsMin().getZ() || event.getTo().getBlockZ() > map.getBoundsMax().getZ()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
package net.tylermurphy.hideAndSeek.world;
|
package net.tylermurphy.hideAndSeek.world;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Map;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
@ -33,16 +33,19 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class WorldLoader {
|
public class WorldLoader {
|
||||||
|
|
||||||
|
private Map map;
|
||||||
private String mapName;
|
private String mapName;
|
||||||
private String saveName;
|
private String saveName;
|
||||||
|
|
||||||
public WorldLoader(String mapName) {
|
public WorldLoader(Map map) {
|
||||||
this.mapName = mapName;
|
this.map = map;
|
||||||
|
this.mapName = map.getSpawn() == null ? "world" : map.getSpawn().getWorld().getName();
|
||||||
this.saveName = "hideandseek_"+ mapName;
|
this.saveName = "hideandseek_"+ mapName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewMap(String mapName){
|
public void setNewMap(Map map){
|
||||||
this.mapName = mapName;
|
this.map = map;
|
||||||
|
this.mapName = map.getSpawn() == null ? "world" : map.getSpawn().getWorld().getName();
|
||||||
this.saveName = "hideandseek_"+ mapName;
|
this.saveName = "hideandseek_"+ mapName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +59,7 @@ public class WorldLoader {
|
||||||
Main.getInstance().getLogger().warning(saveName + " already unloaded.");
|
Main.getInstance().getLogger().warning(saveName + " already unloaded.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
world.getPlayers().forEach(player -> player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ())));
|
world.getPlayers().forEach(player -> player.teleport(exitPosition));
|
||||||
if (Bukkit.getServer().unloadWorld(world, false)) {
|
if (Bukkit.getServer().unloadWorld(world, false)) {
|
||||||
Main.getInstance().getLogger().info("Successfully unloaded " + saveName);
|
Main.getInstance().getLogger().info("Successfully unloaded " + saveName);
|
||||||
}else{
|
}else{
|
||||||
|
@ -127,10 +130,10 @@ public class WorldLoader {
|
||||||
}
|
}
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
if (isMca) {
|
if (isMca) {
|
||||||
int minX = (int)Math.floor(saveMinX / 512.0);
|
int minX = (int)Math.floor(map.getBoundsMin().getX() / 512.0);
|
||||||
int minZ = (int)Math.floor(saveMinZ / 512.0);
|
int minZ = (int)Math.floor(map.getBoundsMin().getZ() / 512.0);
|
||||||
int maxX = (int)Math.floor(saveMaxX / 512.0);
|
int maxX = (int)Math.floor(map.getBoundsMax().getX() / 512.0);
|
||||||
int maxZ = (int)Math.floor(saveMaxZ / 512.0);
|
int maxZ = (int)Math.floor(map.getBoundsMax().getZ() / 512.0);
|
||||||
|
|
||||||
String[] parts = file.split("\\.");
|
String[] parts = file.split("\\.");
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
|
|
|
@ -292,40 +292,8 @@ blockedInteracts: [FURNACE, CRAFTING_TABLE, ANVIL, CHEST, BARREL]
|
||||||
# ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING #
|
# ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING #
|
||||||
# ---------------------------------------------------------- #
|
# ---------------------------------------------------------- #
|
||||||
|
|
||||||
# The 2 coordinate bounds that will contain your hideAndSeek map. Its recommended
|
# Location where players are teleported when they exit (/hs leave)
|
||||||
# that you use /hs setbounds for this, and not edit this directly, as breaking
|
exit:
|
||||||
# this section will completely break the entire plugin when you run /hs savemap.
|
|
||||||
bounds:
|
|
||||||
min:
|
|
||||||
x: 0
|
|
||||||
z: 0
|
|
||||||
max:
|
|
||||||
x: 0
|
|
||||||
z: 0
|
|
||||||
|
|
||||||
# Spawn locations where players are teleported
|
|
||||||
spawns:
|
|
||||||
# Location where players are teleported into the game (/hs start)
|
|
||||||
game:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
z: 0
|
|
||||||
world: world
|
|
||||||
# Location where players are teleported into the lobby (/hs join)
|
|
||||||
lobby:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
z: 0
|
|
||||||
world: world
|
|
||||||
# Location where seekers wait during the hiding grace period
|
|
||||||
seeker:
|
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
z: 0
|
|
||||||
# Currently is not used, seekers are teleported to spawns.game.world
|
|
||||||
world: world
|
|
||||||
# Location where players are teleported when they exit (/hs leave)
|
|
||||||
exit:
|
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
z: 0
|
z: 0
|
||||||
|
|
1
src/main/resources/maps.yml
Normal file
1
src/main/resources/maps.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
maps:
|
Loading…
Reference in a new issue