Merge branch 'tylermurphy534:1.4.3' into 1.4.3

This commit is contained in:
bobby29831 2022-05-14 22:27:34 -05:00 committed by GitHub
commit d3e8151534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 186 additions and 64 deletions

View file

@ -20,11 +20,11 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
public class About implements ICommand { public class About implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
sender.sendMessage( sender.sendMessage(
String.format("%s%sHide and Seek %s(%s1.4.3%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) + String.format("%s%sHide and Seek %s(%s1.4.3%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) +

View file

@ -0,0 +1,111 @@
package net.tylermurphy.hideAndSeek.command;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.PlayerUtil;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
public class Debug implements ICommand {
private static final Map<Integer, Consumer<Player>> debugMenuFunctions = new HashMap<>();
private Inventory debugMenu;
public void execute(Player sender, String[] args) {
if(debugMenu == null) createMenu();
sender.openInventory(debugMenu);
}
private void createMenu(){
debugMenu = Main.getInstance().getServer().createInventory(null, 9, "Debug Menu");
debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
if(mapSaveEnabled) {
if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addHider(player);
PlayerUtil.loadHider(player, Main.getInstance().getGame().getGameWorld());
PlayerUtil.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
if(mapSaveEnabled) {
if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSeeker(player);
PlayerUtil.loadSeeker(player, Main.getInstance().getGame().getGameWorld());
PlayerUtil.resetPlayer(player, Main.getInstance().getBoard());
}));
debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
if(mapSaveEnabled) {
if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
}
Main.getInstance().getBoard().addSpectator(player);
PlayerUtil.loadSpectator(player, Main.getInstance().getGame().getGameWorld());
}));
debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
Main.getInstance().getBoard().remove(player);
PlayerUtil.unloadPlayer(player);
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
}));
debugMenu.setItem(4, createOption(4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
player.setHealth(0.1);
}
}));
debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
if(mapSaveEnabled) {
if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
}
player.teleport(new Location(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
}));
debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> {
player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(), lobbyPosition.getY(), lobbyPosition.getZ()));
}));
debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> {
player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
}));
}
private ItemStack createOption(int slow, Material material, String name, int amount, Consumer<Player> callback){
ItemStack temp = new ItemStack(material, amount);
ItemMeta meta = temp.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
temp.setItemMeta(meta);
debugMenuFunctions.put(slow, callback);
return temp;
}
public static void handleOption(Player player, int slotId){
Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
Consumer<Player> callback = debugMenuFunctions.get(slotId);
if(callback != null) callback.accept(player);
}, 0);
}
public String getLabel() {
return "debug";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Run debug commands";
}
}

View file

@ -21,11 +21,11 @@ package net.tylermurphy.hideAndSeek.command;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.util.CommandHandler; import net.tylermurphy.hideAndSeek.util.CommandHandler;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
public class Help implements ICommand { public class Help implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
for(ICommand command : CommandHandler.COMMAND_REGISTER.values()) { for(ICommand command : CommandHandler.COMMAND_REGISTER.values()) {
message.append(String.format("%s/hs %s%s %s%s\n %s%s%s", ChatColor.AQUA, ChatColor.WHITE, command.getLabel().toLowerCase(), ChatColor.BLUE, command.getUsage(), ChatColor.GRAY, ChatColor.ITALIC, command.getDescription() + "\n")); message.append(String.format("%s/hs %s%s %s%s\n %s%s%s", ChatColor.AQUA, ChatColor.WHITE, command.getLabel().toLowerCase(), ChatColor.BLUE, command.getUsage(), ChatColor.GRAY, ChatColor.ITALIC, command.getDescription() + "\n"));

View file

@ -19,11 +19,11 @@
package net.tylermurphy.hideAndSeek.command; package net.tylermurphy.hideAndSeek.command;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
public interface ICommand { public interface ICommand {
void execute(CommandSender sender, String[] args); void execute(Player sender, String[] args);
String getLabel(); String getLabel();

View file

@ -21,7 +21,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@ -29,7 +28,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand { public class Join implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().isNotSetup()) { if (Main.getInstance().getGame().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP")); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;

View file

@ -21,7 +21,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@ -29,7 +28,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand { public class Leave implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().isNotSetup()) { if (Main.getInstance().getGame().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP")); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;

View file

@ -24,7 +24,7 @@ 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.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
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;
@ -32,7 +32,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Reload implements ICommand { public class Reload implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));

View file

@ -23,7 +23,7 @@ import net.tylermurphy.hideAndSeek.Main;
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.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
@ -33,7 +33,7 @@ public class SaveMap implements ICommand {
public static boolean runningBackup = false; public static boolean runningBackup = false;
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (!mapSaveEnabled) { if (!mapSaveEnabled) {
sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED")); sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED"));
return; return;

View file

@ -21,7 +21,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -30,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetBorder implements ICommand { public class SetBorder implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;

View file

@ -21,7 +21,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
@ -29,7 +28,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetBounds implements ICommand { public class SetBounds implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;

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 org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Setup implements ICommand { public class Setup implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
String msg = message("SETUP").toString(); String msg = message("SETUP").toString();
int count = 0; int count = 0;

View file

@ -22,7 +22,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
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.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Optional; import java.util.Optional;
@ -34,7 +33,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Start implements ICommand { public class Start implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().isNotSetup()) { if (Main.getInstance().getGame().isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP")); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;

View file

@ -21,7 +21,7 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
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;
@ -29,7 +29,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Stop implements ICommand { public class Stop implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().isNotSetup()) { if (Main.getInstance().getGame().isNotSetup()) {
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;

View file

@ -22,7 +22,7 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.PlayerInfo; import net.tylermurphy.hideAndSeek.database.PlayerInfo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
@ -31,7 +31,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Top implements ICommand { public class Top implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
int page; int page;
if (args.length == 0) page = 1; if (args.length == 0) page = 1;
else try{ else try{

View file

@ -22,7 +22,6 @@ package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.database.PlayerInfo; import net.tylermurphy.hideAndSeek.database.PlayerInfo;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.UUID; import java.util.UUID;
@ -32,7 +31,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Wins implements ICommand { public class Wins implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
Main.getInstance().getServer().getScheduler().runTaskAsynchronously(Main.getInstance(), () -> { Main.getInstance().getServer().getScheduler().runTaskAsynchronously(Main.getInstance(), () -> {
UUID uuid; UUID uuid;

View file

@ -22,18 +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 org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (!(sender instanceof Player)) return; LocationUtils.setLocation(sender, Locations.EXIT, vector -> {
Player player = (Player) sender; exitWorld = sender.getLocation().getWorld().getName();
LocationUtils.setLocation(player, Locations.EXIT, vector -> {
exitWorld = player.getLocation().getWorld().getName();
exitPosition = vector; exitPosition = vector;
}); });
} }

View file

@ -22,19 +22,15 @@ 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 org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
public class SetLobbyLocation implements ICommand { public class SetLobbyLocation implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (!(sender instanceof Player)) return; LocationUtils.setLocation(sender, Locations.LOBBY, vector -> {
Player player = (Player) sender; lobbyWorld = sender.getLocation().getWorld().getName();
LocationUtils.setLocation(player, Locations.LOBBY, vector -> {
lobbyWorld = player.getLocation().getWorld().getName();
lobbyPosition = vector; lobbyPosition = vector;
}); });
} }

View file

@ -23,7 +23,6 @@ import net.tylermurphy.hideAndSeek.Main;
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 org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
@ -31,22 +30,19 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetSpawnLocation implements ICommand { public class SetSpawnLocation implements ICommand {
public void execute(CommandSender sender, String[] args) { public void execute(Player sender, String[] args) {
if (!(sender instanceof Player)) return; LocationUtils.setLocation(sender, Locations.GAME, vector -> {
Player player = (Player) sender;
LocationUtils.setLocation(player, Locations.GAME, vector -> {
if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) { if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION")); sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
throw new RuntimeException("World border not enabled or not in valid position!"); throw new RuntimeException("World border not enabled or not in valid position!");
} }
if (!player.getLocation().getWorld().getName().equals(spawnWorld)) { if (!sender.getLocation().getWorld().getName().equals(spawnWorld)) {
Main.getInstance().getGame().getWorldLoader().unloadMap(); Main.getInstance().getGame().getWorldLoader().unloadMap();
Main.getInstance().getGame().getWorldLoader().setNewMap(player.getLocation().getWorld().getName()); Main.getInstance().getGame().getWorldLoader().setNewMap(sender.getLocation().getWorld().getName());
} }
spawnWorld = player.getLocation().getWorld().getName(); spawnWorld = sender.getLocation().getWorld().getName();
spawnPosition = vector; spawnPosition = vector;
}); });
} }

View file

@ -1,7 +1,6 @@
package net.tylermurphy.hideAndSeek.command.location.util; package net.tylermurphy.hideAndSeek.command.location.util;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -14,6 +13,9 @@ import java.util.function.Consumer;
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;
/**
* @author bobby29831
*/
public class LocationUtils { public class LocationUtils {
/** /**

View file

@ -1,5 +1,8 @@
package net.tylermurphy.hideAndSeek.command.location.util; package net.tylermurphy.hideAndSeek.command.location.util;
/**
* @author bobby29831
*/
public enum Locations { public enum Locations {
GAME("spawns.game"), GAME("spawns.game"),

View file

@ -27,7 +27,6 @@ import net.tylermurphy.hideAndSeek.game.util.Status;
import net.tylermurphy.hideAndSeek.game.util.Version; import net.tylermurphy.hideAndSeek.game.util.Version;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
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.bukkit.scoreboard.*; import org.bukkit.scoreboard.*;
@ -48,10 +47,6 @@ public class Board {
return playerList.containsKey(player.getUniqueId().toString()); return playerList.containsKey(player.getUniqueId().toString());
} }
public boolean contains(CommandSender sender) {
return contains((Player) sender);
}
public boolean isHider(Player player) { public boolean isHider(Player player) {
return Hider.contains(player.getUniqueId().toString()); return Hider.contains(player.getUniqueId().toString());
} }
@ -203,7 +198,7 @@ public class Board {
private void createLobbyBoard(Player player, boolean recreate) { private void createLobbyBoard(Player player, boolean recreate) {
CustomBoard board = customBoards.get(player.getUniqueId().toString()); CustomBoard board = customBoards.get(player.getUniqueId().toString());
if (recreate) { if (recreate || board == null) {
board = new CustomBoard(player, LOBBY_TITLE); board = new CustomBoard(player, LOBBY_TITLE);
board.updateTeams(); board.updateTeams();
} }

View file

@ -3,8 +3,13 @@ package net.tylermurphy.hideAndSeek.game.listener;
import com.cryptomorin.xseries.XMaterial; import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.messages.ActionBar; import com.cryptomorin.xseries.messages.ActionBar;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.Debug;
import net.tylermurphy.hideAndSeek.game.util.PlayerUtil;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import net.tylermurphy.hideAndSeek.game.util.Version;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -110,7 +115,7 @@ public class InteractHandler implements Listener {
private ItemStack getSkull(Player player, List<String> lore){ private ItemStack getSkull(Player player, List<String> lore){
assert XMaterial.PLAYER_HEAD.parseMaterial() != null; assert XMaterial.PLAYER_HEAD.parseMaterial() != null;
ItemStack playerhead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1); ItemStack playerhead = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial(), 1, (byte) 3);
SkullMeta playerheadmeta = (SkullMeta) playerhead.getItemMeta(); SkullMeta playerheadmeta = (SkullMeta) playerhead.getItemMeta();
playerheadmeta.setOwner(player.getName()); playerheadmeta.setOwner(player.getName());
playerheadmeta.setDisplayName(player.getName()); playerheadmeta.setDisplayName(player.getName());
@ -123,9 +128,11 @@ public class InteractHandler implements Listener {
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if (event.getWhoClicked() instanceof Player) { if (event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
// Block players from moving lobby items
if (Main.getInstance().getBoard().contains(player) && Main.getInstance().getGame().getStatus() == Status.STANDBY) { if (Main.getInstance().getBoard().contains(player) && Main.getInstance().getGame().getStatus() == Status.STANDBY) {
event.setCancelled(true); event.setCancelled(true);
} }
// Spectator Teleport Menu
if (Main.getInstance().getBoard().isSpectator(player) && event.getCurrentItem().getType() == XMaterial.PLAYER_HEAD.parseMaterial()) { if (Main.getInstance().getBoard().isSpectator(player) && event.getCurrentItem().getType() == XMaterial.PLAYER_HEAD.parseMaterial()) {
event.setCancelled(true); event.setCancelled(true);
player.closeInventory(); player.closeInventory();
@ -134,6 +141,18 @@ public class InteractHandler implements Listener {
if(clicked == null) return; if(clicked == null) return;
player.teleport(clicked); player.teleport(clicked);
} }
// Debug Menu
boolean debug = false;
if(Version.atLeast("1.14")){
debug = event.getView().getTitle().equals("Debug Menu") && player.hasPermission("hideandseek.debug");
} else {
debug = event.getInventory().getName().equals("Debug Menu") && player.hasPermission("hideandseek.debug");
}
if (debug){
event.setCancelled(true);
player.closeInventory();
Debug.handleOption(player, event.getRawSlot());
}
} }
} }

View file

@ -22,7 +22,6 @@ public class MovementHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent event) { public void onMove(PlayerMoveEvent event) {
if (event.getTo() == null || event.getTo().getWorld() == null) return; if (event.getTo() == null || event.getTo().getWorld() == null) return;
checkJumping(event); checkJumping(event);
checkBounds(event); checkBounds(event);
} }

View file

@ -62,16 +62,20 @@ public class CommandHandler {
registerCommand(new Leave()); registerCommand(new Leave());
registerCommand(new Top()); registerCommand(new Top());
registerCommand(new Wins()); registerCommand(new Wins());
registerCommand(new Debug());
} }
public static boolean handleCommand(CommandSender sender, String[] args) { public static boolean handleCommand(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY")); sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY"));
} else if (args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) { return true;
}
Player player = (Player) sender;
if (args.length < 1 || !COMMAND_REGISTER.containsKey(args[0].toLowerCase()) ) {
if (permissionsRequired && !sender.hasPermission("hideandseek.about")) { if (permissionsRequired && !sender.hasPermission("hideandseek.about")) {
sender.sendMessage(errorPrefix + LOCAL.get("")); sender.sendMessage(errorPrefix + LOCAL.get(""));
} else { } else {
COMMAND_REGISTER.get("about").execute(sender, null); COMMAND_REGISTER.get("about").execute(player, null);
} }
} else { } else {
if (!args[0].equalsIgnoreCase("about") && !args[0].equalsIgnoreCase("help") && SaveMap.runningBackup) { if (!args[0].equalsIgnoreCase("about") && !args[0].equalsIgnoreCase("help") && SaveMap.runningBackup) {
@ -80,7 +84,7 @@ public class CommandHandler {
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(sender,Arrays.copyOfRange(args, 1, args.length)); COMMAND_REGISTER.get(args[0].toLowerCase()).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();

View file

@ -95,6 +95,9 @@ public class WorldLoader {
throw new RuntimeException("Failed to create directory: "+destenation.getPath()); throw new RuntimeException("Failed to create directory: "+destenation.getPath());
} }
} }
if(!destenation.delete()){
throw new RuntimeException("Unable to delete folder: "+destenation.getPath());
}
if (!temp_destenation.renameTo(destenation)) { if (!temp_destenation.renameTo(destenation)) {
throw new RuntimeException("Failed to rename directory: "+temp_destenation.getPath()); throw new RuntimeException("Failed to rename directory: "+temp_destenation.getPath());
} }

View file

@ -31,7 +31,8 @@ permissions:
hideandseek.leave: true hideandseek.leave: true
hideandseek.leavebounds: true hideandseek.leavebounds: true
hideandseek.wins: true hideandseek.wins: true
hideand.top: true hideandseek.top: true
hideandseek.debug: 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
@ -83,3 +84,6 @@ permissions:
hideandseek.top: hideandseek.top:
description: Allows players to see the global wins leaderboard description: Allows players to see the global wins leaderboard
default: true default: true
hideandseek.debug:
description: Opens the debug menu
default: op