diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index bf64440..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,33 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: bug report
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**System Info (please complete the following information):**
- - OS: [e.g. Windows/Linux]
- - Server Host [e.g. Apex/Custom]
- - MC Version [e.g. 1.17/1.18]
- - Plugin Version [e.g. 1.3.0/1.3.1 BETA]
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 4aea407..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: new plugin feature
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
deleted file mode 100644
index 977e3be..0000000
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ /dev/null
@@ -1,11 +0,0 @@
-**Describe the change**
-A clear and concise description of what the changes are.
-
-**Expected behavior**
-A clear and concise description of what your changes are going to do.
-
-**Screenshots**
-If applicable, add screenshots to help explain your changes.
-
-**Additional context**
-Add any other context about the pull request here.
diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml
deleted file mode 100644
index 7adde3f..0000000
--- a/.github/workflows/beta.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-name: Beta
-
-on:
- push:
- branches-ignore: [ main ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout branch
- uses: actions/checkout@v2
-
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
-
- - name: Build with Maven
- run: |
- mvn -B package --file pom.xml
- mkdir staging && cp target/*.jar staging
-
- - name: Set up a cache for maven
- uses: actions/cache@v2
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
-
- - name: Upload artifacts
- uses: actions/upload-artifact@v2
- with:
- name: artifacts-beta
- path: staging
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 722d1c6..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-name: Release
-
-on:
- push:
- branches: [ main ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout branch
- uses: actions/checkout@v2
-
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
-
- - name: Build with Maven
- run: |
- mvn -B package --file pom.xml
- mkdir staging && cp target/*.jar staging
-
- - name: Set up a cache for maven
- uses: actions/cache@v2
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
-
- - name: Upload artificats
- uses: actions/upload-artifact@v2
- with:
- name: artifacts-release
- path: staging
diff --git a/lib/ProtocolLib.jar b/lib/ProtocolLib.jar
new file mode 100644
index 0000000..47b952f
Binary files /dev/null and b/lib/ProtocolLib.jar differ
diff --git a/pom.xml b/pom.xml
index dfd99ff..df2ab1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,13 +1,16 @@
4.0.0
net.tylermurphy
KenshinsHideAndSeek
- 1.6.2
+ 1.7.0
Hide and Seek Plugin
+
+ UTF-8
+
+
clean install
src/main/java
-
org.apache.maven.plugins
@@ -30,10 +33,6 @@
com.zaxxer.hikari
net.tylermurphy.dependencies.hikari
-
- org.ibex.nestedvm
- net.tylermurphy.dependencies.nestedvm
-
@@ -58,7 +57,6 @@
META-INF/services/java.sql.Driver
- true
@@ -82,10 +80,10 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/public/
-
- dmulloy2-repo
- https://repo.dmulloy2.net/repository/public/
-
+
+
+
+
placeholderapi
https://repo.extendedclip.com/content/repositories/placeholderapi/
@@ -108,12 +106,14 @@
com.comphenix.protocol
ProtocolLib
- 4.7.0
+ 4.8.0
+ system
+ ${project.basedir}/lib/ProtocolLib.jar
org.xerial
sqlite-jdbc
- 3.7.2
+ 3.39.3.0
org.jetbrains
@@ -123,7 +123,7 @@
com.github.cryptomorin
XSeries
- 9.0.0
+ 9.1.0
me.clip
@@ -134,12 +134,12 @@
com.zaxxer
HikariCP
- 4.0.3
+ 5.0.1
org.mariadb.jdbc
mariadb-java-client
- 2.7.2
+ 3.0.6
\ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
index 4d8581f..36d92ee 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java
@@ -1,49 +1,34 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
package net.tylermurphy.hideAndSeek;
-import net.tylermurphy.hideAndSeek.configuration.Config;
-import net.tylermurphy.hideAndSeek.configuration.Items;
-import net.tylermurphy.hideAndSeek.configuration.Localization;
+import net.tylermurphy.hideAndSeek.command.*;
+import net.tylermurphy.hideAndSeek.command.map.*;
+import net.tylermurphy.hideAndSeek.command.map.blockhunt.Enabled;
+import net.tylermurphy.hideAndSeek.command.map.set.*;
+import net.tylermurphy.hideAndSeek.command.world.Create;
+import net.tylermurphy.hideAndSeek.command.world.Delete;
+import net.tylermurphy.hideAndSeek.command.world.Tp;
+import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.game.*;
-import net.tylermurphy.hideAndSeek.game.util.Status;
-import net.tylermurphy.hideAndSeek.util.CommandHandler;
+import net.tylermurphy.hideAndSeek.command.util.CommandGroup;
import net.tylermurphy.hideAndSeek.game.listener.*;
import net.tylermurphy.hideAndSeek.util.PAPIExpansion;
-import net.tylermurphy.hideAndSeek.util.TabCompleter;
import org.bukkit.Bukkit;
-import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.File;
-import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
-import static net.tylermurphy.hideAndSeek.configuration.Config.exitWorld;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Main extends JavaPlugin implements Listener {
@@ -55,51 +40,136 @@ public class Main extends JavaPlugin implements Listener {
private Disguiser disguiser;
private EntityHider entityHider;
private Game game;
+ private CommandGroup commandGroup;
+ private boolean loaded;
public void onEnable() {
+
+ long start = System.currentTimeMillis();
+
+ getLogger().info("Loading Kenshin's Hide and Seek");
Main.instance = this;
- this.updateVersion();
- Config.loadConfig();
- Localization.loadLocalization();
- Items.loadItems();
+ getLogger().info("Getting minecraft version...");
+ this.updateVersion();;
+ try {
+ getLogger().info("Loading config.yml...");
+ Config.loadConfig();
+ getLogger().info("Loading maps.yml...");
+ Maps.loadMaps();
+ getLogger().info("Loading localization.yml...");
+ Localization.loadLocalization();
+ getLogger().info("Loading items.yml...");
+ Items.loadItems();
+ getLogger().info("Loading leaderboard.yml...");
+ Leaderboard.loadLeaderboard();
+ } catch (Exception e) {
+ getLogger().severe(e.getMessage());
+ Bukkit.getPluginManager().disablePlugin(this);
+ return;
+ }
+
+ getLogger().info("Creating internal scoreboard...");
this.board = new Board();
+ getLogger().info("Connecting to database...");
this.database = new Database();
+ getLogger().info("Loading disguises...");
this.disguiser = new Disguiser();
+ getLogger().info("Loading entity hider...");
this.entityHider = new EntityHider(this, EntityHider.Policy.BLACKLIST);
+ getLogger().info("Registering listeners...");
this.registerListeners();
- CommandHandler.registerCommands();
+ getLogger().info("Registering commands...");
+ this.commandGroup = new CommandGroup("hs",
+ new Help(),
+ new Reload(),
+ new Join(),
+ new Leave(),
+ new Send(),
+ new Start(),
+ new Stop(),
+ new CommandGroup("map",
+ new CommandGroup("blockhunt",
+ new CommandGroup("blocks",
+ new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Add(),
+ new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.Remove(),
+ new net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks.List()
+ ),
+ new Enabled()
+ ),
+ new CommandGroup("set",
+ new Lobby(),
+ new Spawn(),
+ new SeekerLobby(),
+ new Border(),
+ new Bounds()
+ ),
+ new Add(),
+ new Remove(),
+ new List(),
+ new Status(),
+ new Save(),
+ new Debug(),
+ new GoTo()
+ ),
+ new CommandGroup("world",
+ new Create(),
+ new Delete(),
+ new net.tylermurphy.hideAndSeek.command.world.List(),
+ new Tp()
+ ),
+ new SetExitLocation(),
+ new Top(),
+ new Wins(),
+ new Confirm()
+ );
- game = new Game(board);
+ getLogger().info("Loading game...");
+ game = new Game(null, board);
+ getLogger().info("Scheduling tick tasks...");
getServer().getScheduler().runTaskTimer(this, this::onTick,0,1).getTaskId();
+ getLogger().info("Registering outgoing bungeecord plugin channel...");
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+ getLogger().info("Checking for PlaceholderAPI...");
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
+ getLogger().info("PlaceholderAPI found...");
+ getLogger().info("Registering PlaceholderAPI expansion...");
new PAPIExpansion().register();
}
+
+ long end = System.currentTimeMillis();
+ getLogger().info("Finished loading plugin ("+(end-start)+"ms)");
+ loaded = true;
+
}
public void onDisable() {
version = 0;
- board.getPlayers().forEach(player -> {
- board.removeBoard(player);
- PlayerLoader.unloadPlayer(player);
- player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
- });
+ if(board != null) {
+ board.getPlayers().forEach(player -> {
+ board.removeBoard(player);
+ PlayerLoader.unloadPlayer(player);
+ exitPosition.teleport(player);
+ });
+ board.cleanup();
+ }
+
+ if(disguiser != null) {
+ disguiser.cleanUp();
+ }
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
- board.cleanup();
- disguiser.cleanUp();
}
private void onTick() {
- if(game.getStatus() == Status.ENDED) game = new Game(board);
+ if(game.getStatus() == net.tylermurphy.hideAndSeek.game.util.Status.ENDED) game = new Game(game.getCurrentMap(), board);
game.onTick();
disguiser.check();
}
@@ -115,6 +185,7 @@ public class Main extends JavaPlugin implements Listener {
getServer().getPluginManager().registerEvents(new MovementHandler(), this);
getServer().getPluginManager().registerEvents(new PlayerHandler(), this);
getServer().getPluginManager().registerEvents(new RespawnHandler(), this);
+ getServer().getPluginManager().registerEvents(new WorldInteractHandler(), this);
}
private void updateVersion(){
@@ -127,11 +198,20 @@ public class Main extends JavaPlugin implements Listener {
}
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
- return CommandHandler.handleCommand(sender, args);
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(errorPrefix + message("COMMAND_PLAYER_ONLY"));
+ return true;
+ }
+ commandGroup.handleCommand((Player)sender, args);
+ return true;
}
- public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
- return TabCompleter.handleTabComplete(sender, args);
+ public java.util.List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] 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() {
@@ -158,8 +238,34 @@ public class Main extends JavaPlugin implements Listener {
public EntityHider getEntityHider() { return entityHider; }
+ public CommandGroup getCommandGroup() { return commandGroup; }
+
public boolean supports(int v){
return version >= v;
}
+
+ public java.util.List getWorlds() {
+ java.util.List worlds = new ArrayList<>();
+ File[] containers = getWorldContainer().listFiles();
+ if(containers != null) {
+ Arrays.stream(containers).forEach(file -> {
+ if (!file.isDirectory()) return;
+ String[] files = file.list();
+ if (files == null) return;
+ if (!Arrays.asList(files).contains("session.lock") && !Arrays.asList(files).contains("level.dat")) return;
+ worlds.add(file.getName());
+ });
+ }
+ return worlds;
+ }
+
+ public boolean isLoaded() {
+ return loaded;
+ }
+
+ public void scheduleTask(Runnable task) {
+ if(!isEnabled()) return;
+ Bukkit.getServer().getScheduler().runTask(this, task);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
deleted file mode 100644
index 54af32b..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package net.tylermurphy.hideAndSeek.command;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-public class About implements ICommand {
-
- public void execute(Player sender, String[] args) {
- sender.sendMessage(
- String.format("%s%sHide and Seek %s(%s1.6.2%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
- String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
- String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
- );
- }
-
- public String getLabel() {
- return "about";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Get information about the plugin";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java
new file mode 100644
index 0000000..a25185d
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java
@@ -0,0 +1,62 @@
+package net.tylermurphy.hideAndSeek.command;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.*;
+import java.util.function.Consumer;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class Confirm implements ICommand {
+
+ public static final Map confirmations = new HashMap<>();
+
+ public void execute(Player sender, String[] args) {
+ Confirmation confirmation = confirmations.get(sender.getUniqueId());
+ confirmations.remove(sender.getUniqueId());
+ if(confirmation == null) {
+ sender.sendMessage(errorPrefix + message("NO_CONFIRMATION"));
+ } else {
+ long now = System.currentTimeMillis();
+ float secs = (now - confirmation.start) / 1000F;
+ if(secs > 10) {
+ sender.sendMessage(errorPrefix + message("CONFIRMATION_TIMED_OUT"));
+ return;
+ }
+ confirmation.callback.accept(confirmation.data);
+ }
+ }
+
+ public String getLabel() {
+ return "confirm";
+ }
+
+ public String getUsage() {
+ return "";
+ }
+
+ public String getDescription() {
+ return "Confirm another command if required";
+ }
+
+ public List autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
+ public static class Confirmation {
+ public final Consumer callback;
+ public final String data;
+ public final long start;
+
+ public Confirmation(String data, Consumer callback) {
+ this.callback = callback;
+ this.data = data;
+ this.start = System.currentTimeMillis();
+ }
+
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
deleted file mode 100644
index 61d0c46..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package net.tylermurphy.hideAndSeek.command;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.game.PlayerLoader;
-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.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> 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, 18, "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);
- PlayerLoader.loadHider(player, Main.getInstance().getGame().getGameWorld());
- if(Main.getInstance().getGame().getStatus() != Status.STARTING)
- PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
- }));
- debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- Main.getInstance().getBoard().addSeeker(player);
- PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getGameWorld());
- if(Main.getInstance().getGame().getStatus() != Status.STARTING)
- PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
- }));
- debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- Main.getInstance().getBoard().addSpectator(player);
- PlayerLoader.loadSpectator(player, Main.getInstance().getGame().getGameWorld());
- }));
- debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
- Main.getInstance().getBoard().remove(player);
- PlayerLoader.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()))));
- debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, PlayerLoader::openBlockHuntPicker));
- debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
- }
-
- private ItemStack createOption(int slow, Material material, String name, int amount, Consumer 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 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";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
index 97224d7..41db5a9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
@@ -1,36 +1,70 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
package net.tylermurphy.hideAndSeek.command;
-import net.md_5.bungee.api.ChatColor;
-import net.tylermurphy.hideAndSeek.util.CommandHandler;
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.util.Pair;
+import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Help implements ICommand {
public void execute(Player sender, String[] args) {
- StringBuilder message = new StringBuilder();
- 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"));
+ final int pageSize = 4;
+ List> commands = Main.getInstance().getCommandGroup().getCommands();
+ int pages = (commands.size() - 1) / pageSize + 1;
+ int page;
+ try {
+ if(args.length < 1) {
+ page = 1;
+ } else {
+ page = Integer.parseInt(args[0]);
+ if (page < 1) {
+ throw new IllegalArgumentException("Inavlid Input");
+ }
+ }
+ } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
+ return;
}
- message = new StringBuilder(message.substring(0, message.length() - 1));
+ String spacer = ChatColor.GRAY + "?" + ChatColor.WHITE;
+ StringBuilder message = new StringBuilder();
+ message.append(String.format("%s================ %sHelp: Page (%s/%s) %s================",
+ ChatColor.AQUA, ChatColor.WHITE, page, pages, ChatColor.AQUA));
+ int lines = 0;
+ for(Pair pair : commands.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList())) {
+ ICommand command = pair.getRight();
+ String label = pair.getLeft();
+ String start = label.substring(0, label.indexOf(" "));
+ String invoke = label.substring(label.indexOf(" ")+1);
+ message.append(String.format("\n%s %s/%s %s%s %s%s\n%s %s%s%s",
+ spacer,
+ ChatColor.AQUA,
+ start,
+ ChatColor.WHITE,
+ invoke,
+ ChatColor.BLUE,
+ command.getUsage(),
+ spacer,
+ ChatColor.GRAY,
+ ChatColor.ITALIC,
+ command.getDescription()
+ ));
+ lines += 2;
+ }
+ if(lines / 2 < pageSize) {
+ for(int i = 0; i < pageSize * 2 - lines; i++) {
+ message.append("\n").append(spacer);
+ }
+ }
+ message.append("\n").append(ChatColor.AQUA).append("===============================================");
sender.sendMessage(message.toString());
}
@@ -39,11 +73,15 @@ public class Help implements ICommand {
}
public String getUsage() {
- return "";
+ return "<*page>";
}
public String getDescription() {
return "Get the commands for the plugin";
}
+ public List autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return Collections.singletonList(parameter);
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java b/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java
deleted file mode 100644
index 275d189..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package net.tylermurphy.hideAndSeek.command;
-
-import org.bukkit.entity.Player;
-
-public interface ICommand {
-
- void execute(Player sender, String[] args);
-
- String getLabel();
-
- String getUsage();
-
- String getDescription();
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
index 941cec0..0c01265 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
@@ -1,27 +1,14 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@@ -29,7 +16,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@@ -42,7 +29,18 @@ public class Join implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INGAME"));
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);
}
@@ -51,11 +49,18 @@ public class Join implements ICommand {
}
public String getUsage() {
- return "";
+ return "<*map>";
}
public String getDescription() {
return "Joins the lobby if game is set to manual join/leave";
}
+ public List 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;
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
index 092ff50..109930b 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
@@ -1,27 +1,12 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
@@ -29,7 +14,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@@ -57,4 +42,8 @@ public class Leave implements ICommand {
return "Leaves the lobby if game is set to manual join/leave";
}
+ public List autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
index 56f4517..0c2b6b1 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
@@ -1,30 +1,13 @@
-/*
- * This file is part of Kenshins Hide and Seek
- *
- * Copyright (c) 2021 Tyler Murphy.
- *
- * Kenshins Hide and Seek free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * he Free Software Foundation version 3.
- *
- * Kenshins Hide and Seek is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.configuration.Config;
-import net.tylermurphy.hideAndSeek.configuration.Items;
-import net.tylermurphy.hideAndSeek.configuration.Localization;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
@@ -38,9 +21,18 @@ public class Reload implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- Config.loadConfig();
- Localization.loadLocalization();
- Items.loadItems();
+
+ try {
+ Config.loadConfig();
+ Maps.loadMaps();
+ Localization.loadLocalization();
+ Items.loadItems();
+ Leaderboard.loadLeaderboard();
+ } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("CONFIG_ERROR"));
+ return;
+ }
+
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
}
@@ -55,5 +47,9 @@ public class Reload implements ICommand {
public String getDescription() {
return "Reloads the config";
}
-
+
+ public List autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java
new file mode 100644
index 0000000..43620c5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java
@@ -0,0 +1,69 @@
+package net.tylermurphy.hideAndSeek.command;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class Send implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+
+ if(map.isNotSetup()){
+ sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP"));
+ return;
+ }
+
+ if (!Main.getInstance().getBoard().contains(sender)) {
+ sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
+ return;
+ }
+
+ Main.getInstance().getGame().setCurrentMap(map);
+ Main.getInstance().getBoard().reloadLobbyBoards();
+ for(Player player : Main.getInstance().getBoard().getPlayers()) {
+ map.getLobby().teleport(player);
+ }
+
+ }
+
+ public String getLabel() {
+ return "send";
+ }
+
+ public String getUsage() {
+ return "