finish beta build of multi map support
This commit is contained in:
parent
667a365e7b
commit
1325e042a6
40 changed files with 631 additions and 152 deletions
2
pom.xml
2
pom.xml
|
@ -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>
|
<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>
|
<groupId>net.tylermurphy</groupId>
|
||||||
<artifactId>KenshinsHideAndSeek</artifactId>
|
<artifactId>KenshinsHideAndSeek</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.7.0</version>
|
||||||
<name>Hide and Seek Plugin</name>
|
<name>Hide and Seek Plugin</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -22,6 +22,7 @@ package net.tylermurphy.hideAndSeek;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Config;
|
import net.tylermurphy.hideAndSeek.configuration.Config;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Items;
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Localization;
|
import net.tylermurphy.hideAndSeek.configuration.Localization;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.database.Database;
|
import net.tylermurphy.hideAndSeek.database.Database;
|
||||||
import net.tylermurphy.hideAndSeek.game.*;
|
import net.tylermurphy.hideAndSeek.game.*;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
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.PAPIExpansion;
|
||||||
import net.tylermurphy.hideAndSeek.util.TabCompleter;
|
import net.tylermurphy.hideAndSeek.util.TabCompleter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -62,6 +62,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
this.updateVersion();
|
this.updateVersion();
|
||||||
|
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
|
Maps.loadMaps();
|
||||||
Localization.loadLocalization();
|
Localization.loadLocalization();
|
||||||
Items.loadItems();
|
Items.loadItems();
|
||||||
|
|
||||||
|
@ -73,7 +74,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
CommandHandler.registerCommands();
|
CommandHandler.registerCommands();
|
||||||
|
|
||||||
game = new Game(board);
|
game = new Game(game.getCurrentMap(), board);
|
||||||
|
|
||||||
getServer().getScheduler().runTaskTimer(this, this::onTick,0,1).getTaskId();
|
getServer().getScheduler().runTaskTimer(this, this::onTick,0,1).getTaskId();
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,13 @@ package net.tylermurphy.hideAndSeek.command;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class About implements ICommand {
|
public class About implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
sender.sendMessage(
|
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("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
|
||||||
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, 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";
|
return "Get information about the plugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,101 +13,96 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class Debug implements ICommand {
|
public class Debug implements ICommand {
|
||||||
|
|
||||||
private static final Map<Integer, Consumer<Player>> debugMenuFunctions = new HashMap<>();
|
private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
|
||||||
private Inventory debugMenu;
|
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if(args.length < 1) args = new String[]{""};
|
net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
|
||||||
if(debugMenu == null) createMenu(args[0]);
|
if(map == null) {
|
||||||
|
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Inventory debugMenu = createMenu(map, sender);
|
||||||
sender.openInventory(debugMenu);
|
sender.openInventory(debugMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMenu(String mapname){
|
private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){
|
||||||
net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(mapname);
|
Map<Integer, Consumer<Player>> functions = new HashMap<>();
|
||||||
debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
|
Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
|
||||||
debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
|
debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
Main.getInstance().getBoard().addHider(player);
|
||||||
PlayerLoader.loadHider(player, Main.getInstance().getGame().getCurrentMap());
|
PlayerLoader.loadHider(player, map);
|
||||||
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
||||||
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
|
debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
Main.getInstance().getBoard().addSeeker(player);
|
||||||
PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getCurrentMap());
|
PlayerLoader.loadSeeker(player, map);
|
||||||
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
if(Main.getInstance().getGame().getStatus() != Status.STARTING)
|
||||||
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
|
debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
|
||||||
if(mapSaveEnabled) {
|
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);
|
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);
|
Main.getInstance().getBoard().remove(player);
|
||||||
PlayerLoader.unloadPlayer(player);
|
PlayerLoader.unloadPlayer(player);
|
||||||
player.teleport(exitPosition);
|
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){
|
if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
|
||||||
player.setHealth(0.1);
|
player.setHealth(0.1);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
|
debugMenu.setItem(6, createOption(functions, 6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
|
||||||
if(map == null) {
|
|
||||||
player.sendMessage(errorPrefix + message("INVALID_MAP"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(mapSaveEnabled) {
|
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 -> {
|
debugMenu.setItem(7, createOption(functions, 7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
|
||||||
if(map == null) {
|
|
||||||
player.sendMessage(errorPrefix + message("INVALID_MAP"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.teleport(map.getLobby());
|
player.teleport(map.getLobby());
|
||||||
}));
|
}));
|
||||||
debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition)));
|
debugMenu.setItem(8, createOption(functions, 8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(exitPosition)));
|
||||||
debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
|
debugMenu.setItem(9, createOption(functions, 9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
|
||||||
if(map == null) {
|
|
||||||
player.sendMessage(errorPrefix + message("INVALID_MAP"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlayerLoader.openBlockHuntPicker(player, map);
|
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);
|
ItemStack temp = new ItemStack(material, amount);
|
||||||
ItemMeta meta = temp.getItemMeta();
|
ItemMeta meta = temp.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||||
temp.setItemMeta(meta);
|
temp.setItemMeta(meta);
|
||||||
debugMenuFunctions.put(slow, callback);
|
functions.put(slow, callback);
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleOption(Player player, int slotId){
|
public static void handleOption(Player player, int slotId){
|
||||||
Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
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);
|
if(callback != null) callback.accept(player);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
@ -117,11 +112,18 @@ public class Debug implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "<*map>";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Run debug commands";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import net.md_5.bungee.api.ChatColor;
|
||||||
import net.tylermurphy.hideAndSeek.util.CommandHandler;
|
import net.tylermurphy.hideAndSeek.util.CommandHandler;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Help implements ICommand {
|
public class Help implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
|
@ -46,4 +48,8 @@ public class Help implements ICommand {
|
||||||
return "Get the commands for the plugin";
|
return "Get the commands for the plugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ICommand {
|
public interface ICommand {
|
||||||
|
|
||||||
|
@ -30,5 +33,7 @@ public interface ICommand {
|
||||||
String getUsage();
|
String getUsage();
|
||||||
|
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
|
List<String> autoComplete(@Nullable String parameter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,15 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class Join implements ICommand {
|
public class Join implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
if (Main.getInstance().getGame().checkCurrentMap()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,4 +60,8 @@ public class Join implements ICommand {
|
||||||
return "Joins the lobby if game is set to manual join/leave";
|
return "Joins the lobby if game is set to manual join/leave";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,15 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class Leave implements ICommand {
|
public class Leave implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
if (Main.getInstance().getGame().checkCurrentMap()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,4 +59,8 @@ public class Leave implements ICommand {
|
||||||
return "Leaves the lobby if game is set to manual join/leave";
|
return "Leaves the lobby if game is set to manual join/leave";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,9 +23,12 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Config;
|
import net.tylermurphy.hideAndSeek.configuration.Config;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Items;
|
import net.tylermurphy.hideAndSeek.configuration.Items;
|
||||||
import net.tylermurphy.hideAndSeek.configuration.Localization;
|
import net.tylermurphy.hideAndSeek.configuration.Localization;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
@ -39,6 +42,7 @@ public class Reload implements ICommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
|
Maps.loadMaps();
|
||||||
Localization.loadLocalization();
|
Localization.loadLocalization();
|
||||||
Items.loadItems();
|
Items.loadItems();
|
||||||
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
|
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
|
||||||
|
@ -55,5 +59,9 @@ public class Reload implements ICommand {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Reloads the config";
|
return "Reloads the config";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,9 @@ import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
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.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
|
@ -82,5 +85,12 @@ public class SaveMap implements ICommand {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Saves current map for the game. May lag server.";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,11 @@ import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
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.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
|
@ -45,7 +50,7 @@ public class SetBorder implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length < 3) {
|
if (args.length < 4) {
|
||||||
map.setWorldBorderData(0, 0, 0, 0, 0);
|
map.setWorldBorderData(0, 0, 0, 0, 0);
|
||||||
addToConfig("worldBorder.enabled",false);
|
addToConfig("worldBorder.enabled",false);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
@ -91,11 +96,18 @@ public class SetBorder implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "<map> <size> <delay> <move>";
|
return "<map> <*size> <*delay> <*move>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Sets worldboarder's center location, size in blocks, and delay in minutes per shrink. Add no arguments to disable.";
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
|
@ -44,7 +47,7 @@ public class SetBounds implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!sender.getWorld().getName().equals(map.getSpawn().getWorld().getName())) {
|
if (!sender.getWorld().getName().equals(map.getSpawnName())) {
|
||||||
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
|
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +75,7 @@ public class SetBounds implements ICommand {
|
||||||
}
|
}
|
||||||
if (bzl == 0) {
|
if (bzl == 0) {
|
||||||
bzl = sender.getLocation().getBlockZ();
|
bzl = sender.getLocation().getBlockZ();
|
||||||
} else if (map.getBoundsMax().getX() < sender.getLocation().getBlockZ()) {
|
} else if (map.getBoundsMax().getZ() < sender.getLocation().getBlockZ()) {
|
||||||
first = false;
|
first = false;
|
||||||
bzs = bzl;
|
bzs = bzl;
|
||||||
bzl = sender.getLocation().getBlockZ();
|
bzl = sender.getLocation().getBlockZ();
|
||||||
|
@ -82,8 +85,8 @@ public class SetBounds implements ICommand {
|
||||||
}
|
}
|
||||||
map.setBoundMin(bxs, bzs);
|
map.setBoundMin(bxs, bzs);
|
||||||
map.setBoundMax(bxl, bzl);
|
map.setBoundMax(bxl, bzl);
|
||||||
|
Maps.setMap(map.getName(), map);
|
||||||
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
|
sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
|
||||||
saveConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
|
@ -98,4 +101,11 @@ public class SetBounds implements ICommand {
|
||||||
return "Sets the map bounds for the game.";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,6 +25,8 @@ import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
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.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
@ -40,19 +42,19 @@ public class Setup implements ICommand {
|
||||||
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
|
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
|
||||||
return;
|
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");
|
msg = msg + "\n" + message("SETUP_GAME");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_LOBBY");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
|
||||||
count++;
|
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");
|
msg = msg + "\n" + message("SETUP_EXIT");
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,7 @@ public class Setup implements ICommand {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (mapSaveEnabled) {
|
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()) {
|
if (!destenation.exists()) {
|
||||||
msg = msg + "\n" + message("SETUP_SAVEMAP");
|
msg = msg + "\n" + message("SETUP_SAVEMAP");
|
||||||
count++;
|
count++;
|
||||||
|
@ -87,4 +89,11 @@ public class Setup implements ICommand {
|
||||||
return "Shows what needs to be setup";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,12 +20,15 @@
|
||||||
package net.tylermurphy.hideAndSeek.command;
|
package net.tylermurphy.hideAndSeek.command;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
|
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 class Start implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
if (Main.getInstance().getGame().checkCurrentMap()) {
|
||||||
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -86,4 +89,11 @@ public class Start implements ICommand {
|
||||||
return "Starts the game either with a random seeker or chosen one";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ import net.tylermurphy.hideAndSeek.Main;
|
||||||
import net.tylermurphy.hideAndSeek.game.util.Status;
|
import net.tylermurphy.hideAndSeek.game.util.Status;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
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 class Stop implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
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");
|
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,4 +57,8 @@ public class Stop implements ICommand {
|
||||||
return "Stops the game";
|
return "Stops the game";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
|
@ -80,4 +81,9 @@ public class Top implements ICommand {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Gets the top players in the server.";
|
return "Gets the top players in the server.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return Collections.singletonList(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
|
@ -70,10 +72,14 @@ public class Wins implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "<player>";
|
return "<*player>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Get the win information for yourself or another player.";
|
return "Get the win information for yourself or another player.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return Collections.singletonList(parameter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,18 @@ package net.tylermurphy.hideAndSeek.command.location;
|
||||||
import net.tylermurphy.hideAndSeek.command.ICommand;
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import org.bukkit.entity.Player;
|
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.Config.*;
|
||||||
|
|
||||||
public class SetExitLocation implements ICommand {
|
public class SetExitLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
LocationUtils.setLocation(sender, Locations.EXIT, args[0], map -> {
|
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
|
||||||
addToConfig("exit.x", sender.getLocation().getBlockX());
|
addToConfig("exit.x", sender.getLocation().getBlockX());
|
||||||
addToConfig("exit.y", sender.getLocation().getBlockY());
|
addToConfig("exit.y", sender.getLocation().getBlockY());
|
||||||
addToConfig("exit.z", sender.getLocation().getBlockZ());
|
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";
|
return "Sets hide and seeks exit location to current position and world";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> autoComplete(String parameter) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,12 @@ package net.tylermurphy.hideAndSeek.command.location;
|
||||||
import net.tylermurphy.hideAndSeek.command.ICommand;
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import org.bukkit.entity.Player;
|
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.Config.*;
|
||||||
|
|
||||||
public class SetLobbyLocation implements ICommand {
|
public class SetLobbyLocation implements ICommand {
|
||||||
|
@ -39,11 +43,18 @@ public class SetLobbyLocation implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Sets hide and seeks lobby location to current position";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,24 @@ package net.tylermurphy.hideAndSeek.command.location;
|
||||||
import net.tylermurphy.hideAndSeek.command.ICommand;
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
import org.bukkit.entity.Player;
|
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 class SetSeekerLobbyLocation implements ICommand {
|
||||||
|
|
||||||
public void execute(Player sender, String[] args) {
|
public void execute(Player sender, String[] args) {
|
||||||
LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
|
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());
|
map.setSeekerLobby(sender.getLocation());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,11 +30,18 @@ public class SetSeekerLobbyLocation implements ICommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsage() {
|
public String getUsage() {
|
||||||
return "";
|
return "<map>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Sets hide and seeks seeker lobby location to current position";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,14 @@ package net.tylermurphy.hideAndSeek.command.location;
|
||||||
import net.tylermurphy.hideAndSeek.command.ICommand;
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
|
||||||
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
|
||||||
|
import net.tylermurphy.hideAndSeek.configuration.Maps;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
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.Config.*;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
|
@ -41,7 +46,12 @@ public class SetSpawnLocation implements ICommand {
|
||||||
|
|
||||||
map.setSpawn(sender.getLocation());
|
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();
|
map.getWorldLoader().unloadMap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -59,4 +69,11 @@ public class SetSpawnLocation implements ICommand {
|
||||||
return "Sets hide and seeks spawn location to current position";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
if(map != null)
|
||||||
Maps.setMap(mapName, map);
|
Maps.setMap(mapName, map);
|
||||||
player.sendMessage(messagePrefix + message(place.message()));
|
player.sendMessage(messagePrefix + message(place.message()));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.tylermurphy.hideAndSeek.configuration;
|
package net.tylermurphy.hideAndSeek.configuration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.tylermurphy.hideAndSeek.Main;
|
import net.tylermurphy.hideAndSeek.Main;
|
||||||
|
@ -22,7 +23,7 @@ public class Map {
|
||||||
seekerLobbyPosition = new Location(null, 0, 0, 0);
|
seekerLobbyPosition = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
private String
|
private String
|
||||||
gameWorldName;
|
gameWorldName = "world";
|
||||||
|
|
||||||
private int
|
private int
|
||||||
xBoundMin = 0,
|
xBoundMin = 0,
|
||||||
|
@ -36,10 +37,10 @@ public class Map {
|
||||||
worldBorderChange = 0;
|
worldBorderChange = 0;
|
||||||
|
|
||||||
private boolean
|
private boolean
|
||||||
blockhunt;
|
blockhunt = false;
|
||||||
|
|
||||||
private List<Material>
|
private List<Material>
|
||||||
blockhuntBlocks;
|
blockhuntBlocks = new ArrayList<>();
|
||||||
|
|
||||||
private final Border
|
private final Border
|
||||||
worldBorder;
|
worldBorder;
|
||||||
|
@ -55,7 +56,8 @@ public class Map {
|
||||||
|
|
||||||
public void setSpawn(Location pos) {
|
public void setSpawn(Location pos) {
|
||||||
this.spawnPosition = pos;
|
this.spawnPosition = pos;
|
||||||
this.gameWorldName = pos.getWorld().getName();
|
if(pos.getWorld() != null)
|
||||||
|
this.gameWorldName = pos.getWorld().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLobby(Location pos) {
|
public void setLobby(Location pos) {
|
||||||
|
@ -73,7 +75,6 @@ public class Map {
|
||||||
this.worldBorderChange = 0;
|
this.worldBorderChange = 0;
|
||||||
this.xWorldBorder = 0;
|
this.xWorldBorder = 0;
|
||||||
this.zWorldBorder = 0;
|
this.zWorldBorder = 0;
|
||||||
this.worldBorder.resetWorldBorder();
|
|
||||||
} else {
|
} else {
|
||||||
this.worldBorderSize = size;
|
this.worldBorderSize = size;
|
||||||
this.worldBorderDelay = delay;
|
this.worldBorderDelay = delay;
|
||||||
|
@ -81,6 +82,7 @@ public class Map {
|
||||||
this.xWorldBorder = x;
|
this.xWorldBorder = x;
|
||||||
this.zWorldBorder = z;
|
this.zWorldBorder = z;
|
||||||
}
|
}
|
||||||
|
this.worldBorder.resetWorldBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockhunt(boolean enabled, List<Material> blocks) {
|
public void setBlockhunt(boolean enabled, List<Material> blocks) {
|
||||||
|
@ -98,14 +100,31 @@ public class Map {
|
||||||
this.zBoundMax = z;
|
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() {
|
public Location getSpawn() {
|
||||||
if(mapSaveEnabled)
|
|
||||||
spawnPosition.setWorld(Bukkit.getWorld("hs_"+gameWorldName));
|
|
||||||
else
|
|
||||||
spawnPosition.setWorld(Bukkit.getWorld(gameWorldName));
|
|
||||||
return spawnPosition;
|
return spawnPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSpawnName() {
|
||||||
|
return gameWorldName;
|
||||||
|
}
|
||||||
|
|
||||||
public Location getLobby() {
|
public Location getLobby() {
|
||||||
return lobbyPosition;
|
return lobbyPosition;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +133,19 @@ public class Map {
|
||||||
return seekerLobbyPosition;
|
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() {
|
public boolean isWorldBorderEnabled() {
|
||||||
return worldBorderSize > 0;
|
return worldBorderSize > 0;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +190,7 @@ public class Map {
|
||||||
return new Vector(
|
return new Vector(
|
||||||
xBoundMax,
|
xBoundMax,
|
||||||
0,
|
0,
|
||||||
zBoundMin
|
zBoundMax
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,17 @@ public class Maps {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map getRandomMap() {
|
public static Map getRandomMap() {
|
||||||
Optional<Map> map = MAPS.values().stream().skip(new Random().nextInt(MAPS.values().size())).findFirst();
|
Optional<Map> map;
|
||||||
if(map.isPresent()) return map.get();
|
if(MAPS.values().size() > 0) {
|
||||||
setMap("default", new Map("default"));
|
Collection<Map> setupMaps = MAPS.values().stream().filter(m -> !m.isNotSetup()).collect(Collectors.toList());
|
||||||
return MAPS.get("default");
|
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) {
|
public static void setMap(String name, Map map) {
|
||||||
|
@ -32,6 +39,12 @@ public class Maps {
|
||||||
saveMaps();
|
saveMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean removeMap(String name) {
|
||||||
|
boolean status = MAPS.remove(name) != null;
|
||||||
|
saveMaps();
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
public static Collection<Map> getAllMaps() {
|
public static Collection<Map> getAllMaps() {
|
||||||
return MAPS.values();
|
return MAPS.values();
|
||||||
}
|
}
|
||||||
|
@ -69,9 +82,11 @@ public class Maps {
|
||||||
data.getInt("worldborder.delay"),
|
data.getInt("worldborder.delay"),
|
||||||
data.getInt("worldborder.change")
|
data.getInt("worldborder.change")
|
||||||
);
|
);
|
||||||
|
List<String> blockhunt = data.getStringList("blockhunt.blocks");
|
||||||
|
if(blockhunt == null) blockhunt = new ArrayList<>();
|
||||||
map.setBlockhunt(
|
map.setBlockhunt(
|
||||||
data.getBoolean("blockhunt.enabled"),
|
data.getBoolean("blockhunt.enabled"),
|
||||||
data.getStringList("blockhunt.blocks")
|
blockhunt
|
||||||
.stream()
|
.stream()
|
||||||
.map(XMaterial::matchXMaterial)
|
.map(XMaterial::matchXMaterial)
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
|
@ -113,8 +128,8 @@ public class Maps {
|
||||||
data.set("worldborder.pos.delay", map.getWorldBorderData().getY());
|
data.set("worldborder.pos.delay", map.getWorldBorderData().getY());
|
||||||
data.set("worldborder.pos.change", map.getWorldBorderData().getZ());
|
data.set("worldborder.pos.change", map.getWorldBorderData().getZ());
|
||||||
data.set("blockhunt.enabled", map.isBlockHuntEnabled());
|
data.set("blockhunt.enabled", map.isBlockHuntEnabled());
|
||||||
data.set("blockhunt.blocks", map.getBlockHunt().stream().map(Material::name));
|
data.set("blockhunt.blocks", map.getBlockHunt().stream().map(Material::name).collect(Collectors.toList()));
|
||||||
maps.set(map.getName(), map);
|
maps.set(map.getName(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
manager.set("maps", maps);
|
manager.set("maps", maps);
|
||||||
|
@ -128,9 +143,9 @@ public class Maps {
|
||||||
} else {
|
} else {
|
||||||
data.set("spawns." + name + ".world", "world");
|
data.set("spawns." + name + ".world", "world");
|
||||||
}
|
}
|
||||||
data.set("spawns.." + name + ".x", spawn.getX());
|
data.set("spawns." + name + ".x", spawn.getX());
|
||||||
data.set("spawns.." + name + ".y", spawn.getY());
|
data.set("spawns." + name + ".y", spawn.getY());
|
||||||
data.set("spawns.." + name + ".z", spawn.getZ());
|
data.set("spawns." + name + ".z", spawn.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,12 @@ public class Game {
|
||||||
private boolean hiderLeft;
|
private boolean hiderLeft;
|
||||||
|
|
||||||
public Game(Board board) {
|
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.taunt = new Taunt();
|
||||||
this.glow = new Glow();
|
this.glow = new Glow();
|
||||||
|
@ -140,6 +144,8 @@ public class Game {
|
||||||
public void end() {
|
public void end() {
|
||||||
board.getPlayers().forEach(PlayerLoader::unloadPlayer);
|
board.getPlayers().forEach(PlayerLoader::unloadPlayer);
|
||||||
currentMap.getWorldBorder().resetWorldBorder();
|
currentMap.getWorldBorder().resetWorldBorder();
|
||||||
|
Map nextMap = Maps.getRandomMap();
|
||||||
|
if(nextMap != null) this.currentMap = nextMap;
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
if (leaveOnEnd) {
|
if (leaveOnEnd) {
|
||||||
board.removeBoard(player);
|
board.removeBoard(player);
|
||||||
|
@ -213,7 +219,7 @@ public class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
if (currentMap.isNotSetup()) return;
|
if (currentMap == null || currentMap.isNotSetup()) return;
|
||||||
if (status == Status.STANDBY) whileWaiting();
|
if (status == Status.STANDBY) whileWaiting();
|
||||||
else if (status == Status.STARTING) whileStarting();
|
else if (status == Status.STARTING) whileStarting();
|
||||||
else if (status == Status.PLAYING) whilePlaying();
|
else if (status == Status.PLAYING) whilePlaying();
|
||||||
|
@ -249,7 +255,7 @@ public class Game {
|
||||||
board.getPlayers().forEach(player -> {
|
board.getPlayers().forEach(player -> {
|
||||||
PlayerLoader.resetPlayer(player, board);
|
PlayerLoader.resetPlayer(player, board);
|
||||||
if(board.isSeeker(player)){
|
if(board.isSeeker(player)){
|
||||||
player.teleport(currentMap.getSpawn());
|
player.teleport(currentMap.getGameSpawn());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (startingTimer == 1){
|
} else if (startingTimer == 1){
|
||||||
|
@ -327,13 +333,19 @@ public class Game {
|
||||||
return currentMap;
|
return currentMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkCurrentMap() {
|
||||||
|
if(currentMap != null) return false;
|
||||||
|
this.currentMap = Maps.getRandomMap();
|
||||||
|
return this.currentMap == null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCurrentMap(Map map) {
|
public void setCurrentMap(Map map) {
|
||||||
this.currentMap = map;
|
this.currentMap = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getGameWorld() {
|
public String getGameWorld() {
|
||||||
if(currentMap == null || currentMap.getSpawn() == null) return null;
|
if(currentMap == null) return null;
|
||||||
else return currentMap.getSpawn().getWorld();
|
else return currentMap.getGameSpawnName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkWinConditions() {
|
private void checkWinConditions() {
|
||||||
|
|
|
@ -40,7 +40,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
public class PlayerLoader {
|
public class PlayerLoader {
|
||||||
|
|
||||||
public static void loadHider(Player player, Map map){
|
public static void loadHider(Player player, Map map){
|
||||||
player.teleport(map.getSpawn());
|
player.teleport(map.getGameSpawn());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,1000000,5,false,false));
|
||||||
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("HIDER_TEAM_NAME"), ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
|
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("HIDER_TEAM_NAME"), ChatColor.WHITE + message("HIDERS_SUBTITLE").toString());
|
||||||
|
@ -50,13 +50,13 @@ public class PlayerLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadSeeker(Player player, Map map){
|
public static void loadSeeker(Player player, Map map){
|
||||||
player.teleport(map.getSeekerLobby());
|
player.teleport(map.getGameSeekerLobby());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("SEEKER_TEAM_NAME"), ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString());
|
Titles.sendTitle(player, 10, 70, 20, ChatColor.WHITE + "" + message("SEEKER_TEAM_NAME"), ChatColor.WHITE + message("SEEKERS_SUBTITLE").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadSpectator(Player player, Map map){
|
public static void loadSpectator(Player player, Map map){
|
||||||
player.teleport(map.getSpawn());
|
player.teleport(map.getGameSpawn());
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
player.setFlying(true);
|
player.setFlying(true);
|
||||||
|
|
|
@ -41,13 +41,14 @@ public class Border {
|
||||||
running = true;
|
running = true;
|
||||||
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
|
Main.getInstance().getGame().broadcastMessage(worldBorderPrefix + message("WORLDBORDER_DECREASING").addAmount(change));
|
||||||
currentSize -= map.getWorldBorderData().getZ();
|
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);
|
border.setSize(border.getSize()-change,30);
|
||||||
delay = 30;
|
delay = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetWorldBorder() {
|
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()) {
|
if (map.isWorldBorderEnabled()) {
|
||||||
border.setSize(map.getWorldBorderData().getX());
|
border.setSize(map.getWorldBorderData().getX());
|
||||||
border.setCenter(map.getWorldBorderPos().getX(), map.getWorldBorderPos().getY());
|
border.setCenter(map.getWorldBorderPos().getX(), map.getWorldBorderPos().getY());
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DamageHandler implements Listener {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
// If map is not setup we won't be able to process on it :o
|
// 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 there is an attacker, find them
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
if (((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
if (((EntityDamageByEntityEvent) event).getDamager() instanceof Player)
|
||||||
|
@ -71,9 +71,9 @@ public class DamageHandler implements Listener {
|
||||||
if (board.isSpectator(player)) {
|
if (board.isSpectator(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (Main.getInstance().supports(18) && player.getLocation().getBlockY() < -64) {
|
if (Main.getInstance().supports(18) && player.getLocation().getBlockY() < -64) {
|
||||||
player.teleport(game.getCurrentMap().getSpawn());
|
player.teleport(game.getCurrentMap().getGameSpawn());
|
||||||
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
|
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
|
||||||
player.teleport(game.getCurrentMap().getSpawn());
|
player.teleport(game.getCurrentMap().getGameSpawn());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,15 +96,15 @@ public class DamageHandler implements Listener {
|
||||||
Main.getInstance().getDisguiser().reveal(player);
|
Main.getInstance().getDisguiser().reveal(player);
|
||||||
// Teleport player to seeker spawn
|
// Teleport player to seeker spawn
|
||||||
if(delayedRespawn){
|
if(delayedRespawn){
|
||||||
player.teleport(game.getCurrentMap().getSeekerLobby());
|
player.teleport(game.getCurrentMap().getGameSeekerLobby());
|
||||||
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
|
player.sendMessage(messagePrefix + message("RESPAWN_NOTICE").addAmount(delayedRespawnDelay));
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
|
||||||
if(game.getStatus() == Status.PLAYING){
|
if(game.getStatus() == Status.PLAYING){
|
||||||
player.teleport(game.getCurrentMap().getSpawn());
|
player.teleport(game.getCurrentMap().getGameSpawn());
|
||||||
}
|
}
|
||||||
}, delayedRespawnDelay * 20L);
|
}, delayedRespawnDelay * 20L);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(game.getCurrentMap().getSpawn());
|
player.teleport(game.getCurrentMap().getGameSpawn());
|
||||||
}
|
}
|
||||||
// Add leaderboard stats
|
// Add leaderboard stats
|
||||||
board.addDeath(player.getUniqueId());
|
board.addDeath(player.getUniqueId());
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class InteractHandler implements Listener {
|
||||||
|
|
||||||
if (temp.isSimilar(lobbyStartItem) && event.getPlayer().hasPermission("hideandseek.start")) {
|
if (temp.isSimilar(lobbyStartItem) && event.getPlayer().hasPermission("hideandseek.start")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) {
|
if (Main.getInstance().getGame().checkCurrentMap()) {
|
||||||
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
|
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,16 @@ public class JoinLeaveHandler implements Listener {
|
||||||
}
|
}
|
||||||
Main.getInstance().getBoard().remove(event.getPlayer());
|
Main.getInstance().getBoard().remove(event.getPlayer());
|
||||||
removeItems(event.getPlayer());
|
removeItems(event.getPlayer());
|
||||||
if (Main.getInstance().getGame().getCurrentMap().isNotSetup()) return;
|
if (Main.getInstance().getGame().checkCurrentMap()) return;
|
||||||
if (autoJoin) {
|
if (autoJoin) {
|
||||||
Main.getInstance().getGame().join(event.getPlayer());
|
Main.getInstance().getGame().join(event.getPlayer());
|
||||||
} else if (teleportToExit) {
|
} else if (teleportToExit) {
|
||||||
if (event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().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().teleport(exitPosition);
|
||||||
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
event.getPlayer().setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().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) {
|
if (Main.getInstance().getGame().getStatus() != Status.STANDBY && Main.getInstance().getGame().getStatus() != Status.ENDING) {
|
||||||
Main.getInstance().getGame().join(event.getPlayer());
|
Main.getInstance().getGame().join(event.getPlayer());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class MovementHandler implements Listener {
|
||||||
|
|
||||||
private void checkBounds(PlayerMoveEvent event){
|
private void checkBounds(PlayerMoveEvent event){
|
||||||
if (!Main.getInstance().getBoard().contains(event.getPlayer())) return;
|
if (!Main.getInstance().getBoard().contains(event.getPlayer())) return;
|
||||||
if (!event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) return;
|
if (!event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) return;
|
||||||
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld().getName())) return;
|
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) return;
|
||||||
if (event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
|
if (event.getPlayer().hasPermission("hideandseek.leavebounds")) return;
|
||||||
Map map = Main.getInstance().getGame().getCurrentMap();
|
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()) {
|
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()) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
|
||||||
import static net.tylermurphy.hideAndSeek.configuration.Config.permissionsRequired;
|
import static net.tylermurphy.hideAndSeek.configuration.Config.permissionsRequired;
|
||||||
|
@ -65,6 +66,10 @@ public class CommandHandler {
|
||||||
registerCommand(new Top());
|
registerCommand(new Top());
|
||||||
registerCommand(new Wins());
|
registerCommand(new Wins());
|
||||||
registerCommand(new Debug());
|
registerCommand(new Debug());
|
||||||
|
registerCommand(new AddMap());
|
||||||
|
registerCommand(new RemoveMap());
|
||||||
|
registerCommand(new ListMaps());
|
||||||
|
registerCommand(new SetMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleCommand(CommandSender sender, String[] args) {
|
public static boolean handleCommand(CommandSender sender, String[] args) {
|
||||||
|
@ -85,8 +90,15 @@ public class CommandHandler {
|
||||||
} else if (permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
|
} else if (permissionsRequired && !sender.hasPermission("hideandseek."+args[0].toLowerCase())) {
|
||||||
sender.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
|
sender.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(errorPrefix + "An error has occurred.");
|
sender.sendMessage(errorPrefix + "An error has occurred.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package net.tylermurphy.hideAndSeek.util;
|
package net.tylermurphy.hideAndSeek.util;
|
||||||
|
|
||||||
|
import net.tylermurphy.hideAndSeek.command.ICommand;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -36,21 +37,20 @@ public class TabCompleter {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else if (args.length > 1) {
|
} else if (args.length > 1) {
|
||||||
if (!CommandHandler.COMMAND_REGISTER.containsKey(args[0].toLowerCase())) {
|
if (!CommandHandler.COMMAND_REGISTER.containsKey(args[0].toLowerCase())) {
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
} else {
|
} 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) {
|
if (args.length - 2 < usage.length) {
|
||||||
String parameter = usage[args.length-2];
|
String parameter = usage[args.length-2];
|
||||||
if (parameter.equals("<player>")) {
|
String name = parameter.replace("<", "").replace(">", "");
|
||||||
return null;
|
complete = command.autoComplete(name);
|
||||||
} else {
|
|
||||||
List<String> temp = new ArrayList<>();
|
|
||||||
temp.add(parameter.replace("<", "").replace(">", ""));
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
complete = command.autoComplete(null);
|
||||||
}
|
}
|
||||||
|
if(complete == null) return new ArrayList<>();
|
||||||
|
else return complete;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -33,45 +33,35 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
|
||||||
|
|
||||||
public class WorldLoader {
|
public class WorldLoader {
|
||||||
|
|
||||||
private Map map;
|
private final Map map;
|
||||||
private String mapName;
|
|
||||||
private String saveName;
|
|
||||||
|
|
||||||
public WorldLoader(Map map) {
|
public WorldLoader(Map map) {
|
||||||
this.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() {
|
public World getWorld() {
|
||||||
return Bukkit.getServer().getWorld(saveName);
|
return Bukkit.getServer().getWorld(map.getGameSpawnName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadMap() {
|
public void unloadMap() {
|
||||||
World world = Bukkit.getServer().getWorld(saveName);
|
World world = Bukkit.getServer().getWorld(map.getGameSpawnName());
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
Main.getInstance().getLogger().warning(saveName + " already unloaded.");
|
Main.getInstance().getLogger().warning(map.getGameSpawnName() + " already unloaded.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
world.getPlayers().forEach(player -> player.teleport(exitPosition));
|
world.getPlayers().forEach(player -> player.teleport(exitPosition));
|
||||||
if (Bukkit.getServer().unloadWorld(world, false)) {
|
if (Bukkit.getServer().unloadWorld(world, false)) {
|
||||||
Main.getInstance().getLogger().info("Successfully unloaded " + saveName);
|
Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName());
|
||||||
}else{
|
}else{
|
||||||
Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + saveName);
|
Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + map.getGameSpawnName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMap() {
|
public void loadMap() {
|
||||||
Bukkit.getServer().createWorld(new WorldCreator(saveName).generator(new VoidGenerator()));
|
Bukkit.getServer().createWorld(new WorldCreator(map.getGameSpawnName()).generator(new VoidGenerator()));
|
||||||
World world = Bukkit.getServer().getWorld(saveName);
|
World world = Bukkit.getServer().getWorld(map.getGameSpawnName());
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
Main.getInstance().getLogger().severe("COULD NOT LOAD " + saveName);
|
Main.getInstance().getLogger().severe("COULD NOT LOAD " + map.getGameSpawnName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
|
@ -83,15 +73,15 @@ public class WorldLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String save() {
|
public String save() {
|
||||||
World world = Bukkit.getServer().getWorld(mapName);
|
World world = Bukkit.getServer().getWorld(map.getSpawnName());
|
||||||
if(world == null){
|
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()) {
|
if (current.exists()) {
|
||||||
try {
|
try {
|
||||||
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName);
|
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getGameSpawnName());
|
||||||
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName);
|
File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ map.getGameSpawnName());
|
||||||
copyFileFolder("region",true);
|
copyFileFolder("region",true);
|
||||||
copyFileFolder("entities",true);
|
copyFileFolder("entities",true);
|
||||||
copyFileFolder("datapacks",false);
|
copyFileFolder("datapacks",false);
|
||||||
|
@ -104,7 +94,7 @@ public class WorldLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!temp_destination.renameTo(destination)) {
|
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) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -117,8 +107,8 @@ public class WorldLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFileFolder(String name, Boolean isMca) throws IOException {
|
private void copyFileFolder(String name, Boolean isMca) throws IOException {
|
||||||
File region = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName +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_"+ saveName +File.separator+name);
|
File temp = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ map.getGameSpawnName() +File.separator+name);
|
||||||
if (region.exists() && region.isDirectory()) {
|
if (region.exists() && region.isDirectory()) {
|
||||||
if (!temp.exists())
|
if (!temp.exists())
|
||||||
if (!temp.mkdirs())
|
if (!temp.mkdirs())
|
||||||
|
|
|
@ -17,7 +17,7 @@ Localization:
|
||||||
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
|
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
|
||||||
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
|
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
|
||||||
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
|
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_INGAME: "You are already in the lobby/game."
|
||||||
GAME_NOT_INGAME: "You are not in a lobby/game."
|
GAME_NOT_INGAME: "You are not in a lobby/game."
|
||||||
GAME_INPROGRESS: "There is currently a game in progress."
|
GAME_INPROGRESS: "There is currently a game in progress."
|
||||||
|
@ -77,6 +77,19 @@ Localization:
|
||||||
FLYING_ENABLED: "&l&bFlying Enabled"
|
FLYING_ENABLED: "&l&bFlying Enabled"
|
||||||
FLYING_DISABLED: "&l&bFlying Disabled"
|
FLYING_DISABLED: "&l&bFlying Disabled"
|
||||||
RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds."
|
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
|
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
|
||||||
version: 3
|
version: 3
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: KenshinsHideAndSeek
|
name: KenshinsHideAndSeek
|
||||||
main: net.tylermurphy.hideAndSeek.Main
|
main: net.tylermurphy.hideAndSeek.Main
|
||||||
version: 1.6.2
|
version: 1.7.0
|
||||||
author: KenshinEto
|
author: KenshinEto
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
@ -34,6 +34,10 @@ permissions:
|
||||||
hideandseek.wins: true
|
hideandseek.wins: true
|
||||||
hideandseek.top: true
|
hideandseek.top: true
|
||||||
hideandseek.debug: true
|
hideandseek.debug: true
|
||||||
|
hideandseek.addmap: true
|
||||||
|
hideandseek.removemap: true
|
||||||
|
hideandseek.listmaps: true
|
||||||
|
hideandseek.setmap: true
|
||||||
hideandseek.about:
|
hideandseek.about:
|
||||||
description: Allows you to run the about command
|
description: Allows you to run the about command
|
||||||
default: true
|
default: true
|
||||||
|
@ -91,3 +95,15 @@ permissions:
|
||||||
hideandseek.debug:
|
hideandseek.debug:
|
||||||
description: Opens the debug menu
|
description: Opens the debug menu
|
||||||
default: op
|
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
|
||||||
|
|
Loading…
Reference in a new issue