finish beta build of multi map support

This commit is contained in:
tylermurphy534 2022-10-30 21:40:59 -04:00
parent 667a365e7b
commit 1325e042a6
40 changed files with 631 additions and 152 deletions

View file

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>net.tylermurphy</groupId>
<artifactId>KenshinsHideAndSeek</artifactId>
<version>1.6.2</version>
<version>1.7.0</version>
<name>Hide and Seek Plugin</name>
<build>

View file

@ -22,6 +22,7 @@ package net.tylermurphy.hideAndSeek;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.game.*;
import net.tylermurphy.hideAndSeek.game.util.Status;
@ -30,7 +31,6 @@ import net.tylermurphy.hideAndSeek.game.listener.*;
import net.tylermurphy.hideAndSeek.util.PAPIExpansion;
import net.tylermurphy.hideAndSeek.util.TabCompleter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
@ -62,6 +62,7 @@ public class Main extends JavaPlugin implements Listener {
this.updateVersion();
Config.loadConfig();
Maps.loadMaps();
Localization.loadLocalization();
Items.loadItems();
@ -73,7 +74,7 @@ public class Main extends JavaPlugin implements Listener {
CommandHandler.registerCommands();
game = new Game(board);
game = new Game(game.getCurrentMap(), board);
getServer().getScheduler().runTaskTimer(this, this::onTick,0,1).getTaskId();

View file

@ -22,11 +22,13 @@ package net.tylermurphy.hideAndSeek.command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.List;
public class About implements ICommand {
public void execute(Player sender, String[] args) {
sender.sendMessage(
String.format("%s%sHide and Seek %s(%s1.6.2%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
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("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);
@ -44,4 +46,8 @@ public class About implements ICommand {
return "Get information about the plugin";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -0,0 +1,54 @@
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 java.util.Arrays;
import java.util.Collections;
import java.util.List;
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 AddMap implements ICommand {
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("MAP_ALREADY_EXISTS"));
} else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) {
sender.sendMessage(errorPrefix + message("INVALID_MAP_NAME"));
} else {
Maps.setMap(args[0], new Map(args[0]));
sender.sendMessage(messagePrefix + message("MAP_CREATED").addAmount(args[0]));
}
}
public String getLabel() {
return "addmap";
}
public String getUsage() {
return "<name>";
}
public String getDescription() {
return "Add a map to the plugin!";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("name")) {
return Collections.singletonList("name");
}
return null;
}
}

View file

@ -13,101 +13,96 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Debug implements ICommand {
private static final Map<Integer, Consumer<Player>> debugMenuFunctions = new HashMap<>();
private Inventory debugMenu;
private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
public void execute(Player sender, String[] args) {
if(args.length < 1) args = new String[]{""};
if(debugMenu == null) createMenu(args[0]);
net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
Inventory debugMenu = createMenu(map, sender);
sender.openInventory(debugMenu);
}
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 -> {
private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){
Map<Integer, Consumer<Player>> functions = new HashMap<>();
Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
if(mapSaveEnabled) {
if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addHider(player);
PlayerLoader.loadHider(player, Main.getInstance().getGame().getCurrentMap());
PlayerLoader.loadHider(player, map);
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 -> {
debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
if(mapSaveEnabled) {
if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSeeker(player);
PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getCurrentMap());
PlayerLoader.loadSeeker(player, map);
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 -> {
debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
if(mapSaveEnabled) {
if(Main.getInstance().getGame().getCurrentMap().getSpawn().getWorld() == null) Main.getInstance().getGame().getCurrentMap().getWorldLoader().loadMap();
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSpectator(player);
PlayerLoader.loadSpectator(player, Main.getInstance().getGame().getCurrentMap());
PlayerLoader.loadSpectator(player, map);
}));
debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
debugMenu.setItem(3, createOption(functions, 3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
Main.getInstance().getBoard().remove(player);
PlayerLoader.unloadPlayer(player);
player.teleport(exitPosition);
}));
debugMenu.setItem(4, createOption(4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
debugMenu.setItem(4, createOption(functions, 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){
player.setHealth(0.1);
}
}));
debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
if(map == null) {
player.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
debugMenu.setItem(6, createOption(functions, 6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
if(mapSaveEnabled) {
if(map.getSpawn().getWorld() == null) map.getWorldLoader().loadMap();
if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
}
player.teleport(map.getSpawn());
player.teleport(map.getGameSpawn());
}));
debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
if(map == null) {
player.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
debugMenu.setItem(7, createOption(functions, 7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
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;
}
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 -> {
PlayerLoader.openBlockHuntPicker(player, map);
}));
debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
debugMenu.setItem(10, createOption(functions, 10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
debugMenuFunctions.put(sender, functions);
return debugMenu;
}
private ItemStack createOption(int slow, Material material, String name, int amount, Consumer<Player> callback){
private ItemStack createOption(Map<Integer, Consumer<Player>> functions, int slow, Material material, String name, int amount, Consumer<Player> callback){
ItemStack temp = new ItemStack(material, amount);
ItemMeta meta = temp.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
temp.setItemMeta(meta);
debugMenuFunctions.put(slow, callback);
functions.put(slow, callback);
return temp;
}
public static void handleOption(Player player, int slotId){
Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
Consumer<Player> callback = debugMenuFunctions.get(slotId);
Consumer<Player> callback = debugMenuFunctions.get(player).get(slotId);
if(callback != null) callback.accept(player);
}, 0);
}
@ -117,11 +112,18 @@ public class Debug implements ICommand {
}
public String getUsage() {
return "<*map>";
return "<map>";
}
public String getDescription() {
return "Run debug commands";
}
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());
}
return null;
}
}

View file

@ -23,6 +23,8 @@ import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.util.CommandHandler;
import org.bukkit.entity.Player;
import java.util.List;
public class Help implements ICommand {
public void execute(Player sender, String[] args) {
@ -46,4 +48,8 @@ public class Help implements ICommand {
return "Get the commands for the plugin";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -20,6 +20,9 @@
package net.tylermurphy.hideAndSeek.command;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface ICommand {
@ -30,5 +33,7 @@ public interface ICommand {
String getUsage();
String getDescription();
List<String> autoComplete(@Nullable String parameter);
}

View file

@ -23,13 +23,15 @@ import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@ -58,4 +60,8 @@ public class Join implements ICommand {
return "Joins the lobby if game is set to manual join/leave";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -23,13 +23,15 @@ import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@ -57,4 +59,8 @@ public class Leave implements ICommand {
return "Leaves the lobby if game is set to manual join/leave";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -0,0 +1,46 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.List;
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 ListMaps implements ICommand {
public void execute(Player sender, String[] args) {
Collection<Map> maps = Maps.getAllMaps();
if(maps.size() < 1) {
sender.sendMessage(errorPrefix + message("NO_MAPS"));
return;
}
StringBuilder response = new StringBuilder(messagePrefix + message("LIST_MAPS"));
for(Map map : maps) {
response.append("\n ").append(map.getName()).append(": ").append(map.isNotSetup() ? ChatColor.RED + "NOT SETUP" : ChatColor.GREEN + "SETUP").append(ChatColor.WHITE);
}
sender.sendMessage(response.toString());
}
public String getLabel() {
return "listmaps";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "List all maps in the plugin";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -23,9 +23,12 @@ import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -39,6 +42,7 @@ public class Reload implements ICommand {
return;
}
Config.loadConfig();
Maps.loadMaps();
Localization.loadLocalization();
Items.loadItems();
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
@ -55,5 +59,9 @@ public class Reload implements ICommand {
public String getDescription() {
return "Reloads the config";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -0,0 +1,52 @@
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 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 RemoveMap implements ICommand {
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"));
} else if(!Maps.removeMap(args[0])){
sender.sendMessage(errorPrefix + message("MAP_FAIL_DELETE").addAmount(args[0]));
} else {
sender.sendMessage(messagePrefix + message("MAP_DELETED").addAmount(args[0]));
}
}
public String getLabel() {
return "removemap";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "Remove a map from the plugin!";
}
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());
}
return null;
}
}

View file

@ -27,6 +27,9 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -82,5 +85,12 @@ public class SaveMap implements ICommand {
public String getDescription() {
return "Saves current map for the game. May lag server.";
}
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());
}
return null;
}
}

View file

@ -26,6 +26,11 @@ import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -45,7 +50,7 @@ public class SetBorder implements ICommand {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
if (args.length < 3) {
if (args.length < 4) {
map.setWorldBorderData(0, 0, 0, 0, 0);
addToConfig("worldBorder.enabled",false);
saveConfig();
@ -91,11 +96,18 @@ public class SetBorder implements ICommand {
}
public String getUsage() {
return "<map> <size> <delay> <move>";
return "<map> <*size> <*delay> <*move>";
}
public String getDescription() {
return "Sets worldboarder's center location, size in blocks, and delay in minutes per shrink. Add no arguments to disable.";
}
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());
}
return Collections.singletonList(parameter);
}
}

View file

@ -25,6 +25,9 @@ import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -44,7 +47,7 @@ public class SetBounds implements ICommand {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
if (!sender.getWorld().getName().equals(map.getSpawn().getWorld().getName())) {
if (!sender.getWorld().getName().equals(map.getSpawnName())) {
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
return;
}
@ -72,7 +75,7 @@ public class SetBounds implements ICommand {
}
if (bzl == 0) {
bzl = sender.getLocation().getBlockZ();
} else if (map.getBoundsMax().getX() < sender.getLocation().getBlockZ()) {
} else if (map.getBoundsMax().getZ() < sender.getLocation().getBlockZ()) {
first = false;
bzs = bzl;
bzl = sender.getLocation().getBlockZ();
@ -82,8 +85,8 @@ public class SetBounds implements ICommand {
}
map.setBoundMin(bxs, bzs);
map.setBoundMax(bxl, bzl);
Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
saveConfig();
}
public String getLabel() {
@ -98,4 +101,11 @@ public class SetBounds implements ICommand {
return "Sets the map bounds for the game.";
}
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());
}
return null;
}
}

View file

@ -0,0 +1,66 @@
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 java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetMap implements ICommand {
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;
}
if(map.isNotSetup()){
sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP"));
return;
}
if (!Main.getInstance().getBoard().contains(sender)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return;
}
Main.getInstance().getGame().setCurrentMap(map);
for(Player player : Main.getInstance().getBoard().getPlayers()) {
player.teleport(map.getLobby());
}
}
public String getLabel() {
return "setmap";
}
public String getUsage() {
return "<map>";
}
public String getDescription() {
return "Set the current lobby to another map";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -25,6 +25,8 @@ import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -40,19 +42,19 @@ public class Setup implements ICommand {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0) {
if (map.getSpawn().getWorld() == null || map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_GAME");
count++;
}
if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0) {
if (map.getLobby().getWorld() == null || map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_LOBBY");
count++;
}
if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0) {
if (map.getSeekerLobby().getWorld() == null || map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
count++;
}
if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
if (exitWorld == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_EXIT");
count++;
}
@ -62,7 +64,7 @@ public class Setup implements ICommand {
count++;
}
if (mapSaveEnabled) {
File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + map.getSpawn().getWorld().getName());
File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + map.getGameSpawnName());
if (!destenation.exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
count++;
@ -87,4 +89,11 @@ public class Setup implements ICommand {
return "Shows what needs to be setup";
}
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());
}
return null;
}
}

View file

@ -20,12 +20,15 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
@ -34,7 +37,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().getCurrentMap().isNotSetup()) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@ -86,4 +89,11 @@ public class Start implements ICommand {
return "Starts the game either with a random seeker or chosen one";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("player")) {
return Main.getInstance().getBoard().getPlayers().stream().map(Player::getName).collect(Collectors.toList());
}
return null;
}
}

View file

@ -23,6 +23,9 @@ import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -30,7 +33,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().getCurrentMap().isNotSetup()) {
if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
return;
}
@ -54,4 +57,8 @@ public class Stop implements ICommand {
return "Stops the game";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -24,6 +24,7 @@ import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@ -80,4 +81,9 @@ public class Top implements ICommand {
public String getDescription() {
return "Gets the top players in the server.";
}
public List<String> autoComplete(String parameter) {
return Collections.singletonList(parameter);
}
}

View file

@ -24,6 +24,8 @@ import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@ -70,10 +72,14 @@ public class Wins implements ICommand {
}
public String getUsage() {
return "<player>";
return "<*player>";
}
public String getDescription() {
return "Get the win information for yourself or another player.";
}
public List<String> autoComplete(String parameter) {
return Collections.singletonList(parameter);
}
}

View file

@ -22,13 +22,18 @@ package net.tylermurphy.hideAndSeek.command.location;
import net.tylermurphy.hideAndSeek.command.ICommand;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetExitLocation implements ICommand {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.EXIT, args[0], map -> {
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
addToConfig("exit.x", sender.getLocation().getBlockX());
addToConfig("exit.y", sender.getLocation().getBlockY());
addToConfig("exit.z", sender.getLocation().getBlockZ());
@ -51,4 +56,8 @@ public class SetExitLocation implements ICommand {
return "Sets hide and seeks exit location to current position and world";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -22,8 +22,12 @@ package net.tylermurphy.hideAndSeek.command.location;
import net.tylermurphy.hideAndSeek.command.ICommand;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetLobbyLocation implements ICommand {
@ -39,11 +43,18 @@ public class SetLobbyLocation implements ICommand {
}
public String getUsage() {
return "";
return "<map>";
}
public String getDescription() {
return "Sets hide and seeks lobby location to current position";
}
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());
}
return null;
}
}

View file

@ -3,14 +3,24 @@ package net.tylermurphy.hideAndSeek.command.location;
import net.tylermurphy.hideAndSeek.command.ICommand;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetSeekerLobbyLocation implements ICommand {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
if(map.isSpawnNotSetup()) {
throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString());
}
if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) {
throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString());
}
map.setSeekerLobby(sender.getLocation());
});
}
@ -20,11 +30,18 @@ public class SetSeekerLobbyLocation implements ICommand {
}
public String getUsage() {
return "";
return "<map>";
}
public String getDescription() {
return "Sets hide and seeks seeker lobby location to current position";
}
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());
}
return null;
}
}

View file

@ -22,9 +22,14 @@ package net.tylermurphy.hideAndSeek.command.location;
import net.tylermurphy.hideAndSeek.command.ICommand;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@ -41,7 +46,12 @@ public class SetSpawnLocation implements ICommand {
map.setSpawn(sender.getLocation());
if (!sender.getLocation().getWorld().getName().equals(map.getSpawn().getWorld().getName()) && mapSaveEnabled) {
if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().getName().equals(sender.getLocation().getWorld().getName())) {
sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString());
map.setSeekerLobby(new Location(null, 0, 0, 0));
}
if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) {
map.getWorldLoader().unloadMap();
}
});
@ -59,4 +69,11 @@ public class SetSpawnLocation implements ICommand {
return "Sets hide and seeks spawn location to current position";
}
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());
}
return null;
}
}

View file

@ -38,7 +38,13 @@ public class LocationUtils {
}
}
consumer.accept(map);
try {
consumer.accept(map);
} catch (Exception e) {
player.sendMessage(errorPrefix + e.getMessage());
return;
}
if(map != null)
Maps.setMap(mapName, map);
player.sendMessage(messagePrefix + message(place.message()));

View file

@ -1,6 +1,7 @@
package net.tylermurphy.hideAndSeek.configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import net.tylermurphy.hideAndSeek.Main;
@ -22,7 +23,7 @@ public class Map {
seekerLobbyPosition = new Location(null, 0, 0, 0);
private String
gameWorldName;
gameWorldName = "world";
private int
xBoundMin = 0,
@ -36,10 +37,10 @@ public class Map {
worldBorderChange = 0;
private boolean
blockhunt;
blockhunt = false;
private List<Material>
blockhuntBlocks;
blockhuntBlocks = new ArrayList<>();
private final Border
worldBorder;
@ -55,7 +56,8 @@ public class Map {
public void setSpawn(Location pos) {
this.spawnPosition = pos;
this.gameWorldName = pos.getWorld().getName();
if(pos.getWorld() != null)
this.gameWorldName = pos.getWorld().getName();
}
public void setLobby(Location pos) {
@ -73,7 +75,6 @@ public class Map {
this.worldBorderChange = 0;
this.xWorldBorder = 0;
this.zWorldBorder = 0;
this.worldBorder.resetWorldBorder();
} else {
this.worldBorderSize = size;
this.worldBorderDelay = delay;
@ -81,6 +82,7 @@ public class Map {
this.xWorldBorder = x;
this.zWorldBorder = z;
}
this.worldBorder.resetWorldBorder();
}
public void setBlockhunt(boolean enabled, List<Material> blocks) {
@ -98,14 +100,31 @@ public class Map {
this.zBoundMax = z;
}
public Location getGameSpawn() {
if(mapSaveEnabled) {
return new Location(
Bukkit.getWorld("hs_" + gameWorldName),
spawnPosition.getX(),
spawnPosition.getY(),
spawnPosition.getZ()
);
} else {
return spawnPosition;
}
}
public String getGameSpawnName() {
return "hs_"+gameWorldName;
}
public Location getSpawn() {
if(mapSaveEnabled)
spawnPosition.setWorld(Bukkit.getWorld("hs_"+gameWorldName));
else
spawnPosition.setWorld(Bukkit.getWorld(gameWorldName));
return spawnPosition;
}
public String getSpawnName() {
return gameWorldName;
}
public Location getLobby() {
return lobbyPosition;
}
@ -114,6 +133,19 @@ public class Map {
return seekerLobbyPosition;
}
public Location getGameSeekerLobby() {
if(mapSaveEnabled) {
return new Location(
Bukkit.getWorld("hs_" + gameWorldName),
seekerLobbyPosition.getX(),
seekerLobbyPosition.getY(),
seekerLobbyPosition.getZ()
);
} else {
return seekerLobbyPosition;
}
}
public boolean isWorldBorderEnabled() {
return worldBorderSize > 0;
}
@ -158,7 +190,7 @@ public class Map {
return new Vector(
xBoundMax,
0,
zBoundMin
zBoundMax
);
}

View file

@ -21,10 +21,17 @@ public class Maps {
}
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");
Optional<Map> map;
if(MAPS.values().size() > 0) {
Collection<Map> setupMaps = MAPS.values().stream().filter(m -> !m.isNotSetup()).collect(Collectors.toList());
if(setupMaps.size() < 1) {
return null;
}
map = setupMaps.stream().skip(new Random().nextInt(setupMaps.size())).findFirst();
} else {
map = Optional.empty();
}
return map.orElse(null);
}
public static void setMap(String name, Map map) {
@ -32,6 +39,12 @@ public class Maps {
saveMaps();
}
public static boolean removeMap(String name) {
boolean status = MAPS.remove(name) != null;
saveMaps();
return status;
}
public static Collection<Map> getAllMaps() {
return MAPS.values();
}
@ -69,9 +82,11 @@ public class Maps {
data.getInt("worldborder.delay"),
data.getInt("worldborder.change")
);
List<String> blockhunt = data.getStringList("blockhunt.blocks");
if(blockhunt == null) blockhunt = new ArrayList<>();
map.setBlockhunt(
data.getBoolean("blockhunt.enabled"),
data.getStringList("blockhunt.blocks")
data.getBoolean("blockhunt.enabled"),
blockhunt
.stream()
.map(XMaterial::matchXMaterial)
.filter(Optional::isPresent)
@ -113,8 +128,8 @@ public class Maps {
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);
data.set("blockhunt.blocks", map.getBlockHunt().stream().map(Material::name).collect(Collectors.toList()));
maps.set(map.getName(), data);
}
manager.set("maps", maps);
@ -128,9 +143,9 @@ public class Maps {
} 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());
data.set("spawns." + name + ".x", spawn.getX());
data.set("spawns." + name + ".y", spawn.getY());
data.set("spawns." + name + ".z", spawn.getZ());
}
}

View file

@ -59,8 +59,12 @@ public class Game {
private boolean hiderLeft;
public Game(Board board) {
this(Maps.getRandomMap(), board);
}
this.currentMap = Maps.getRandomMap();
public Game(Map map, Board board) {
this.currentMap = map;
this.taunt = new Taunt();
this.glow = new Glow();
@ -140,6 +144,8 @@ public class Game {
public void end() {
board.getPlayers().forEach(PlayerLoader::unloadPlayer);
currentMap.getWorldBorder().resetWorldBorder();
Map nextMap = Maps.getRandomMap();
if(nextMap != null) this.currentMap = nextMap;
board.getPlayers().forEach(player -> {
if (leaveOnEnd) {
board.removeBoard(player);
@ -213,7 +219,7 @@ public class Game {
}
public void onTick() {
if (currentMap.isNotSetup()) return;
if (currentMap == null || currentMap.isNotSetup()) return;
if (status == Status.STANDBY) whileWaiting();
else if (status == Status.STARTING) whileStarting();
else if (status == Status.PLAYING) whilePlaying();
@ -249,7 +255,7 @@ public class Game {
board.getPlayers().forEach(player -> {
PlayerLoader.resetPlayer(player, board);
if(board.isSeeker(player)){
player.teleport(currentMap.getSpawn());
player.teleport(currentMap.getGameSpawn());
}
});
} else if (startingTimer == 1){
@ -327,13 +333,19 @@ public class Game {
return currentMap;
}
public boolean checkCurrentMap() {
if(currentMap != null) return false;
this.currentMap = Maps.getRandomMap();
return this.currentMap == null;
}
public void setCurrentMap(Map map) {
this.currentMap = map;
}
public World getGameWorld() {
if(currentMap == null || currentMap.getSpawn() == null) return null;
else return currentMap.getSpawn().getWorld();
public String getGameWorld() {
if(currentMap == null) return null;
else return currentMap.getGameSpawnName();
}
private void checkWinConditions() {

View file

@ -40,7 +40,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class PlayerLoader {
public static void loadHider(Player player, Map map){
player.teleport(map.getSpawn());
player.teleport(map.getGameSpawn());
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());
@ -50,13 +50,13 @@ public class PlayerLoader {
}
public static void loadSeeker(Player player, Map map){
player.teleport(map.getSeekerLobby());
player.teleport(map.getGameSeekerLobby());
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, Map map){
player.teleport(map.getSpawn());
player.teleport(map.getGameSpawn());
loadPlayer(player);
player.setAllowFlight(true);
player.setFlying(true);

View file

@ -41,13 +41,14 @@ public class Border {
running = true;
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
currentSize -= map.getWorldBorderData().getZ();
org.bukkit.WorldBorder border = map.getSpawn().getWorld().getWorldBorder();
org.bukkit.WorldBorder border = map.getGameSpawn().getWorld().getWorldBorder();
border.setSize(border.getSize()-change,30);
delay = 30;
}
public void resetWorldBorder() {
org.bukkit.WorldBorder border = map.getSpawn().getWorld().getWorldBorder();
if(map.getGameSpawn().getWorld() == null) return;
org.bukkit.WorldBorder border = map.getGameSpawn().getWorld().getWorldBorder();
if (map.isWorldBorderEnabled()) {
border.setSize(map.getWorldBorderData().getX());
border.setCenter(map.getWorldBorderPos().getX(), map.getWorldBorderPos().getY());

View file

@ -31,7 +31,7 @@ public class DamageHandler implements Listener {
Player player = (Player) event.getEntity();
Player attacker = null;
// If map is not setup we won't be able to process on it :o
if (game.getCurrentMap().isNotSetup()) { return; }
if (game.getCurrentMap() == null || game.getCurrentMap().isNotSetup()) { return; }
// If there is an attacker, find them
if (event instanceof EntityDamageByEntityEvent) {
if (((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
@ -71,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(game.getCurrentMap().getSpawn());
player.teleport(game.getCurrentMap().getGameSpawn());
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
player.teleport(game.getCurrentMap().getSpawn());
player.teleport(game.getCurrentMap().getGameSpawn());
}
return;
}
@ -96,15 +96,15 @@ public class DamageHandler implements Listener {
Main.getInstance().getDisguiser().reveal(player);
// Teleport player to seeker spawn
if(delayedRespawn){
player.teleport(game.getCurrentMap().getSeekerLobby());
player.teleport(game.getCurrentMap().getGameSeekerLobby());
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
if(game.getStatus() == Status.PLAYING){
player.teleport(game.getCurrentMap().getSpawn());
player.teleport(game.getCurrentMap().getGameSpawn());
}
}, delayedRespawnDelay * 20L);
} else {
player.teleport(game.getCurrentMap().getSpawn());
player.teleport(game.getCurrentMap().getGameSpawn());
}
// Add leaderboard stats
board.addDeath(player.getUniqueId());

View file

@ -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().getCurrentMap().isNotSetup()) {
if (Main.getInstance().getGame().checkCurrentMap()) {
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}

View file

@ -24,16 +24,16 @@ public class JoinLeaveHandler implements Listener {
}
Main.getInstance().getBoard().remove(event.getPlayer());
removeItems(event.getPlayer());
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) return;
if (Main.getInstance().getGame().checkCurrentMap()) return;
if (autoJoin) {
Main.getInstance().getGame().join(event.getPlayer());
} else if (teleportToExit) {
if (event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName()) || event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getLobby().getWorld().getName())) {
if (event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld()) || 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().getName())) {
if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY && Main.getInstance().getGame().getStatus() != Status.ENDING) {
Main.getInstance().getGame().join(event.getPlayer());
} else {

View file

@ -49,8 +49,8 @@ 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().getName())) return;
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) 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().hasPermission("hideandseek.leavebounds")) return;
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()) {

View file

@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.permissionsRequired;
@ -65,6 +66,10 @@ public class CommandHandler {
registerCommand(new Top());
registerCommand(new Wins());
registerCommand(new Debug());
registerCommand(new AddMap());
registerCommand(new RemoveMap());
registerCommand(new ListMaps());
registerCommand(new SetMap());
}
public static boolean handleCommand(CommandSender sender, String[] args) {
@ -85,8 +90,15 @@ public class CommandHandler {
} else if (permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
sender.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
} else {
try {
COMMAND_REGISTER.get(args[0].toLowerCase()).execute(player,Arrays.copyOfRange(args, 1, args.length));
ICommand command = COMMAND_REGISTER.get(args[0].toLowerCase());
int parameters = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count();
if(args.length - 1 < parameters) {
sender.sendMessage(errorPrefix + message("ARGUMENT_COUNT"));
return true;
}
command.execute(player,Arrays.copyOfRange(args, 1, args.length));
} catch (Exception e) {
sender.sendMessage(errorPrefix + "An error has occurred.");
e.printStackTrace();

View file

@ -19,6 +19,7 @@
package net.tylermurphy.hideAndSeek.util;
import net.tylermurphy.hideAndSeek.command.ICommand;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
@ -36,21 +37,20 @@ public class TabCompleter {
.collect(Collectors.toList());
} else if (args.length > 1) {
if (!CommandHandler.COMMAND_REGISTER.containsKey(args[0].toLowerCase())) {
return null;
return new ArrayList<>();
} else {
String[] usage = CommandHandler.COMMAND_REGISTER.get(args[0].toLowerCase()).getUsage().split(" ");
ICommand command = CommandHandler.COMMAND_REGISTER.get(args[0].toLowerCase());
String[] usage = command.getUsage().split(" ");
List<String> complete;
if (args.length - 2 < usage.length) {
String parameter = usage[args.length-2];
if (parameter.equals("<player>")) {
return null;
} else {
List<String> temp = new ArrayList<>();
temp.add(parameter.replace("<", "").replace(">", ""));
return temp;
}
String name = parameter.replace("<", "").replace(">", "");
complete = command.autoComplete(name);
} else {
return null;
complete = command.autoComplete(null);
}
if(complete == null) return new ArrayList<>();
else return complete;
}
}
return null;

View file

@ -33,45 +33,35 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class WorldLoader {
private Map map;
private String mapName;
private String saveName;
private final Map map;
public WorldLoader(Map map) {
this.map = map;
this.mapName = map.getSpawn() == null ? "world" : map.getSpawn().getWorld().getName();
this.saveName = "hideandseek_"+ mapName;
}
public void setNewMap(Map map){
this.map = map;
this.mapName = map.getSpawn() == null ? "world" : map.getSpawn().getWorld().getName();
this.saveName = "hideandseek_"+ mapName;
}
public World getWorld() {
return Bukkit.getServer().getWorld(saveName);
return Bukkit.getServer().getWorld(map.getGameSpawnName());
}
public void unloadMap() {
World world = Bukkit.getServer().getWorld(saveName);
World world = Bukkit.getServer().getWorld(map.getGameSpawnName());
if (world == null) {
Main.getInstance().getLogger().warning(saveName + " already unloaded.");
Main.getInstance().getLogger().warning(map.getGameSpawnName() + " already unloaded.");
return;
}
world.getPlayers().forEach(player -> player.teleport(exitPosition));
if (Bukkit.getServer().unloadWorld(world, false)) {
Main.getInstance().getLogger().info("Successfully unloaded " + saveName);
Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName());
}else{
Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + saveName);
Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + map.getGameSpawnName());
}
}
public void loadMap() {
Bukkit.getServer().createWorld(new WorldCreator(saveName).generator(new VoidGenerator()));
World world = Bukkit.getServer().getWorld(saveName);
Bukkit.getServer().createWorld(new WorldCreator(map.getGameSpawnName()).generator(new VoidGenerator()));
World world = Bukkit.getServer().getWorld(map.getGameSpawnName());
if (world == null) {
Main.getInstance().getLogger().severe("COULD NOT LOAD " + saveName);
Main.getInstance().getLogger().severe("COULD NOT LOAD " + map.getGameSpawnName());
return;
}
world.setAutoSave(false);
@ -83,15 +73,15 @@ public class WorldLoader {
}
public String save() {
World world = Bukkit.getServer().getWorld(mapName);
World world = Bukkit.getServer().getWorld(map.getSpawnName());
if(world == null){
throw new RuntimeException("Invalid world to save: " + mapName);
return errorPrefix + "Invalid world to save: " + map.getSpawnName();
}
File current = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName);
File current = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getSpawnName());
if (current.exists()) {
try {
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getGameSpawnName());
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ map.getGameSpawnName());
copyFileFolder("region",true);
copyFileFolder("entities",true);
copyFileFolder("datapacks",false);
@ -104,7 +94,7 @@ public class WorldLoader {
}
if (!temp_destination.renameTo(destination)) {
throw new RuntimeException("Failed to rename directory: "+temp_destination.getPath());
return errorPrefix + "Failed to rename directory: " + temp_destination.getPath();
}
} catch(IOException e) {
e.printStackTrace();
@ -117,8 +107,8 @@ public class WorldLoader {
}
private void copyFileFolder(String name, Boolean isMca) throws IOException {
File region = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName +File.separator+name);
File temp = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName +File.separator+name);
File region = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getSpawnName() +File.separator+name);
File temp = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ map.getGameSpawnName() +File.separator+name);
if (region.exists() && region.isDirectory()) {
if (!temp.exists())
if (!temp.mkdirs())

View file

@ -17,7 +17,7 @@ Localization:
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_SETUP: "Game is not setup. Run /hs setup to see what you need to do."
GAME_SETUP: "There are no setup maps! Run /hs setup on a map to see what you need to do."
GAME_INGAME: "You are already in the lobby/game."
GAME_NOT_INGAME: "You are not in a lobby/game."
GAME_INPROGRESS: "There is currently a game in progress."
@ -77,6 +77,19 @@ Localization:
FLYING_ENABLED: "&l&bFlying Enabled"
FLYING_DISABLED: "&l&bFlying Disabled"
RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds."
INVALID_MAP: "That is an invalid map name!!"
MAP_ALREADY_EXISTS: "This map already exists!"
INVALID_MAP_NAME: "A map name can only contain numbers or letters"
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>)"
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."
SEEKER_LOBBY_SPAWN_RESET: "Seeker lobby spawn reset since the game spawn was moved to a new world"
SEEKER_LOBBY_INVALID: "Seeker lobby must be in the same world as game spawn"
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 3

View file

@ -1,6 +1,6 @@
name: KenshinsHideAndSeek
main: net.tylermurphy.hideAndSeek.Main
version: 1.6.2
version: 1.7.0
author: KenshinEto
load: STARTUP
api-version: 1.13
@ -34,6 +34,10 @@ permissions:
hideandseek.wins: true
hideandseek.top: true
hideandseek.debug: true
hideandseek.addmap: true
hideandseek.removemap: true
hideandseek.listmaps: true
hideandseek.setmap: true
hideandseek.about:
description: Allows you to run the about command
default: true
@ -91,3 +95,15 @@ permissions:
hideandseek.debug:
description: Opens the debug menu
default: op
hideandseek.addmap:
description: Adds a map to the plugin
default: op
hideandseek.removemap:
description: Removes a map from the plugin
default: op
hideandseek.listmaps:
description: Lists all maps in the plugin
default: op
hideandseek.setmap:
description: Sets the current lobby to a new map
default: op