summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2023-02-08 23:24:53 +0000
committertylermurphy534 <tylermurphy534@gmail.com>2023-02-08 23:24:53 +0000
commitb87174e7701863f54ab26998feaf4bdaa9a0df20 (patch)
treebf3cec7f3d0be7aa6bc26fc647a06527dfe49235 /src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
parentMerge pull request '1.7.0 - Multi Map Support' (#4) from dev into main (diff)
parentupdate dependicies, fix worldborder, fix timer when player leaves, fix drop i... (diff)
downloadkenshinshideandseek-b87174e7701863f54ab26998feaf4bdaa9a0df20.tar.gz
kenshinshideandseek-b87174e7701863f54ab26998feaf4bdaa9a0df20.tar.bz2
kenshinshideandseek-b87174e7701863f54ab26998feaf4bdaa9a0df20.zip
Merge pull request '1.7.1 - A few tweaks and bug squashes' (#5) from dev into main
Reviewed-on: https://g.tylerm.dev/tylermurphy534/KenshinsHideAndSeek/pulls/5
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java363
1 files changed, 183 insertions, 180 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
index a23a1f7..394bbf3 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/configuration/Map.java
@@ -15,224 +15,227 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class Map {
- private final String name;
+ private final String name;
- private Location
- spawnPosition = Location.getDefault(),
- lobbyPosition = Location.getDefault(),
- seekerLobbyPosition = Location.getDefault();
+ private Location
+ spawnPosition = Location.getDefault(),
+ lobbyPosition = Location.getDefault(),
+ seekerLobbyPosition = Location.getDefault();
- private int
- xBoundMin = 0,
- zBoundMin = 0,
- xBoundMax = 0,
- zBoundMax = 0,
- xWorldBorder = 0,
- zWorldBorder = 0,
- worldBorderSize = 0,
- worldBorderDelay = 0,
- worldBorderChange = 0;
+ private int
+ xBoundMin = 0,
+ zBoundMin = 0,
+ xBoundMax = 0,
+ zBoundMax = 0,
+ xWorldBorder = 0,
+ zWorldBorder = 0,
+ worldBorderSize = 0,
+ worldBorderDelay = 0,
+ worldBorderChange = 0;
- private boolean
- blockhunt = false;
+ private boolean
+ blockhunt = false;
- private List<Material>
- blockhuntBlocks = new ArrayList<>();
+ private List<Material>
+ blockhuntBlocks = new ArrayList<>();
- private final Border
- worldBorder;
+ private final Border
+ worldBorder;
- private final WorldLoader
- worldLoader;
+ private final WorldLoader
+ worldLoader;
- public Map(String name) {
- this.name = name;
- this.worldBorder = new Border(this);
- this.worldLoader = new WorldLoader(this);
- }
+ 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;
- }
+ public void setSpawn(Location pos) {
+ this.spawnPosition = pos;
+ }
- public void setLobby(Location pos) {
- this.lobbyPosition = pos;
- }
+ public void setLobby(Location pos) {
+ this.lobbyPosition = pos;
+ }
- public void setSeekerLobby(Location pos) {
- this.seekerLobbyPosition = 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;
- } else {
- this.worldBorderSize = size;
- this.worldBorderDelay = delay;
- this.worldBorderChange = move;
- this.xWorldBorder = x;
- this.zWorldBorder = z;
+ 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;
+ } else {
+ this.worldBorderSize = size;
+ this.worldBorderDelay = delay;
+ this.worldBorderChange = move;
+ this.xWorldBorder = x;
+ this.zWorldBorder = z;
+ }
+ this.worldBorder.resetWorldBorder();
}
- this.worldBorder.resetWorldBorder();
- }
- public void setBlockhunt(boolean enabled, List<Material> blocks) {
- if (Main.getInstance().supports(9)) {
- this.blockhunt = enabled;
- } else {
- this.blockhunt = false;
+ public void setBlockhunt(boolean enabled, List<Material> blocks) {
+ if (Main.getInstance().supports(9)) {
+ this.blockhunt = enabled;
+ } else {
+ this.blockhunt = false;
+ }
+ this.blockhuntBlocks = blocks;
}
- this.blockhuntBlocks = blocks;
- }
- public void setBoundMin(int x, int z) {
- this.xBoundMin = x;
- this.zBoundMin = z;
- }
+ 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 void setBoundMax(int x, int z) {
+ this.xBoundMax = x;
+ this.zBoundMax = z;
+ }
- @NotNull
- public Location getGameSpawn() {
- if(mapSaveEnabled) {
- return spawnPosition.changeWorld("hs_"+name);
- } else {
- return spawnPosition;
+ @NotNull
+ public Location getGameSpawn() {
+ if(mapSaveEnabled) {
+ return spawnPosition.changeWorld("hs_"+name);
+ } else {
+ return spawnPosition;
+ }
}
- }
- @NotNull
- public String getGameSpawnName() {
- if(mapSaveEnabled)
- return getGameSpawn().getWorld();
- else
- return getSpawn().getWorld();
- }
+ @NotNull
+ public String getGameSpawnName() {
+ if(mapSaveEnabled)
+ return getGameSpawn().getWorld();
+ else
+ return getSpawn().getWorld();
+ }
- @NotNull
- public Location getSpawn() {
- return spawnPosition;
- }
+ @NotNull
+ public Location getSpawn() {
+ return spawnPosition;
+ }
- @NotNull
- public String getSpawnName() {
- return getSpawn().getWorld();
- }
+ @NotNull
+ public String getSpawnName() {
+ return getSpawn().getWorld();
+ }
- @NotNull
- public Location getLobby() {
- return lobbyPosition;
- }
+ @NotNull
+ public Location getLobby() {
+ return lobbyPosition;
+ }
- @NotNull
- public String getLobbyName() {
- return getLobby().getWorld();
- }
+ @NotNull
+ public String getLobbyName() {
+ return getLobby().getWorld();
+ }
- @NotNull
- public Location getSeekerLobby() {
- return seekerLobbyPosition;
- }
+ @NotNull
+ public Location getSeekerLobby() {
+ return seekerLobbyPosition;
+ }
- @NotNull
- public String getSeekerLobbyName() {
- return getSeekerLobby().getWorld();
- }
+ @NotNull
+ public String getSeekerLobbyName() {
+ return getSeekerLobby().getWorld();
+ }
- @NotNull
- public Location getGameSeekerLobby() {
- if(mapSaveEnabled) {
- return seekerLobbyPosition.changeWorld("hs_"+name);
- } else {
- return seekerLobbyPosition;
+ @NotNull
+ public Location getGameSeekerLobby() {
+ if(mapSaveEnabled) {
+ return seekerLobbyPosition.changeWorld("hs_"+name);
+ } else {
+ return seekerLobbyPosition;
+ }
}
- }
- public boolean isWorldBorderEnabled() {
- return worldBorderSize > 0;
- }
+ public boolean isWorldBorderEnabled() {
+ return worldBorderSize > 0;
+ }
- @NotNull
- public Vector getWorldBorderPos() {
- return new Vector(
- xWorldBorder,
- 0,
- zWorldBorder
- );
- }
+ @NotNull
+ public Vector getWorldBorderPos() {
+ return new Vector(
+ xWorldBorder,
+ 0,
+ zWorldBorder
+ );
+ }
- @NotNull
- public Vector getWorldBorderData() {
- return new Vector(
- worldBorderSize,
- worldBorderDelay,
- worldBorderChange
- );
- }
+ @NotNull
+ public Vector getWorldBorderData() {
+ return new Vector(
+ worldBorderSize,
+ worldBorderDelay,
+ worldBorderChange
+ );
+ }
- @NotNull
- public Border getWorldBorder() {
- return worldBorder;
- }
+ @NotNull
+ public Border getWorldBorder() {
+ return worldBorder;
+ }
- public boolean isBlockHuntEnabled() {
- return blockhunt;
- }
+ public boolean isBlockHuntEnabled() {
+ return blockhunt;
+ }
- @NotNull
- public List<Material> getBlockHunt() {
- return blockhuntBlocks;
- }
+ @NotNull
+ public List<Material> getBlockHunt() {
+ return blockhuntBlocks;
+ }
- @NotNull
- public Vector getBoundsMin() {
- return new Vector(
- xBoundMin,
- 0,
- zBoundMin
- );
- }
+ @NotNull
+ public Vector getBoundsMin() {
+ return new Vector(
+ xBoundMin,
+ 0,
+ zBoundMin
+ );
+ }
- @NotNull
- public Vector getBoundsMax() {
- return new Vector(
- xBoundMax,
- 0,
- zBoundMax
- );
- }
+ @NotNull
+ public Vector getBoundsMax() {
+ return new Vector(
+ xBoundMax,
+ 0,
+ zBoundMax
+ );
+ }
- @NotNull
- public String getName() {
- return name;
- }
+ @NotNull
+ public String getName() {
+ return name;
+ }
- @NotNull
- public WorldLoader getWorldLoader() {
- return worldLoader;
- }
+ @NotNull
+ public WorldLoader getWorldLoader() {
+ return worldLoader;
+ }
- public boolean isNotSetup() {
- if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || !spawnPosition.exists()) return true;
- if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || !lobbyPosition.exists()) return true;
- if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) return true;
- if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || !seekerLobbyPosition.exists()) return true;
- if (mapSaveEnabled && !getGameSpawn().exists()) return true;
- if (blockhunt && blockhuntBlocks.isEmpty()) 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 isNotSetup() {
+ if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || !spawnPosition.exists()) return true;
+ if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || !lobbyPosition.exists()) return true;
+ if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) return true;
+ if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || !seekerLobbyPosition.exists()) return true;
+ if (mapSaveEnabled && !getGameSpawn().exists()) return true;
+ if (blockhunt && blockhuntBlocks.isEmpty()) return true;
+ if(isWorldBorderEnabled() &&
+ new Vector(spawnPosition.getX(), 0, spawnPosition.getZ()).distance(new Vector(xWorldBorder, 0, zWorldBorder)) > 100) return true;
+ return isBoundsNotSetup();
+ }
- public boolean isBoundsNotSetup() {
- return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0;
- }
+ public boolean isBoundsNotSetup() {
+ if (xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0) return true;
+ int xDiff = xBoundMax - xBoundMin;
+ int zDiff = zBoundMax - zBoundMin;
+ return xDiff < 5 || zDiff < 5;
+ }
}