1.7.0 beta 5

This commit is contained in:
Tyler Murphy 2022-11-20 23:39:55 -05:00
parent 0f1d49ba80
commit 5615fa7f32
45 changed files with 467 additions and 385 deletions

BIN
lib/ProtocolLib.jar Normal file

Binary file not shown.

20
pom.xml
View file

@ -82,10 +82,10 @@
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository> </repository>
<repository> <!-- <repository>-->
<id>dmulloy2-repo</id> <!-- <id>dmulloy2-repo</id>-->
<url>https://repo.dmulloy2.net/repository/public/</url> <!-- <url>https://repo.dmulloy2.net/repository/public/</url>-->
</repository> <!-- </repository>-->
<repository> <repository>
<id>placeholderapi</id> <id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
@ -108,12 +108,14 @@
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.7.0</version> <version>4.4.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProtocolLib.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version> <version>3.39.3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>
@ -123,7 +125,7 @@
<dependency> <dependency>
<groupId>com.github.cryptomorin</groupId> <groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId> <artifactId>XSeries</artifactId>
<version>9.0.0</version> <version>9.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
@ -134,12 +136,12 @@
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>4.0.3</version> <version>5.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version> <version>3.0.6</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -38,7 +38,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.Objects; import java.util.ArrayList;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -125,6 +125,7 @@ public class Main extends JavaPlugin implements Listener {
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) { if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PAPIExpansion().register(); new PAPIExpansion().register();
} }
} }
public void onDisable() { public void onDisable() {
@ -135,8 +136,7 @@ public class Main extends JavaPlugin implements Listener {
board.getPlayers().forEach(player -> { board.getPlayers().forEach(player -> {
board.removeBoard(player); board.removeBoard(player);
PlayerLoader.unloadPlayer(player); PlayerLoader.unloadPlayer(player);
if (!Objects.equals(exitWorld, "")) exitPosition.teleport(player);
player.teleport(exitPosition);
}); });
board.cleanup(); board.cleanup();
} }
@ -181,11 +181,16 @@ public class Main extends JavaPlugin implements Listener {
sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY")); sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY"));
return true; return true;
} }
return commandGroup.handleCommand((Player)sender, "", args); commandGroup.handleCommand((Player)sender, args);
return true;
} }
public java.util.List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { public java.util.List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
return commandGroup.handleTabComplete(sender, args); if (!(sender instanceof Player)) {
sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY"));
return new ArrayList<>();
}
return commandGroup.handleTabComplete((Player)sender, args);
} }
public static Main getInstance() { public static Main getInstance() {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.util.Pair; import net.tylermurphy.hideAndSeek.util.Pair;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,11 +33,11 @@ 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.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Help extends Command { public class Help implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
final int pageSize = 4; final int pageSize = 4;
List<Pair<String, Command>> commands = Main.getInstance().getCommandGroup().getCommands(); List<Pair<String, ICommand>> commands = Main.getInstance().getCommandGroup().getCommands();
int pages = (commands.size() - 1) / pageSize + 1; int pages = (commands.size() - 1) / pageSize + 1;
int page; int page;
try { try {
@ -58,8 +58,8 @@ public class Help extends Command {
message.append(String.format("%s================ %sHelp: Page (%s/%s) %s================", message.append(String.format("%s================ %sHelp: Page (%s/%s) %s================",
ChatColor.AQUA, ChatColor.WHITE, page, pages, ChatColor.AQUA)); ChatColor.AQUA, ChatColor.WHITE, page, pages, ChatColor.AQUA));
int lines = 0; int lines = 0;
for(Pair<String, Command> pair : commands.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList())) { for(Pair<String, ICommand> pair : commands.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList())) {
Command command = pair.getRight(); ICommand command = pair.getRight();
String label = pair.getLeft(); String label = pair.getLeft();
String start = label.substring(0, label.indexOf(" ")); String start = label.substring(0, label.indexOf(" "));
String invoke = label.substring(label.indexOf(" ")+1); String invoke = label.substring(label.indexOf(" ")+1);

View file

@ -20,17 +20,19 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
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.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join extends Command { public class Join implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) { if (Main.getInstance().getGame().checkCurrentMap()) {
@ -46,7 +48,18 @@ public class Join extends Command {
sender.sendMessage(errorPrefix + message("GAME_INGAME")); sender.sendMessage(errorPrefix + message("GAME_INGAME"));
return; return;
} }
if(args.length > 0) {
if(Main.getInstance().getBoard().size() > 0) {
sender.sendMessage(errorPrefix + message("LOBBY_IN_USE"));
return;
}
net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
if(map == null) {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
Main.getInstance().getGame().setCurrentMap(map);
}
Main.getInstance().getGame().join(player); Main.getInstance().getGame().join(player);
} }
@ -55,7 +68,7 @@ public class Join extends Command {
} }
public String getUsage() { public String getUsage() {
return ""; return "<*map>";
} }
public String getDescription() { public String getDescription() {
@ -63,6 +76,9 @@ public class Join extends Command {
} }
public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) { public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
if(parameter.equals("*map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
return null; return null;
} }

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -30,7 +30,7 @@ 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 extends Command { public class Leave implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) { if (Main.getInstance().getGame().checkCurrentMap()) {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.*; import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -32,7 +32,7 @@ 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;
public class Reload extends Command { public class Reload implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -14,7 +14,7 @@ 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.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Send extends Command { public class Send implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
@ -41,7 +41,7 @@ public class Send extends Command {
Main.getInstance().getGame().setCurrentMap(map); Main.getInstance().getGame().setCurrentMap(map);
for(Player player : Main.getInstance().getBoard().getPlayers()) { for(Player player : Main.getInstance().getBoard().getPlayers()) {
player.teleport(map.getLobby()); map.getLobby().teleport(player);
} }
} }

View file

@ -19,9 +19,10 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -29,7 +30,7 @@ import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetExitLocation extends Command { public class SetExitLocation implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> { LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
@ -37,8 +38,7 @@ public class SetExitLocation extends Command {
addToConfig("exit.y", sender.getLocation().getBlockY()); addToConfig("exit.y", sender.getLocation().getBlockY());
addToConfig("exit.z", sender.getLocation().getBlockZ()); addToConfig("exit.z", sender.getLocation().getBlockZ());
addToConfig("exit.world", sender.getLocation().getWorld().getName()); addToConfig("exit.world", sender.getLocation().getWorld().getName());
exitPosition = sender.getLocation(); exitPosition = Location.from(sender);
exitWorld = sender.getLocation().getWorld().getName();
saveConfig(); saveConfig();
}); });
} }

View file

@ -20,22 +20,20 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.stream.Collectors; 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;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Start extends Command { public class Start implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) { if (Main.getInstance().getGame().checkCurrentMap()) {
@ -56,12 +54,8 @@ public class Start extends Command {
} }
String seekerName; String seekerName;
if (args.length < 1) { if (args.length < 1) {
Optional<Player> rand = Main.getInstance().getBoard().getPlayers().stream().skip(new Random().nextInt(Main.getInstance().getBoard().size())).findFirst(); Main.getInstance().getGame().start();
if (!rand.isPresent()) {
sender.sendMessage(errorPrefix + message("START_FAILED_SEEKER"));
return; return;
}
seekerName = rand.get().getName();
} else { } else {
seekerName = args[0]; seekerName = args[0];
} }

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -31,7 +31,7 @@ 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;
public class Stop extends Command { public class Stop implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) { if (Main.getInstance().getGame().checkCurrentMap()) {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo; 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;
@ -32,7 +32,7 @@ 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 Top extends Command { public class Top implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
int page; int page;

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo; 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;
@ -33,7 +33,7 @@ import java.util.UUID;
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 Wins extends Command { public class Wins implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
Main.getInstance().getServer().getScheduler().runTaskAsynchronously(Main.getInstance(), () -> { Main.getInstance().getServer().getScheduler().runTaskAsynchronously(Main.getInstance(), () -> {

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -15,7 +15,7 @@ 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;
public class Add extends Command { public class Add implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -2,7 +2,7 @@ package net.tylermurphy.hideAndSeek.command.map;
import com.cryptomorin.xseries.XMaterial; import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.PlayerLoader; import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -23,7 +23,7 @@ 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 extends Command { public class Debug implements ICommand {
private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>(); private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
@ -68,7 +68,7 @@ public class Debug extends Command {
debugMenu.setItem(3, createOption(functions, 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); exitPosition.teleport(player);
})); }));
debugMenu.setItem(4, createOption(functions, 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){

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,11 +10,10 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class GoTo extends Command { public class GoTo implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
Map map = Maps.getMap(args[0]); Map map = Maps.getMap(args[0]);
@ -28,13 +27,13 @@ public class GoTo extends Command {
} }
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "spawn": case "spawn":
sender.teleport(map.getSpawn()); break; map.getSpawn().teleport(sender); break;
case "lobby": case "lobby":
sender.teleport(map.getLobby()); break; map.getLobby().teleport(sender); break;
case "seekerlobby": case "seekerlobby":
sender.teleport(map.getSeekerLobby()); break; map.getSeekerLobby().teleport(sender); break;
case "exit": case "exit":
sender.teleport(exitPosition); break; exitPosition.teleport(sender); break;
default: default:
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase())); sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase()));
} }

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -13,7 +13,7 @@ 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;
public class List extends Command { public class List implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
Collection<Map> maps = Maps.getAllMaps(); Collection<Map> maps = Maps.getAllMaps();

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -15,7 +15,7 @@ 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;
public class Remove extends Command { public class Remove implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -35,7 +35,7 @@ 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 Save extends Command { public class Save implements ICommand {
public static boolean runningBackup = false; public static boolean runningBackup = false;
@ -63,7 +63,7 @@ public class Save extends Command {
} }
sender.sendMessage(messagePrefix + message("MAPSAVE_START")); sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING")); sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
World world = map.getSpawn().getWorld(); World world = map.getSpawn().load();
if (world == null) { if (world == null) {
sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD")); sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD"));
return; return;

View file

@ -19,7 +19,7 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ 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 Status extends Command { public class Status implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
@ -42,19 +42,19 @@ public class Status extends Command {
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 || Map.worldDoesntExist(map.getLobbyName())) { if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !map.getSpawn().exists()) {
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 || Map.worldDoesntExist(map.getLobbyName())) { if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !map.getLobby().exists()) {
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 || Map.worldDoesntExist(map.getSeekerLobbyName())) { if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !map.getSeekerLobby().exists()) {
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 || Map.worldDoesntExist(exitWorld)) { if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) {
msg = msg + "\n" + message("SETUP_EXIT"); msg = msg + "\n" + message("SETUP_EXIT");
count++; count++;
} }
@ -62,7 +62,7 @@ public class Status extends Command {
msg = msg + "\n" + message("SETUP_BOUNDS"); msg = msg + "\n" + message("SETUP_BOUNDS");
count++; count++;
} }
if (mapSaveEnabled && Map.worldDoesntExist(map.getGameSpawnName())) { if (mapSaveEnabled && !map.getGameSpawn().exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP"); msg = msg + "\n" + message("SETUP_SAVEMAP");
count++; count++;
} }

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt; package net.tylermurphy.hideAndSeek.command.map.blockhunt;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -17,7 +17,7 @@ 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;
public class Enabled extends Command { public class Enabled implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks; package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -17,7 +17,7 @@ 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;
public class Add extends Command { public class Add implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks; package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
@ -14,7 +14,7 @@ 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;
public class List extends Command { public class List implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
Map map = Maps.getMap(args[0]); Map map = Maps.getMap(args[0]);

View file

@ -1,7 +1,7 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks; package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -17,7 +17,7 @@ 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;
public class Remove extends Command { public class Remove implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command.map.set; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -34,7 +34,7 @@ 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 Border extends Command { public class Border implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command.map.set; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
@ -33,7 +33,7 @@ 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 Bounds extends Command { public class Bounds implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {

View file

@ -19,21 +19,22 @@
package net.tylermurphy.hideAndSeek.command.map.set; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class Lobby extends Command { public class Lobby implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> { LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
map.setLobby(sender.getLocation()); map.setLobby(Location.from(sender));
}); });
} }

View file

@ -1,9 +1,10 @@
package net.tylermurphy.hideAndSeek.command.map.set; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -12,7 +13,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SeekerLobby extends Command { public class SeekerLobby 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 -> {
@ -22,7 +23,7 @@ public class SeekerLobby extends Command {
if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) { if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) {
throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString()); throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString());
} }
map.setSeekerLobby(sender.getLocation()); map.setSeekerLobby(Location.from(sender));
}); });
} }

View file

@ -19,11 +19,11 @@
package net.tylermurphy.hideAndSeek.command.map.set; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Location; import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -34,7 +34,7 @@ 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 Spawn extends Command { public class Spawn implements ICommand {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> { LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> {
@ -45,11 +45,11 @@ public class Spawn extends Command {
throw new RuntimeException("World border not enabled or not in valid position!"); throw new RuntimeException("World border not enabled or not in valid position!");
} }
map.setSpawn(sender.getLocation()); map.setSpawn(Location.from(sender));
if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().getName().equals(sender.getLocation().getWorld().getName())) { if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().equals(sender.getLocation().getWorld().getName())) {
sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString()); sender.sendMessage(message("SEEKER_LOBBY_SPAWN_RESET").toString());
map.setSeekerLobby(new Location(null, 0, 0, 0)); map.setSeekerLobby(Location.getDefault());
} }
if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) { if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) {

View file

@ -21,9 +21,10 @@ package net.tylermurphy.hideAndSeek.command.util;
import net.tylermurphy.hideAndSeek.command.map.Save; import net.tylermurphy.hideAndSeek.command.map.Save;
import net.tylermurphy.hideAndSeek.util.Pair; import net.tylermurphy.hideAndSeek.util.Pair;
import net.tylermurphy.hideAndSeek.util.Tuple;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,7 +41,9 @@ public class CommandGroup {
public CommandGroup(String label, Object... data) { public CommandGroup(String label, Object... data) {
this.label = label; this.label = label;
this.commandRegister = new LinkedHashMap<>(); this.commandRegister = new LinkedHashMap<>();
for(Object o : data) registerCommand(o); for(Object o : data) {
registerCommand(o);
}
} }
public String getLabel() { public String getLabel() {
@ -48,8 +51,8 @@ public class CommandGroup {
} }
private void registerCommand(Object object) { private void registerCommand(Object object) {
if(object instanceof Command) { if (object instanceof ICommand) {
Command command = (Command) object; ICommand command = (ICommand) object;
if (!commandRegister.containsKey(command.getLabel())) { if (!commandRegister.containsKey(command.getLabel())) {
commandRegister.put(command.getLabel().toLowerCase(), command); commandRegister.put(command.getLabel().toLowerCase(), command);
} }
@ -61,87 +64,99 @@ public class CommandGroup {
} }
} }
public boolean handleCommand(Player player, String permission, String[] args) { public void handleCommand(Player player, String[] args) {
if (args.length < 1 || !commandRegister.containsKey(args[0].toLowerCase()) ) {
if (permissionsRequired && !player.hasPermission("hs.about")) { Tuple<ICommand, String, String[]> data = getCommand(args, this.getLabel());
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
} else { if (data == null) {
player.sendMessage( player.sendMessage(
String.format("%s%sKenshin's Hide and Seek %s(%s1.7.0 BETA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + String.format("%s%sKenshin's Hide and Seek %s(%s1.7.0 BETA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) + String.format("%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)
); );
return;
} }
} else {
String invoke = args[0].toLowerCase(); ICommand command = data.getLeft();
if (!invoke.equals("about") && !invoke.equals("help") && Save.runningBackup) { String permission = data.getCenter();
String[] parameters = data.getRight();
if (Save.runningBackup) {
player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS")); player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
} else { return;
try { }
Object object = commandRegister.get(invoke);
if(object instanceof CommandGroup) { if (permissionsRequired && !player.hasPermission(permission)) {
CommandGroup group = (CommandGroup) object;
return group.handleCommand(player, permission+"."+group.getLabel(), Arrays.copyOfRange(args, 1, args.length));
} else if(object instanceof Command) {
Command command = (Command) object;
if (permissionsRequired && !player.hasPermission(permission+"."+command.getLabel())) {
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
return true; return;
} }
int parameterCount = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count(); int parameterCount = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count();
if(args.length - 1 < parameterCount) { if(parameters.length < parameterCount) {
player.sendMessage(errorPrefix + message("ARGUMENT_COUNT")); player.sendMessage(errorPrefix + message("ARGUMENT_COUNT"));
return true; return;
} }
command.execute(player,Arrays.copyOfRange(args, 1, args.length)); try {
} command.execute(player, parameters);
} catch (Exception e) { } catch (Exception e) {
player.sendMessage(errorPrefix + "An error has occurred."); player.sendMessage(errorPrefix + "An error has occurred.");
e.printStackTrace(); e.printStackTrace();
} }
} }
@Nullable
private Tuple<ICommand, String, String[]> getCommand(String[] args, String permission) {
if(args.length < 1) {
return null;
} }
return true; String invoke = args[0];
if(commandRegister.containsKey(invoke)) {
Object o = commandRegister.get(invoke);
if (o instanceof CommandGroup) {
CommandGroup group = (CommandGroup) o;
return group.getCommand(
Arrays.copyOfRange(args, 1, args.length),
permission + "." + group.getLabel()
);
} else if(o instanceof ICommand) {
ICommand command = (ICommand) o;
return new Tuple<>(command, permission + "." + command.getLabel(), Arrays.copyOfRange(args, 1, args.length));
}
}
return null;
} }
public List<String> handleTabComplete(CommandSender sender, String[] args) { public List<String> handleTabComplete(Player player, String[] args) {
return handleTabComplete(player, this.getLabel(), args);
}
private List<String> handleTabComplete(Player player, String permission, String[] args) {
String invoke = args[0].toLowerCase(); String invoke = args[0].toLowerCase();
if (args.length == 1) { if (args.length == 1) {
if(sender instanceof Player) {
Player player = (Player) sender;
return new ArrayList<>(commandRegister.keySet()) return new ArrayList<>(commandRegister.keySet())
.stream() .stream()
.filter(handle -> handle.toLowerCase().startsWith(invoke)) .filter(handle -> handle.toLowerCase().startsWith(invoke))
.filter(handle -> { .filter(handle -> {
Object object = commandRegister.get(handle); Object object = commandRegister.get(handle);
if (object instanceof Command) { if (object instanceof ICommand) {
Command command = (Command) object; ICommand command = (ICommand) object;
return player.hasPermission(command.getLabel()); return !permissionsRequired || player.hasPermission(permission + "." + command.getLabel());
} else if (object instanceof CommandGroup) { } else if (object instanceof CommandGroup) {
CommandGroup group = (CommandGroup) object; CommandGroup group = (CommandGroup) object;
return group.hasPermission(player, group.getLabel()); return !permissionsRequired || group.hasPermission(player, permission + "." + group.getLabel());
} }
return false; return false;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} else {
return commandRegister.keySet()
.stream()
.filter(handle -> handle.toLowerCase().startsWith(invoke))
.collect(Collectors.toList());
}
} else { } else {
if (commandRegister.containsKey(invoke)) { if (commandRegister.containsKey(invoke)) {
Object object = commandRegister.get(invoke); Object object = commandRegister.get(invoke);
if (object instanceof CommandGroup) { if (object instanceof CommandGroup) {
CommandGroup group = (CommandGroup) object; CommandGroup group = (CommandGroup) object;
return group.handleTabComplete(sender, Arrays.copyOfRange(args, 1, args.length)); return group.handleTabComplete(player, permission + "." + group.getLabel(), Arrays.copyOfRange(args, 1, args.length));
} else if (object instanceof Command) { } else if (object instanceof ICommand) {
Command command = (Command) object; ICommand command = (ICommand) object;
String[] usage = command.getUsage().split(" "); String[] usage = command.getUsage().split(" ");
if (args.length - 2 < usage.length) { if (args.length - 2 < usage.length) {
String parameter = usage[args.length - 2]; String parameter = usage[args.length - 2];
@ -159,26 +174,26 @@ public class CommandGroup {
private boolean hasPermission(Player player, String permission) { private boolean hasPermission(Player player, String permission) {
for(Object object : commandRegister.values()) { for(Object object : commandRegister.values()) {
if(object instanceof Command) { if(object instanceof ICommand) {
Command command = (Command) object; ICommand command = (ICommand) object;
if(player.hasPermission(permission+"."+command.getLabel())) return true; if(player.hasPermission(permission + command.getLabel())) return true;
} else if(object instanceof CommandGroup) { } else if(object instanceof CommandGroup) {
CommandGroup group = (CommandGroup) object; CommandGroup group = (CommandGroup) object;
if (group.hasPermission(player, permission+"."+group.getLabel())) return true; if (group.hasPermission(player, permission + this.label + ".")) return true;
} }
} }
return false; return false;
} }
public List<Pair<String, Command>> getCommands() { public List<Pair<String, ICommand>> getCommands() {
return getCommands(this.getLabel()); return getCommands(this.getLabel());
} }
private List<Pair<String, Command>> getCommands(String prefix) { private List<Pair<String, ICommand>> getCommands(String prefix) {
List<Pair<String, Command>> commands = new LinkedList<>(); List<Pair<String, ICommand>> commands = new LinkedList<>();
for(Object object : commandRegister.values()) { for(Object object : commandRegister.values()) {
if(object instanceof Command) { if(object instanceof ICommand) {
Command command = (Command) object; ICommand command = (ICommand) object;
commands.add(new Pair<>(prefix+" "+command.getLabel(), command)); commands.add(new Pair<>(prefix+" "+command.getLabel(), command));
} else if(object instanceof CommandGroup) { } else if(object instanceof CommandGroup) {
CommandGroup group = (CommandGroup) object; CommandGroup group = (CommandGroup) object;

View file

@ -24,16 +24,16 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public abstract class Command { public interface ICommand {
public abstract void execute(Player sender, String[] args); void execute(Player sender, String[] args);
public abstract String getLabel(); String getLabel();
public abstract String getUsage(); String getUsage();
public abstract String getDescription(); String getDescription();
public abstract List<String> autoComplete(@NotNull String parameter, @NotNull String typed); List<String> autoComplete(@NotNull String parameter, @NotNull String typed);
} }

View file

@ -24,9 +24,8 @@ import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound; import com.cryptomorin.xseries.XSound;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay; import net.tylermurphy.hideAndSeek.game.util.CountdownDisplay;
import org.bukkit.Bukkit; import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -34,7 +33,6 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -59,8 +57,7 @@ public class Config {
databasePort, databasePort,
databaseUser, databaseUser,
databasePass, databasePass,
databaseName, databaseName;
exitWorld;
public static boolean public static boolean
nameTagsVisible, nameTagsVisible,
@ -150,12 +147,11 @@ public class Config {
// Locations // Locations
exitPosition = new Location( exitPosition = new Location(
Bukkit.getWorld(config.getString("exit.world")), config.getString("exit.world"),
config.getInt("exit.x"), config.getInt("exit.x"),
config.getInt("exit.y"), config.getInt("exit.y"),
config.getInt("exit.z") config.getInt("exit.z")
); );
exitWorld = config.getString("exit.world");
mapSaveEnabled = config.getBoolean("mapSaveEnabled"); mapSaveEnabled = config.getBoolean("mapSaveEnabled");
//Taunt //Taunt

View file

@ -1,12 +1,11 @@
package net.tylermurphy.hideAndSeek.configuration; package net.tylermurphy.hideAndSeek.configuration;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.events.Border; import net.tylermurphy.hideAndSeek.game.events.Border;
import net.tylermurphy.hideAndSeek.world.WorldLoader; import net.tylermurphy.hideAndSeek.world.WorldLoader;
import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -18,14 +17,9 @@ public class Map {
private final String name; private final String name;
private Location private Location
spawnPosition = new Location(null, 0, 0, 0), spawnPosition = Location.getDefault(),
lobbyPosition = new Location(null, 0, 0, 0), lobbyPosition = Location.getDefault(),
seekerLobbyPosition = new Location(null, 0, 0, 0); seekerLobbyPosition = Location.getDefault();
private String
spawnWorldName = "world",
lobbyWorldName = "world",
seekerLobbyWorldName = "world";
private int private int
xBoundMin = 0, xBoundMin = 0,
@ -58,32 +52,14 @@ public class Map {
public void setSpawn(Location pos) { public void setSpawn(Location pos) {
this.spawnPosition = pos; this.spawnPosition = pos;
if(pos.getWorld() != null)
this.spawnWorldName = pos.getWorld().getName();
} }
public void setLobby(Location pos) { public void setLobby(Location pos) {
this.lobbyPosition = pos; this.lobbyPosition = pos;
if(pos.getWorld() != null)
this.lobbyWorldName = pos.getWorld().getName();
} }
public void setSeekerLobby(Location pos) { public void setSeekerLobby(Location pos) {
this.seekerLobbyPosition = pos; this.seekerLobbyPosition = pos;
if(pos.getWorld() != null)
this.seekerLobbyWorldName = pos.getWorld().getName();
}
public void setSpawnName(String name) {
this.spawnWorldName = name;
}
public void setLobbyName(String name) {
this.lobbyWorldName = name;
}
public void setSeekerLobbyName(String name) {
this.seekerLobbyWorldName = name;
} }
public void setWorldBorderData(int x, int z, int size, int delay, int move) { public void setWorldBorderData(int x, int z, int size, int delay, int move) {
@ -121,12 +97,7 @@ public class Map {
@NotNull @NotNull
public Location getGameSpawn() { public Location getGameSpawn() {
if(mapSaveEnabled) { if(mapSaveEnabled) {
return new Location( return spawnPosition.changeWorld("hs_"+name);
Bukkit.getWorld("hs_" + spawnWorldName),
spawnPosition.getX(),
spawnPosition.getY(),
spawnPosition.getZ()
);
} else { } else {
return spawnPosition; return spawnPosition;
} }
@ -135,9 +106,9 @@ public class Map {
@NotNull @NotNull
public String getGameSpawnName() { public String getGameSpawnName() {
if(mapSaveEnabled) if(mapSaveEnabled)
return "hs_"+ spawnWorldName; return getGameSpawn().getWorld();
else else
return spawnWorldName; return getSpawn().getWorld();
} }
@NotNull @NotNull
@ -147,7 +118,7 @@ public class Map {
@NotNull @NotNull
public String getSpawnName() { public String getSpawnName() {
return spawnWorldName; return getSpawn().getWorld();
} }
@NotNull @NotNull
@ -157,7 +128,7 @@ public class Map {
@NotNull @NotNull
public String getLobbyName() { public String getLobbyName() {
return lobbyWorldName; return getLobby().getWorld();
} }
@NotNull @NotNull
@ -167,18 +138,13 @@ public class Map {
@NotNull @NotNull
public String getSeekerLobbyName() { public String getSeekerLobbyName() {
return seekerLobbyWorldName; return getSeekerLobby().getWorld();
} }
@NotNull @NotNull
public Location getGameSeekerLobby() { public Location getGameSeekerLobby() {
if(mapSaveEnabled) { if(mapSaveEnabled) {
return new Location( return seekerLobbyPosition.changeWorld("hs_"+name);
Bukkit.getWorld("hs_" + getSeekerLobbyName()),
seekerLobbyPosition.getX(),
seekerLobbyPosition.getY(),
seekerLobbyPosition.getZ()
);
} else { } else {
return seekerLobbyPosition; return seekerLobbyPosition;
} }
@ -249,11 +215,11 @@ public class Map {
} }
public boolean isNotSetup() { public boolean isNotSetup() {
if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || Map.worldDoesntExist(spawnWorldName)) return true; if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0 || !spawnPosition.exists()) return true;
if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || Map.worldDoesntExist(lobbyWorldName)) return true; if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0 || !lobbyPosition.exists()) return true;
if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || Map.worldDoesntExist(exitWorld)) return true; if (exitPosition == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) return true;
if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || Map.worldDoesntExist(seekerLobbyWorldName)) return true; if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0 || !seekerLobbyPosition.exists()) return true;
if (mapSaveEnabled && Map.worldDoesntExist(getGameSpawnName())) return true; if (mapSaveEnabled && !getGameSpawn().exists()) return true;
if (blockhunt && blockhuntBlocks.isEmpty()) return true; if (blockhunt && blockhuntBlocks.isEmpty()) return true;
if(isWorldBorderEnabled() && if(isWorldBorderEnabled() &&
new Vector(spawnPosition.getX(), 0, spawnPosition.getZ()).distance(new Vector(xWorldBorder, 0, zWorldBorder)) > 100) return true; new Vector(spawnPosition.getX(), 0, spawnPosition.getZ()).distance(new Vector(xWorldBorder, 0, zWorldBorder)) > 100) return true;
@ -268,9 +234,4 @@ public class Map {
return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0; return xBoundMin == 0 || zBoundMin == 0 || xBoundMax == 0 || zBoundMax == 0;
} }
public static boolean worldDoesntExist(String worldName) {
File destination = new File(Main.getInstance().getWorldContainer()+File.separator+worldName);
return !destination.isDirectory();
}
} }

View file

@ -3,10 +3,8 @@ package net.tylermurphy.hideAndSeek.configuration;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Bukkit; import net.tylermurphy.hideAndSeek.util.Location;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -74,12 +72,9 @@ public class Maps {
ConfigurationSection data = maps.getConfigurationSection(name); ConfigurationSection data = maps.getConfigurationSection(name);
if(data == null) return null; if(data == null) return null;
Map map = new Map(name); Map map = new Map(name);
map.setSpawn(setSpawn(data, "game")); map.setSpawn(getSpawn(data, "game"));
map.setSpawnName(data.getString("spawns.game.world")); map.setLobby(getSpawn(data, "lobby"));
map.setLobby(setSpawn(data, "lobby")); map.setSeekerLobby(getSpawn(data, "seeker"));
map.setLobbyName(data.getString("spawns.lobby.world"));
map.setSeekerLobby(setSpawn(data, "seeker"));
map.setSeekerLobbyName(data.getString("spawns.seeker.world"));
map.setBoundMin(data.getInt("bounds.min.x"), data.getInt("bounds.min.z")); map.setBoundMin(data.getInt("bounds.min.x"), data.getInt("bounds.min.z"));
map.setBoundMax(data.getInt("bounds.max.x"), data.getInt("bounds.max.z")); map.setBoundMax(data.getInt("bounds.max.x"), data.getInt("bounds.max.z"));
map.setWorldBorderData( map.setWorldBorderData(
@ -104,11 +99,8 @@ public class Maps {
return map; return map;
} }
private static Location setSpawn(ConfigurationSection data, String spawn) { private static Location getSpawn(ConfigurationSection data, String spawn) {
String worldName = data.getString("spawns."+spawn+".world"); String world = data.getString("spawns."+spawn+".world");
if(worldName == null) return new Location(null, 0, 0, 0);
if(Map.worldDoesntExist(worldName)) return new Location(null, 0, 0, 0);
World world = Bukkit.getWorld(worldName);
double x = data.getDouble("spawns."+spawn+".x"); double x = data.getDouble("spawns."+spawn+".x");
double y = data.getDouble("spawns."+spawn+".y"); double y = data.getDouble("spawns."+spawn+".y");
double z = data.getDouble("spawns."+spawn+".z"); double z = data.getDouble("spawns."+spawn+".z");
@ -146,11 +138,7 @@ public class Maps {
private static void saveSpawn(ConfigurationSection data, Location spawn, String name, Map map) { private static void saveSpawn(ConfigurationSection data, Location spawn, String name, Map map) {
String worldName = getWorldName(name, map); String worldName = getWorldName(name, map);
if(worldName == null || Map.worldDoesntExist(worldName)) {
data.set("spawns." + name + ".world", "world");
} else {
data.set("spawns." + name + ".world", worldName); data.set("spawns." + name + ".world", worldName);
}
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());

View file

@ -98,8 +98,8 @@ public class Game {
public void start() { public void start() {
try { try {
Optional<Player> rand = board.getPlayers().stream().skip(new Random().nextInt(board.size())).findFirst(); int rand = (int) (Math.random() * board.getPlayers().size());
Player seeker = rand.orElse(board.getPlayers().get(0)); Player seeker = board.getPlayers().get(rand);
start(seeker); start(seeker);
} catch (Exception e){ } catch (Exception e){
Main.getInstance().getLogger().warning("Failed to select random seeker."); Main.getInstance().getLogger().warning("Failed to select random seeker.");
@ -148,7 +148,7 @@ public class Game {
board.remove(player); board.remove(player);
handleBungeeLeave(player); handleBungeeLeave(player);
} else { } else {
player.teleport(currentMap.getLobby()); currentMap.getLobby().teleport(player);
board.createLobbyBoard(player); board.createLobbyBoard(player);
board.addHider(player); board.addHider(player);
PlayerLoader.joinPlayer(player, currentMap); PlayerLoader.joinPlayer(player, currentMap);
@ -210,7 +210,7 @@ public class Game {
out.writeUTF(leaveServer); out.writeUTF(leaveServer);
player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray()); player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray());
} else { } else {
player.teleport(exitPosition); exitPosition.teleport(player);
} }
} }
@ -251,7 +251,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.getGameSpawn()); currentMap.getGameSpawn().teleport(player);
} }
}); });
} else if (startingTimer == 1){ } else if (startingTimer == 1){
@ -325,8 +325,8 @@ public class Game {
} }
} }
public Map getCurrentMap() { public boolean isCurrentMapValid() {
return currentMap; return currentMap != null && !currentMap.isNotSetup();
} }
public boolean checkCurrentMap() { public boolean checkCurrentMap() {
@ -339,9 +339,8 @@ public class Game {
this.currentMap = map; this.currentMap = map;
} }
public String getGameWorld() { public Map getCurrentMap() {
if(currentMap == null) return null; return currentMap;
else return currentMap.getGameSpawnName();
} }
private void checkWinConditions() { private void checkWinConditions() {

View file

@ -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.getGameSpawn()); map.getGameSpawn().teleport(player);
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.getGameSeekerLobby()); map.getGameSeekerLobby().teleport(player);
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.getGameSpawn()); map.getGameSpawn().teleport(player);
loadPlayer(player); loadPlayer(player);
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
@ -114,7 +114,7 @@ public class PlayerLoader {
} }
public static void joinPlayer(Player player, Map map){ public static void joinPlayer(Player player, Map map){
player.teleport(map.getLobby()); map.getLobby().teleport(player);
loadPlayer(player); loadPlayer(player);
if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start"))) if (lobbyStartItem != null && (!lobbyItemStartAdmin || player.hasPermission("hideandseek.start")))
player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem); player.getInventory().setItem(lobbyItemStartPosition, lobbyStartItem);

View file

@ -34,6 +34,7 @@ public class Border {
private void decreaseWorldBorder() { private void decreaseWorldBorder() {
if (currentSize == 100) return; if (currentSize == 100) return;
if(map.getGameSpawn().load() == null) return;
int change = (int) map.getWorldBorderData().getZ(); int change = (int) map.getWorldBorderData().getZ();
if (currentSize-change < 100) { if (currentSize-change < 100) {
change = currentSize-100; change = currentSize-100;
@ -41,14 +42,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.getGameSpawn().getWorld().getWorldBorder(); org.bukkit.WorldBorder border = map.getGameSpawn().load().getWorldBorder();
border.setSize(border.getSize()-change,30); border.setSize(border.getSize()-change,30);
delay = 30; delay = 30;
} }
public void resetWorldBorder() { public void resetWorldBorder() {
if(map.getGameSpawn().getWorld() == null) return; if(map.getGameSpawn().load() == null) return;
org.bukkit.WorldBorder border = map.getGameSpawn().getWorld().getWorldBorder(); org.bukkit.WorldBorder border = map.getGameSpawn().load().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());

View file

@ -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() == null || game.getCurrentMap().isNotSetup()) { return; } if (!game.isCurrentMapValid()) { 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)
@ -70,9 +70,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().getGameSpawn()); game.getCurrentMap().getGameSpawn().teleport(player);
} else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) { } else if (!Main.getInstance().supports(18) && player.getLocation().getY() < 0) {
player.teleport(game.getCurrentMap().getGameSpawn()); game.getCurrentMap().getGameSpawn().teleport(player);
} }
return; return;
} }
@ -95,15 +95,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().getGameSeekerLobby()); game.getCurrentMap().getGameSeekerLobby().teleport(player);
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().getGameSpawn()); game.getCurrentMap().getGameSpawn().teleport(player);
} }
}, delayedRespawnDelay * 20L); }, delayedRespawnDelay * 20L);
} else { } else {
player.teleport(game.getCurrentMap().getGameSpawn()); game.getCurrentMap().getGameSpawn().teleport(player);
} }
// Add leaderboard stats // Add leaderboard stats
board.addDeath(player.getUniqueId()); board.addDeath(player.getUniqueId());

View file

@ -15,6 +15,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class JoinLeaveHandler implements Listener { public class JoinLeaveHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -26,18 +28,25 @@ public class JoinLeaveHandler implements Listener {
removeItems(event.getPlayer()); removeItems(event.getPlayer());
if (Main.getInstance().getGame().checkCurrentMap()) return; if (Main.getInstance().getGame().checkCurrentMap()) return;
if (autoJoin) { if (autoJoin) {
if (Main.getInstance().getGame().checkCurrentMap()) {
event.getPlayer().sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
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()) || event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getLobby().getWorld().getName())) { if (
event.getPlayer().teleport(exitPosition); event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getLobbyName()) ||
event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getGameSpawnName())
) {
exitPosition.teleport(event.getPlayer());
event.getPlayer().setGameMode(GameMode.ADVENTURE); event.getPlayer().setGameMode(GameMode.ADVENTURE);
} }
} else { } else {
if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) { if (mapSaveEnabled && event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getGameSpawnName())) {
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 {
event.getPlayer().teleport(exitPosition); exitPosition.teleport(event.getPlayer());
event.getPlayer().setGameMode(GameMode.ADVENTURE); event.getPlayer().setGameMode(GameMode.ADVENTURE);
} }
} }

View file

@ -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())) return; if (!event.getPlayer().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getGameSpawnName())) return;
if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getGameWorld())) return; if (!event.getTo().getWorld().getName().equals(Main.getInstance().getGame().getCurrentMap().getGameSpawnName())) 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()) {

View file

@ -0,0 +1,111 @@
package net.tylermurphy.hideAndSeek.util;
import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.File;
public class Location {
private final String world;
private final double x;
private final double y;
private final double z;
public static Location getDefault() {
return new Location(
"",
0.0,
0.0,
0.0
);
}
public static Location from(Player player) {
org.bukkit.Location location = player.getLocation();
return new Location(
player.getWorld().getName(),
location.getX(),
location.getY(),
location.getZ()
);
}
public Location(@NotNull String world, double x, double y, double z) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
}
public World load() {
World bukkitWorld = Bukkit.getWorld(world);
if(bukkitWorld != null) return bukkitWorld;
Bukkit.getServer().createWorld(new WorldCreator(world));
return Bukkit.getWorld(world);
}
private org.bukkit.Location toBukkit() {
return new org.bukkit.Location(
Bukkit.getWorld(world),
x,
y,
z
);
}
public void teleport(Player player) {
if(!exists()) return;
if(load() == null) return;
player.teleport(toBukkit());
}
public Location changeWorld(String world) {
return new Location(
world,
x,
y,
z
);
}
public String getWorld() {
return world;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public int getBlockX() {
return (int)x;
}
public int getBlockY() {
return (int)y;
}
public int getBlockZ() {
return (int)z;
}
public boolean exists() {
if(world.equals("")) return false;
String path = Main.getInstance().getWorldContainer()+File.separator+world;
File destination = new File(path);
return destination.isDirectory();
}
}

View file

@ -0,0 +1,27 @@
package net.tylermurphy.hideAndSeek.util;
public class Tuple<L, C, R> {
private final L left;
private final C center;
private final R right;
public Tuple(L left, C center, R right) {
this.left = left;
this.center = center;
this.right = right;
}
public L getLeft() {
return left;
}
public C getCenter() {
return center;
}
public R getRight() {
return right;
}
}

View file

@ -49,7 +49,7 @@ public class WorldLoader {
Main.getInstance().getLogger().warning(map.getGameSpawnName() + " already unloaded."); Main.getInstance().getLogger().warning(map.getGameSpawnName() + " already unloaded.");
return; return;
} }
world.getPlayers().forEach(player -> player.teleport(exitPosition)); world.getPlayers().forEach(player -> exitPosition.teleport(player));
if (Bukkit.getServer().unloadWorld(world, false)) { if (Bukkit.getServer().unloadWorld(world, false)) {
Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName()); Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName());
}else{ }else{

View file

@ -26,6 +26,7 @@ Localization:
GAME_JOIN: "{PLAYER} has joined the HideAndSeek lobby." GAME_JOIN: "{PLAYER} has joined the HideAndSeek lobby."
GAME_JOIN_SPECTATOR: "You have joined mid game and are now a spectator." GAME_JOIN_SPECTATOR: "You have joined mid game and are now a spectator."
GAME_LEAVE: "{PLAYER} has left the HideAndSeek lobby." GAME_LEAVE: "{PLAYER} has left the HideAndSeek lobby."
LOBBY_IN_USE: "Cant modify the lobby while the lobby isn't empty."
CONFIG_RELOAD: "Reloaded the config." CONFIG_RELOAD: "Reloaded the config."
MAPSAVE_INPROGRESS: "Map save is currently in progress. Try again later." MAPSAVE_INPROGRESS: "Map save is currently in progress. Try again later."
MAPSAVE_START: "Starting map save." MAPSAVE_START: "Starting map save."

View file

@ -12,98 +12,54 @@ commands:
usage: /hideandseek [command] usage: /hideandseek [command]
aliases: hs aliases: hs
permissions: permissions:
hideandseek.*: hs.help:
description: Gives access to all hideandseek commands
children:
hideandseek.about: true
hideandseek.help: true
hideandseek.reload: true
hideandseek.setborder: true
hideandseek.setspawn: true
hideandseek.setlobby: true
hideandseek.setseekerlobby: true
hideandseek.setexit: true
hideadnseek.setbounds: true
hideandseek.setup: true
hideandseek.start: true
hideandseek.stop: true
hideandseek.savemap: true
hideandseek.join: true
hideandseek.leave: true
hideandseek.leavebounds: true
hideandseek.wins: true
hideandseek.top: true
hideandseek.debug: true
hideandseek.addmap: true
hideandseek.removemap: true
hideandseek.listmaps: true
hideandseek.setmap: true
hideandseek.about:
description: Allows you to run the about command
default: true default: true
hideandseek.help: hs.join:
description: Allows you to run the help command
default: true default: true
hideandseek.reload: hs.leave:
description: Allows you to reload the config
default: op
hideandseek.setborder:
description: Allows you to set the game world border
default: op
hideandseek.setspawn:
description: Allows you to set the game spawn point
default: op
hideandseek.setlobby:
description: Allows you to set the game lobby point
default: op
hideandseek.setseekerlobby:
description: Allows you to set the game seeker lobby point
default: op
hideandseek.setexit:
description: Allows you to set the game exit point
default: op
hideandseek.setbounds:
description: Allows you to set bounds for the game map
default: op
hideandseek.setup:
description: Allows you to see what needs to be setup for the plugin to function
default: op
hideandseek.start:
description: Allows you to start the game
default: op
hideandseek.stop:
description: Allows you to stop the game
default: op
hideandseek.savemap:
description: Allows you to set the current game map
default: op
hideandseek.join:
description: Allows you to join the game manual lobby
default: true default: true
hideandseek.leave: hs.top:
description: Allows you to leave the game manual lobby
default: true default: true
hideandseek.leavebounds: hs.wins:
description: Allows players to leave specified game bounderies
default: op
hideandseek.wins:
description: Allows players to see a players amount of wins
default: true default: true
hideandseek.top: hs.reload:
description: Allows players to see the global wins leaderboard
default: true
hideandseek.debug:
description: Opens the debug menu
default: op default: op
hideandseek.addmap: hs.send:
description: Adds a map to the plugin
default: op default: op
hideandseek.removemap: hs.setexit:
description: Removes a map from the plugin
default: op default: op
hideandseek.listmaps: hs.start:
description: Lists all maps in the plugin
default: op default: op
hideandseek.setmap: hs.stop:
description: Sets the current lobby to a new map
default: op default: op
hs.map.add:
default: op
hs.map.remove:
default: op
hs.map.list:
default: op
hs.map.status:
default: op
hs.map.save:
default: op
hs.map.debug:
default: op
hs.map.goto:
default: op
hs.map.set.lobby:
default: op
hs.map.set.spawn:
default: op
hs.map.set.seekerlobby:
default: op
hs.map.set.border:
default: op
hs.map.set.bounds:
default: op
hs.map.blockhunt.add:
default: op
hs.map.blockhunt.remove:
default: op
hs.map.blockhunt.list:
default: op