1.7.0 beta 3

This commit is contained in:
Tyler Murphy 2022-11-02 13:38:22 -04:00
parent bb254145ed
commit 37b3840ca1
17 changed files with 324 additions and 64 deletions

View file

@ -21,6 +21,7 @@ package net.tylermurphy.hideAndSeek;
import net.tylermurphy.hideAndSeek.command.*;
import net.tylermurphy.hideAndSeek.command.map.*;
import net.tylermurphy.hideAndSeek.command.map.blockhunt.Enabled;
import net.tylermurphy.hideAndSeek.command.map.set.*;
import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.database.Database;
@ -87,6 +88,14 @@ public class Main extends JavaPlugin implements Listener {
new Start(),
new Stop(),
new CommandGroup("map",
new CommandGroup("blockhunt",
new CommandGroup("blocks",
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Add(),
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Remove(),
new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.List()
),
new Enabled()
),
new CommandGroup("set",
new Lobby(),
new Spawn(),
@ -99,7 +108,8 @@ public class Main extends JavaPlugin implements Listener {
new List(),
new Status(),
new Save(),
new Debug()
new Debug(),
new GoTo()
),
new SetExitLocation(),
new Top(),

View file

@ -74,20 +74,12 @@ public class Debug extends Command {
player.setHealth(0.1);
}
}));
debugMenu.setItem(6, createOption(functions, 6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
if(mapSaveEnabled) {
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
player.teleport(map.getGameSpawn());
}));
debugMenu.setItem(7, createOption(functions, 7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
player.teleport(map.getLobby());
}));
debugMenu.setItem(8, createOption(functions, 8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition)));
debugMenu.setItem(9, createOption(functions, 9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
if(map.isBlockHuntEnabled()) {
debugMenu.setItem(9, createOption(functions, 7, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
PlayerLoader.openBlockHuntPicker(player, map);
}));
debugMenu.setItem(10, createOption(functions, 10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
debugMenu.setItem(10, createOption(functions, 8, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
}
debugMenuFunctions.put(sender, functions);
return debugMenu;
}

View file

@ -56,6 +56,10 @@ public class Save extends Command {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
if (map.isBoundsNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_MAP_BOUNDS"));
return;
}
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
World world = map.getSpawn().getWorld();

View file

@ -41,31 +41,33 @@ public class Status extends Command {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || Map.worldDoesntExist(map.getLobbyName())) {
msg = msg + "\n" + message("SETUP_GAME");
count++;
}
if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || Map.worldDoesntExist(map.getLobbyName())) {
msg = msg + "\n" + message("SETUP_LOBBY");
count++;
}
if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !Map.worldExists(map.getSeekerLobbyName())) {
if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || Map.worldDoesntExist(map.getSeekerLobbyName())) {
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
count++;
}
if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld)) {
if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || Map.worldDoesntExist(exitWorld)) {
msg = msg + "\n" + message("SETUP_EXIT");
count++;
}
if (map.getBoundsMin().getBlockX() == 0 || map.getBoundsMin().getBlockZ() == 0 ||
map.getBoundsMax().getBlockX() == 0 || map.getBoundsMax().getBlockX() == 0) {
if (map.isBoundsNotSetup()) {
msg = msg + "\n" + message("SETUP_BOUNDS");
count++;
}
if (mapSaveEnabled && !Map.worldExists(map.getGameSpawnName())) {
if (mapSaveEnabled && Map.worldDoesntExist(map.getGameSpawnName())) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
count++;
}
if (map.isBlockHuntEnabled() && map.getBlockHunt().isEmpty()) {
msg = msg + "\n" + message("SETUP_BLOCKHUNT");
}
if (count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
} else {

View file

@ -1,21 +1,38 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Enabled extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
map.setLobby(sender.getLocation());
});
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
boolean bool = Boolean.parseBoolean(args[1]);
map.setBlockhunt(bool, map.getBlockHunt());
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_SET_TO")
.addAmount(bool ? ChatColor.GREEN + "true" : ChatColor.RED + "false") + ChatColor.WHITE);
}
public String getLabel() {
@ -27,7 +44,7 @@ public class Enabled extends Command {
}
public String getDescription() {
return "Sets hide and seeks lobby location to current position";
return "Sets blockhunt enabled or disabled in a current map";
}
public List<String> autoComplete(String parameter) {

View file

@ -0,0 +1,68 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command;
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;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Add extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
Material block;
try { block = Material.valueOf(args[1]); }
catch (IllegalArgumentException e) {
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
return;
}
List<Material> blocks = map.getBlockHunt();
if(blocks.contains(block)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_EXISTS").addAmount(args[1]));
}
blocks.add(block);
map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_ADDED").addAmount(args[1]));
}
public String getLabel() {
return "add";
}
public String getUsage() {
return "<map> <block>";
}
public String getDescription() {
return "Add a blockhunt block to a map!";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
} else if(parameter != null && parameter.equals("block")) {
return Arrays.stream(Material.values()).filter(Material::isBlock).map(Material::toString).collect(Collectors.toList());
}
return null;
}
}

View file

@ -0,0 +1,54 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class List extends Command {
public void execute(Player sender, String[] args) {
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
java.util.List<Material> blocks = map.getBlockHunt();
if(blocks.isEmpty()) {
sender.sendMessage(errorPrefix + message("NO_BLOCKS"));
return;
}
StringBuilder response = new StringBuilder(messagePrefix + message("BLOCKHUNT_LIST_BLOCKS"));
for(int i = 0; i < blocks.size(); i++) {
response.append(String.format("\n%s. %s", i, blocks.get(i).toString()));
}
sender.sendMessage(response.toString());
}
public String getLabel() {
return "list";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "List all blockhunt blocks in a map";
}
public java.util.List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -0,0 +1,68 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command;
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;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Remove extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
Material block;
try { block = Material.valueOf(args[1]); }
catch (IllegalArgumentException e) {
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
return;
}
java.util.List<Material> blocks = map.getBlockHunt();
if(!blocks.contains(block)) {
sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_DOESNT_EXIT").addAmount(args[1]));
}
blocks.remove(block);
map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_REMOVED").addAmount(args[1]));
}
public String getLabel() {
return "remove";
}
public String getUsage() {
return "<map> <block>";
}
public String getDescription() {
return "Remove a blockhunt block from a map!";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
} else if(parameter != null && parameter.equals("block")) {
return Arrays.stream(Material.values()).filter(Material::isBlock).map(Material::toString).collect(Collectors.toList());
}
return null;
}
}

View file

@ -67,7 +67,7 @@ public class CommandGroup {
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
} else {
player.sendMessage(
String.format("%s%sHide and Seek %s(%s1.7.0 ALPHA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%s%sHide and Seek %s(%s1.7.0 BETA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);

View file

@ -137,16 +137,16 @@ public class Config {
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
//Prefix
char SYMBOLE = '\u00A7';
String SYMBOLE_STRING = String.valueOf(SYMBOLE);
char SYMBOL = '\u00A7';
String SYMBOL_STRING = String.valueOf(SYMBOL);
messagePrefix = config.getString("prefix.default").replace("&", SYMBOLE_STRING);
errorPrefix = config.getString("prefix.error").replace("&", SYMBOLE_STRING);
tauntPrefix = config.getString("prefix.taunt").replace("&", SYMBOLE_STRING);
worldBorderPrefix = config.getString("prefix.border").replace("&", SYMBOLE_STRING);
abortPrefix = config.getString("prefix.abort").replace("&", SYMBOLE_STRING);
gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOLE_STRING);
warningPrefix = config.getString("prefix.warning").replace("&", SYMBOLE_STRING);
messagePrefix = config.getString("prefix.default").replace("&", SYMBOL_STRING);
errorPrefix = config.getString("prefix.error").replace("&", SYMBOL_STRING);
tauntPrefix = config.getString("prefix.taunt").replace("&", SYMBOL_STRING);
worldBorderPrefix = config.getString("prefix.border").replace("&", SYMBOL_STRING);
abortPrefix = config.getString("prefix.abort").replace("&", SYMBOL_STRING);
gameOverPrefix = config.getString("prefix.gameover").replace("&", SYMBOL_STRING);
warningPrefix = config.getString("prefix.warning").replace("&", SYMBOL_STRING);
// Locations
exitPosition = new Location(
@ -211,8 +211,7 @@ public class Config {
try {
countdownDisplay = CountdownDisplay.valueOf(config.getString("hideCountdownDisplay"));
} catch (IllegalArgumentException e) {
countdownDisplay = CountdownDisplay.CHAT;
Main.getInstance().getLogger().warning("hideCountdownDisplay: "+config.getString("hideCountdownDisplay")+" is not a valid configuration option!");
throw new RuntimeException("hideCountdownDisplay: "+config.getString("hideCountdownDisplay")+", is not a valid configuration option!");
}
blockedInteracts = new ArrayList<>();
List<String> tempInteracts = config.getStringList("blockedInteracts");
@ -255,8 +254,7 @@ public class Config {
databaseType = config.getString("databaseType").toUpperCase();
if(!databaseType.equals("SQLITE") && !databaseType.equals("MYSQL")){
Main.getInstance().getLogger().warning("databaseType: "+databaseType+" is not a valid configuration option!");
databaseType = "SQLITE";
throw new RuntimeException("databaseType: "+databaseType+" is not a valid configuration option!");
}
delayedRespawn = config.getBoolean("delayedRespawn.enabled");

View file

@ -344,6 +344,8 @@ public class ConfigManager {
private String convert(Object o) {
if(o instanceof String) {
return "\"" + o + "\"";
} else if (o instanceof Boolean) {
return (boolean)o ? "true" : "false";
}
return o.toString();
}

View file

@ -31,8 +31,15 @@ public class Localization {
public static final Map<String,LocalizationString> DEFAULT_LOCAL = new HashMap<>();
private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{
put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"},{"GAME_SETUP"}});
put("de-DE", new String[][]{{},{"TAUNTED"}});
put("en-US", new String[][]{
{"WORLDBORDER_DECREASING"},
{"START","TAUNTED"},
{"GAME_SETUP", "SETUP_GAME", "SETUP_LOBBY", "SETUP_SEEKER_LOBBY", "SETUP_EXIT", "SETUP_SAVEMAP", "SETUP_BOUNDS"}
});
put("de-DE", new String[][]{
{},
{"TAUNTED"}
});
}};
public static void loadLocalization() {

View file

@ -6,10 +6,10 @@ 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 org.jetbrains.annotations.NotNull;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
@ -118,6 +118,7 @@ public class Map {
this.zBoundMax = z;
}
@NotNull
public Location getGameSpawn() {
if(mapSaveEnabled) {
return new Location(
@ -131,6 +132,7 @@ public class Map {
}
}
@NotNull
public String getGameSpawnName() {
if(mapSaveEnabled)
return "hs_"+ spawnWorldName;
@ -138,30 +140,37 @@ public class Map {
return spawnWorldName;
}
@NotNull
public Location getSpawn() {
return spawnPosition;
}
@NotNull
public String getSpawnName() {
return spawnWorldName;
}
@NotNull
public Location getLobby() {
return lobbyPosition;
}
@NotNull
public String getLobbyName() {
return lobbyWorldName;
}
@NotNull
public Location getSeekerLobby() {
return seekerLobbyPosition;
}
@NotNull
public String getSeekerLobbyName() {
return seekerLobbyWorldName;
}
@NotNull
public Location getGameSeekerLobby() {
if(mapSaveEnabled) {
return new Location(
@ -179,6 +188,7 @@ public class Map {
return worldBorderSize > 0;
}
@NotNull
public Vector getWorldBorderPos() {
return new Vector(
xWorldBorder,
@ -187,6 +197,7 @@ public class Map {
);
}
@NotNull
public Vector getWorldBorderData() {
return new Vector(
worldBorderSize,
@ -195,6 +206,7 @@ public class Map {
);
}
@NotNull
public Border getWorldBorder() {
return worldBorder;
}
@ -203,10 +215,12 @@ public class Map {
return blockhunt;
}
@NotNull
public List<Material> getBlockHunt() {
return blockhuntBlocks;
}
@NotNull
public Vector getBoundsMin() {
return new Vector(
xBoundMin,
@ -215,6 +229,7 @@ public class Map {
);
}
@NotNull
public Vector getBoundsMax() {
return new Vector(
xBoundMax,
@ -223,20 +238,23 @@ public class Map {
);
}
@NotNull
public String getName() {
return name;
}
@NotNull
public WorldLoader getWorldLoader() {
return worldLoader;
}
public boolean isNotSetup() {
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || !Map.worldExists(spawnWorldName)) return true;
if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || !Map.worldExists(lobbyWorldName)) return true;
if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld) ) return true;
if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || !Map.worldExists(seekerLobbyWorldName)) return true;
if (mapSaveEnabled && !Map.worldExists(getGameSpawnName())) return true;
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || Map.worldDoesntExist(spawnWorldName)) return true;
if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || Map.worldDoesntExist(lobbyWorldName)) return true;
if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || Map.worldDoesntExist(exitWorld)) return true;
if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || Map.worldDoesntExist(seekerLobbyWorldName)) return true;
if (mapSaveEnabled && Map.worldDoesntExist(getGameSpawnName())) 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;
@ -246,9 +264,13 @@ public class Map {
return spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0;
}
public static boolean worldExists(String worldName) {
public boolean isBoundsNotSetup() {
return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0;
}
public static boolean worldDoesntExist(String worldName) {
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+worldName);
return destination.isDirectory();
return !destination.isDirectory();
}
}

View file

@ -11,15 +11,19 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.cryptomorin.xseries.XMaterial;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class Maps {
private static final HashMap<String, Map> MAPS = new HashMap<>();
@Nullable
public static Map getMap(String name) {
return MAPS.get(name);
}
@Nullable
public static Map getRandomMap() {
Optional<Map> map;
if(MAPS.values().size() > 0) {
@ -45,6 +49,7 @@ public class Maps {
return status;
}
@NotNull
public static Collection<Map> getAllMaps() {
return MAPS.values();
}
@ -102,7 +107,7 @@ public class Maps {
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);
if(!Map.worldExists(worldName)) return new Location(null, 0, 0, 0);
if(Map.worldDoesntExist(worldName)) return new Location(null, 0, 0, 0);
World world = Bukkit.getWorld(worldName);
double x = data.getDouble("spawns."+spawn+".x");
double y = data.getDouble("spawns."+spawn+".y");
@ -141,7 +146,7 @@ public class Maps {
private static void saveSpawn(ConfigurationSection data, Location spawn, String name, Map map) {
String worldName = getWorldName(name, map);
if(worldName == null || !Map.worldExists(worldName)) {
if(worldName == null || Map.worldDoesntExist(worldName)) {
data.set("spawns." + name + ".world", "world");
} else {
data.set("spawns." + name + ".world", worldName);

View file

@ -330,7 +330,7 @@ public class Game {
}
public boolean checkCurrentMap() {
if(currentMap != null) return false;
if(currentMap != null && !currentMap.isNotSetup()) return false;
this.currentMap = Maps.getRandomMap();
return this.currentMap == null;
}

View file

@ -82,12 +82,13 @@ public class InventoryHandler implements Listener {
String mapName;
if(Main.getInstance().supports(14)){
test = event.getView().getTitle().startsWith("Select a Block: ");
if(!test) return;
mapName = event.getView().getTitle().substring("Select a Block: ".length());
} else {
test = event.getInventory().getName().startsWith("Select a Block: ");
if(!test) return;
mapName = event.getInventory().getName().substring("Select a Block: ".length());
}
if(!test) return;
event.setCancelled(true);
Map map = Maps.getMap(mapName);
if(map == null) return;
@ -105,12 +106,13 @@ public class InventoryHandler implements Listener {
String mapName;
if(Main.getInstance().supports(14)){
test = event.getView().getTitle().startsWith("Select a Block: ");
if(!test) return;
mapName = event.getView().getTitle().substring("Select a Block: ".length());
} else {
test = event.getInventory().getName().startsWith("Select a Block: ");
if(!test) return;
mapName = event.getInventory().getName().substring("Select a Block: ".length());
}
if(!test) return;
Map map = Maps.getMap(mapName);
if(map == null) return;
Material mat = map.getBlockHunt().get(0);

View file

@ -48,13 +48,15 @@ Localization:
TAUNT: "A random hider will be taunted in the next 30s."
TAUNT_ACTIVATE: "Taunt has been activated."
ERROR_GAME_SPAWN: "Please set game spawn location first"
ERROR_MAP_BOUNDS: "Please set map bounds before saving"
SETUP: "&f&lThe following is needed for setup..."
SETUP_GAME: "&c&l- &fGame spawn isn't set, /hs setspawn"
SETUP_LOBBY: "&c&l- &fLobby spawn isn't set, /hs setlobby"
SETUP_SEEKER_LOBBY: "&c&l- &fSeeker Lobby spawn isn't set, /hs setseekerlobby"
SETUP_GAME: "&c&l- &fGame spawn isn't set, /hs map set spawn <map>"
SETUP_LOBBY: "&c&l- &fLobby spawn isn't set, /hs map set lobby <map>"
SETUP_SEEKER_LOBBY: "&c&l- &fSeeker Lobby spawn isn't set, /hs map set seekerlobby <map>"
SETUP_EXIT: "&c&l- &fQuit/exit teleport location isn't set, /hs setexit"
SETUP_SAVEMAP: "&c&l- &fHide and seek map isn't saved, /hs savemap (after /hs setspawn)"
SETUP_BOUNDS: "&c&l- &fPlease set game bounds in 2 opposite corners of the game map, /hs setbounds"
SETUP_SAVEMAP: "&c&l- &fHide and seek map isn't saved, /hs map save <map>"
SETUP_BOUNDS: "&c&l- &fPlease set game bounds in 2 opposite corners of the game map, /hs map set bounds <map>"
SETUP_BLOCKHUNT: "&c&l - &fIf blockhunt is enabled, there needs to be at least 1 block set, /hs map blockhunt block add block <map> <block>"
SETUP_COMPLETE: "Everything is setup and ready to go!"
GAME_SPAWN: "Set game spawn position to current location"
LOBBY_SPAWN: "Set lobby position to current location"
@ -88,8 +90,8 @@ Localization:
MAP_CREATED: "Created new map: {AMOUNT}"
MAP_FAIL_DELETE: "Failed to delete map: {AMOUNT}"
MAP_DELETED: "Deleted map: {AMOUNT}"
NO_MAPS: "There are no maps in the plugin rn (/hs addmap)"
MAP_NOT_SETUP: "Map {AMOUNT} is not setup (/hs setup <map>)"
NO_MAPS: "There are no maps in the plugin rn (/hs map add <name>)"
MAP_NOT_SETUP: "Map {AMOUNT} is not setup (/hs map status <map>)"
LIST_MAPS: "The current maps are:"
ARGUMENT_COUNT: "This command requires more arguments to run."
GAME_SPAWN_NEEDED: "Game spawn must be set before seeker spawn."
@ -97,6 +99,13 @@ Localization:
SEEKER_LOBBY_INVALID: "Seeker lobby must be in the same world as game spawn."
CONFIG_ERROR: "Error reloading config. Check server logs."
BLOCKHUNT_DISABLED: "Please enable blockhunt in this map inside maps.yml to enable disguises. Blockhunt does not work on 1.8"
BLOCKHUNT_SET_TO: "Blockhunt set to {AMOUNT}."
BLOCKHUNT_BLOCK_EXISTS: "{AMOUNT} is already set in the blockhunt config."
BLOCKHUNT_BLOCK_DOESNT_EXIT: "{AMOUNT} is already not set in the blochunt config."
BLOCKHUNT_BLOCK_ADDED: "Added {AMOUNT} to blockhunt config."
BLOCKHUNT_BLOCK_REMOVED: "Removed {AMOUNT} from blockhunt config."
BLOCKHUNT_LIST_BLOCKS: "The following blockhunt blocks are:"
NO_BLOCKS: "There are no blockhunt blocks in this map."
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 4