1.7.0 beta 2

This commit is contained in:
tylermurphy534 2022-11-02 07:18:00 -04:00
parent 7530fe5e2d
commit bb254145ed
37 changed files with 440 additions and 301 deletions

View file

@ -20,15 +20,11 @@
package net.tylermurphy.hideAndSeek; package net.tylermurphy.hideAndSeek;
import net.tylermurphy.hideAndSeek.command.*; import net.tylermurphy.hideAndSeek.command.*;
import net.tylermurphy.hideAndSeek.command.location.*;
import net.tylermurphy.hideAndSeek.command.map.*; import net.tylermurphy.hideAndSeek.command.map.*;
import net.tylermurphy.hideAndSeek.configuration.Config; import net.tylermurphy.hideAndSeek.command.map.set.*;
import net.tylermurphy.hideAndSeek.configuration.Items; import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.database.Database; import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.game.*; import net.tylermurphy.hideAndSeek.game.*;
import net.tylermurphy.hideAndSeek.game.util.Status;
import net.tylermurphy.hideAndSeek.command.util.CommandGroup; import net.tylermurphy.hideAndSeek.command.util.CommandGroup;
import net.tylermurphy.hideAndSeek.game.listener.*; import net.tylermurphy.hideAndSeek.game.listener.*;
import net.tylermurphy.hideAndSeek.util.PAPIExpansion; import net.tylermurphy.hideAndSeek.util.PAPIExpansion;
@ -41,7 +37,6 @@ 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.List;
import java.util.Objects; import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -65,10 +60,17 @@ public class Main extends JavaPlugin implements Listener {
Main.instance = this; Main.instance = this;
this.updateVersion(); this.updateVersion();
try {
Config.loadConfig(); Config.loadConfig();
Maps.loadMaps(); Maps.loadMaps();
Localization.loadLocalization(); Localization.loadLocalization();
Items.loadItems(); Items.loadItems();
Leaderboard.loadLeaderboard();
} catch (Exception e) {
getLogger().severe(e.getMessage());
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.board = new Board(); this.board = new Board();
this.database = new Database(); this.database = new Database();
@ -77,28 +79,27 @@ public class Main extends JavaPlugin implements Listener {
this.registerListeners(); this.registerListeners();
this.commandGroup = new CommandGroup("hs", this.commandGroup = new CommandGroup("hs",
new About(),
new Debug(),
new Help(), new Help(),
new Reload(), new Reload(),
new Join(), new Join(),
new Leave(), new Leave(),
new Send(),
new Start(), new Start(),
new Stop(), new Stop(),
new CommandGroup("map", new CommandGroup("map",
new CommandGroup("set", new CommandGroup("set",
new SetLobbyLocation(), new Lobby(),
new SetSpawnLocation(), new Spawn(),
new SetSeekerLobbyLocation(), new SeekerLobby(),
new SetBorder(), new Border(),
new SetBounds() new Bounds()
), ),
new AddMap(), new Add(),
new RemoveMap(), new Remove(),
new ListMaps(), new List(),
new SetMap(), new Status(),
new Setup(), new Save(),
new SaveMap() new Debug()
), ),
new SetExitLocation(), new SetExitLocation(),
new Top(), new Top(),
@ -120,20 +121,25 @@ public class Main extends JavaPlugin implements Listener {
version = 0; version = 0;
if(board != null) {
board.getPlayers().forEach(player -> { board.getPlayers().forEach(player -> {
board.removeBoard(player); board.removeBoard(player);
PlayerLoader.unloadPlayer(player); PlayerLoader.unloadPlayer(player);
if(!Objects.equals(exitWorld, "")) if (!Objects.equals(exitWorld, ""))
player.teleport(exitPosition); player.teleport(exitPosition);
}); });
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
board.cleanup(); board.cleanup();
}
if(disguiser != null) {
disguiser.cleanUp(); disguiser.cleanUp();
} }
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
}
private void onTick() { private void onTick() {
if(game.getStatus() == Status.ENDED) game = new Game(game.getCurrentMap(), board); if(game.getStatus() == net.tylermurphy.hideAndSeek.game.util.Status.ENDED) game = new Game(game.getCurrentMap(), board);
game.onTick(); game.onTick();
disguiser.check(); disguiser.check();
} }
@ -168,7 +174,7 @@ public class Main extends JavaPlugin implements Listener {
return commandGroup.handleCommand((Player)sender, "", args); return commandGroup.handleCommand((Player)sender, "", args);
} }
public 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); return commandGroup.handleTabComplete(sender, args);
} }

View file

@ -1,54 +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 <http://www.gnu.org/licenses/>.
*
*/
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.command.util.Command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.List;
public class About extends Command {
public void execute(Player sender, String[] args) {
sender.sendMessage(
String.format("%s%sHide and Seek %s(%s1.7.0 ALPHA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);
}
public String getLabel() {
return "about";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Get information about the plugin";
}
public List<String> autoComplete(String parameter) {
return null;
}
}

View file

@ -21,10 +21,7 @@ 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.Command;
import net.tylermurphy.hideAndSeek.configuration.Config; import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status; import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,10 +39,18 @@ public class Reload extends Command {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS")); sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return; return;
} }
try {
Config.loadConfig(); Config.loadConfig();
Maps.loadMaps(); Maps.loadMaps();
Localization.loadLocalization(); Localization.loadLocalization();
Items.loadItems(); Items.loadItems();
Leaderboard.loadLeaderboard();
} catch (Exception e) {
sender.sendMessage(errorPrefix + message("CONFIG_ERROR"));
return;
}
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD")); sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
} }

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command.map; 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.Command;
@ -13,7 +13,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 SetMap extends Command { public class Send extends Command {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
@ -46,7 +46,7 @@ public class SetMap extends Command {
} }
public String getLabel() { public String getLabel() {
return "goto"; return "send";
} }
public String getUsage() { public String getUsage() {

View file

@ -17,11 +17,11 @@
* *
*/ */
package net.tylermurphy.hideAndSeek.command.location; package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;

View file

@ -57,7 +57,7 @@ public class Start extends Command {
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(); Optional<Player> rand = Main.getInstance().getBoard().getPlayers().stream().skip(new Random().nextInt(Main.getInstance().getBoard().size())).findFirst();
if (!rand.isPresent()) { if (!rand.isPresent()) {
Main.getInstance().getLogger().warning("Failed to select random seeker."); sender.sendMessage(errorPrefix + message("START_FAILED_SEEKER"));
return; return;
} }
seekerName = rand.get().getName(); seekerName = rand.get().getName();
@ -82,7 +82,7 @@ public class Start extends Command {
} }
public String getUsage() { public String getUsage() {
return "<player>"; return "<*player>";
} }
public String getDescription() { public String getDescription() {

View file

@ -34,7 +34,7 @@ public class Stop extends Command {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) { if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do"); sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return; return;
} }
if (Main.getInstance().getGame().getStatus() == Status.STARTING || Main.getInstance().getGame().getStatus() == Status.PLAYING) { if (Main.getInstance().getGame().getStatus() == Status.STARTING || Main.getInstance().getGame().getStatus() == Status.PLAYING) {

View file

@ -76,7 +76,7 @@ public class Top extends Command {
} }
public String getUsage() { public String getUsage() {
return "<page>"; return "<*page>";
} }
public String getDescription() { public String getDescription() {

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command.location.util; package net.tylermurphy.hideAndSeek.command.location;
import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;

View file

@ -1,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command.location.util; package net.tylermurphy.hideAndSeek.command.location;
/** /**
* @author bobby29831 * @author bobby29831

View file

@ -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 AddMap extends Command { public class Add extends Command {
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,4 +1,4 @@
package net.tylermurphy.hideAndSeek.command; 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;

View file

@ -0,0 +1,63 @@
package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class GoTo extends Command {
public void execute(Player sender, String[] args) {
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").addAmount(map.getName()));
return;
}
switch (args[1].toLowerCase()) {
case "spawn":
sender.teleport(map.getSpawn()); break;
case "lobby":
sender.teleport(map.getLobby()); break;
case "seekerlobby":
sender.teleport(map.getSeekerLobby()); break;
case "exit":
sender.teleport(exitPosition); break;
default:
sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase()));
}
}
public String getLabel() {
return "goto";
}
public String getUsage() {
return "<map> <spawn>";
}
public String getDescription() {
return "Get the commands for the plugin";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
} else if(parameter != null && parameter.equals("spawn")) {
return Arrays.asList("spawn","lobby","seekerlobby","exit");
}
return null;
}
}

View file

@ -7,13 +7,12 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix; import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix; import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class ListMaps extends Command { public class List extends Command {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
Collection<Map> maps = Maps.getAllMaps(); Collection<Map> maps = Maps.getAllMaps();
@ -40,7 +39,7 @@ public class ListMaps extends Command {
return "List all maps in the plugin"; return "List all maps in the plugin";
} }
public List<String> autoComplete(String parameter) { public java.util.List<String> autoComplete(String parameter) {
return null; return null;
} }

View file

@ -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 RemoveMap extends Command { public class Remove extends Command {
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

@ -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 SaveMap extends Command { public class Save extends Command {
public static boolean runningBackup = false; public static boolean runningBackup = false;
@ -60,7 +60,8 @@ public class SaveMap extends Command {
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING")); sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
World world = map.getSpawn().getWorld(); World world = map.getSpawn().getWorld();
if (world == null) { if (world == null) {
throw new RuntimeException("Unable to get spawn world"); sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD"));
return;
} }
world.save(); world.save();
BukkitRunnable runnable = new BukkitRunnable() { BukkitRunnable runnable = new BukkitRunnable() {

View file

@ -19,20 +19,18 @@
package net.tylermurphy.hideAndSeek.command.map; package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.Command;
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;
import java.io.File;
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.*; 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 Setup extends Command { public class Status extends Command {
public void execute(Player sender, String[] args) { public void execute(Player sender, String[] args) {
@ -76,7 +74,7 @@ public class Setup extends Command {
} }
public String getLabel() { public String getLabel() {
return "setup"; return "status";
} }
public String getUsage() { public String getUsage() {

View file

@ -0,0 +1,43 @@
package net.tylermurphy.hideAndSeek.command.map.blockhunt;
import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Enabled extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
map.setLobby(sender.getLocation());
});
}
public String getLabel() {
return "enabled";
}
public String getUsage() {
return "<map> <bool>";
}
public String getDescription() {
return "Sets hide and seeks lobby location to current position";
}
public List<String> autoComplete(String parameter) {
if(parameter != null && parameter.equals("map")) {
return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
}
if(parameter != null && parameter.equals("bool")) {
return Arrays.asList("true", "false");
}
return null;
}
}

View file

@ -17,7 +17,7 @@
* *
*/ */
package net.tylermurphy.hideAndSeek.command.map; 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.Command;
@ -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 SetBorder extends Command { public class Border extends Command {
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) {
@ -86,7 +86,7 @@ public class SetBorder extends Command {
change change
); );
Maps.setMap(map.getName(), map); Maps.setMap(map.getName(), map);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay)); sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay).addAmount(change));
map.getWorldBorder().resetWorldBorder(); map.getWorldBorder().resetWorldBorder();
} }

View file

@ -17,7 +17,7 @@
* *
*/ */
package net.tylermurphy.hideAndSeek.command.map; 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.Command;
@ -32,7 +32,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 SetBounds extends Command { public class Bounds extends Command {
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

@ -17,18 +17,18 @@
* *
*/ */
package net.tylermurphy.hideAndSeek.command.location; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SetLobbyLocation extends Command { public class Lobby extends Command {
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 -> {

View file

@ -1,8 +1,8 @@
package net.tylermurphy.hideAndSeek.command.location; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations; import net.tylermurphy.hideAndSeek.command.location.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps; import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,7 +11,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetSeekerLobbyLocation extends Command { public class SeekerLobby extends Command {
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 -> {

View file

@ -17,11 +17,11 @@
* *
*/ */
package net.tylermurphy.hideAndSeek.command.location; package net.tylermurphy.hideAndSeek.command.map.set;
import net.tylermurphy.hideAndSeek.command.util.Command; import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.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 org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -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 SetSpawnLocation extends Command { public class Spawn extends Command {
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 -> {

View file

@ -20,7 +20,8 @@
package net.tylermurphy.hideAndSeek.command.util; package net.tylermurphy.hideAndSeek.command.util;
import net.tylermurphy.hideAndSeek.command.*; import net.tylermurphy.hideAndSeek.command.*;
import net.tylermurphy.hideAndSeek.command.map.SaveMap; import net.tylermurphy.hideAndSeek.command.map.Save;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,7 +39,7 @@ public class CommandGroup {
public CommandGroup(String label, Object... data) { public CommandGroup(String label, Object... data) {
this.label = label; this.label = label;
this.commandRegister = new HashMap<>(); this.commandRegister = new LinkedHashMap<>();
for(Object o : data) registerCommand(o); for(Object o : data) registerCommand(o);
} }
@ -65,11 +66,15 @@ public class CommandGroup {
if (permissionsRequired && !player.hasPermission("hs.about")) { if (permissionsRequired && !player.hasPermission("hs.about")) {
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
} else { } else {
new About().execute(player, null); player.sendMessage(
String.format("%s%sHide and Seek %s(%s1.7.0 ALPHA%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
);
} }
} else { } else {
String invoke = args[0].toLowerCase(); String invoke = args[0].toLowerCase();
if (!invoke.equals("about") && !invoke.equals("help") && SaveMap.runningBackup) { if (!invoke.equals("about") && !invoke.equals("help") && Save.runningBackup) {
player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS")); player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
} else if (permissionsRequired && !player.hasPermission(permission+"."+invoke)) { } else if (permissionsRequired && !player.hasPermission(permission+"."+invoke)) {
player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED")); player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));

View file

@ -101,7 +101,6 @@ public class Config {
lobbyItemStartPosition, lobbyItemStartPosition,
flightToggleItemPosition, flightToggleItemPosition,
teleportItemPosition, teleportItemPosition,
solidifyTime,
delayedRespawnDelay; delayedRespawnDelay;
public static float public static float
@ -113,24 +112,6 @@ public class Config {
blockedCommands, blockedCommands,
blockedInteracts; blockedInteracts;
public static String
LOBBY_TITLE,
GAME_TITLE,
COUNTDOWN_WAITING,
COUNTDOWN_COUNTING,
COUNTDOWN_ADMINSTART,
TAUNT_COUNTING,
TAUNT_ACTIVE,
TAUNT_EXPIRED,
GLOW_ACTIVE,
GLOW_INACTIVE,
BORDER_COUNTING,
BORDER_DECREASING;
public static List<String>
LOBBY_CONTENTS,
GAME_CONTENTS;
public static ItemStack public static ItemStack
lobbyLeaveItem, lobbyLeaveItem,
lobbyStartItem, lobbyStartItem,
@ -152,7 +133,6 @@ public class Config {
config = ConfigManager.create("config.yml"); config = ConfigManager.create("config.yml");
config.saveConfig(); config.saveConfig();
ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers"); announceMessagesToNonPlayers = config.getBoolean("announceMessagesToNonPlayers");
@ -247,25 +227,6 @@ public class Config {
} }
bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy"); bungeeLeave = config.getString("leaveType") == null || config.getString("leaveType").equalsIgnoreCase("proxy");
leaveServer = config.getString("leaveServer"); leaveServer = config.getString("leaveServer");
solidifyTime = Math.max(20,config.getInt("blockhunt.solidifyTime"));
//Leaderboard
LOBBY_TITLE = leaderboard.getString("lobby.title");
GAME_TITLE = leaderboard.getString("game.title");
LOBBY_CONTENTS = leaderboard.getStringList("lobby.content");
Collections.reverse(LOBBY_CONTENTS);
GAME_CONTENTS = leaderboard.getStringList("game.content");
Collections.reverse(GAME_CONTENTS);
COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting");
COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting");
COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart");
TAUNT_COUNTING = leaderboard.getString("taunt.counting");
TAUNT_ACTIVE = leaderboard.getString("taunt.active");
TAUNT_EXPIRED = leaderboard.getString("taunt.expired");
GLOW_ACTIVE = leaderboard.getString("glow.active");
GLOW_INACTIVE = leaderboard.getString("glow.inactive");
BORDER_COUNTING = leaderboard.getString("border.counting");
BORDER_DECREASING = leaderboard.getString("border.decreasing");
//Lobby Items //Lobby Items
if (config.getBoolean("lobbyItems.leave.enabled")) { if (config.getBoolean("lobbyItems.leave.enabled")) {

View file

@ -93,6 +93,7 @@ public class ConfigManager {
try { try {
this.config.load(reader); this.config.load(reader);
} catch(InvalidConfigurationException e) { } catch(InvalidConfigurationException e) {
Main.getInstance().getLogger().severe(e.getMessage());
throw new RuntimeException("Invalid configuration in config file: "+file.getPath()); throw new RuntimeException("Invalid configuration in config file: "+file.getPath());
} catch(IOException e) { } catch(IOException e) {
throw new RuntimeException("Could not access file: "+file.getPath()); throw new RuntimeException("Could not access file: "+file.getPath());
@ -107,9 +108,10 @@ public class ConfigManager {
try { try {
this.defaultConfig.load(default_reader); this.defaultConfig.load(default_reader);
} catch(InvalidConfigurationException e) { } catch(InvalidConfigurationException e) {
throw new RuntimeException("Invalid configuration in config file: "+file.getPath()); Main.getInstance().getLogger().severe(e.getMessage());
throw new RuntimeException("Invalid configuration in internal config file: "+defaultFilename);
} catch(IOException e) { } catch(IOException e) {
throw new RuntimeException("Could not access file: "+file.getPath()); throw new RuntimeException("Could not access internal file: "+defaultFilename);
} }
try{ try{
@ -240,69 +242,110 @@ public class ConfigManager {
public void saveConfig() { public void saveConfig() {
try { try {
// open config file
InputStream is = Main.getInstance().getResource(defaultFilename); InputStream is = Main.getInstance().getResource(defaultFilename);
// if failed error
if (is == null) { if (is == null) {
throw new RuntimeException("Could not create input stream for "+defaultFilename); throw new RuntimeException("Could not create input stream for "+defaultFilename);
} }
// manually read in each character to preserve string data
StringBuilder textBuilder = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8)); StringBuilder textBuilder = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8));
Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); Reader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
int c; int c;
while((c = reader.read()) != -1) { while((c = reader.read()) != -1)
textBuilder.append((char) c); textBuilder.append((char) c);
} // store yaml file into a string
String yamlString = new String(textBuilder.toString().getBytes(), StandardCharsets.UTF_8); String yaml = new String(textBuilder.toString().getBytes(), StandardCharsets.UTF_8);
Map<String, Object> temp = config.getValues(true); // get config values
for(Map.Entry<String, Object> entry: temp.entrySet()) { Map<String, Object> data = config.getValues(true);
if (entry.getValue() instanceof Integer || entry.getValue() instanceof Double || entry.getValue() instanceof String || entry.getValue() instanceof Boolean || entry.getValue() instanceof List) { // write each stored config value into the yaml string
String[] parts = entry.getKey().split("\\."); for(Map.Entry<String, Object> entry: data.entrySet()) {
int index = 0; // if type isn't supported, skip
int i = 0; if(!isSupported(entry.getValue())) continue;
for(String part : parts) { // get index of key in yaml string
if (i == 0) { int index = getIndex(yaml, entry.getKey());
index = yamlString.indexOf(part+":", index); // if index not found, skip
} else {
index = yamlString.indexOf(" " + part+":", index);
index++;
}
i++;
if (index == -1) break;
}
if (index < 10) continue; if (index < 10) continue;
int start = yamlString.indexOf(' ', index); // get start and end of the value
int end = yamlString.indexOf('\n', index); int start = yaml.indexOf(' ', index) + 1;
if (end == -1) end = yamlString.length(); int end = yaml.indexOf('\n', index);
// if end not found, set it to the end of the file
if (end == -1) end = yaml.length();
// create new replace sting
StringBuilder replace = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8)); StringBuilder replace = new StringBuilder(new String("".getBytes(), StandardCharsets.UTF_8));
if (entry.getValue() instanceof List) { // get value
if (((List<?>) entry.getValue()).isEmpty()) { Object value = entry.getValue();
// if the value is a list,
if (value instanceof List) {
end = yaml.indexOf(']', start) + 1;
List<?> list = (List<?>) entry.getValue();
if (list.isEmpty()) {
// if list is empty, put an empty list
replace.append("[]"); replace.append("[]");
} else { } else {
replace.append("["); // if list has values, populate values into the string
for (Object o : (List<?>) entry.getValue()) { // get gap before key
replace.append(o.toString()).append(", "); int gap = whitespaceBefore(yaml, index);
String space = new String(new char[gap]).replace('\0', ' ');
replace.append("[\n");
for (int i = 0; i < list.size(); i++) {
replace.append(space).append(" ").append(convert(list.get(i)));
if(i != list.size() -1) replace.append(",\n");
} }
replace = new StringBuilder(replace.substring(0, replace.length() - 2)); replace.append('\n').append(space).append("]");
replace.append("]");
} }
// otherwise just put the value directly
} else { } else {
replace.append(entry.getValue()); replace.append(convert(value));
}
if (entry.getValue() instanceof String) {
replace.append("\"");
replace.reverse();
replace.append("\"");
replace.reverse();
}
StringBuilder builder = new StringBuilder(yamlString);
builder.replace(start+1, end, replace.toString());
yamlString = builder.toString();
} }
// replace the new value in the yaml string
StringBuilder builder = new StringBuilder(yaml);
builder.replace(start, end, replace.toString());
yaml = builder.toString();
} }
// write yaml string to file
Writer fileWriter = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8)); Writer fileWriter = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8));
fileWriter.write(yamlString); fileWriter.write(yaml);
fileWriter.close(); fileWriter.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private int getIndex(String yaml, String key) {
String[] parts = key.split("\\.");
int index = 0;
for(String part : parts) {
if (index == 0) {
index = yaml.indexOf(part + ":", index);
} else {
index = yaml.indexOf(" " + part + ":", index) + 1;
}
if (index == -1) break;
}
return index;
}
public boolean isSupported(Object o) {
return o instanceof Integer ||
o instanceof Double ||
o instanceof String ||
o instanceof Boolean ||
o instanceof List;
}
public int whitespaceBefore(String yaml, int index) {
int count = 0;
for(int i = index - 1; yaml.charAt(i) == ' '; i--) count++;
return count;
}
private String convert(Object o) {
if(o instanceof String) {
return "\"" + o + "\"";
}
return o.toString();
}
} }

View file

@ -0,0 +1,51 @@
package net.tylermurphy.hideAndSeek.configuration;
import java.util.Collections;
import java.util.List;
public class Leaderboard {
public static String
LOBBY_TITLE,
GAME_TITLE,
COUNTDOWN_WAITING,
COUNTDOWN_COUNTING,
COUNTDOWN_ADMINSTART,
TAUNT_COUNTING,
TAUNT_ACTIVE,
TAUNT_EXPIRED,
GLOW_ACTIVE,
GLOW_INACTIVE,
BORDER_COUNTING,
BORDER_DECREASING;
public static List<String>
LOBBY_CONTENTS,
GAME_CONTENTS;
public static void loadLeaderboard() {
ConfigManager leaderboard = ConfigManager.create("leaderboard.yml");
LOBBY_TITLE = leaderboard.getString("lobby.title");
GAME_TITLE = leaderboard.getString("game.title");
LOBBY_CONTENTS = leaderboard.getStringList("lobby.content");
Collections.reverse(LOBBY_CONTENTS);
GAME_CONTENTS = leaderboard.getStringList("game.content");
Collections.reverse(GAME_CONTENTS);
COUNTDOWN_WAITING = leaderboard.getString("countdown.waiting");
COUNTDOWN_COUNTING = leaderboard.getString("countdown.counting");
COUNTDOWN_ADMINSTART = leaderboard.getString("countdown.adminStart");
TAUNT_COUNTING = leaderboard.getString("taunt.counting");
TAUNT_ACTIVE = leaderboard.getString("taunt.active");
TAUNT_EXPIRED = leaderboard.getString("taunt.expired");
GLOW_ACTIVE = leaderboard.getString("glow.active");
GLOW_INACTIVE = leaderboard.getString("glow.inactive");
BORDER_COUNTING = leaderboard.getString("border.counting");
BORDER_DECREASING = leaderboard.getString("border.decreasing");
leaderboard.saveConfig();
}
}

View file

@ -31,7 +31,7 @@ public class Localization {
public static final Map<String,LocalizationString> DEFAULT_LOCAL = new HashMap<>(); public static final Map<String,LocalizationString> DEFAULT_LOCAL = new HashMap<>();
private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{ private static final Map<String,String[][]> CHANGES = new HashMap<String,String[][]>() {{
put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"}}); put("en-US", new String[][]{{"WORLDBORDER_DECREASING"},{"START","TAUNTED"},{"GAME_SETUP"}});
put("de-DE", new String[][]{{},{"TAUNTED"}}); put("de-DE", new String[][]{{},{"TAUNTED"}});
}}; }};

View file

@ -33,6 +33,7 @@ import java.util.*;
import java.util.stream.Collectors; 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.Leaderboard.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message; import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Board { public class Board {
@ -218,7 +219,9 @@ public class Board {
} else if (line.contains("{SEEKER%}")) { } else if (line.contains("{SEEKER%}")) {
board.setLine(String.valueOf(i), line.replace("{SEEKER%}", getSeekerPercent()+"")); board.setLine(String.valueOf(i), line.replace("{SEEKER%}", getSeekerPercent()+""));
} else if (line.contains("{HIDER%}")) { } else if (line.contains("{HIDER%}")) {
board.setLine(String.valueOf(i), line.replace("{HIDER%}", getHiderPercent()+"")); board.setLine(String.valueOf(i), line.replace("{HIDER%}", getHiderPercent() + ""));
} else if (line.contains("{MAP}")) {
board.setLine(String.valueOf(i), line.replace("{MAP}", getMapName() + ""));
} else { } else {
board.setLine(String.valueOf(i), line); board.setLine(String.valueOf(i), line);
} }
@ -228,6 +231,12 @@ public class Board {
customBoards.put(player.getUniqueId().toString(), board); customBoards.put(player.getUniqueId().toString(), board);
} }
public String getMapName() {
net.tylermurphy.hideAndSeek.configuration.Map map = Main.getInstance().getGame().getCurrentMap();
if(map == null) return "Invalid";
else return map.getName();
}
public void createGameBoard(Player player) { public void createGameBoard(Player player) {
createGameBoard(player, true); createGameBoard(player, true);
} }
@ -288,6 +297,8 @@ public class Board {
board.setLine(String.valueOf(i), line.replace("{#SEEKER}", getSeekers().size()+"")); board.setLine(String.valueOf(i), line.replace("{#SEEKER}", getSeekers().size()+""));
} else if (line.contains("{#HIDER}")) { } else if (line.contains("{#HIDER}")) {
board.setLine(String.valueOf(i), line.replace("{#HIDER}", getHiders().size()+"")); board.setLine(String.valueOf(i), line.replace("{#HIDER}", getHiders().size()+""));
} else if (line.contains("{MAP}")) {
board.setLine(String.valueOf(i), line.replace("{MAP}", getMapName() + ""));
} else { } else {
board.setLine(String.valueOf(i), line); board.setLine(String.valueOf(i), line);
} }

View file

@ -1,6 +1,7 @@
package net.tylermurphy.hideAndSeek.game; package net.tylermurphy.hideAndSeek.game;
import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
import net.tylermurphy.hideAndSeek.configuration.Map; import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.game.util.Disguise; import net.tylermurphy.hideAndSeek.game.util.Disguise;
@ -49,7 +50,7 @@ public class Disguiser {
public void disguise(Player player, Material material, Map map){ public void disguise(Player player, Material material, Map map){
if(!map.isBlockHuntEnabled()){ if(!map.isBlockHuntEnabled()){
player.sendMessage(errorPrefix + "Please enable blockhunt in this map inside maps.yml to enable disguises. Blockhunt does not work on 1.8"); player.sendMessage(errorPrefix + message("BLOCKHUNT_DISABLED"));
return; return;
} }
if(disguises.containsKey(player)){ if(disguises.containsKey(player)){

View file

@ -11,7 +11,7 @@ public class ChatHandler implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) { public void onChat(AsyncPlayerChatEvent event) {
if (Main.getInstance().getBoard().isSeeker(event.getPlayer())) { if (Main.getInstance().getBoard().isSpectator(event.getPlayer())) {
event.setCancelled(true); event.setCancelled(true);
Main.getInstance().getBoard().getSpectators().forEach(spectator -> spectator.sendMessage(ChatColor.GRAY + "[SPECTATOR] " + event.getPlayer().getName() + ": " + event.getMessage())); Main.getInstance().getBoard().getSpectators().forEach(spectator -> spectator.sendMessage(ChatColor.GRAY + "[SPECTATOR] " + event.getPlayer().getName() + ": " + event.getMessage()));
} }

View file

@ -1,7 +1,6 @@
package net.tylermurphy.hideAndSeek.game.listener; package net.tylermurphy.hideAndSeek.game.listener;
import static com.comphenix.protocol.PacketType.Play.Client.*; import static com.comphenix.protocol.PacketType.Play.Client.*;
import static net.tylermurphy.hideAndSeek.configuration.Config.solidifyTime;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.ProtocolManager;
@ -42,7 +41,7 @@ public class DisguiseHandler implements Listener {
if(lastLocation.getWorld() != currentLocation.getWorld()) return; if(lastLocation.getWorld() != currentLocation.getWorld()) return;
double distance = lastLocation.distance(currentLocation); double distance = lastLocation.distance(currentLocation);
disguise.setSolidify(distance < .1); disguise.setSolidify(distance < .1);
}, solidifyTime); }, 20 * 3);
if(event.getFrom().distance(event.getTo()) > .1) if(event.getFrom().distance(event.getTo()) > .1)
disguise.setSolidify(false); disguise.setSolidify(false);
} }

View file

@ -19,11 +19,9 @@
package net.tylermurphy.hideAndSeek.game.listener; package net.tylermurphy.hideAndSeek.game.listener;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
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.Debug; import net.tylermurphy.hideAndSeek.command.map.Debug;
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;

View file

@ -75,7 +75,7 @@ public class WorldLoader {
public String save() { public String save() {
World world = Bukkit.getServer().getWorld(map.getSpawnName()); World world = Bukkit.getServer().getWorld(map.getSpawnName());
if(world == null){ if(world == null){
return errorPrefix + "Invalid world to save: " + map.getSpawnName(); return errorPrefix + message("MAPSAVE_INVALID").addAmount(map.getSpawnName());
} }
File current = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getSpawnName()); File current = new File(Main.getInstance().getWorldContainer()+File.separator+ map.getSpawnName());
if (current.exists()) { if (current.exists()) {
@ -94,7 +94,7 @@ public class WorldLoader {
} }
if (!temp_destination.renameTo(destination)) { if (!temp_destination.renameTo(destination)) {
return errorPrefix + "Failed to rename directory: " + temp_destination.getPath(); return errorPrefix + message("MAPSAVE_FAIL_DIR").addAmount(temp_destination.getPath());
} }
} catch(IOException e) { } catch(IOException e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -15,23 +15,23 @@ gameLength: 1200
announceMessagesToNonPlayers: true announceMessagesToNonPlayers: true
# When the game is starting, the plugin will state there is x seconds left to hide. # When the game is starting, the plugin will state there is x seconds left to hide.
# You change where countdown messages to be displayed: in the chat, action bar, or a title. # You change where countdown messages are to be displayed: in the chat, action bar, or a title.
# Below you can set CHAT, ACTIONBAR, or TITLE. Any invalid option will revert to CHAT. # Below you can set CHAT, ACTIONBAR, or TITLE. Any invalid option will revert to CHAT.
# #
# CHAT - Messages will be displayed in the chat # CHAT - Staring messages will be displayed in the chat
# #
# ACTIONBAR - Messages will be displayed in the action bar (area above the hotbar) # ACTIONBAR - Staring messages will be displayed in the action bar (area above the hotbar)
# #
# TITLE - Messages will be displayed as a title # TITLE - Staring messages will be displayed as a title
# #
# default: CHAT # default: CHAT
hideCountdownDisplay: CHAT hideCountdownDisplay: "CHAT"
# Allow Hiders to see their own teams nametags as well as seekers. Seekers can never see nametags regardless. # Allow Hiders to see their own teams nametags as well as seekers. Seekers can never see nametags regardless.
# default: false # default: false
nametagsVisible: false nametagsVisible: false
# Require bukkit permissions though a plugin to run commands, recommended on large servers # Require bukkit permissions though a permissions plugin to run commands, or require op, recommended on most servers
# default: true # default: true
permissionsRequired: true permissionsRequired: true
@ -80,11 +80,11 @@ leaveOnEnd: false
# PROXY - Send the player to a specified server in a bungee-cord / velocity setup. # PROXY - Send the player to a specified server in a bungee-cord / velocity setup.
# #
# default: EXIT # default: EXIT
leaveType: EXIT leaveType: "EXIT"
# Ignore this setting if you aren't using the PROXY leave type method above. If you are, set this to the server you want to send # Ignore this setting if you aren't using the PROXY leave type method above. If you are, set this to the server you want to send
# players too. # players too.
leaveServer: hub leaveServer: "hub"
# By default, the plugin forces you to use a map save to protect from changes to a map thought a game play though. It copies your # By default, the plugin forces you to use a map save to protect from changes to a map thought a game play though. It copies your
# hide-and-seek world to a separate world, and loads the game there to contain the game in an isolated and backed up map This allows you to # hide-and-seek world to a separate world, and loads the game there to contain the game in an isolated and backed up map This allows you to
@ -117,40 +117,16 @@ delayedRespawn:
# MYSQL - Uses a mysql server to store data, good for multi-server setups or large servers. # MYSQL - Uses a mysql server to store data, good for multi-server setups or large servers.
# #
# default: SQLITE # default: SQLITE
databaseType: SQLITE databaseType: "SQLITE"
# The following settings are used for MYSQL databases ONLY. If you are running SQLITE, these # The following settings are used for MYSQL databases ONLY. If you are running SQLITE, these
# will be ignored. If you are running MYSQL, you need to provide the database host url, database # will be ignored. If you are running MYSQL, you need to provide the database host url, database
# host port (usually 3306), database username, and database password. # host port (usually 3306), database username, and database password.
databaseHost: localhost databaseHost: "localhost"
databasePort: 3306 databasePort: 3306
databaseUser: root databaseUser: "root"
databasePass: databasePass: "pass"
databaseName: hideandseek databaseName: "hideandseek"
# The world border closes every interval, which is evey [delay] in minutes.
# Thw world border starts at [size], and decreases 100 blocks every interval.
# x & z are the center location. [enabled] is whenever the border is enabled.
# You can choose if Hiders are warned 30 seconds before the border moves.
# You want block hunt? We have block hunt! Just enable it below, and set the
# available blocks to pick from, and you're all set! It's that easy!
# Items are displayed in the order that they are listed below.
# The solidifyTime is the time in server ticks that it takes players to solidify.
# Every 20 ticks is a second. Minimum solidifyTime is 20 ticks.
blockhunt:
enabled: false
solidifyTime: 60
blocks: [CRAFTING_TABLE, GRASS_BLOCK, DIRT, BEACON, BOOKSHELF]
worldBorder:
x: 0
z: 0
delay: 10
size: 500
moveAmount: 100
warn: true
enabled: false
# The taunt will activate every delay set in seconds. It will spawn a firework # The taunt will activate every delay set in seconds. It will spawn a firework
# on a random Hider to alert a Seeker where someone may be. You can choose # on a random Hider to alert a Seeker where someone may be. You can choose
@ -173,8 +149,12 @@ glow:
stackable: true stackable: true
enabled: true enabled: true
name: "Glow Powerup" name: "Glow Powerup"
lore: [ "Throw to make all seekers glow", "Last 30s, all hiders can see it", "Time stacks on multi use" ] lore: [
material: SNOWBALL "Throw to make all seekers glow",
"Last 30s, all hiders can see it",
"Time stacks on multi use"
]
material: "SNOWBALL"
model-data: 0 model-data: 0
# This has the same glow effect as the glow powerup in that all seekers positions get # This has the same glow effect as the glow powerup in that all seekers positions get
@ -221,14 +201,16 @@ lobby:
# If you set adminOnly to false, only the item will become non admin only, not the command. # If you set adminOnly to false, only the item will become non admin only, not the command.
lobbyItems: lobbyItems:
leave: leave:
material: BED material: "BED"
name: "&cLeave Lobby" name: "&cLeave Lobby"
lore: ["Go back to server hub"] lore: [
"Go back to server hub"
]
position: 8 position: 8
model-data: 0 model-data: 0
enabled: true enabled: true
start: start:
material: CLOCK material: "CLOCK"
name: "&bStart Game" name: "&bStart Game"
lore: [] lore: []
position: 0 position: 0
@ -241,15 +223,19 @@ lobbyItems:
# and position of the item. You can also change the model data if your server is running 1.14 or above. # and position of the item. You can also change the model data if your server is running 1.14 or above.
spectatorItems: spectatorItems:
flight: flight:
material: FEATHER material: "FEATHER"
name: "&bToggle Flight" name: "&bToggle Flight"
lore: [ "Turns flying on and off" ] lore: [
"Turns flying on and off"
]
position: 3 position: 3
model-data: 0 model-data: 0
teleport: teleport:
material: COMPASS material: "COMPASS"
name: "&bTeleport to Others" name: "&bTeleport to Others"
lore: [ "Allows you to teleport to all other players in game" ] lore: [
"Allows you to teleport to all other players in game"
]
position: 5 position: 5
model-data: 0 model-data: 0
@ -265,8 +251,8 @@ seekerPing:
leadingVolume: 0.5 leadingVolume: 0.5
volume: 0.3 volume: 0.3
pitch: 1 pitch: 1
heartbeatNoise: BLOCK_NOTE_BLOCK_BASEDRUM heartbeatNoise: "BLOCK_NOTE_BLOCK_BASEDRUM"
ringingNoise: BLOCK_NOTE_BLOCK_PLING ringingNoise: "BLOCK_NOTE_BLOCK_PLING"
enabled: true enabled: true
# Changes the default plugin language. Currently, Supported localizations are: # Changes the default plugin language. Currently, Supported localizations are:
@ -275,26 +261,37 @@ seekerPing:
locale: "en-US" locale: "en-US"
# Stop commands being run by any user while playing the game. # Stop commands being run by any user while playing the game.
# Can be usefull If you aren't using a permission plugin and want # Can be usefull If you aren't using a permission plugin and don't want
# to op people, but still want to block certain commands. # to op people, but still want to block certain commands.
# Not really usefully if using permission plugins. # Not really usefully if using permission plugins.
# You can add /kill for any use, but it's already blocked on those # You can add /kill for any use, but it's already blocked on those
# playing the game. # playing the game.
blockedCommands: [msg, tp, gamemode, kill, give, effect] blockedCommands: [
"msg",
"tp",
"gamemode",
"kill",
"give",
"effect"
]
# Stop interactions with any block by any user while playing the game. # Stop interactions with any block by any user while playing the game.
# If your map has things such as chests for aesthetic only, you can # If your map has things such as chests for aesthetic only, you can
# block the use of clicking them. It shouldn't matter what version of # block the use of clicking them. It shouldn't matter what version of
# the block ID you enter, as the plugin will automatically switch to the # the block ID you enter, as the plugin will automatically switch to the
# block ID of your current Minecraft server version. # block ID of your current Minecraft server version.
blockedInteracts: [FURNACE, CRAFTING_TABLE, ANVIL, CHEST, BARREL] blockedInteracts: [
# ---------------------------------------------------------- # "FURNACE",
# ONLY EDIT BEYOND THIS POINT IF YOU KNOW WHAT YOU ARE DOING # "CRAFTING_TABLE",
# ---------------------------------------------------------- # "ANVIL",
"CHEST",
"BARREL"
]
# Location where players are teleported when they exit (/hs leave) # Location where players are teleported when they exit (/hs leave)
# Auto filled by /hs setexit, so you don't need to touch this here
exit: exit:
x: 0 x: 0
y: 0 y: 0
z: 0 z: 0
world: world world: "world"

View file

@ -10,6 +10,7 @@ Localization:
COMMAND_PLAYER_ONLY: "This command can only be run as a player." COMMAND_PLAYER_ONLY: "This command can only be run as a player."
COMMAND_NOT_ALLOWED: "You are not allowed to run this command." COMMAND_NOT_ALLOWED: "You are not allowed to run this command."
COMMAND_ERROR: "An internal error has occurred." COMMAND_ERROR: "An internal error has occurred."
COMMAND_INVALID_ARG: "Invalid argument: {AMOUNT}"
GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed." GAME_PLAYER_DEATH: "&c{PLAYER}&f was killed."
GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker." GAME_PLAYER_FOUND: "&e{PLAYER}&f was found and became a seeker."
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker." GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker."
@ -17,7 +18,7 @@ Localization:
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit." GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit." GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!" GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_SETUP: "There are no setup maps! Run /hs setup on a map to see what you need to do." GAME_SETUP: "There are no setup maps! Run /hs map status on a map to see what you need to do."
GAME_INGAME: "You are already in the lobby/game." GAME_INGAME: "You are already in the lobby/game."
GAME_NOT_INGAME: "You are not in a lobby/game." GAME_NOT_INGAME: "You are not in a lobby/game."
GAME_INPROGRESS: "There is currently a game in progress." GAME_INPROGRESS: "There is currently a game in progress."
@ -32,6 +33,9 @@ Localization:
MAPSAVE_END: "Map save complete." MAPSAVE_END: "Map save complete."
MAPSAVE_ERROR: "Couldn't find current map." MAPSAVE_ERROR: "Couldn't find current map."
MAPSAVE_DISABLED: "Mapsave is disabled in config.yml." MAPSAVE_DISABLED: "Mapsave is disabled in config.yml."
MAPSAVE_FAIL_WORLD: "Mapsave failed. Failed to load current world."
MAPSAVE_INVALID: "Invalid world to save: {AMOUNT}"
MAPSAVE_FAIL_DIR: "Failed to rename directory: {AMOUNT}"
WORLDBORDER_DISABLE: "Disabled world border." WORLDBORDER_DISABLE: "Disabled world border."
WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}." WORLDBORDER_INVALID_INPUT: "Invalid integer {AMOUNT}."
WORLDBORDER_MIN_SIZE: "World border cannot be smaller than 100 blocks." WORLDBORDER_MIN_SIZE: "World border cannot be smaller than 100 blocks."
@ -58,6 +62,7 @@ Localization:
SEEKER_SPAWN: "Set seeker lobby position to current location" SEEKER_SPAWN: "Set seeker lobby position to current location"
START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start." START_MIN_PLAYERS: "You must have at least {AMOUNT} players to start."
START_INVALID_NAME: "Invalid player: {PLAYER}." START_INVALID_NAME: "Invalid player: {PLAYER}."
START_FAILED_SEEKER: "Failed to select random seeker."
START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!" START_COUNTDOWN: "Hiders have {AMOUNT} seconds to hide!"
START_COUNTDOWN_LAST: "Hiders have {AMOUNT} second to hide!" START_COUNTDOWN_LAST: "Hiders have {AMOUNT} second to hide!"
START: "Attention SEEKERS, its time to find the hiders!" START: "Attention SEEKERS, its time to find the hiders!"
@ -77,9 +82,9 @@ Localization:
FLYING_ENABLED: "&l&bFlying Enabled" FLYING_ENABLED: "&l&bFlying Enabled"
FLYING_DISABLED: "&l&bFlying Disabled" FLYING_DISABLED: "&l&bFlying Disabled"
RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds." RESPAWN_NOTICE: "You will respawn in {AMOUNT} seconds."
INVALID_MAP: "That is an invalid map name!!" INVALID_MAP: "That is an invalid map name!"
MAP_ALREADY_EXISTS: "This map already exists!" MAP_ALREADY_EXISTS: "This map already exists!"
INVALID_MAP_NAME: "A map name can only contain numbers or letters" INVALID_MAP_NAME: "A map name can only contain numbers or letters."
MAP_CREATED: "Created new map: {AMOUNT}" MAP_CREATED: "Created new map: {AMOUNT}"
MAP_FAIL_DELETE: "Failed to delete map: {AMOUNT}" MAP_FAIL_DELETE: "Failed to delete map: {AMOUNT}"
MAP_DELETED: "Deleted map: {AMOUNT}" MAP_DELETED: "Deleted map: {AMOUNT}"
@ -88,9 +93,11 @@ Localization:
LIST_MAPS: "The current maps are:" LIST_MAPS: "The current maps are:"
ARGUMENT_COUNT: "This command requires more arguments to run." ARGUMENT_COUNT: "This command requires more arguments to run."
GAME_SPAWN_NEEDED: "Game spawn must be set before seeker spawn." GAME_SPAWN_NEEDED: "Game spawn must be set before seeker spawn."
SEEKER_LOBBY_SPAWN_RESET: "Seeker lobby spawn reset since the game spawn was moved to a new world" SEEKER_LOBBY_SPAWN_RESET: "Seeker lobby spawn reset since the game spawn was moved to a new world."
SEEKER_LOBBY_INVALID: "Seeker lobby must be in the same world as game spawn" SEEKER_LOBBY_INVALID: "Seeker lobby must be in the same world as game spawn."
CONFIG_ERROR: "Error reloading config. Check server logs."
BLOCKHUNT_DISABLED: "Please enable blockhunt in this map inside maps.yml to enable disguises. Blockhunt does not work on 1.8"
# DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE # DO NOT EDIT IT OR IT MAY BREAK OR RESET FILE
version: 3 version: 4
type: "en-US" type: "en-US"

View file

@ -16,6 +16,7 @@
# {COUNT} - The amount of player currently in the lobby. # {COUNT} - The amount of player currently in the lobby.
# {SEEKER%} - The chance that a player will be selected to be a seeker. # {SEEKER%} - The chance that a player will be selected to be a seeker.
# {HIDER%} - The chance that a player will be selected to be a hider. # {HIDER%} - The chance that a player will be selected to be a hider.
# {MAP} - The current map the player is on
# #
# GAME BOARD PLACEHOLDERS # GAME BOARD PLACEHOLDERS
# #
@ -38,6 +39,7 @@
# only Hiders will be able to see its effects though. # only Hiders will be able to see its effects though.
# {#SEEKER} - Number of current seekers. # {#SEEKER} - Number of current seekers.
# {#HIDER} - Number of current hiders. # {#HIDER} - Number of current hiders.
# {MAP} - The current map the player is on
# #
# YOU CANNOT USE TWO PLACEHOLDERS ON THE SAME LINE. ONLY THE FIRST ONE WILL # YOU CANNOT USE TWO PLACEHOLDERS ON THE SAME LINE. ONLY THE FIRST ONE WILL
# BE CHANGED, AND THE SECOND ONE WILL SAY A PLACEHOLDER MARKER! # BE CHANGED, AND THE SECOND ONE WILL SAY A PLACEHOLDER MARKER!
@ -50,12 +52,15 @@ lobby:
"Players: {COUNT}", "Players: {COUNT}",
"", "",
"&cSEEKER % &f{SEEKER%}", "&cSEEKER % &f{SEEKER%}",
"&6HIDER % &f{HIDER%}" "&6HIDER % &f{HIDER%}",
"",
"Map: {MAP}",
] ]
game: game:
title: "&eHIDE AND SEEK" title: "&eHIDE AND SEEK"
content: [ content: [
"Map: {MAP}",
"Team: {TEAM}", "Team: {TEAM}",
"", "",
"Time Left: &a{TIME}", "Time Left: &a{TIME}",