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