diff --git a/common/src/main/java/ro/fr33styler/arcade/ArcadeGames.java b/common/src/main/java/ro/fr33styler/arcade/ArcadeGames.java index 390ea1c..8e2aeb3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/ArcadeGames.java +++ b/common/src/main/java/ro/fr33styler/arcade/ArcadeGames.java @@ -65,16 +65,16 @@ public abstract class ArcadeGames extends JavaPlugin { this.command = new DefaultCommand(this.engine, "Arcade", "arcade", new String[]{"arc"}); this.registerCommands(); VersionAdapters.get().registerCommand(this, serverPlatform, this.command, this.engine.getSettings().isUseBrigadierCommands()); - this.engine.getGameManagerRegistry().a(new BlockPartyManager(this.engine)); - this.engine.getGameManagerRegistry().a(new BombLobbersManager(this.engine)); - this.engine.getGameManagerRegistry().a(new MiniWallsManager(this.engine)); - this.engine.getGameManagerRegistry().a(new PartyGamesManager(this.engine)); - this.engine.getGameManagerRegistry().a(new PropHuntManager(this.engine)); - this.engine.getGameManagerRegistry().a(new QuakeManager(this.engine)); - this.engine.getGameManagerRegistry().a(new SpleggManager(this.engine)); - this.engine.getGameManagerRegistry().a(new TempleRunManager(this.engine)); - this.engine.getGameManagerRegistry().a(new TNTTagManager(this.engine)); - this.engine.getGameManagerRegistry().a(new TNTRunManager(this.engine)); + this.engine.getGameManagerRegistry().register(new BlockPartyManager(this.engine)); + this.engine.getGameManagerRegistry().register(new BombLobbersManager(this.engine)); + this.engine.getGameManagerRegistry().register(new MiniWallsManager(this.engine)); + this.engine.getGameManagerRegistry().register(new PartyGamesManager(this.engine)); + this.engine.getGameManagerRegistry().register(new PropHuntManager(this.engine)); + this.engine.getGameManagerRegistry().register(new QuakeManager(this.engine)); + this.engine.getGameManagerRegistry().register(new SpleggManager(this.engine)); + this.engine.getGameManagerRegistry().register(new TempleRunManager(this.engine)); + this.engine.getGameManagerRegistry().register(new TNTTagManager(this.engine)); + this.engine.getGameManagerRegistry().register(new TNTRunManager(this.engine)); this.engine.start(); this.registerMetricsCharts(this.engine); basicLogger.sendInfo(this.getName() + " has been loaded!"); @@ -137,7 +137,7 @@ public abstract class ArcadeGames extends JavaPlugin { int count = 0; for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) { - count += abstractGameManager.getSessions().i(); + count += abstractGameManager.getSessions().getTotalPlayers(); } return count; @@ -146,7 +146,7 @@ public abstract class ArcadeGames extends JavaPlugin { HashMap map = new HashMap<>(); for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) { - map.put(abstractGameManager.getName(), abstractGameManager.getSessions().d().size()); + map.put(abstractGameManager.getName(), abstractGameManager.getSessions().getGames().size()); } return map; @@ -155,7 +155,7 @@ public abstract class ArcadeGames extends JavaPlugin { HashMap map = new HashMap<>(); for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) { - map.put(abstractGameManager.getName(), abstractGameManager.getSessions().i()); + map.put(abstractGameManager.getName(), abstractGameManager.getSessions().getTotalPlayers()); } return map; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/DefaultAddonManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/DefaultAddonManager.java index 9dd5782..17a6c02 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/DefaultAddonManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/DefaultAddonManager.java @@ -37,7 +37,7 @@ public class DefaultAddonManager implements AddonManager { public void start() { this.engine.getLogger().sendInfo(" - Loading addons..."); - this.a(this.file); + this.loadAddonsFromDirectory(this.file); this.githubAddonRepository.refresh(Bukkit.getConsoleSender()); } @@ -46,7 +46,7 @@ public class DefaultAddonManager implements AddonManager { for (Addon addon : this.map.values()) { addon.onUnload(); - this.b(addon); + this.closeAddonClassLoader(addon); } this.map.clear(); @@ -72,19 +72,19 @@ public class DefaultAddonManager implements AddonManager { return this.map.get(text); } - private void a(JarFile jarFile, URLClassLoader uRLClassLoader, File file2) throws IOException { + private void loadAddonFromJar(JarFile jarFile, URLClassLoader uRLClassLoader, File file2) throws IOException { JarEntry jarEntry = jarFile.getJarEntry("addon.txt"); if (jarEntry == null) { this.engine.getLogger().sendError("The addon must contain the addon.txt file!"); } else { - this.a(jarFile.getInputStream(jarEntry), uRLClassLoader, file2); + this.loadAddonFromStream(jarFile.getInputStream(jarEntry), uRLClassLoader, file2); } } - private void a(InputStream inputStream, ClassLoader classLoader, File file2) { + private void loadAddonFromStream(InputStream inputStream, ClassLoader classLoader, File file2) { try { String text = new String(inputStream.readAllBytes()); - this.a((Addon)Class.forName(text, true, classLoader).getConstructor().newInstance(), file2); + this.loadAddon((Addon)Class.forName(text, true, classLoader).getConstructor().newInstance(), file2); } catch (ClassNotFoundException | IOException ex) { this.engine.getLogger().sendError("Could not find path '" + ex.getMessage() + "'"); } catch (ReflectiveOperationException ex2) { @@ -100,13 +100,13 @@ public class DefaultAddonManager implements AddonManager { try (JarFile var2 = new JarFile(file2)) { URL[] uRLs = new URL[]{file2.toURI().toURL()}; - this.a(var2, URLClassLoader.newInstance(uRLs, this.getClass().getClassLoader()), file2); + this.loadAddonFromJar(var2, URLClassLoader.newInstance(uRLs, this.getClass().getClassLoader()), file2); } catch (Exception ex) { this.engine.getPlugin().getLogger().log(Level.SEVERE, "The addon couldn't be loaded", ex); } } - public void a(Addon addon, File file2) { + public void loadAddon(Addon addon, File file2) { AddonDescription addonDescription = new AddonDescription(addon); File file3 = new File(this.file, addonDescription.getId()); addon.initialize(this.engine, addonDescription, file3, file2); @@ -115,24 +115,24 @@ public class DefaultAddonManager implements AddonManager { } public void loadAddon(Addon addon) { - this.a(addon, null); + this.loadAddon(addon, null); } - public void a(Addon addon) { + public void unloadAddon(Addon addon) { this.map.remove(addon.getDescription().getId()); addon.onUnload(); - this.b(addon); + this.closeAddonClassLoader(addon); } - public void a(String text) { + public void unloadAddon(String text) { Addon addon = this.map.remove(text); if (addon != null) { addon.onUnload(); - this.b(addon); + this.closeAddonClassLoader(addon); } } - private void b(Addon addon) { + private void closeAddonClassLoader(Addon addon) { if (addon.getFile() != null) { try { ((URLClassLoader)addon.getClass().getClassLoader()).close(); @@ -142,8 +142,8 @@ public class DefaultAddonManager implements AddonManager { } } - public void a(File file2) { - Files.a(file2, file3 -> { + public void loadAddonsFromDirectory(File file2) { + Files.forEachChild(file2, file3 -> { if (file3.isFile() && file3.getName().endsWith(".jar")) { this.loadAddon(file3); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryAllCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryAllCommand.java index b66b035..3541b07 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryAllCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryAllCommand.java @@ -16,6 +16,6 @@ public class AddonRepositoryAllCommand extends AddonRepositoryListCommand { } public void execute(CommandSender sender, String text, String[] texts, int index) { - this.a(sender, this.manager.getAddonRepository().getAddonRepository().values(), 1); + this.sendPage(sender, this.manager.getAddonRepository().getAddonRepository().values(), 1); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryListCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryListCommand.java index afa5250..a3f0e8c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryListCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryListCommand.java @@ -18,7 +18,7 @@ public abstract class AddonRepositoryListCommand implements CommandExecutor { return sender.hasPermission(this.manager.getEngine().getPlugin().getName() + ".admin"); } - protected void a(CommandSender sender, Collection collection, int index) { + protected void sendPage(CommandSender sender, Collection collection, int index) { int index2 = (index - 1) * 7; if (index >= 1 && index2 <= collection.size()) { sender.sendMessage("§8[§cAddon Repository§8] §7- §dList."); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryPageCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryPageCommand.java index 288734b..86a6e2f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryPageCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/AddonRepositoryPageCommand.java @@ -22,7 +22,7 @@ public class AddonRepositoryPageCommand extends AddonRepositoryListCommand { public void execute(CommandSender sender, String text, String[] texts, int index) { try { int index2 = Integer.parseInt(texts[index]); - this.a(sender, this.manager.getAddonRepository().getAddonRepository().values(), index2); + this.sendPage(sender, this.manager.getAddonRepository().getAddonRepository().values(), index2); } catch (NumberFormatException ex) { sender.sendMessage("§cThe page must be a number!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ListAddonsCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ListAddonsCommand.java index 31bdb61..b7472b7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ListAddonsCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ListAddonsCommand.java @@ -20,7 +20,7 @@ public class ListAddonsCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { List list = this.manager.getAddons(); - String text2 = Strings.a(", ", list, addon -> addon.getDescription().getId()); + String text2 = Strings.join(", ", list, addon -> addon.getDescription().getId()); sender.sendMessage("§aAddons(§f" + list.size() + "§a): §f" + text2); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ManageAddonCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ManageAddonCommand.java index 4a30572..dde44a4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ManageAddonCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/command/ManageAddonCommand.java @@ -38,7 +38,7 @@ public class ManageAddonCommand implements CommandExecutor { if (addon == null) { sender.sendMessage("§cThere is no addon with such name!"); } else { - this.manager.a(addon); + this.manager.unloadAddon(addon); File file = addon.getFile(); if (file != null) { file.delete(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/addon/repository/github/GithubAddonRepository.java b/common/src/main/java/ro/fr33styler/arcade/engine/addon/repository/github/GithubAddonRepository.java index 84124c6..05368cb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/addon/repository/github/GithubAddonRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/addon/repository/github/GithubAddonRepository.java @@ -36,7 +36,7 @@ public class GithubAddonRepository implements AddonRepository, Configuration { public void refresh(CommandSender sender) { DefaultEngine defaultEngine = this.manager.getEngine(); String text = "/Fr33styler/AddonsRepository/main/" + defaultEngine.getPlugin().getName() + "/addons.yml"; - InputStream inputStream = EngineUtils.a("https", "raw.githubusercontent.com", text, 5000); + InputStream inputStream = EngineUtils.openStream("https", "raw.githubusercontent.com", text, 5000); if (inputStream != null) { InputStreamReader inputStreamReader = new InputStreamReader(inputStream); @@ -62,23 +62,23 @@ public class GithubAddonRepository implements AddonRepository, Configuration { if (addonRepositoryEntry == null) { sender.sendMessage("§cThere is no addon with such name!"); } else { - this.a(sender, defaultEngine.getPlugin().getName(), addonRepositoryEntry.getName()); + this.downloadAddon(sender, defaultEngine.getPlugin().getName(), addonRepositoryEntry.getName()); } } - private void a(CommandSender sender, String text, String text2) { + private void downloadAddon(CommandSender sender, String text, String text2) { String text3 = "/Fr33styler/AddonsRepository/main/" + text + "/" + text2 + ".jar"; - InputStream inputStream = EngineUtils.a("https", "raw.githubusercontent.com", text3, 60000); + InputStream inputStream = EngineUtils.openStream("https", "raw.githubusercontent.com", text3, 60000); if (inputStream == null) { sender.sendMessage("§cThe addon failed to download."); } else { - this.a(sender, inputStream, text2); + this.installAddon(sender, inputStream, text2); } } - private void a(CommandSender sender, InputStream inputStream, String text) { + private void installAddon(CommandSender sender, InputStream inputStream, String text) { try { - this.manager.a(text); + this.manager.unloadAddon(text); File file = new File(this.manager.getEngine().getAddonManager().getAddonsDirectory(), text + ".jar"); Files.copy(inputStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING); this.manager.loadAddon(file); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandNode.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandNode.java index b6a8d20..2868180 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandNode.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandNode.java @@ -10,7 +10,7 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor; import ro.fr33styler.arcade.api.engine.util.Path; public class CommandNode { - private final String a; + private final String name; private final Path path; private final Map map = new TreeMap<>(); private final CommandRegistry commandRegistry = new CommandRegistry(); @@ -20,12 +20,12 @@ public class CommandNode { } CommandNode(String text, Path path2) { - this.a = text; + this.name = text; this.path = path2; } - public String a() { - return this.a; + public String getName() { + return this.name; } public Path getPath() { @@ -36,47 +36,47 @@ public class CommandNode { return this.commandRegistry; } - public void a(Collection collection) { + public void collectChildren(Collection collection) { collection.addAll(this.map.values()); } - public void a(Path path2, Path path3, CommandExecutor commandExecutor) { + public void registerExecutor(Path path2, Path path3, CommandExecutor commandExecutor) { if (path3 == null) { - this.commandRegistry.a(commandExecutor); + this.commandRegistry.register(commandExecutor); } else { CommandNode commandNode = this.map.computeIfAbsent(path3.getNode(), text -> new CommandNode(text, path2)); - commandNode.a(path2, path3.getChild(), commandExecutor); + commandNode.registerExecutor(path2, path3.getChild(), commandExecutor); } } - public boolean a(CommandSender sender, String text, String[] texts, int index) { + public boolean execute(CommandSender sender, String text, String[] texts, int index) { if (texts.length >= index) { CommandNode commandNode = null; if (texts.length > index) { commandNode = this.map.get(texts[index]); } - return commandNode == null ? this.commandRegistry.a(sender, text, texts, index) : commandNode.a(sender, text, texts, index + 1); + return commandNode == null ? this.commandRegistry.execute(sender, text, texts, index) : commandNode.execute(sender, text, texts, index + 1); } else { return false; } } - public void a(CommandSender sender, List list, String[] texts, int index) { + public void collectSuggestions(CommandSender sender, List list, String[] texts, int index) { if (texts.length > index) { CommandNode commandNode = this.map.get(texts[index]); if (commandNode == null) { - this.b(sender, list, texts, index); - this.commandRegistry.a(sender, list, texts, index); + this.collectChildSuggestions(sender, list, texts, index); + this.commandRegistry.collectSuggestions(sender, list, texts, index); } else { - commandNode.a(sender, list, texts, index + 1); + commandNode.collectSuggestions(sender, list, texts, index + 1); } } } - private boolean a(CommandSender sender) { + private boolean isAccessibleTo(CommandSender sender) { for (CommandNode commandNode : this.map.values()) { - if (commandNode.a(sender)) { + if (commandNode.isAccessibleTo(sender)) { return true; } } @@ -90,11 +90,11 @@ public class CommandNode { return false; } - private void b(CommandSender sender, List list, String[] texts, int index) { + private void collectChildSuggestions(CommandSender sender, List list, String[] texts, int index) { if (index == texts.length - 1) { for (CommandNode commandNode : this.map.values()) { - if (commandNode.a(sender) && commandNode.a().startsWith(texts[index])) { - list.add(commandNode.a()); + if (commandNode.isAccessibleTo(sender) && commandNode.getName().startsWith(texts[index])) { + list.add(commandNode.getName()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandRegistry.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandRegistry.java index b546670..dae2813 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandRegistry.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/CommandRegistry.java @@ -16,15 +16,15 @@ public class CommandRegistry implements Iterable { CommandRegistry() { } - public void a(CommandExecutor commandExecutor) { + public void register(CommandExecutor commandExecutor) { this.queue.removeIf(commandExecutor2 -> commandExecutor2.getArguments().isConflicting(commandExecutor.getArguments())); this.queue.add(commandExecutor); } - public boolean a(CommandSender sender, String text, String[] texts, int index) { + public boolean execute(CommandSender sender, String text, String[] texts, int index) { for (CommandExecutor commandExecutor : this.queue) { if (commandExecutor.getArguments().isMatching(texts, index)) { - this.a(sender, commandExecutor, text, texts, index); + this.dispatch(sender, commandExecutor, text, texts, index); return true; } } @@ -32,7 +32,7 @@ public class CommandRegistry implements Iterable { return false; } - private static void a(CommandExecutor commandExecutor, String[] texts, int index) { + private static void normalizeArguments(CommandExecutor commandExecutor, String[] texts, int index) { for (int index2 = 0; index2 < commandExecutor.getArguments().size(); index2++) { for (String text : commandExecutor.getArguments().get(index2).getSuggestions()) { if (text.equalsIgnoreCase(texts[index + index2])) { @@ -43,18 +43,18 @@ public class CommandRegistry implements Iterable { } } - private void a(CommandSender sender, CommandExecutor commandExecutor, String text, String[] texts, int index) { + private void dispatch(CommandSender sender, CommandExecutor commandExecutor, String text, String[] texts, int index) { if (commandExecutor.isPlayerOnly() && !(sender instanceof Player)) { sender.sendMessage("§cOnly players can execute this!"); } else if (!commandExecutor.hasPermission(sender)) { sender.sendMessage("§cYou're not allowed to use this command!"); } else { - a(commandExecutor, texts, index); + normalizeArguments(commandExecutor, texts, index); commandExecutor.execute(sender, text, texts, index); } } - public void a(CommandSender sender, List list, String[] texts, int index) { + public void collectSuggestions(CommandSender sender, List list, String[] texts, int index) { int index2 = texts.length - 1; for (CommandExecutor commandExecutor : this.queue) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/DefaultCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/DefaultCommand.java index e2b8a24..c05b21d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/DefaultCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/DefaultCommand.java @@ -14,50 +14,50 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor; import ro.fr33styler.arcade.api.engine.util.Path; public class DefaultCommand implements Command { - private final String a; - private final String b; + private final String command; + private final String displayName; private final List list; private final CommandNode commandNode; public DefaultCommand(DefaultEngine defaultEngine, String text, String text2, String... texts) { - this.a = text2; - this.b = text; + this.command = text2; + this.displayName = text; this.list = List.of(texts); this.commandNode = new CommandNode(text); - this.a(defaultEngine.getSettings()); + this.registerDefaultExecutors(defaultEngine.getSettings()); } public String getDisplayName() { - return this.b; + return this.displayName; } public String getCommand() { - return this.a; + return this.command; } public List getAliases() { return this.list; } - private void a(EngineSettings engineSettings) { - this.putExecutor(new RootCommand(this.b, engineSettings)); + private void registerDefaultExecutors(EngineSettings engineSettings) { + this.putExecutor(new RootCommand(this.displayName, engineSettings)); this.putExecutor(Path.of("help"), new HelpListCommand(this.commandNode)); this.putExecutor(Path.of("help"), new HelpPageCommand(this.commandNode)); } public void putExecutor(Path path, CommandExecutor commandExecutor) { - this.commandNode.a(path, path, commandExecutor); + this.commandNode.registerExecutor(path, path, commandExecutor); } public List onSuggestion(CommandSender sender, String[] texts) { ArrayList list2 = new ArrayList(); - this.commandNode.a(sender, list2, texts, 0); + this.commandNode.collectSuggestions(sender, list2, texts, 0); Collections.sort(list2); return list2; } public void onExecute(CommandSender sender, String text, String[] texts) { - if (!this.commandNode.a(sender, text, texts, 0)) { + if (!this.commandNode.execute(sender, text, texts, 0)) { sender.sendMessage("§cInvalid command. Please use §e/" + text + " help§c for the available commands!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/RootCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/RootCommand.java index 85e258c..e285a6c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/RootCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/RootCommand.java @@ -5,19 +5,19 @@ import ro.fr33styler.arcade.engine.config.EngineSettings; import org.bukkit.command.CommandSender; public class RootCommand extends BaseCommandExecutor { - private final String b; + private final String displayName; private final EngineSettings settings; public RootCommand(String text, EngineSettings settings2) { - this.b = text; + this.displayName = text; this.settings = settings2; } public void execute(CommandSender sender, String text, String[] texts, int index) { if (!this.settings.isHideCredits()) { - sender.sendMessage("§8[§3" + this.b + "§8] §ePlugin made by §aFr33styler§e."); + sender.sendMessage("§8[§3" + this.displayName + "§8] §ePlugin made by §aFr33styler§e."); } - sender.sendMessage("§8[§3" + this.b + "§8] §eType §c/" + text + " help§e for help."); + sender.sendMessage("§8[§3" + this.displayName + "§8] §eType §c/" + text + " help§e for help."); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/admin/SetLobbyCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/admin/SetLobbyCommand.java index 03a0384..9a58c53 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/admin/SetLobbyCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/admin/SetLobbyCommand.java @@ -24,7 +24,7 @@ public class SetLobbyCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { Player player = (Player)sender; this.engine.getDatabaseManager().setLobby(player.getLocation()); - this.engine.getDatabaseManager().f(); + this.engine.getDatabaseManager().saveConfig(); player.sendMessage("§aThe lobby has been set!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/ArrayArgument.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/ArrayArgument.java index ff431da..febc4c2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/ArrayArgument.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/ArrayArgument.java @@ -5,19 +5,19 @@ import ro.fr33styler.arcade.support.text.Strings; import java.util.Collection; public class ArrayArgument extends StringArgument { - public final String[] a; - private final String b; + public final String[] options; + private final String fallbackSuggestion; public ArrayArgument(String text, String text2, String... texts) { super(text); - this.b = text2; - this.a = (String[])texts.clone(); + this.fallbackSuggestion = text2; + this.options = (String[])texts.clone(); } @Override public boolean isMatching(String text) { - if (this.b == null) { - for (String text2 : this.a) { + if (this.fallbackSuggestion == null) { + for (String text2 : this.options) { if (text2.equalsIgnoreCase(text)) { return true; } @@ -31,14 +31,14 @@ public class ArrayArgument extends StringArgument { @Override public void getSuggestions(String text, Collection collection) { - for (String text2 : this.a) { - if (Strings.a(text2, text, true)) { + for (String text2 : this.options) { + if (Strings.startsWith(text2, text, true)) { collection.add(text2); } } - if (this.b != null) { - collection.add(this.b); + if (this.fallbackSuggestion != null) { + collection.add(this.fallbackSuggestion); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/BaseArgument.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/BaseArgument.java index ca5f8e5..811c967 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/BaseArgument.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/BaseArgument.java @@ -4,17 +4,17 @@ import java.util.Collection; import ro.fr33styler.arcade.api.engine.command.argument.Argument; public abstract class BaseArgument implements Argument { - private final String a; + private final String name; public BaseArgument(String text) { - this.a = text; + this.name = text; } public String getName() { - return this.a; + return this.name; } public void getSuggestions(String text, Collection collection) { - collection.add("<" + this.a + ">"); + collection.add("<" + this.name + ">"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/CollectionArgument.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/CollectionArgument.java index 971612e..8063c97 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/CollectionArgument.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/CollectionArgument.java @@ -5,19 +5,19 @@ import ro.fr33styler.arcade.support.text.Strings; import java.util.Collection; public class CollectionArgument extends StringArgument { - private final Collection a; - private final String b; + private final Collection options; + private final String fallbackSuggestion; public CollectionArgument(String text, String text2, Collection collection) { super(text); - this.b = text2; - this.a = collection; + this.fallbackSuggestion = text2; + this.options = collection; } @Override public boolean isMatching(String text) { - if (this.b == null) { - for (String text2 : this.a) { + if (this.fallbackSuggestion == null) { + for (String text2 : this.options) { if (text2.equalsIgnoreCase(text)) { return true; } @@ -31,14 +31,14 @@ public class CollectionArgument extends StringArgument { @Override public void getSuggestions(String text, Collection collection) { - for (String text2 : this.a) { - if (Strings.a(text2, text, true)) { + for (String text2 : this.options) { + if (Strings.startsWith(text2, text, true)) { collection.add(text2); } } - if (this.b != null) { - collection.add(this.b); + if (this.fallbackSuggestion != null) { + collection.add(this.fallbackSuggestion); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/PlayerArgument.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/PlayerArgument.java index 3d9c01f..7d687ef 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/PlayerArgument.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/PlayerArgument.java @@ -14,7 +14,7 @@ public class PlayerArgument extends StringArgument { @Override public void getSuggestions(String text, Collection collection) { for (Player player : Bukkit.getOnlinePlayers()) { - if (Strings.a(player.getName(), text, true)) { + if (Strings.startsWith(player.getName(), text, true)) { collection.add(player.getName()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/SuggestedArgument.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/SuggestedArgument.java index c72f9d0..7287857 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/SuggestedArgument.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/argument/SuggestedArgument.java @@ -7,17 +7,17 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; public class SuggestedArgument extends StringArgument { - private final Consumer> a; + private final Consumer> suggestionProvider; public SuggestedArgument(String text, Consumer> consumer) { super(text); - this.a = consumer; + this.suggestionProvider = consumer; } @Override public boolean isMatching(String text) { AtomicBoolean atomicBoolean = new AtomicBoolean(); - this.a.accept(text2 -> { + this.suggestionProvider.accept(text2 -> { if (text2.equalsIgnoreCase(text)) { atomicBoolean.set(true); } @@ -27,8 +27,8 @@ public class SuggestedArgument extends StringArgument { @Override public void getSuggestions(String text, Collection collection) { - this.a.accept(text2 -> { - if (Strings.a(text2, text, true)) { + this.suggestionProvider.accept(text2 -> { + if (Strings.startsWith(text2, text, true)) { collection.add(text2); } }); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpCommand.java index 1f508ca..0a62b2d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpCommand.java @@ -10,19 +10,19 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public abstract class HelpCommand implements CommandExecutor { - protected void a(CommandSender sender, CommandNode commandNode, String text, int index) { - List list = this.a(sender, commandNode, text); + protected void sendHelpPage(CommandSender sender, CommandNode commandNode, String text, int index) { + List list = this.collectAllUsages(sender, commandNode, text); int index2 = (index - 1) * 8; if (index >= 1 && index2 <= list.size()) { - sender.sendMessage("§8[§3" + commandNode.a() + "§8] §7- §dHelp."); - this.a(list, sender, index2); - this.a(list, sender, index, text); + sender.sendMessage("§8[§3" + commandNode.getName() + "§8] §7- §dHelp."); + this.sendEntriesPage(list, sender, index2); + this.sendPageFooter(list, sender, index, text); } else { sender.sendMessage("§cThe page doesn't exists!"); } } - private void a(List list, CommandSender sender, int index) { + private void sendEntriesPage(List list, CommandSender sender, int index) { int index2 = Math.min(index + 8, list.size()); for (int index3 = index; index3 < index2; index3++) { @@ -30,38 +30,38 @@ public abstract class HelpCommand implements CommandExecutor { } } - private void a(List list, CommandSender sender, int index, String text) { + private void sendPageFooter(List list, CommandSender sender, int index, String text) { int index2 = Math.max(1, (list.size() + 8 - 1) / 8); if (index2 > 1) { sender.sendMessage("§3Page " + index + " out of " + index2 + ". Use §7/§c" + text + " help §8<§bpage§8>§3 to change pages!"); } } - private List a(CommandSender sender, CommandNode commandNode, String text) { + private List collectAllUsages(CommandSender sender, CommandNode commandNode, String text) { ArrayList list = new ArrayList(); ArrayDeque arrayDeque = new ArrayDeque(); - commandNode.a(arrayDeque); + commandNode.collectChildren(arrayDeque); while (!arrayDeque.isEmpty()) { CommandNode commandNode2 = (CommandNode)arrayDeque.pop(); - this.a(list, sender, commandNode2, text); - commandNode2.a(arrayDeque); + this.collectNodeUsages(list, sender, commandNode2, text); + commandNode2.collectChildren(arrayDeque); } return list; } - private void a(List list, CommandSender sender, CommandNode commandNode, String text) { + private void collectNodeUsages(List list, CommandSender sender, CommandNode commandNode, String text) { String text2 = commandNode.getPath().toString(); for (CommandExecutor commandExecutor : commandNode.getCommandRegistry()) { if (commandExecutor.hasPermission(sender) && !(commandExecutor instanceof HelpCommand)) { - list.add(this.a(commandExecutor, text2, text)); + list.add(this.formatCommandUsage(commandExecutor, text2, text)); } } } - private String a(CommandExecutor commandExecutor, String text, String text2) { + private String formatCommandUsage(CommandExecutor commandExecutor, String text, String text2) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(" ➥ §7/§c").append(text2).append(' ').append(text); ArgumentSet argumentSet = commandExecutor.getArguments(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpListCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpListCommand.java index 43a3eff..e66e5db 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpListCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpListCommand.java @@ -18,6 +18,6 @@ public class HelpListCommand extends HelpCommand { } public void execute(CommandSender sender, String text, String[] texts, int index) { - this.a(sender, this.commandNode, text, 1); + this.sendHelpPage(sender, this.commandNode, text, 1); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpPageCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpPageCommand.java index 8073afb..026375d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpPageCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/command/help/HelpPageCommand.java @@ -23,7 +23,7 @@ public class HelpPageCommand extends HelpCommand { public void execute(CommandSender sender, String text, String[] texts, int index) { try { int index2 = Integer.parseInt(texts[index]); - this.a(sender, this.commandNode, text, index2); + this.sendHelpPage(sender, this.commandNode, text, index2); } catch (NumberFormatException ex) { sender.sendMessage("§cThe page must be a number!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/EngineSettings.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/EngineSettings.java index c3f65ba..ed3d613 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/EngineSettings.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/EngineSettings.java @@ -47,7 +47,7 @@ public class EngineSettings implements Configuration { @Setting("disabled") private Set disabled = new HashSet<>(List.of("Game1", "Game2")); @Setting("text-settings") - private TextSyntaxSettings textSettings = TextSyntaxSettings.a; + private TextSyntaxSettings textSettings = TextSyntaxSettings.INSTANCE; public boolean isHideCredits() { return this.hideCredits; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/CuboidTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/CuboidTypeToken.java index 87d9088..0e0b602 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/CuboidTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/CuboidTypeToken.java @@ -13,8 +13,8 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class CuboidTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { Cuboid cuboid = (Cuboid)obj; - Location location = cuboid.b(); - Location location2 = cuboid.c(); + Location location = cuboid.getMin(); + Location location2 = cuboid.getMax(); String text = location.getWorld().getName(); int index = location.getBlockX(); int index2 = location.getBlockY(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/LocationTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/LocationTypeToken.java index 77aa5f2..93f7760 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/LocationTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/LocationTypeToken.java @@ -13,11 +13,11 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class LocationTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { Location location = (Location)obj; - String text = Strings.a(location.getX(), 2); - String text2 = Strings.a(location.getY(), 2); - String text3 = Strings.a(location.getZ(), 2); - String text4 = Strings.a(location.getYaw(), 2); - String text5 = Strings.a(location.getPitch(), 2); + String text = Strings.formatFixedDecimal(location.getX(), 2); + String text2 = Strings.formatFixedDecimal(location.getY(), 2); + String text3 = Strings.formatFixedDecimal(location.getZ(), 2); + String text4 = Strings.formatFixedDecimal(location.getYaw(), 2); + String text5 = Strings.formatFixedDecimal(location.getPitch(), 2); return location.getWorld().getName() + "," + text + "," + text2 + "," + text3 + "," + text4 + "," + text5; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/TextTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/TextTypeToken.java index eb09e1d..7f5d2f2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/TextTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/bukkit/TextTypeToken.java @@ -11,6 +11,6 @@ public class TextTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - return TextParser.a(obj.toString()); + return TextParser.parse(obj.toString()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/ArrayTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/ArrayTypeToken.java index bcd0946..40e4b82 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/ArrayTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/ArrayTypeToken.java @@ -9,7 +9,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class ArrayTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveComponentToken(typeContext); ArrayList list = new ArrayList(); for (Object obj2 : (Object[])obj) { @@ -20,9 +20,9 @@ public class ArrayTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - Object[] objs = (Object[])ConfigurationReflection.b(typeContext.getField()); + Object[] objs = (Object[])ConfigurationReflection.getOrCreateArray(typeContext.getField()); if (obj instanceof List var4) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveComponentToken(typeContext); ArrayList list = new ArrayList(); for (Object obj2 : var4) { @@ -38,8 +38,8 @@ public class ArrayTypeToken implements TypeToken { } } - private TypeToken a(TypeContext typeContext) { - Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType()); + private TypeToken resolveComponentToken(TypeContext typeContext) { + Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType()); return typeContext.getRegistry().get(clazz, typeContext.getField().getId()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/CollectionTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/CollectionTypeToken.java index f4ae4b1..9b85ca1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/CollectionTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/CollectionTypeToken.java @@ -12,7 +12,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class CollectionTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveElementToken(typeContext); ArrayList list = new ArrayList(); for (Object obj2 : (Collection)obj) { @@ -23,9 +23,9 @@ public class CollectionTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - Collection collection = ConfigurationReflection.c(typeContext.getField()); + Collection collection = ConfigurationReflection.getOrCreateCollection(typeContext.getField()); if (obj instanceof List var4) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveElementToken(typeContext); collection.clear(); for (Object obj2 : var4) { @@ -39,10 +39,10 @@ public class CollectionTypeToken implements TypeToken { return collection; } - private TypeToken a(TypeContext typeContext) { + private TypeToken resolveElementToken(TypeContext typeContext) { Type[] types = typeContext.getField().getGenericParameters(); - GenericTypeValidation.a(types); - Class clazz = ConfigurationReflection.a(types[0]); + GenericTypeValidation.validateListGenericTypes(types); + Class clazz = ConfigurationReflection.resolveRawClass(types[0]); typeContext.setField(typeContext.getField().modifiedClone(types[0])); return typeContext.getRegistry().get(clazz, typeContext.getField().getId()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/MapTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/MapTypeToken.java index a428d8c..fd521b1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/MapTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/collection/MapTypeToken.java @@ -13,7 +13,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class MapTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveValueToken(typeContext); typeContext.setSection(typeContext.getSection().createSection(typeContext.getField().getId())); LinkedHashMap linkedHashMap = new LinkedHashMap(); @@ -26,9 +26,9 @@ public class MapTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - Map map = ConfigurationReflection.d(typeContext.getField()); + Map map = ConfigurationReflection.getOrCreateMap(typeContext.getField()); if (obj instanceof ConfigurationSection var4) { - TypeToken typeToken = this.a(typeContext); + TypeToken typeToken = this.resolveValueToken(typeContext); typeContext.setSection(var4); map.clear(); @@ -43,10 +43,10 @@ public class MapTypeToken implements TypeToken { return map; } - private TypeToken a(TypeContext typeContext) { + private TypeToken resolveValueToken(TypeContext typeContext) { Type[] types = typeContext.getField().getGenericParameters(); - GenericTypeValidation.b(types); - Class clazz = ConfigurationReflection.a(types[1]); + GenericTypeValidation.validateMapGenericTypes(types); + Class clazz = ConfigurationReflection.resolveRawClass(types[1]); TypeToken typeToken = typeContext.getRegistry().get(clazz, typeContext.getField().getId()); typeContext.setField(typeContext.getField().modifiedClone(types[1])); return typeToken; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/reflection/ConfigurationTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/reflection/ConfigurationTypeToken.java index 6c0f3ed..45bb4e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/reflection/ConfigurationTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/reflection/ConfigurationTypeToken.java @@ -22,7 +22,7 @@ public class ConfigurationTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - Configuration configuration = (Configuration)ConfigurationReflection.a(typeContext.getField()); + Configuration configuration = (Configuration)ConfigurationReflection.getOrCreateConfiguration(typeContext.getField()); if (obj instanceof ConfigurationSection var4) { this.configManager.load(configuration, var4); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/EnumTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/EnumTypeToken.java index 5b52530..f8cbf5f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/EnumTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/EnumTypeToken.java @@ -17,7 +17,7 @@ public class EnumTypeToken implements TypeToken { public Object deserialize(TypeContext typeContext, Object obj) { try { - Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType()); + Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType()); return Enum.valueOf(clazz, obj.toString()); } catch (IllegalArgumentException ex) { throw GenericTypeValidation.re$propagate(new InvalidConfigException("The enum is invalid!", ex)); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/IdentityTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/IdentityTypeToken.java index 832cfc0..b07fc2c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/IdentityTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/IdentityTypeToken.java @@ -11,7 +11,7 @@ public class IdentityTypeToken implements TypeToken { } public Object deserialize(TypeContext typeContext, Object obj) { - Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType()); + Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType()); return clazz.isInstance(obj) ? obj : typeContext.getField().get(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/StringTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/StringTypeToken.java index a3ffc62..fed5b21 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/StringTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/codec/scalar/StringTypeToken.java @@ -10,11 +10,11 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken; public class StringTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { - return Strings.c(obj.toString()).replace('§', '&'); + return Strings.stripHexColors(obj.toString()).replace('§', '&'); } public Object deserialize(TypeContext typeContext, Object obj) { - return Strings.a(obj.toString()); + return Strings.colorize(obj.toString()); } public boolean canModify(SettingField settingField, Object obj) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/message/EngineMessages.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/message/EngineMessages.java index 0d8cbda..1c0a0a3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/message/EngineMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/message/EngineMessages.java @@ -10,107 +10,107 @@ import ro.fr33styler.arcade.api.engine.config.serialize.Configuration; public class EngineMessages implements Configuration { @Setting("command-no-permission") - private String commandNoPermission = Strings.a("&cYou're not allowed to use this command!"); + private String commandNoPermission = Strings.colorize("&cYou're not allowed to use this command!"); @Setting("restricted-command") - private String restrictedCommand = Strings.a("&cYou can't use commands while in game!"); + private String restrictedCommand = Strings.colorize("&cYou can't use commands while in game!"); @Setting("quickjoin-not-found") - private String quickjoinNotFound = Strings.a("&cNo game found!"); + private String quickjoinNotFound = Strings.colorize("&cNo game found!"); @Setting("quickjoin-started-not-found") - private String quickjoinStartedNotFound = Strings.a("&cThere are no in-progress games with room! Try joining a new game!"); + private String quickjoinStartedNotFound = Strings.colorize("&cThere are no in-progress games with room! Try joining a new game!"); @Setting("chat-waiting") - private Text chatWaiting = TextParser.a("&7%player%&f: %message%"); + private Text chatWaiting = TextParser.parse("&7%player%&f: %message%"); @Setting("game-you-left") - private String gameYouLeft = Strings.a("&cYou left the game!"); + private String gameYouLeft = Strings.colorize("&cYou left the game!"); @Setting("game-no-reservation") - private String gameNoReservation = Strings.a("&cNo reservation found!"); + private String gameNoReservation = Strings.colorize("&cNo reservation found!"); @Setting("spectator-title") - private String spectatorTitle = Strings.a("Spectator settings"); + private String spectatorTitle = Strings.colorize("Spectator settings"); @Setting("spectator-item-no-speed") - private String spectatorItemNoSpeed = Strings.a("&aNo speed"); + private String spectatorItemNoSpeed = Strings.colorize("&aNo speed"); @Setting("spectator-item-speed-1") - private String spectatorItemSpeed1 = Strings.a("&aSpeed 1"); + private String spectatorItemSpeed1 = Strings.colorize("&aSpeed 1"); @Setting("spectator-item-speed-2") - private String spectatorItemSpeed2 = Strings.a("&aSpeed 2"); + private String spectatorItemSpeed2 = Strings.colorize("&aSpeed 2"); @Setting("spectator-item-speed-3") - private String spectatorItemSpeed3 = Strings.a("&aSpeed 3"); + private String spectatorItemSpeed3 = Strings.colorize("&aSpeed 3"); @Setting("spectator-item-speed-4") - private String spectatorItemSpeed4 = Strings.a("&aSpeed 4"); + private String spectatorItemSpeed4 = Strings.colorize("&aSpeed 4"); @Setting("spectator-item-teleport-on") - private String spectatorItemTeleportOn = Strings.a("&aEnable Auto Teleport"); + private String spectatorItemTeleportOn = Strings.colorize("&aEnable Auto Teleport"); @Setting("spectator-item-teleport-off") - private String spectatorItemTeleportOff = Strings.a("&cDisable Auto Teleport"); + private String spectatorItemTeleportOff = Strings.colorize("&cDisable Auto Teleport"); @Setting("spectator-item-night-vision-on") - private String spectatorItemNightVisionOn = Strings.a("&aEnable Night Vision"); + private String spectatorItemNightVisionOn = Strings.colorize("&aEnable Night Vision"); @Setting("spectator-item-night-vision-off") - private String spectatorItemNightVisionOff = Strings.a("&cDisable Night Vision"); + private String spectatorItemNightVisionOff = Strings.colorize("&cDisable Night Vision"); @Setting("spectator-item-first-person-on") - private String spectatorItemFirstPersonOn = Strings.a("&aEnable First Person"); + private String spectatorItemFirstPersonOn = Strings.colorize("&aEnable First Person"); @Setting("spectator-item-first-person-off") - private String spectatorItemFirstPersonOff = Strings.a("&cDisable First Person"); + private String spectatorItemFirstPersonOff = Strings.colorize("&cDisable First Person"); @Setting("spectator-no-speed") - private String spectatorNoSpeed = Strings.a("&cYou no longer have any speed effects!"); + private String spectatorNoSpeed = Strings.colorize("&cYou no longer have any speed effects!"); @Setting("spectator-speed-1") - private String spectatorSpeed1 = Strings.a("&aYou now have Speed 1"); + private String spectatorSpeed1 = Strings.colorize("&aYou now have Speed 1"); @Setting("spectator-speed-2") - private String spectatorSpeed2 = Strings.a("&aYou now have Speed 2"); + private String spectatorSpeed2 = Strings.colorize("&aYou now have Speed 2"); @Setting("spectator-speed-3") - private String spectatorSpeed3 = Strings.a("&aYou now have Speed 3"); + private String spectatorSpeed3 = Strings.colorize("&aYou now have Speed 3"); @Setting("spectator-speed-4") - private String spectatorSpeed4 = Strings.a("&aYou now have Speed 4"); + private String spectatorSpeed4 = Strings.colorize("&aYou now have Speed 4"); @Setting("spectator-teleport-on") - private String spectatorTeleportOn = Strings.a("&aOnce you select a player using your compass, it will auto teleport you to them!"); + private String spectatorTeleportOn = Strings.colorize("&aOnce you select a player using your compass, it will auto teleport you to them!"); @Setting("spectator-teleport-off") - private String spectatorTeleportOff = Strings.a("&cYou will no longer auto teleport to targets!"); + private String spectatorTeleportOff = Strings.colorize("&cYou will no longer auto teleport to targets!"); @Setting("spectator-night-vision-on") - private String spectatorNightVisionOn = Strings.a("&aYou now have night vision!"); + private String spectatorNightVisionOn = Strings.colorize("&aYou now have night vision!"); @Setting("spectator-night-vision-off") - private String spectatorNightVisionOff = Strings.a("&cYou no longer have night vision!"); + private String spectatorNightVisionOff = Strings.colorize("&cYou no longer have night vision!"); @Setting("spectator-first-person-on") - private String spectatorFirstPersonOn = Strings.a("&aYou will now by default use First Person spectating!"); + private String spectatorFirstPersonOn = Strings.colorize("&aYou will now by default use First Person spectating!"); @Setting("spectator-first-person-off") - private String spectatorFirstPersonOff = Strings.a("&cYou will now by default use Third Person spectating!"); + private String spectatorFirstPersonOff = Strings.colorize("&cYou will now by default use Third Person spectating!"); @Setting("party-not-available") - private String partyNotAvailable = Strings.a("&cThe party is not available!"); + private String partyNotAvailable = Strings.colorize("&cThe party is not available!"); @Setting("party-already-in-a-party") - private String partyAlreadyInAParty = Strings.a("&cPlayer is already in a party!"); + private String partyAlreadyInAParty = Strings.colorize("&cPlayer is already in a party!"); @Setting("party-not-in-a-party") - private String partyNotInAParty = Strings.a("&cPlayer is not in a party!"); + private String partyNotInAParty = Strings.colorize("&cPlayer is not in a party!"); @Setting("party-not-in-your-party") - private String partyNotInYourParty = Strings.a("&cThe player is not in your party!"); + private String partyNotInYourParty = Strings.colorize("&cThe player is not in your party!"); @Setting("party-not-a-leader") - private String partyNotALeader = Strings.a("&cYou are not the leader of this party!"); + private String partyNotALeader = Strings.colorize("&cYou are not the leader of this party!"); @Setting("party-kick-leader-denied") - private String partyKickLeaderDenied = Strings.a("&cThe party leader cannot be kicked."); + private String partyKickLeaderDenied = Strings.colorize("&cThe party leader cannot be kicked."); @Setting("party-disbanded") - private String partyDisbanded = Strings.a("&aThe party has been disbanded!"); + private String partyDisbanded = Strings.colorize("&aThe party has been disbanded!"); @Setting("party-left") - private String partyLeft = Strings.a("&aYou left the party!"); + private String partyLeft = Strings.colorize("&aYou left the party!"); @Setting("party-player-left") - private Text partyPlayerLeft = TextParser.a("&a%player% &eleft the party!"); + private Text partyPlayerLeft = TextParser.parse("&a%player% &eleft the party!"); @Setting("party-only-leader") - private String partyOnlyLeader = Strings.a("&cOnly the party leader can join games!"); + private String partyOnlyLeader = Strings.colorize("&cOnly the party leader can join games!"); @Setting("party-kick-by-you") - private String partyKickByYou = Strings.a("&aThe player has been kicked from your party!"); + private String partyKickByYou = Strings.colorize("&aThe player has been kicked from your party!"); @Setting("party-kick-received") - private String partyKickReceived = Strings.a("&aYou have been kicked from this party!"); + private String partyKickReceived = Strings.colorize("&aYou have been kicked from this party!"); @Setting("party-invited-sent") - private Text partyInvitedSent = TextParser.a("&eYou've invited &a%player% &eto the party!"); + private Text partyInvitedSent = TextParser.parse("&eYou've invited &a%player% &eto the party!"); @Setting("party-invited-received") - private Text partyInvitedReceived = TextParser.a("&eYou've been invited to &a%player%&e's party!"); + private Text partyInvitedReceived = TextParser.parse("&eYou've been invited to &a%player%&e's party!"); @Setting("party-invitation-not-found") - private String partyInvitationNotFound = Strings.a("&cYou have not been invited by this party!"); + private String partyInvitationNotFound = Strings.colorize("&cYou have not been invited by this party!"); @Setting("party-invitation-yourself") - private String partyInvitationYourself = Strings.a("&cYou can't invite yourself!"); + private String partyInvitationYourself = Strings.colorize("&cYou can't invite yourself!"); @Setting("party-invitation-accepted") - private String partyInvitationAccepted = Strings.a("&aYou've accepted the party invitation!"); + private String partyInvitationAccepted = Strings.colorize("&aYou've accepted the party invitation!"); @Setting("party-invitation-accepted-by-player") - private Text partyInvitationAcceptedByPlayer = TextParser.a("&a%player% &ehas joined the party!"); + private Text partyInvitationAcceptedByPlayer = TextParser.parse("&a%player% &ehas joined the party!"); @Setting("party-invitation-denied") - private String partyInvitationDenied = Strings.a("&aYou've denied the party invitation!"); + private String partyInvitationDenied = Strings.colorize("&aYou've denied the party invitation!"); @Setting("party-invitation-denied-by-player") - private Text partyInvitationDeniedByPlayer = TextParser.a("&a%player% &chas denied the party invitation!"); + private Text partyInvitationDeniedByPlayer = TextParser.parse("&a%player% &chas denied the party invitation!"); @Setting("party-info") - private List partyInfo = TextParser.a(new String[]{"&eParty Info: ", "&cOwner: &a%owner%", "&3Members (&f%amount%&3): &a%members%"}); + private List partyInfo = TextParser.parseAll(new String[]{"&eParty Info: ", "&cOwner: &a%owner%", "&3Members (&f%amount%&3): &a%members%"}); @Setting("leaderboard-none") private String leaderboardNone = "None"; @Setting("leaderboard-time-lifetime") @@ -120,11 +120,11 @@ public class EngineMessages implements Configuration { @Setting("leaderboard-time-weekly") private String leaderboardTimeWeekly = "Weekly"; @Setting("leaderboard-position") - private Text leaderboardPosition = TextParser.a("&aShowing &b&l%position%&a positions!"); + private Text leaderboardPosition = TextParser.parse("&aShowing &b&l%position%&a positions!"); @Setting("leaderboard-name-papi-format") - private String leaderboardNamePapiFormat = Strings.a("%name%"); + private String leaderboardNamePapiFormat = Strings.colorize("%name%"); @Setting("leaderboard") - private List leaderboard = TextParser.a( + private List leaderboard = TextParser.parseAll( new String[]{ "&b&l%time% %type%", "&7%mode%", @@ -144,7 +144,7 @@ public class EngineMessages implements Configuration { } ); @Setting("toggler") - private List toggler = TextParser.a(new String[]{"&b&l&nClick to toggle!", "&a&l%mode_1%", "&7%mode_2%", "&7%mode_3%"}); + private List toggler = TextParser.parseAll(new String[]{"&b&l&nClick to toggle!", "&a&l%mode_1%", "&7%mode_2%", "&7%mode_3%"}); public String getCommandNoPermission() { return this.commandNoPermission; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/reflection/ConfigurationReflection.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/reflection/ConfigurationReflection.java index a1a93eb..6a449da 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/reflection/ConfigurationReflection.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/reflection/ConfigurationReflection.java @@ -16,8 +16,8 @@ import ro.fr33styler.arcade.api.engine.config.InvalidConfigException; import ro.fr33styler.arcade.api.engine.config.SettingField; public class ConfigurationReflection { - public static Object a(SettingField settingField) { - Class clazz = a(settingField.getGenericType()); + public static Object getOrCreateConfiguration(SettingField settingField) { + Class clazz = resolveRawClass(settingField.getGenericType()); if (settingField.getType() == clazz) { Object obj = settingField.get(); if (obj != null) { @@ -28,13 +28,13 @@ public class ConfigurationReflection { return settingField.newInstance(); } - public static Object b(SettingField settingField) { - Class clazz = a(settingField.getGenericType()); + public static Object getOrCreateArray(SettingField settingField) { + Class clazz = resolveRawClass(settingField.getGenericType()); return settingField.getType() == clazz ? settingField.get() : Array.newInstance(clazz, 0); } - public static Collection c(SettingField settingField) { - Class clazz = a(settingField.getGenericType()); + public static Collection getOrCreateCollection(SettingField settingField) { + Class clazz = resolveRawClass(settingField.getGenericType()); if (settingField.getType() == clazz) { return (Collection)settingField.get(); } else if (Set.class.isAssignableFrom(clazz)) { @@ -46,12 +46,12 @@ public class ConfigurationReflection { } } - public static Map d(SettingField settingField) { - Class clazz = a(settingField.getGenericType()); + public static Map getOrCreateMap(SettingField settingField) { + Class clazz = resolveRawClass(settingField.getGenericType()); return settingField.getType() == clazz ? (Map)settingField.get() : new HashMap<>(); } - public static Class a(Type type) { + public static Class resolveRawClass(Type type) { if (type instanceof Class var1) { return var1.isArray() ? var1.getComponentType() : var1; } else if (type instanceof ParameterizedType var2) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/registry/DefaultTypeRegistry.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/registry/DefaultTypeRegistry.java index 77f4cad..45e99cc 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/registry/DefaultTypeRegistry.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/registry/DefaultTypeRegistry.java @@ -38,11 +38,11 @@ public class DefaultTypeRegistry implements TypeRegistry { private final Map, TypeToken> map = new HashMap<>(); public DefaultTypeRegistry(ConfigManager configManager) { - this.a(); - this.a(configManager); + this.registerScalarTokens(); + this.registerComplexTokens(configManager); } - private void a() { + private void registerScalarTokens() { this.register(boolean.class, Boolean.class, new BooleanTypeToken()); this.register(int.class, Integer.class, new IntegerTypeToken()); this.register(long.class, Long.class, new LongTypeToken()); @@ -52,7 +52,7 @@ public class DefaultTypeRegistry implements TypeRegistry { this.register(String.class, new StringTypeToken()); } - private void a(ConfigManager configManager) { + private void registerComplexTokens(ConfigManager configManager) { this.register(Block.class, new BlockTypeToken()); this.register(Location.class, new LocationTypeToken()); this.register(Enum.class, new EnumTypeToken()); @@ -72,7 +72,7 @@ public class DefaultTypeRegistry implements TypeRegistry { this.map.put(clazz, typeToken); } - private Class a(Class clazz) { + private Class resolveRegisteredType(Class clazz) { if (this.map.containsKey(clazz)) { return clazz; } @@ -87,7 +87,7 @@ public class DefaultTypeRegistry implements TypeRegistry { } public TypeToken get(Class clazz, String text) { - TypeToken typeToken = this.map.get(this.a(clazz)); + TypeToken typeToken = this.map.get(this.resolveRegisteredType(clazz)); if (typeToken == null) { throw GenericTypeValidation.re$propagate(new InvalidConfigException("The type for the setting '" + text + "' is not registered!")); } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/config/validation/GenericTypeValidation.java b/common/src/main/java/ro/fr33styler/arcade/engine/config/validation/GenericTypeValidation.java index 296311b..fb546d2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/config/validation/GenericTypeValidation.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/config/validation/GenericTypeValidation.java @@ -9,13 +9,13 @@ public class GenericTypeValidation { public static RuntimeException re$propagate(Throwable cause) throws E { throw (E)cause; } - public static void a(Type[] types) { + public static void validateListGenericTypes(Type[] types) { if (types.length != 1) { throw GenericTypeValidation.re$propagate(new InvalidConfigException("The list must have a generic parameter!")); } } - public static void b(Type[] types) { + public static void validateMapGenericTypes(Type[] types) { if (types.length != 2) { throw GenericTypeValidation.re$propagate(new InvalidConfigException("The map must have 2 generic parameters!")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/core/DefaultEngine.java b/common/src/main/java/ro/fr33styler/arcade/engine/core/DefaultEngine.java index 7a395e2..26eeb66 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/core/DefaultEngine.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/core/DefaultEngine.java @@ -116,7 +116,7 @@ public class DefaultEngine implements Engine { } public PartyManager getPartyManager() { - return this.partyManagerFactory.c(); + return this.partyManagerFactory.getPartyManager(); } public DisplayManager getDisplayManager() { @@ -156,26 +156,26 @@ public class DefaultEngine implements Engine { } public void start() { - this.users.a(); + this.users.loadOnlineUsers(); this.loadConfigs(); this.registerIntegrations(); - this.databaseManager.g(); + this.databaseManager.start(); if (this.plugin.isEnabled()) { - this.ticker.a(); - this.gameManagerRegistry.d(); + this.ticker.start(); + this.gameManagerRegistry.start(); this.addonManager.start(); - this.networkManager.d(); - this.partyManagerFactory.a(); - this.users.a(player -> VersionAdapters.get().updatePlayerCommands(player)); + this.networkManager.start(); + this.partyManagerFactory.load(); + this.users.forEachPlayer(player -> VersionAdapters.get().updatePlayerCommands(player)); this.plugin.getServer().getPluginManager().registerEvents(this.inventoryListener, this.plugin); this.plugin.getServer().getPluginManager().registerEvents(this.gameActionListener, this.plugin); this.gameActionListener.registerExtraListeners(); - VersionAdapters.get().registerSwapHandListener(this.plugin, this.platform, player -> this.gameActionListener.a(player, GameAction.CLICK) ? true : null); + VersionAdapters.get().registerSwapHandListener(this.plugin, this.platform, player -> this.gameActionListener.isActionBlocked(player, GameAction.CLICK) ? true : null); } } private void registerIntegrations() { - this.integrations.a(new PlaceholderApiIntegration(this)); + this.integrations.register(new PlaceholderApiIntegration(this)); } private void loadConfigs() { @@ -186,17 +186,17 @@ public class DefaultEngine implements Engine { } public void stop() { - this.ticker.b(); + this.ticker.stop(); this.addonManager.stop(); - this.networkManager.e(); - this.partyManagerFactory.b(); - this.displayManager.getViewers().a(); - this.gameManagerRegistry.e(); - this.databaseManager.l(); - this.users.b(); + this.networkManager.stop(); + this.partyManagerFactory.unload(); + this.displayManager.getViewers().clear(); + this.gameManagerRegistry.stop(); + this.databaseManager.stop(); + this.users.unloadOnlineUsers(); HandlerList.unregisterAll(this.inventoryListener); HandlerList.unregisterAll(this.gameActionListener); VersionAdapters.get().unregisterSwapHandListener(); - this.integrations.a(); + this.integrations.disableAll(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/DisplayManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/DisplayManager.java index 668aeb0..9e898a5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/DisplayManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/DisplayManager.java @@ -28,15 +28,15 @@ public class DisplayManager implements Runnable { private final ViewerManager viewers = new DefaultViewerManager(); - private int c; + private int tickCounter; - private final List d = new ArrayList<>(); + private final List npcDisplays = new ArrayList<>(); - private final Map e = new HashMap<>(); + private final Map commandSigns = new HashMap<>(); - private final Map f = new HashMap<>(); + private final Map leaderboardGroups = new HashMap<>(); - private final List g = new ArrayList<>(); + private final List leaderboardToggles = new ArrayList<>(); public DisplayManager(DefaultEngine engine2) { this.engine = engine2; @@ -46,119 +46,119 @@ public class DisplayManager implements Runnable { return this.viewers; } - public Map b() { - return this.f; + public Map getLeaderboardGroups() { + return this.leaderboardGroups; } - public List c() { - return this.g; + public List getLeaderboardToggles() { + return this.leaderboardToggles; } - public void a(LeaderboardSource leaderboardSource) { - LeaderboardGroup leaderboardGroup = this.f.get(leaderboardSource.getSettings().getId()); + public void registerLeaderboardSource(LeaderboardSource leaderboardSource) { + LeaderboardGroup leaderboardGroup = this.leaderboardGroups.get(leaderboardSource.getSettings().getId()); if (leaderboardGroup != null) { leaderboardGroup.getMap().put(leaderboardSource.getSettings().getMode(), leaderboardSource); - this.a(leaderboardGroup); + this.updateLeaderboardGroup(leaderboardGroup); } } - public void a(GameLeaderboardSettings gameLeaderboardSettings) { - LeaderboardGroup leaderboardGroup = this.f.get(gameLeaderboardSettings.getId()); + public void unregisterLeaderboardSource(GameLeaderboardSettings gameLeaderboardSettings) { + LeaderboardGroup leaderboardGroup = this.leaderboardGroups.get(gameLeaderboardSettings.getId()); if (leaderboardGroup != null) { leaderboardGroup.getMap().remove(gameLeaderboardSettings.getMode()); - this.a(leaderboardGroup); + this.updateLeaderboardGroup(leaderboardGroup); } } - public void a(String text, Location location) { + public void addLeaderboardGroup(String text, Location location) { LeaderboardGroup leaderboardGroup = new LeaderboardGroup(this.engine, text, location); - this.f.put(text, leaderboardGroup); - this.engine.getUsers().a(leaderboardGroup); + this.leaderboardGroups.put(text, leaderboardGroup); + this.engine.getUsers().addLeaderboardGroup(leaderboardGroup); } - public void d() { - this.f.values().forEach(leaderboardGroup -> this.engine.getUsers().b(leaderboardGroup)); - this.f.clear(); + public void clearLeaderboardGroups() { + this.leaderboardGroups.values().forEach(leaderboardGroup -> this.engine.getUsers().removeLeaderboardGroup(leaderboardGroup)); + this.leaderboardGroups.clear(); } - public void e() { - this.f.values().forEach(LeaderboardGroup::e); + public void refreshLeaderboardGroups() { + this.leaderboardGroups.values().forEach(LeaderboardGroup::refresh); } - public void a(String text, LeaderboardToggleSettings leaderboardToggleSettings) { + public void addLeaderboardToggle(String text, LeaderboardToggleSettings leaderboardToggleSettings) { LeaderboardToggle leaderboardToggle = new LeaderboardToggle(this.engine, text, leaderboardToggleSettings); - this.g.add(leaderboardToggle); - leaderboardToggle.f(); - this.engine.getUsers().a(leaderboardToggle); + this.leaderboardToggles.add(leaderboardToggle); + leaderboardToggle.refreshAvailableModes(); + this.engine.getUsers().addLeaderboardToggle(leaderboardToggle); } - public void f() { - this.g.forEach(leaderboardToggle -> this.engine.getUsers().b(leaderboardToggle)); - this.g.clear(); + public void clearLeaderboardToggles() { + this.leaderboardToggles.forEach(leaderboardToggle -> this.engine.getUsers().removeLeaderboardToggle(leaderboardToggle)); + this.leaderboardToggles.clear(); } - public void g() { - this.g.forEach(LeaderboardToggle::f); + public void refreshLeaderboardToggles() { + this.leaderboardToggles.forEach(LeaderboardToggle::refreshAvailableModes); } - public void a(LeaderboardGroup leaderboardGroup) { - this.g(); - this.engine.getUsers().c(leaderboardGroup); + public void updateLeaderboardGroup(LeaderboardGroup leaderboardGroup) { + this.refreshLeaderboardToggles(); + this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup); } - public void a(NpcDisplaySettings npcDisplaySettings) { + public void addNpcDisplay(NpcDisplaySettings npcDisplaySettings) { NpcDisplay npcDisplay = new NpcDisplay(this.engine, npcDisplaySettings); - this.d.add(npcDisplay); - this.viewers.a(npcDisplay); + this.npcDisplays.add(npcDisplay); + this.viewers.register(npcDisplay); } - public NpcDisplay a(Location location) { - for (NpcDisplay npcDisplay : this.d) { - if (Locations.a(npcDisplay.getLocation(), location, 1.8)) { + public NpcDisplay getNpcDisplay(Location location) { + for (NpcDisplay npcDisplay : this.npcDisplays) { + if (Locations.isNear(npcDisplay.getLocation(), location, 1.8)) { return npcDisplay; } } return null; } - public void b(Location location) { - NpcDisplay npcDisplay = this.a(location); + public void removeNpcDisplay(Location location) { + NpcDisplay npcDisplay = this.getNpcDisplay(location); if (npcDisplay != null) { - this.viewers.b(npcDisplay); - this.d.remove(npcDisplay); + this.viewers.unregister(npcDisplay); + this.npcDisplays.remove(npcDisplay); } } - public void a(int index, Player player) { - for (NpcDisplay npcDisplay : this.d) { - if (npcDisplay.a() == index) { - npcDisplay.a(player); + public void handleNpcInteract(int index, Player player) { + for (NpcDisplay npcDisplay : this.npcDisplays) { + if (npcDisplay.getEntityId() == index) { + npcDisplay.executeCommand(player); break; } } } - public void a(Block block, String text, List list, Context context) { + public void addCommandSign(Block block, String text, List list, Context context) { CommandSign commandSign = new CommandSign(block, text, list, context); - this.e.put(block, commandSign); - commandSign.a(); + this.commandSigns.put(block, commandSign); + commandSign.update(); } - public CommandSign a(Block block) { - return this.e.get(block); + public CommandSign getCommandSign(Block block) { + return this.commandSigns.get(block); } - public void b(Block block) { - this.e.remove(block); + public void removeCommandSign(Block block) { + this.commandSigns.remove(block); } @Override public void run() { - this.c++; - this.d.forEach(NpcDisplay::b); - this.e.values().forEach(CommandSign::a); - if (this.c % this.engine.getSettings().getUpdateLeaderboardCacheInSeconds() == 0) { - this.e(); + this.tickCounter++; + this.npcDisplays.forEach(NpcDisplay::updateHologram); + this.commandSigns.values().forEach(CommandSign::update); + if (this.tickCounter % this.engine.getSettings().getUpdateLeaderboardCacheInSeconds() == 0) { + this.refreshLeaderboardGroups(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/hologram/Hologram.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/hologram/Hologram.java index 464b165..7d525a4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/hologram/Hologram.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/hologram/Hologram.java @@ -17,7 +17,7 @@ import org.bukkit.entity.Player; public class Hologram implements Viewable { private final Location location; private HologramEntity[] hologramEntitys = new HologramEntity[0]; - private String[] c = new String[0]; + private String[] lines = new String[0]; private final Set set; public Hologram(Location location2) { @@ -37,7 +37,7 @@ public class Hologram implements Viewable { return this.set; } - public boolean a(int index) { + public boolean hasEntityId(int index) { for (HologramEntity hologramEntity : this.hologramEntitys) { if (hologramEntity.getEntity().getEntityId() == index) { return true; @@ -47,13 +47,13 @@ public class Hologram implements Viewable { return false; } - public void a(Player player, boolean flag) { + public void setVisible(Player player, boolean flag) { for (HologramEntity hologramEntity : this.hologramEntitys) { hologramEntity.setVisible(player, flag); } } - private void a(HologramEntity hologramEntity) { + private void updateMetadata(HologramEntity hologramEntity) { for (UUID uuid : this.set) { Player player = Bukkit.getPlayer(uuid); if (player != null) { @@ -62,65 +62,65 @@ public class Hologram implements Viewable { } } - public void a(ServerPlatform serverPlatform, String... texts) { - this.a(serverPlatform, Arrays.asList(texts)); + public void setLines(ServerPlatform serverPlatform, String... texts) { + this.setLines(serverPlatform, Arrays.asList(texts)); } - public void a(ServerPlatform serverPlatform, List list) { + public void setLines(ServerPlatform serverPlatform, List list) { if (list.size() != this.hologramEntitys.length) { - this.a(serverPlatform, list.size()); + this.resize(serverPlatform, list.size()); } for (int index = list.size() - 1; index >= 0; index--) { int index2 = list.size() - index - 1; HologramEntity hologramEntity = this.hologramEntitys[index2]; String text = (String)list.get(index); - String text2 = this.c[index2]; + String text2 = this.lines[index2]; if (text2 == null || !text2.equals(text)) { hologramEntity.setText(text); - this.c[index2] = text; - this.a(hologramEntity); + this.lines[index2] = text; + this.updateMetadata(hologramEntity); } } } - private void a(HologramEntity[] hologramEntitys2, String[] texts, int index) { + private void shrink(HologramEntity[] hologramEntitys2, String[] texts, int index) { for (int index2 = index; index2 < this.hologramEntitys.length; index2++) { - this.a(this.hologramEntitys[index2], false); + this.setEntityVisible(this.hologramEntitys[index2], false); } System.arraycopy(this.hologramEntitys, 0, hologramEntitys2, 0, index); - System.arraycopy(this.c, 0, texts, 0, index); + System.arraycopy(this.lines, 0, texts, 0, index); } - private void a(HologramEntity[] hologramEntitys2, String[] texts, ServerPlatform serverPlatform, int index) { + private void grow(HologramEntity[] hologramEntitys2, String[] texts, ServerPlatform serverPlatform, int index) { World world = this.location.getWorld(); double doubleVal = this.location.getY() + this.hologramEntitys.length * 0.3; for (int index2 = this.hologramEntitys.length; index2 < index; index2++) { hologramEntitys2[index2] = serverPlatform.createHologram(world, this.location.getX(), doubleVal, this.location.getZ()); - this.a(hologramEntitys2[index2], true); + this.setEntityVisible(hologramEntitys2[index2], true); doubleVal += 0.3; } System.arraycopy(this.hologramEntitys, 0, hologramEntitys2, 0, this.hologramEntitys.length); - System.arraycopy(this.c, 0, texts, 0, this.hologramEntitys.length); + System.arraycopy(this.lines, 0, texts, 0, this.hologramEntitys.length); } - private void a(ServerPlatform serverPlatform, int index) { + private void resize(ServerPlatform serverPlatform, int index) { HologramEntity[] hologramEntitys2 = new HologramEntity[index]; String[] texts = new String[index]; if (this.hologramEntitys.length < index) { - this.a(hologramEntitys2, texts, serverPlatform, index); + this.grow(hologramEntitys2, texts, serverPlatform, index); } else { - this.a(hologramEntitys2, texts, index); + this.shrink(hologramEntitys2, texts, index); } this.hologramEntitys = hologramEntitys2; - this.c = texts; + this.lines = texts; } - private void a(HologramEntity hologramEntity, boolean flag) { + private void setEntityVisible(HologramEntity hologramEntity, boolean flag) { for (UUID uuid : this.set) { Player player = Bukkit.getPlayer(uuid); if (player != null) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/NpcDisplay.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/NpcDisplay.java index cbb5f19..39ad9e7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/NpcDisplay.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/NpcDisplay.java @@ -26,7 +26,7 @@ public class NpcDisplay implements Viewable { private final Npc npc; private final Hologram hologram; private final DefaultEngine engine; - private final String e = Randoms.a(8); + private final String npcName = Randoms.randomAlphanumeric(8); private final Set set = new HashSet<>(); public NpcDisplay(DefaultEngine engine2, NpcDisplaySettings settings2) { @@ -35,11 +35,11 @@ public class NpcDisplay implements Viewable { SkinTexture skinTexture = settings2.getSkinTexture(); NpcEquipment npcEquipment = settings2.getNpcEquipment(); Location location = settings2.getLocation(); - this.hologram = new Hologram(Locations.a(location).add(0.0, 1.9, 0.0), this.set); - this.npc = engine2.getPlatform().getNpcFactory().createNpc(location, this.e, skinTexture, npcEquipment); + this.hologram = new Hologram(Locations.copy(location).add(0.0, 1.9, 0.0), this.set); + this.npc = engine2.getPlatform().getNpcFactory().createNpc(location, this.npcName, skinTexture, npcEquipment); } - public int a() { + public int getEntityId() { return this.npc.getEntityId(); } @@ -51,21 +51,21 @@ public class NpcDisplay implements Viewable { return this.set; } - public void a(Player player) { - player.performCommand(this.settings.d()); + public void executeCommand(Player player) { + player.performCommand(this.settings.getCommand()); } - public void a(Player player, boolean flag) { + public void setVisible(Player player, boolean flag) { if (flag) { - this.b(player); + this.hideNameTag(player); Bukkit.getScheduler().runTaskLater(this.engine.getPlugin(), () -> this.npc.removeFromTabList(player), 60L); } this.npc.setVisible(player, flag); - this.hologram.a(player, flag); + this.hologram.setVisible(player, flag); } - private void b(Player player) { + private void hideNameTag(Player player) { Team team = player.getScoreboard().getTeam("GameEngineNpc"); if (team == null) { team = player.getScoreboard().registerNewTeam("GameEngineNpc"); @@ -73,10 +73,10 @@ public class NpcDisplay implements Viewable { VersionAdapters.get().applyTeamNameTagVisibility(team, TeamRule.NEVER); } - team.addEntry(this.e); + team.addEntry(this.npcName); } - public void b() { - this.hologram.a(this.engine.getPlatform(), TextRenderer.a(this.settings.getList(), this.settings.getContext())); + public void updateHologram() { + this.hologram.setLines(this.engine.getPlatform(), TextRenderer.render(this.settings.getList(), this.settings.getContext())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/AddNpcCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/AddNpcCommand.java index ed58bbc..4e79df2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/AddNpcCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/AddNpcCommand.java @@ -24,13 +24,13 @@ public class AddNpcCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { Player player = (Player)sender; - if (this.manager.getEngine().getDisplayManager().a(player.getLocation()) != null) { + if (this.manager.getEngine().getDisplayManager().getNpcDisplay(player.getLocation()) != null) { player.sendMessage("§cYou can only have 1 npc on the same location!"); } else { Location location = player.getLocation(); this.manager.spawnNpcDisplay(location); - this.manager.getStorage().getStorage2().getNpcs().add(location); - this.manager.getStorage().getStorage2().c(); + this.manager.getStorage().getNpcStorage().getNpcs().add(location); + this.manager.getStorage().getNpcStorage().save(); player.sendMessage("§aNPC added!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/RemoveNpcCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/RemoveNpcCommand.java index 517d729..3d78bae 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/RemoveNpcCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/command/RemoveNpcCommand.java @@ -32,14 +32,14 @@ public class RemoveNpcCommand extends BaseCommandExecutor { for (int index2 = 0; index2 < 20; index2++) { location.add(vector); - Iterator iterator = this.manager.getStorage().getStorage2().getNpcs().iterator(); + Iterator iterator = this.manager.getStorage().getNpcStorage().getNpcs().iterator(); while (iterator.hasNext()) { Location location2 = (Location)iterator.next(); - if (Locations.b(location2, location) <= 4.0) { + if (Locations.distanceSquared(location2, location) <= 4.0) { iterator.remove(); - this.manager.getEngine().getDisplayManager().b(location2); - this.manager.getStorage().getStorage2().c(); + this.manager.getEngine().getDisplayManager().removeNpcDisplay(location2); + this.manager.getStorage().getNpcStorage().save(); player.sendMessage("§aNPC removed!"); return; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/config/NpcDisplaySettings.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/config/NpcDisplaySettings.java index ba37c49..3e4b39b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/config/NpcDisplaySettings.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/config/NpcDisplaySettings.java @@ -12,7 +12,7 @@ public class NpcDisplaySettings { private List list; private Context context; private Location location; - private String d; + private String command; private SkinTexture skinTexture; private NpcEquipment npcEquipment; @@ -40,12 +40,12 @@ public class NpcDisplaySettings { this.location = location2; } - public String d() { - return this.d; + public String getCommand() { + return this.command; } - public void a(String text) { - this.d = text; + public void setCommand(String text) { + this.command = text; } public SkinTexture getSkinTexture() { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/storage/NpcStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/storage/NpcStorage.java index c177b7a..4ac09a8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/storage/NpcStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/npc/storage/NpcStorage.java @@ -23,11 +23,11 @@ public class NpcStorage implements Configuration { return this.npcs; } - public void b() { + public void load() { this.configManager.tryLoad(this, this.file); } - public void c() { + public void save() { this.configManager.trySave(this, this.file); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/DefaultViewerManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/DefaultViewerManager.java index 6b45f42..7239d71 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/DefaultViewerManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/DefaultViewerManager.java @@ -13,103 +13,103 @@ import org.bukkit.entity.Player; public class DefaultViewerManager implements ViewerManager { private final Map> map = new LinkedHashMap<>(); - public void a(Viewable viewable) { + public void register(Viewable viewable) { World world = viewable.getLocation().getWorld(); if (world != null) { this.map.computeIfAbsent(world.getUID(), uuid -> new ArrayList<>()).add(viewable); } } - public void b(Viewable viewable) { + public void unregister(Viewable viewable) { World world = viewable.getLocation().getWorld(); if (world != null) { - this.a(world.getUID(), viewable); + this.unregisterFromWorld(world.getUID(), viewable); } } - private void a(UUID uuid, Viewable viewable) { + private void unregisterFromWorld(UUID uuid, Viewable viewable) { List list = this.map.get(uuid); if (list != null) { - this.a(uuid, viewable, list); + this.removeFromWorldList(uuid, viewable, list); } } - private void a(UUID uuid, Viewable viewable, List list) { + private void removeFromWorldList(UUID uuid, Viewable viewable, List list) { list.remove(viewable); - this.c(viewable); + this.hideFromAll(viewable); if (list.isEmpty()) { this.map.remove(uuid); } } - public void a() { + public void clear() { for (List list : this.map.values()) { for (Viewable viewable : list) { - this.c(viewable); + this.hideFromAll(viewable); } } this.map.clear(); } - public void c(Viewable viewable) { + public void hideFromAll(Viewable viewable) { for (UUID uuid : viewable.getSet()) { Player player = Bukkit.getPlayer(uuid); if (player != null) { - viewable.a(player, false); + viewable.setVisible(player, false); } } } - public void a(Player player) { - this.a(player, player.getWorld().getUID()); + public void hideWorld(Player player) { + this.hideWorld(player, player.getWorld().getUID()); } - public void a(Player player, UUID uuid) { + public void hideWorld(Player player, UUID uuid) { List list = this.map.get(uuid); if (list != null) { - this.a(player, list); + this.hideAll(player, list); } } - private void a(Player player, List list) { + private void hideAll(Player player, List list) { for (Viewable viewable : list) { - this.b(player, viewable); + this.hide(player, viewable); } } - private void a(Player player, Viewable viewable) { - viewable.a(player, true); + private void show(Player player, Viewable viewable) { + viewable.setVisible(player, true); viewable.getSet().add(player.getUniqueId()); } - private void b(Player player, Viewable viewable) { - viewable.a(player, false); + private void hide(Player player, Viewable viewable) { + viewable.setVisible(player, false); viewable.getSet().remove(player.getUniqueId()); } - public void b(Player player) { + public void update(Player player) { List list = this.map.get(player.getWorld().getUID()); if (list != null) { - this.b(player, list); + this.updateAll(player, list); } } - private void b(Player player, List list) { + private void updateAll(Player player, List list) { Location location = player.getLocation(); for (Viewable viewable : list) { - this.a(player, location, viewable); + this.updateVisibility(player, location, viewable); } } - private void a(Player player, Location location, Viewable viewable) { + private void updateVisibility(Player player, Location location, Viewable viewable) { double doubleVal = location.distanceSquared(viewable.getLocation()); boolean flag = viewable.getSet().contains(player.getUniqueId()); if (flag && doubleVal > 3025.0) { - this.b(player, viewable); + this.hide(player, viewable); } else if (!flag && doubleVal <= 3025.0) { - this.a(player, viewable); + this.show(player, viewable); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewDistance.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewDistance.java index 98292bf..eec637b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewDistance.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewDistance.java @@ -8,7 +8,7 @@ import org.bukkit.Location; import org.bukkit.util.Vector; public class ViewDistance { - public static T a(Location location, Collection collection, Function function) { + public static T findTarget(Location location, Collection collection, Function function) { Vector vector = location.getDirection(); for (int index = 0; index < 20; index++) { @@ -17,7 +17,7 @@ public class ViewDistance { double doubleVal = 9.0; for (T obj2 : collection) { - double doubleVal2 = Locations.b((Location)function.apply(obj2), location); + double doubleVal2 = Locations.distanceSquared((Location)function.apply(obj2), location); if (doubleVal2 < doubleVal) { obj = obj2; doubleVal = doubleVal2; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/Viewable.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/Viewable.java index bab91a5..5f3ef04 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/Viewable.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/Viewable.java @@ -10,5 +10,5 @@ public interface Viewable { Set getSet(); - void a(Player var1, boolean var2); + void setVisible(Player var1, boolean var2); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewerManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewerManager.java index c2838a4..2cb9ef5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewerManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/display/viewer/ViewerManager.java @@ -4,15 +4,15 @@ import java.util.UUID; import org.bukkit.entity.Player; public interface ViewerManager { - void a(Viewable var1); + void register(Viewable var1); - void b(Viewable var1); + void unregister(Viewable var1); - void a(); + void clear(); - void a(Player var1); + void hideWorld(Player var1); - void a(Player var1, UUID var2); + void hideWorld(Player var1, UUID var2); - void b(Player var1); + void update(Player var1); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/effect/firework/Fireworks.java b/common/src/main/java/ro/fr33styler/arcade/engine/effect/firework/Fireworks.java index 36efab0..cdffe2f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/effect/firework/Fireworks.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/effect/firework/Fireworks.java @@ -14,38 +14,38 @@ import org.bukkit.entity.Firework; import org.bukkit.inventory.meta.FireworkMeta; public final class Fireworks { - private static final FireworkEffect[] a = new FireworkEffect[3]; - private static final Type[] b = new Type[]{Type.BURST, Type.BALL, Type.BALL_LARGE}; + private static final FireworkEffect[] DEFAULT_EFFECTS = new FireworkEffect[3]; + private static final Type[] DEFAULT_TYPES = new Type[]{Type.BURST, Type.BALL, Type.BALL_LARGE}; - public static Firework a(Location location) { - return a(location, (FireworkEffect)Randoms.a(a)); + public static Firework spawnRandom(Location location) { + return spawn(location, (FireworkEffect)Randoms.pickRandom(DEFAULT_EFFECTS)); } - public static void b(Location location) { - VersionAdapters.get().detonateFirework(null, a(location)); + public static void detonateRandom(Location location) { + VersionAdapters.get().detonateFirework(null, spawnRandom(location)); } - public static void a(ServerPlatform serverPlatform, Location location) { - VersionAdapters.get().detonateFirework(serverPlatform, a(location)); + public static void detonateRandom(ServerPlatform serverPlatform, Location location) { + VersionAdapters.get().detonateFirework(serverPlatform, spawnRandom(location)); } - public static Firework a(Location location, Color color) { - return a(location, (Type)Randoms.a(b), new Color[]{color}); + public static Firework spawnColored(Location location, Color color) { + return spawn(location, (Type)Randoms.pickRandom(DEFAULT_TYPES), new Color[]{color}); } - public static void a(ServerPlatform serverPlatform, Location location, Color color) { - VersionAdapters.get().detonateFirework(serverPlatform, a(location, color)); + public static void detonateColored(ServerPlatform serverPlatform, Location location, Color color) { + VersionAdapters.get().detonateFirework(serverPlatform, spawnColored(location, color)); } - public static Firework b(Location location, Color color) { - return a(location, (Type)Randoms.a(b), color); + public static Firework spawnWithColor(Location location, Color color) { + return spawn(location, (Type)Randoms.pickRandom(DEFAULT_TYPES), color); } - public static Firework a(Location location, Type type, Color... colors) { - return a(location, FireworkEffect.builder().withColor(colors).with(type).build()); + public static Firework spawn(Location location, Type type, Color... colors) { + return spawn(location, FireworkEffect.builder().withColor(colors).with(type).build()); } - public static Firework a(Location location, FireworkEffect fireworkEffect) { + public static Firework spawn(Location location, FireworkEffect fireworkEffect) { Validate.notNull(location.getWorld(), "The world cannot be null!"); Firework firework = (Firework)location.getWorld().spawn(location, Firework.class); FireworkMeta fireworkMeta = firework.getFireworkMeta(); @@ -58,8 +58,8 @@ public final class Fireworks { Builder var0 = FireworkEffect.builder(); var0.withColor(new Color[]{Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE}); - for (int var1 = 0; var1 < b.length; var1++) { - a[var1] = var0.with(b[var1]).build(); + for (int var1 = 0; var1 < DEFAULT_TYPES.length; var1++) { + DEFAULT_EFFECTS[var1] = var0.with(DEFAULT_TYPES[var1]).build(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGame.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGame.java index 39759e3..d80dbe9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGame.java @@ -149,7 +149,7 @@ public abstract class AbstractGame implements Game, Context { case "players" -> String.valueOf(this.getGamers().size()); case "min_players" -> String.valueOf(this.getMap().getMinimumPlayers()); case "max_players" -> String.valueOf(this.getMap().getMaximumPlayers()); - default -> (String)EngineUtils.a((Object)this.phase.getVariable(text), this.getManager().getVariable(text)); + default -> (String)EngineUtils.orElse((Object)this.phase.getVariable(text), this.getManager().getVariable(text)); }; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGameManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGameManager.java index ad44058..c5c3e15 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGameManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/AbstractGameManager.java @@ -159,9 +159,9 @@ public abstract class AbstractGameManager implements GameManager, Context { } protected void registerIntegrations() { - this.integrations.a(new GamePlaceholderIntegration(this)); + this.integrations.register(new GamePlaceholderIntegration(this)); VersionAdapters.get().registerVariantGameIntegrations(this.integrations, this); - this.integrations.a(new SlimeWorldManagerIntegration(this)); + this.integrations.register(new SlimeWorldManagerIntegration(this)); } protected void initDefaultProperties() { @@ -172,21 +172,21 @@ public abstract class AbstractGameManager implements GameManager, Context { } protected void populateMenu(GameMenuPage gameMenuPage, Context context) { - gameMenuPage.page().a(12, defaultUser -> { + gameMenuPage.page().setSlot(12, defaultUser -> { defaultUser.toPlayer().closeInventory(); - defaultUser.a(this.getSessions().getGameSearcher()); - }, new ItemBuilder(ArcadeMaterial.ENDER_EYE).setDisplayName(this.getMessages().getJoinGuiQuickJoinName(), context).setLore(TextRenderer.a(this.getMessages().getJoinGuiQuickJoinLore(), context)).build()); - gameMenuPage.page().a(14, defaultUser2 -> { + defaultUser.quickJoin(this.getSessions().getGameSearcher()); + }, new ItemBuilder(ArcadeMaterial.ENDER_EYE).setDisplayName(this.getMessages().getJoinGuiQuickJoinName(), context).setLore(TextRenderer.render(this.getMessages().getJoinGuiQuickJoinLore(), context)).build()); + gameMenuPage.page().setSlot(14, defaultUser2 -> { Player player = defaultUser2.toPlayer(); if (this.engine.getSettings().isPermissionOnMapSelector() && !player.hasPermission(this.id + ".map.selector")) { defaultUser2.sendMessage(this.getMessages().getMapSelectorNoPermission()); player.closeInventory(); } else { - gameMenuPage.mapSelector().a(defaultUser2); + gameMenuPage.mapSelector().open(defaultUser2); defaultUser2.setMenu(gameMenuPage.page()); } - }, new ItemBuilder(ArcadeMaterial.OAK_SIGN).setDisplayName(this.getMessages().getJoinGuiMapSelectorName(), context).setLore(TextRenderer.a(this.getMessages().getJoinGuiMapSelectorLore(), context)).build()); - gameMenuPage.page().a(31, defaultUser3 -> defaultUser3.toPlayer().closeInventory(), new ItemBuilder(Material.BARRIER).setDisplayName(this.getMessages().getJoinGuiClose()).build()); + }, new ItemBuilder(ArcadeMaterial.OAK_SIGN).setDisplayName(this.getMessages().getJoinGuiMapSelectorName(), context).setLore(TextRenderer.render(this.getMessages().getJoinGuiMapSelectorLore(), context)).build()); + gameMenuPage.page().setSlot(31, defaultUser3 -> defaultUser3.toPlayer().closeInventory(), new ItemBuilder(Material.BARRIER).setDisplayName(this.getMessages().getJoinGuiClose()).build()); } public void spawnNpcDisplay(Location location) { @@ -194,21 +194,21 @@ public abstract class AbstractGameManager implements GameManager, Context { npcDisplaySettings.setList(this.getMessages().getNpc()); npcDisplaySettings.setContext(this); npcDisplaySettings.setLocation(location); - npcDisplaySettings.a(this.getCommand().getCommand() + " gui"); + npcDisplaySettings.setCommand(this.getCommand().getCommand() + " gui"); npcDisplaySettings.setSkinTexture(this.getSettings().getNpcSkin()); npcDisplaySettings.setNpcEquipment(this.getSettings().getNpcEquipment()); - this.getEngine().getDisplayManager().a(npcDisplaySettings); + this.getEngine().getDisplayManager().addNpcDisplay(npcDisplaySettings); } protected void spawnNpcDisplays() { - for (Location location : this.getStorage().getStorage2().getNpcs()) { + for (Location location : this.getStorage().getNpcStorage().getNpcs()) { this.spawnNpcDisplay(location); } } protected void despawnNpcDisplays() { - for (Location location : this.getStorage().getStorage2().getNpcs()) { - this.getEngine().getDisplayManager().b(location); + for (Location location : this.getStorage().getNpcStorage().getNpcs()) { + this.getEngine().getDisplayManager().removeNpcDisplay(location); } } @@ -216,53 +216,53 @@ public abstract class AbstractGameManager implements GameManager, Context { Session session = this.getSessions().getSession(text); if (session != null) { String text2 = this.getCommand().getCommand() + " join " + text; - this.getEngine().getDisplayManager().a(block, text2, this.getMessages().getJoinSigns(), session); + this.getEngine().getDisplayManager().addCommandSign(block, text2, this.getMessages().getJoinSigns(), session); } } public void createQuickJoinSign(Block block) { String text = this.getCommand().getCommand() + " quickjoin"; - this.getEngine().getDisplayManager().a(block, text, this.getMessages().getQuickJoinSigns(), this); + this.getEngine().getDisplayManager().addCommandSign(block, text, this.getMessages().getQuickJoinSigns(), this); } protected void registerSigns() { - this.getStorage().getStorage3().getSigns().forEach((text, gameSignSettings) -> this.createJoinSign(gameSignSettings.getBlock(), gameSignSettings.getId())); - this.getStorage().getStorage3().getQuickJoinSigns().forEach(this::createQuickJoinSign); + this.getStorage().getSignStorage().getSigns().forEach((text, gameSignSettings) -> this.createJoinSign(gameSignSettings.getBlock(), gameSignSettings.getId())); + this.getStorage().getSignStorage().getQuickJoinSigns().forEach(this::createQuickJoinSign); } protected void unregisterSigns() { - this.getStorage().getStorage3().getSigns().forEach((text, gameSignSettings) -> this.getEngine().getDisplayManager().b(gameSignSettings.getBlock())); - this.getStorage().getStorage3().getQuickJoinSigns().forEach(block -> this.getEngine().getDisplayManager().b(block)); + this.getStorage().getSignStorage().getSigns().forEach((text, gameSignSettings) -> this.getEngine().getDisplayManager().removeCommandSign(gameSignSettings.getBlock())); + this.getStorage().getSignStorage().getQuickJoinSigns().forEach(block -> this.getEngine().getDisplayManager().removeCommandSign(block)); } public void registerLeaderboards() { - for (Entry entry : this.getStorage().getStorage4().getLeaderboards().entrySet()) { + for (Entry entry : this.getStorage().getLeaderboardStorage().getLeaderboards().entrySet()) { GameLeaderboardSettings gameLeaderboardSettings = (GameLeaderboardSettings)entry.getValue(); if (this.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) { LeaderboardSource leaderboardSource = this.createLeaderboardSource(gameLeaderboardSettings); - this.getEngine().getDisplayManager().a(leaderboardSource); - leaderboardSource.d(); + this.getEngine().getDisplayManager().registerLeaderboardSource(leaderboardSource); + leaderboardSource.refreshCache(); } } } public void unregisterLeaderboards() { - for (Entry entry : this.getStorage().getStorage4().getLeaderboards().entrySet()) { - this.getEngine().getDisplayManager().a((GameLeaderboardSettings)entry.getValue()); + for (Entry entry : this.getStorage().getLeaderboardStorage().getLeaderboards().entrySet()) { + this.getEngine().getDisplayManager().unregisterLeaderboardSource((GameLeaderboardSettings)entry.getValue()); } } public void buildGameMenu() { - InventoryMenu inventoryMenu = new InventoryMenu(this.getMessages().getJoinGuiName().a(this), 36); - GameMenu gameMenu = new GameMenu(this, () -> new ArrayList(this.getSessions().f().values())); + InventoryMenu inventoryMenu = new InventoryMenu(this.getMessages().getJoinGuiName().render(this), 36); + GameMenu gameMenu = new GameMenu(this, () -> new ArrayList(this.getSessions().getSessions().values())); this.menuPage = new GameMenuPage(inventoryMenu, gameMenu); this.populateMenu(this.menuPage, this); } protected void reloadConfig() { - this.getStorage().getStorage2().b(); - this.getStorage().getStorage3().c(); - this.getStorage().getStorage4().b(); + this.getStorage().getNpcStorage().load(); + this.getStorage().getSignStorage().load(); + this.getStorage().getLeaderboardStorage().load(); this.getConfigManager().tryLoad(this.getMessages(), new File(this.getDataFolder(), "messages.yml")); } @@ -277,13 +277,13 @@ public abstract class AbstractGameManager implements GameManager, Context { } public void start() { - TemplateCallbackLoader.a(this.engine); + TemplateCallbackLoader.load(this.engine); this.reloadConfig(); VersionAdapters.get().registerCommand(this.engine.getPlugin(), this.engine.getPlatform(), this.getCommand(), this.engine.getSettings().isUseBrigadierCommands()); - this.getStorage().e().b(); - this.engine.getUsers().a(this::loadPlayerData); - this.getSessions().a(); + this.getStorage().getStatisticsRepository().createTables(); + this.engine.getUsers().forEachPlayer(this::loadPlayerData); + this.getSessions().load(); this.spawnNpcDisplays(); this.registerSigns(); this.buildGameMenu(); @@ -292,14 +292,14 @@ public abstract class AbstractGameManager implements GameManager, Context { } public void stop() { - this.integrations.a(); + this.integrations.disableAll(); this.unregisterSigns(); this.despawnNpcDisplays(); this.unregisterLeaderboards(); - this.getSessions().c(); + this.getSessions().unload(); VersionAdapters.get().unregisterCommand(this.engine.getPlatform(), this.getCommand(), this.engine.getSettings().isUseBrigadierCommands()); - this.engine.getUsers().a(player -> this.unloadPlayerData(player.getUniqueId())); + this.engine.getUsers().forEachPlayer(player -> this.unloadPlayerData(player.getUniqueId())); } public String getVariable(String text) { @@ -308,17 +308,17 @@ public abstract class AbstractGameManager implements GameManager, Context { case "month" -> String.valueOf(LocalDate.now().getMonthValue()); case "year" -> String.valueOf(LocalDate.now().getYear()); case "display_name" -> this.getMessages().getDisplayName(); - case "players" -> String.valueOf(this.getSessions().i()); + case "players" -> String.valueOf(this.getSessions().getTotalPlayers()); case "version" -> this.getVersion(); - case "line" -> Strings.a; + case "line" -> Strings.SEPARATOR_LINE; default -> null; }; } public void onTick(long longVal) { - this.getSessions().a(longVal); + this.getSessions().onTick(longVal); if (longVal % 20L == 0L) { - this.menuPage.mapSelector().a(); + this.menuPage.mapSelector().update(); } } @@ -326,7 +326,7 @@ public abstract class AbstractGameManager implements GameManager, Context { int index = 0; int index2 = 0; - for (Entry entry : this.getSessions().f().entrySet()) { + for (Entry entry : this.getSessions().getSessions().entrySet()) { Session session = (Session)entry.getValue(); if (text.equals((String)entry.getKey() + "_players")) { return String.valueOf(session.getStatus().players()); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/BaseGameSettings.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/BaseGameSettings.java index 21dbe9c..ebc381f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/BaseGameSettings.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/BaseGameSettings.java @@ -43,7 +43,7 @@ public abstract class BaseGameSettings implements Configuration { @Setting("leave-game-data") private int leaveGameData = VersionAdapters.get().getDefaultLeaveGameData(); @Setting("commands-allowed") - private List commandsAllowed = Strings.a(new String[]{"start", "leave", "shout", "rejoin", "party", "par"}); + private List commandsAllowed = Strings.colorizeLines(new String[]{"start", "leave", "shout", "rejoin", "party", "par"}); public int getWaitingTime() { return this.waitingTime; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/DefaultGameManagerRegistry.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/DefaultGameManagerRegistry.java index b6baa86..6147881 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/DefaultGameManagerRegistry.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/DefaultGameManagerRegistry.java @@ -16,7 +16,7 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.game.GameManagerRegistry; public class DefaultGameManagerRegistry implements Iterable, GameManagerRegistry { - private boolean a; + private boolean started; private final File file; private final DefaultEngine engine; private final DefaultSessionSearcher defaultSessionSearcher = new DefaultSessionSearcher(this); @@ -40,8 +40,8 @@ public class DefaultGameManagerRegistry implements Iterable return this.map; } - public void d() { - this.a = true; + public void start() { + this.started = true; Iterator iterator = this.list.iterator(); while (iterator.hasNext()) { @@ -54,22 +54,22 @@ public class DefaultGameManagerRegistry implements Iterable } } - public void e() { + public void stop() { for (AbstractGameManager abstractGameManager : this.list) { abstractGameManager.stop(); } - this.a = false; + this.started = false; } - public void a(long longVal) { + public void onTick(long longVal) { for (AbstractGameManager abstractGameManager : this.list) { abstractGameManager.onTick(longVal); } if (longVal % 20L == 0L) { - this.map.forEach((uuid, sessionRequest) -> sessionRequest.a(sessionRequest.d() + 1)); - this.map.values().removeIf(sessionRequest2 -> sessionRequest2.d() >= this.engine.getSettings().getPurgeReservationsInSeconds()); + this.map.forEach((uuid, sessionRequest) -> sessionRequest.setElapsedSeconds(sessionRequest.getElapsedSeconds() + 1)); + this.map.values().removeIf(sessionRequest2 -> sessionRequest2.getElapsedSeconds() >= this.engine.getSettings().getPurgeReservationsInSeconds()); } } @@ -83,24 +83,24 @@ public class DefaultGameManagerRegistry implements Iterable return null; } - public void a(DefaultUser defaultUser) { + public void rejoin(DefaultUser defaultUser) { AbstractGameManager abstractGameManager = null; for (AbstractGameManager abstractGameManager2 : this) { - if (abstractGameManager == null || abstractGameManager2.getSessions().e().containsKey(defaultUser.getUUID())) { + if (abstractGameManager == null || abstractGameManager2.getSessions().getRejoinGames().containsKey(defaultUser.getUUID())) { abstractGameManager = abstractGameManager2; } } if (abstractGameManager != null) { - abstractGameManager.getSessions().a(defaultUser); + abstractGameManager.getSessions().rejoin(defaultUser); } } - public void a(AbstractGameManager abstractGameManager) { + public void register(AbstractGameManager abstractGameManager) { if (!this.engine.getSettings().getDisabled().contains(abstractGameManager.getId())) { this.list.add(abstractGameManager); - if (this.a) { + if (this.started) { abstractGameManager.start(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/action/GameAction.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/action/GameAction.java index b5ad35d..e401010 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/action/GameAction.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/action/GameAction.java @@ -13,7 +13,7 @@ public enum GameAction { BLOCK_PLACE, HEALTH_REGAIN; - private static final GameAction[] l = { + private static final GameAction[] VALUES = { CLICK, DAMAGE, ATTACK, HUNGER, INTERACT, ENTITY_INTERACT, ITEM_DROP, ITEM_PICKUP, BLOCK_BREAK, BLOCK_PLACE, HEALTH_REGAIN }; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/DeleteGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/DeleteGameCommand.java index 03af324..b415fd9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/DeleteGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/DeleteGameCommand.java @@ -15,7 +15,7 @@ public class DeleteGameCommand implements CommandExecutor { public DeleteGameCommand(AbstractGameManager manager2) { this.manager = manager2; - this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())}); + this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())}); } public ArgumentSet getArguments() { @@ -28,8 +28,8 @@ public class DeleteGameCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - if (this.manager.getSessions().c(text2)) { - this.manager.getStorage().getStorage().a(text2); + if (this.manager.getSessions().unregisterGame(text2)) { + this.manager.getStorage().getStorage().delete(text2); sender.sendMessage("§aThe game has been deleted!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/GameGuiCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/GameGuiCommand.java index b198902..48276ab 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/GameGuiCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/GameGuiCommand.java @@ -21,7 +21,7 @@ public class GameGuiCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c((Player)sender); if (defaultUser != null) { - defaultUser.a(this.manager.getMenuPage().page()); + defaultUser.openMenu(this.manager.getMenuPage().page()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/JoinGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/JoinGameCommand.java index 4913bae..27e6933 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/JoinGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/JoinGameCommand.java @@ -20,7 +20,7 @@ public class JoinGameCommand implements CommandExecutor { public JoinGameCommand(AbstractGameManager manager2) { this.manager = manager2; - this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().f().keySet()) }); + this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().getSessions().keySet()) }); } public boolean isPlayerOnly() { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesAllCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesAllCommand.java index 70f6c39..1bb2df4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesAllCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesAllCommand.java @@ -20,6 +20,6 @@ public class ListGamesAllCommand extends ListGamesCommand { } public void execute(CommandSender sender, String text, String[] texts, int index) { - this.a(sender, text, 1); + this.sendList(sender, text, 1); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesCommand.java index 645a209..a06e8e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesCommand.java @@ -16,25 +16,25 @@ public abstract class ListGamesCommand implements CommandExecutor { this.manager = manager2; } - protected void a(CommandSender sender, String text, int index) { + protected void sendList(CommandSender sender, String text, int index) { int index2 = (index - 1) * 8; - if (index >= 1 && index2 <= this.manager.getSessions().f().size()) { + if (index >= 1 && index2 <= this.manager.getSessions().getSessions().size()) { sender.sendMessage("§8[§3" + this.manager.getName() + "§8] §7- §dList"); - ArrayList list = this.a(); + ArrayList list = this.getSortedSessions(); int index3 = Math.min(index2 + 8, list.size()); for (int index4 = index2; index4 < index3; index4++) { - sender.sendMessage(this.a((Entry)list.get(index4))); + sender.sendMessage(this.formatSessionEntry((Entry)list.get(index4))); } - this.a(sender, index, text); + this.sendPageFooter(sender, index, text); } else { sender.sendMessage("§cThe page doesn't exists!"); } } - private ArrayList> a() { - ArrayList> list = new ArrayList<>(this.manager.getSessions().f().entrySet()); + private ArrayList> getSortedSessions() { + ArrayList> list = new ArrayList<>(this.manager.getSessions().getSessions().entrySet()); list.sort((entry, entry2) -> { int index = ((Session)entry.getValue()).getStatus().players(); int index2 = ((Session)entry2.getValue()).getStatus().players(); @@ -44,15 +44,15 @@ public abstract class ListGamesCommand implements CommandExecutor { return list; } - private String a(Entry entry) { + private String formatSessionEntry(Entry entry) { Status status = ((Session)entry.getValue()).getStatus(); return status.players() > 0 ? " - §c" + (String)entry.getKey() + " §8(§d" + status.players() + "§8)§f: §b" + String.join("§7, §b", status.playersNames()) : " - §c" + (String)entry.getKey() + " §8(§d" + status.players() + "§8)§f: §bNone"; } - private void a(CommandSender sender, int index, String text) { - int index2 = Math.max(1, (this.manager.getSessions().f().size() + 8 - 1) / 8); + private void sendPageFooter(CommandSender sender, int index, String text) { + int index2 = Math.max(1, (this.manager.getSessions().getSessions().size() + 8 - 1) / 8); if (index2 > 1) { sender.sendMessage("§3Page " + index + " out of " + index2 + ". Use §7/§c" + text + " list §8<§bpage§8>§3 to change pages!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesPageCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesPageCommand.java index 8400da6..46bc51a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesPageCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/ListGamesPageCommand.java @@ -25,6 +25,6 @@ public class ListGamesPageCommand extends ListGamesCommand { public void execute(CommandSender sender, String text, String[] texts, int index) { int index2 = Integer.parseInt(texts[index]); - this.a(sender, text, index2); + this.sendList(sender, text, index2); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/MapSelectorCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/MapSelectorCommand.java index a8b84d9..a57a0ee 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/MapSelectorCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/MapSelectorCommand.java @@ -25,7 +25,7 @@ public class MapSelectorCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender); if (defaultUser != null) { - this.manager.getMenuPage().mapSelector().a(defaultUser); + this.manager.getMenuPage().mapSelector().open(defaultUser); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/QuickJoinGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/QuickJoinGameCommand.java index 4c83221..675df72 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/QuickJoinGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/QuickJoinGameCommand.java @@ -25,7 +25,7 @@ public class QuickJoinGameCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender); if (defaultUser != null) { - defaultUser.a(this.manager.getSessions().getGameSearcher()); + defaultUser.quickJoin(this.manager.getSessions().getGameSearcher()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/RejoinGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/RejoinGameCommand.java index f9cef5e..297ad71 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/RejoinGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/RejoinGameCommand.java @@ -25,7 +25,7 @@ public class RejoinGameCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender); if (defaultUser != null) { - this.manager.getSessions().a(defaultUser); + this.manager.getSessions().rejoin(defaultUser); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StartGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StartGameCommand.java index cc4b8d6..78e4e5e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StartGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StartGameCommand.java @@ -16,7 +16,7 @@ public class StartGameCommand implements CommandExecutor { public StartGameCommand(AbstractGameManager manager2) { this.manager = manager2; - this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())}); + this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())}); } public ArgumentSet getArguments() { @@ -29,6 +29,6 @@ public class StartGameCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - ((AbstractGame)this.manager.getSessions().d().get(text2)).handleStartCommand(sender); + ((AbstractGame)this.manager.getSessions().getGames().get(text2)).handleStartCommand(sender); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StopGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StopGameCommand.java index 5455389..f0bf93a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StopGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/command/StopGameCommand.java @@ -16,7 +16,7 @@ public class StopGameCommand implements CommandExecutor { public StopGameCommand(AbstractGameManager manager2) { this.manager = manager2; - this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())}); + this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())}); } public ArgumentSet getArguments() { @@ -29,6 +29,6 @@ public class StopGameCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - ((AbstractGame)this.manager.getSessions().d().get(text2)).handleStopCommand(sender); + ((AbstractGame)this.manager.getSessions().getGames().get(text2)).handleStopCommand(sender); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/config/BaseGameMessages.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/config/BaseGameMessages.java index df6068b..28e714a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/config/BaseGameMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/config/BaseGameMessages.java @@ -11,113 +11,113 @@ import ro.fr33styler.arcade.api.engine.config.serialize.Configuration; public abstract class BaseGameMessages implements Configuration { @Setting("game-start-countdown") - private Text gameStartCountdown = TextParser.a("&eThe game starts in &c%countdown_formatted%&e seconds."); + private Text gameStartCountdown = TextParser.parse("&eThe game starts in &c%countdown_formatted%&e seconds."); @Setting("game-start-actionbar") - public Text gameStartActionbar = TextParser.a("%countdown_formatted%"); + public Text gameStartActionbar = TextParser.parse("%countdown_formatted%"); @Setting("game-start-cancelled") - private String gameStartCancelled = Strings.a("&cWe don't have enough players! Start cancelled."); + private String gameStartCancelled = Strings.colorize("&cWe don't have enough players! Start cancelled."); @Setting("game-player-prefix") - private String gamePlayerPrefix = Strings.a(""); + private String gamePlayerPrefix = Strings.colorize(""); @Setting("game-phase-waiting") - private String gamePhaseWaiting = Strings.a("WAITING"); + private String gamePhaseWaiting = Strings.colorize("WAITING"); @Setting("game-phase-playing") - private String gamePhasePlaying = Strings.a("PLAYING"); + private String gamePhasePlaying = Strings.colorize("PLAYING"); @Setting("game-phase-ending") - private String gamePhaseEnding = Strings.a("ENDING"); + private String gamePhaseEnding = Strings.colorize("ENDING"); @Setting("game-phase-resetting") - private String gamePhaseResetting = Strings.a("RESETTING"); + private String gamePhaseResetting = Strings.colorize("RESETTING"); @Setting("game-broadcast-join") - private Text gameBroadcastJoin = TextParser.a("&7%player%&e has joined. (&b%players%&e/&b%max_players%&e)"); + private Text gameBroadcastJoin = TextParser.parse("&7%player%&e has joined. (&b%players%&e/&b%max_players%&e)"); @Setting("game-broadcast-leave") - private Text gameBroadcastLeave = TextParser.a("&7%player%&e has quit."); + private Text gameBroadcastLeave = TextParser.parse("&7%player%&e has quit."); @Setting("auto-join-send-to-server") - private Text autoJoinSendToServer = TextParser.a("&aSending you to %id%@%server_name%"); + private Text autoJoinSendToServer = TextParser.parse("&aSending you to %id%@%server_name%"); @Setting("map-selector-no-permission") - private String mapSelectorNoPermission = Strings.a("&cYou do not have permission to view the map selector!"); + private String mapSelectorNoPermission = Strings.colorize("&cYou do not have permission to view the map selector!"); @Setting("join-arenas-name") - private String joinArenasName = Strings.a("Arenas"); + private String joinArenasName = Strings.colorize("Arenas"); @Setting("join-arenas-page-name") - private Text joinArenasPageName = TextParser.a("Arenas (Page %page%)"); + private Text joinArenasPageName = TextParser.parse("Arenas (Page %page%)"); @Setting("join-arenas-change-page-name") - private Text joinArenasChangePageName = TextParser.a("Arenas (Page %page%)"); + private Text joinArenasChangePageName = TextParser.parse("Arenas (Page %page%)"); @Setting("join-arenas-go-back") - private String joinArenasGoBack = Strings.a("&aGo back"); + private String joinArenasGoBack = Strings.colorize("&aGo back"); @Setting("join-arenas-arena-name") - private Text joinArenasArenaName = TextParser.a("&a%name%"); + private Text joinArenasArenaName = TextParser.parse("&a%name%"); @Setting("join-arenas-arena-lore") - private List joinArenasArenaLore = TextParser.a(new String[]{"&8%mode%", " ", "&e%players%&7/&e%maximum%", "&aClick to join!"}); + private List joinArenasArenaLore = TextParser.parseAll(new String[]{"&8%mode%", " ", "&e%players%&7/&e%maximum%", "&aClick to join!"}); @Setting("spectator-teleporter-name") - private String spectatorTeleporterName = Strings.a("Teleporter"); + private String spectatorTeleporterName = Strings.colorize("Teleporter"); @Setting("spectator-teleporter-page-name") - private Text spectatorTeleporterPageName = TextParser.a("Teleporter (Page %page%)"); + private Text spectatorTeleporterPageName = TextParser.parse("Teleporter (Page %page%)"); @Setting("spectator-teleporter-change-page-name") - private Text spectatorTeleporterChangePageName = TextParser.a("Teleporter (Page %page%)"); + private Text spectatorTeleporterChangePageName = TextParser.parse("Teleporter (Page %page%)"); @Setting("spectator-target-name") - private Text spectatorTargetName = TextParser.a("&7%player%"); + private Text spectatorTargetName = TextParser.parse("&7%player%"); @Setting("spectator-target-lore") - protected List spectatorTargetLore = new ArrayList<>(List.of(TextParser.a("&7Left-click to spectate"))); + protected List spectatorTargetLore = new ArrayList<>(List.of(TextParser.parse("&7Left-click to spectate"))); @Setting("spectator-target") - private Text spectatorTarget = TextParser.a("Target: &a&l%player% &aLEFT CLICK for menu &cSNEAK to exit"); + private Text spectatorTarget = TextParser.parse("Target: &a&l%player% &aLEFT CLICK for menu &cSNEAK to exit"); @Setting("spectator-target-first-person") - private Text spectatorTargetFirstPerson = TextParser.a("Target: &a&l%player% &fDistance: &a&l%distance%"); + private Text spectatorTargetFirstPerson = TextParser.parse("Target: &a&l%player% &fDistance: &a&l%distance%"); @Setting("spectator-spectate-exit-title") - private String spectatorSpectateExitTitle = Strings.a("&eExiting Spectator mode"); + private String spectatorSpectateExitTitle = Strings.colorize("&eExiting Spectator mode"); @Setting("spectator-spectate-title") - private Text spectatorSpectateTitle = TextParser.a("&aSpectating &b%player%"); + private Text spectatorSpectateTitle = TextParser.parse("&aSpectating &b%player%"); @Setting("spectator-spectate-subtitle") - private Text spectatorSpectateSubtitle = TextParser.a("&aLEFT CLICK for menu &cSNEAK to exit"); + private Text spectatorSpectateSubtitle = TextParser.parse("&aLEFT CLICK for menu &cSNEAK to exit"); @Setting("statistics-not-found") - private String statisticsNotFound = Strings.a("&cPlayer statistics not found!"); + private String statisticsNotFound = Strings.colorize("&cPlayer statistics not found!"); @Setting("statistics-view") - protected List statisticsView = TextParser.a( + protected List statisticsView = TextParser.parseAll( new String[]{" ", " &l%display_name% Statistics", " ", " Wins&a: %wins%", " Loses&a: %loses%", " Played&a: %played%", " "} ); @Setting("join-already-in-game") - private String joinAlreadyInGame = Strings.a("&cYou're already in a game!"); + private String joinAlreadyInGame = Strings.colorize("&cYou're already in a game!"); @Setting("join-game-is-private") - private String joinGameIsPrivate = Strings.a("&cThis game is private!"); + private String joinGameIsPrivate = Strings.colorize("&cThis game is private!"); @Setting("join-is-full") - private String joinIsFull = Strings.a("&cThe game is full!"); + private String joinIsFull = Strings.colorize("&cThe game is full!"); @Setting("join-is-started") - private String joinIsStarted = Strings.a("&cThe game is already started!"); + private String joinIsStarted = Strings.colorize("&cThe game is already started!"); @Setting("join-is-not-started") - private String joinIsNotStarted = Strings.a("&cThe game must be started!"); + private String joinIsNotStarted = Strings.colorize("&cThe game must be started!"); @Setting("join-not-found") - private String joinNotFound = Strings.a("&cGame not found!"); + private String joinNotFound = Strings.colorize("&cGame not found!"); @Setting("join-gui-name") - private Text joinGuiName = TextParser.a("Play %display_name%"); + private Text joinGuiName = TextParser.parse("Play %display_name%"); @Setting("join-gui-quick-join-name") - private Text joinGuiQuickJoinName = TextParser.a("&a%display_name%"); + private Text joinGuiQuickJoinName = TextParser.parse("&a%display_name%"); @Setting("join-gui-quick-join-lore") - private List joinGuiQuickJoinLore = TextParser.a(new String[]{"&7Play a game of %display_name%.", " ", "&eClick to play!"}); + private List joinGuiQuickJoinLore = TextParser.parseAll(new String[]{"&7Play a game of %display_name%.", " ", "&eClick to play!"}); @Setting("join-gui-map-selector-name") - private Text joinGuiMapSelectorName = TextParser.a("&aMap Selector (%display_name%)"); + private Text joinGuiMapSelectorName = TextParser.parse("&aMap Selector (%display_name%)"); @Setting("join-gui-map-selector-lore") - private List joinGuiMapSelectorLore = TextParser.a(new String[]{"&7Pick which map you want to play from", "&7a list of available games.", " ", "&eClick to browse!"}); + private List joinGuiMapSelectorLore = TextParser.parseAll(new String[]{"&7Pick which map you want to play from", "&7a list of available games.", " ", "&eClick to browse!"}); @Setting("join-gui-close") - private String joinGuiClose = Strings.a("&cClose"); + private String joinGuiClose = Strings.colorize("&cClose"); @Setting("join-gui-rejoin-name") - private String joinGuiRejoinName = Strings.a("&cClick here to rejoin!"); + private String joinGuiRejoinName = Strings.colorize("&cClick here to rejoin!"); @Setting("join-gui-rejoin-lore") - private List joinGuiRejoinLore = Strings.a(new String[]{"&7Click here to rejoin your game if", "&7you have been disconnected from it."}); + private List joinGuiRejoinLore = Strings.colorizeLines(new String[]{"&7Click here to rejoin your game if", "&7you have been disconnected from it."}); @Setting("item-settings") - private String itemSettings = Strings.a("&a&lTeleporter &7(Right Click)"); + private String itemSettings = Strings.colorize("&a&lTeleporter &7(Right Click)"); @Setting("item-spectator-settings") - private String itemSpectatorSettings = Strings.a("&b&lSpectator Settings &7(Right Click)"); + private String itemSpectatorSettings = Strings.colorize("&b&lSpectator Settings &7(Right Click)"); @Setting("item-play-again") - private String itemPlayAgain = Strings.a("&b&lPlay Again &7(Right Click)"); + private String itemPlayAgain = Strings.colorize("&b&lPlay Again &7(Right Click)"); @Setting("item-leave") - private String itemLeave = Strings.a("&c&lReturn to Lobby &7(Right Click)"); + private String itemLeave = Strings.colorize("&c&lReturn to Lobby &7(Right Click)"); @Setting("rejoin") - private String rejoin = Strings.a("&cNo game to rejoin. This usually happens when the last game you played has already ended and is nothing to worry about."); + private String rejoin = Strings.colorize("&cNo game to rejoin. This usually happens when the last game you played has already ended and is nothing to worry about."); @Setting("chat-in-game") - protected Text chatInGame = TextParser.a("&7%player%&f: %message%"); + protected Text chatInGame = TextParser.parse("&7%player%&f: %message%"); @Setting("chat-in-game-spectator") - private Text chatInGameSpectator = TextParser.a("&6[SPECTATOR] &7%player%&f: %message%"); + private Text chatInGameSpectator = TextParser.parse("&6[SPECTATOR] &7%player%&f: %message%"); @Setting("sidebar-waiting-title") - private Text sidebarWaitingTitle = TextParser.a("&e&l%display_name%"); + private Text sidebarWaitingTitle = TextParser.parse("&e&l%display_name%"); @Setting("sidebar-waiting") - protected List sidebarWaiting = TextParser.a( + protected List sidebarWaiting = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year% &8%id%", " ", @@ -132,11 +132,11 @@ public abstract class BaseGameMessages implements Configuration { } ); @Setting("npc") - private List npc = TextParser.a(new String[]{"&e&lCLICK TO PLAY", "&b%display_name%", "&e&l%players% Players"}); + private List npc = TextParser.parseAll(new String[]{"&e&lCLICK TO PLAY", "&b%display_name%", "&e&l%players% Players"}); @Setting("join-signs") - private List joinSigns = TextParser.a(new String[]{"&2&l%display_name%", "%name%", "&5• &f&l%phase% &5•", "&c»&e&l%players%/%maximum%&c«"}); + private List joinSigns = TextParser.parseAll(new String[]{"&2&l%display_name%", "%name%", "&5• &f&l%phase% &5•", "&c»&e&l%players%/%maximum%&c«"}); @Setting("quick-join-signs") - private List quickJoinSigns = TextParser.a(new String[]{"&2&l%display_name%", "Quick Join", "&e&l%players% Players"}); + private List quickJoinSigns = TextParser.parseAll(new String[]{"&2&l%display_name%", "Quick Join", "&e&l%players% Players"}); public abstract String getDisplayName(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameActionListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameActionListener.java index c3ca18e..8b56a63 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameActionListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameActionListener.java @@ -34,16 +34,16 @@ public class GameActionListener implements Listener { public void registerExtraListeners() { VersionAdapters.get().registerExtraActionListeners( this.engine.getPlugin(), - entity -> this.a(entity, GameAction.ITEM_PICKUP), - player -> this.a(player, GameAction.ITEM_PICKUP), - player -> this.a(player, GameAction.CLICK) + entity -> this.isActionBlocked(entity, GameAction.ITEM_PICKUP), + player -> this.isActionBlocked(player, GameAction.ITEM_PICKUP), + player -> this.isActionBlocked(player, GameAction.CLICK) ); } @EventHandler - public void a(EntityDamageEvent event) { + public void onEntityDamage(EntityDamageEvent event) { Entity entity = event.getEntity(); - if (this.a(entity, GameAction.DAMAGE)) { + if (this.isActionBlocked(entity, GameAction.DAMAGE)) { event.setCancelled(true); entity.setFireTicks(0); } @@ -55,85 +55,85 @@ public class GameActionListener implements Listener { } @EventHandler - public void a(EntityDamageByEntityEvent event) { + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity entity = event.getDamager(); if (entity instanceof Projectile var3 && var3.getShooter() instanceof Entity var4) { entity = var4; } - if (this.a(entity, GameAction.ATTACK)) { + if (this.isActionBlocked(entity, GameAction.ATTACK)) { event.setCancelled(true); } } @EventHandler - public void a(EntityRegainHealthEvent event) { - if (this.a(event.getEntity(), GameAction.HEALTH_REGAIN)) { + public void onEntityRegainHealth(EntityRegainHealthEvent event) { + if (this.isActionBlocked(event.getEntity(), GameAction.HEALTH_REGAIN)) { event.setCancelled(true); } } @EventHandler - public void a(PlayerDropItemEvent event) { - if (this.a(event.getPlayer(), GameAction.ITEM_DROP)) { + public void onPlayerDropItem(PlayerDropItemEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.ITEM_DROP)) { event.setCancelled(true); } } @EventHandler - public void a(FoodLevelChangeEvent event) { - if (this.a(event.getEntity(), GameAction.HUNGER)) { + public void onFoodLevelChange(FoodLevelChangeEvent event) { + if (this.isActionBlocked(event.getEntity(), GameAction.HUNGER)) { event.setCancelled(true); } } @EventHandler - public void a(BlockPlaceEvent event) { - if (this.a(event.getPlayer(), GameAction.BLOCK_PLACE)) { + public void onBlockPlace(BlockPlaceEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.BLOCK_PLACE)) { event.setCancelled(true); } } @EventHandler - public void a(BlockBreakEvent event) { - if (this.a(event.getPlayer(), GameAction.BLOCK_BREAK)) { + public void onBlockBreak(BlockBreakEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.BLOCK_BREAK)) { event.setCancelled(true); } } @EventHandler - public void a(PlayerInteractEvent event) { - if (this.a(event.getPlayer(), GameAction.INTERACT)) { + public void onPlayerInteract(PlayerInteractEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.INTERACT)) { event.setCancelled(true); } } @EventHandler - public void a(PlayerInteractEntityEvent event) { - if (this.a(event.getPlayer(), GameAction.ENTITY_INTERACT) && event.getRightClicked().getType() != EntityType.PLAYER) { + public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.ENTITY_INTERACT) && event.getRightClicked().getType() != EntityType.PLAYER) { event.setCancelled(true); } } @EventHandler - public void a(PlayerInteractAtEntityEvent event) { - if (this.a(event.getPlayer(), GameAction.ENTITY_INTERACT)) { + public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { + if (this.isActionBlocked(event.getPlayer(), GameAction.ENTITY_INTERACT)) { event.setCancelled(true); } } @EventHandler - public void a(InventoryClickEvent event) { - if (this.a(event.getWhoClicked(), GameAction.CLICK)) { + public void onInventoryClick(InventoryClickEvent event) { + if (this.isActionBlocked(event.getWhoClicked(), GameAction.CLICK)) { event.setCancelled(true); } } - public boolean a(Entity entity, GameAction gameAction) { + public boolean isActionBlocked(Entity entity, GameAction gameAction) { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(entity.getUniqueId()); if (defaultUser != null && defaultUser.isInGame() && defaultUser.getGamer() instanceof BaseGamer var4) { AbstractGame abstractGame = var4.getGame(); - return !var4.f() && abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getPlaying() ? abstractGame instanceof GameEventHandler var6 && var6.getBlockedActions().contains(gameAction) : true; + return !var4.isSpectator() && abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getPlaying() ? abstractGame instanceof GameEventHandler var6 && var6.getBlockedActions().contains(gameAction) : true; } else { return false; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameListener.java index 186084e..d8be79b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/listener/GameListener.java @@ -39,7 +39,7 @@ public class GameListener implements Listener { this.manager = manager2; } - protected T a(Entity entity, Class clazz) { + protected T getActiveGamer(Entity entity, Class clazz) { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(entity); if (defaultUser != null && defaultUser.isInGame()) { Game game = defaultUser.getGame(); @@ -55,46 +55,46 @@ public class GameListener implements Listener { } @EventHandler - public void a(PlayerJoinEvent event) { + public void onPlayerJoin(PlayerJoinEvent event) { this.manager.loadPlayerData(event.getPlayer()); } @EventHandler(priority = EventPriority.HIGHEST) - public void a(PlayerQuitEvent event) { + public void onPlayerQuit(PlayerQuitEvent event) { this.manager.unloadPlayerData(event.getPlayer().getUniqueId()); } @EventHandler - public void a(GameJoinEvent event) { + public void onGameJoin(GameJoinEvent event) { Game game = event.getGame(); if (game.getManager() == this.manager && event.getGamer() instanceof BaseGamer var3) { if (game.getPhase() instanceof CountdownPhase var6) { - var6.a(var3); + var6.onJoin(var3); } BaseGameStatistics baseGameStatistics = this.manager.getData(var3.getUUID()); - if (baseGameStatistics != null && baseGameStatistics.a()) { - var3.a(baseGameStatistics.getMap()); + if (baseGameStatistics != null && baseGameStatistics.isLoaded()) { + var3.loadProperties(baseGameStatistics.getMap()); } } } @EventHandler - public void a(GameLeaveEvent event) { + public void onGameLeave(GameLeaveEvent event) { Game game = event.getGame(); if (game.getManager() == this.manager && event.getGamer() instanceof BaseGamer var3 && game.getPhase() instanceof CountdownPhase var4) { - var4.b(var3); + var4.onLeave(var3); } } @EventHandler - public void a(PlayerInteractAtEntityEvent event) { + public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { Player player = event.getPlayer(); - BaseGamer baseGamer = this.a(player, BaseGamer.class); - if (baseGamer != null && baseGamer.g()) { + BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class); + if (baseGamer != null && baseGamer.isActiveSpectator()) { AbstractGame abstractGame = baseGamer.getGame(); BaseGamer baseGamer2 = (BaseGamer)abstractGame.getGamers().a(event.getRightClicked()); - if (baseGamer2 != null && !baseGamer2.f()) { + if (baseGamer2 != null && !baseGamer2.isSpectator()) { baseGamer.getSpectatorOptions().setPlayer(baseGamer2.toPlayer()); player.setGameMode(GameMode.SPECTATOR); player.setSpectatorTarget(baseGamer2.toPlayer()); @@ -103,10 +103,10 @@ public class GameListener implements Listener { } @EventHandler - public void a(PlayerToggleSneakEvent event) { + public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); - BaseGamer baseGamer = this.a(player, BaseGamer.class); - if (baseGamer != null && event.isSneaking() && player.getSpectatorTarget() != null && baseGamer.f()) { + BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class); + if (baseGamer != null && event.isSneaking() && player.getSpectatorTarget() != null && baseGamer.isSpectator()) { player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(true); player.setFlying(true); @@ -115,9 +115,9 @@ public class GameListener implements Listener { } @EventHandler(priority = EventPriority.HIGH) - public void a(AsyncPlayerChatEvent event) { + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); - BaseGamer baseGamer = this.a(player, BaseGamer.class); + BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class); if (baseGamer != null && baseGamer.getGame().getSettings().isChatPrivate() && !event.isCancelled()) { if (baseGamer.getGame().getPhase() != baseGamer.getGame().getPhaseLifecycle().getPlaying()) { return; @@ -126,27 +126,27 @@ public class GameListener implements Listener { event.setCancelled(true); Bukkit.getScheduler().runTask(this.manager.getEngine().getPlugin(), () -> { AbstractGame abstractGame = baseGamer.getGame(); - Context context = Contexts.a(baseGamer, var1xx -> var1xx.equals("message") ? event.getMessage() : null); - if (baseGamer.g()) { - String text = abstractGame.getMessages().getChatInGameSpectator().a(context); + Context context = Contexts.withVariables(baseGamer, var1xx -> var1xx.equals("message") ? event.getMessage() : null); + if (baseGamer.isActiveSpectator()) { + String text = abstractGame.getMessages().getChatInGameSpectator().render(context); if (abstractGame.getEngine().hasPlaceholderResolver()) { - text = abstractGame.getEngine().getPlaceholderResolver().a(player, text); + text = abstractGame.getEngine().getPlaceholderResolver().resolve(player, text); } for (BaseGamer baseGamer2 : abstractGame.getGamers()) { - if (baseGamer2.g()) { + if (baseGamer2.isActiveSpectator()) { baseGamer2.sendMessage(text); } } Bukkit.getConsoleSender().sendMessage(text); } else { - String text2 = abstractGame.getMessages().getChatInGame().a(context); + String text2 = abstractGame.getMessages().getChatInGame().render(context); if (abstractGame.getEngine().hasPlaceholderResolver()) { - text2 = abstractGame.getEngine().getPlaceholderResolver().a(player, text2); + text2 = abstractGame.getEngine().getPlaceholderResolver().resolve(player, text2); } - abstractGame.getGamers().a(text2); + abstractGame.getGamers().broadcast(text2); Bukkit.getConsoleSender().sendMessage(text2); } }); @@ -154,7 +154,7 @@ public class GameListener implements Listener { } @EventHandler - public void a(SignChangeEvent event) { + public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); String text = event.getLine(0); if (text != null && text.length() > 2) { @@ -165,16 +165,16 @@ public class GameListener implements Listener { event.setCancelled(true); if ("QuickJoin".equals(text2)) { this.manager.createQuickJoinSign(block); - this.manager.getStorage().getStorage3().getQuickJoinSigns().add(event.getBlock()); - this.manager.getStorage().getStorage3().d(); + this.manager.getStorage().getSignStorage().getQuickJoinSigns().add(event.getBlock()); + this.manager.getStorage().getSignStorage().save(); player.sendMessage("§aThe sign has been added!"); } else { Session session = this.manager.getSessions().getSession(text2); if (session == null) { player.sendMessage("§cThe game doesn't exists."); } else if (VersionAdapters.get().isWallSign(block)) { - this.manager.getStorage().getStorage3().a(block, text2); - this.manager.getStorage().getStorage3().d(); + this.manager.getStorage().getSignStorage().addSign(block, text2); + this.manager.getStorage().getSignStorage().save(); this.manager.createJoinSign(block, text2); player.sendMessage("§aThe sign has been added!"); } else { @@ -186,14 +186,14 @@ public class GameListener implements Listener { } @EventHandler - public void a(BlockBreakEvent event) { + public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); if (player.hasPermission(this.manager.getId() + ".admin")) { Block block = event.getBlock(); - SignStorage signStorage = this.manager.getStorage().getStorage3(); - if (signStorage.a(block) || signStorage.getQuickJoinSigns().remove(block)) { - this.manager.getEngine().getDisplayManager().b(block); - signStorage.d(); + SignStorage signStorage = this.manager.getStorage().getSignStorage(); + if (signStorage.removeSign(block) || signStorage.getQuickJoinSigns().remove(block)) { + this.manager.getEngine().getDisplayManager().removeCommandSign(block); + signStorage.save(); player.sendMessage("§aThe sign has been removed!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/CountdownPhase.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/CountdownPhase.java index 7798017..f0d4deb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/CountdownPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/CountdownPhase.java @@ -3,7 +3,7 @@ package ro.fr33styler.arcade.engine.game.phase; import ro.fr33styler.arcade.engine.game.player.BaseGamer; public interface CountdownPhase { - void a(BaseGamer var1); + void onJoin(BaseGamer var1); - void b(BaseGamer var1); + void onLeave(BaseGamer var1); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/EndingPhase.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/EndingPhase.java index 45bcac1..cb52229 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/EndingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/EndingPhase.java @@ -10,7 +10,7 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; import ro.fr33styler.arcade.api.engine.game.phase.PhaseType; public class EndingPhase implements Phase { - protected int a; + protected int remainingSeconds; private final AbstractGame game; public EndingPhase(AbstractGame game2) { @@ -26,28 +26,28 @@ public class EndingPhase implements Phase { } public void start() { - this.a = this.game.getSettings().getEndingTime(); + this.remainingSeconds = this.game.getSettings().getEndingTime(); for (BaseGamer baseGamer : this.game.getGamers()) { - if (baseGamer.f()) { + if (baseGamer.isSpectator()) { baseGamer.toPlayer().closeInventory(); } else { - baseGamer.b(true); - baseGamer.getSpectatorOptions().d(false); + baseGamer.setSpectator(true); + baseGamer.getSpectatorOptions().setTemporary(false); } - baseGamer.getHotbar().a(0, null, null); + baseGamer.getHotbar().setSlot(0, null, null); } } public void stop() { - if (!UserNonceMarkerProbe.a(this.game.getEngine().getPlugin())) { + if (!UserNonceMarkerProbe.probe(this.game.getEngine().getPlugin())) { this.game.getRollbackQueue().clear(); } this.game.getGamers().leaveAll(); if (this.game.getPhase() == this) { - this.game.getSpectatorMenu().a(); + this.game.getSpectatorMenu().clear(); if (this.game.getRollbackQueue().isEmpty()) { this.game.setPhase(this.game.getPhaseLifecycle().getWaiting()); } else { @@ -60,20 +60,20 @@ public class EndingPhase implements Phase { return text.equals("phase") ? this.game.getMessages().getGamePhaseEnding() : null; } - protected void a() { + protected void spawnFireworks() { for (Gamer gamer : this.game.getGamers()) { - Fireworks.a(gamer.toPlayer().getEyeLocation()); + Fireworks.spawnRandom(gamer.toPlayer().getEyeLocation()); } } public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.a > 0) { - if (this.a % 2 == 0) { - this.a(); + if (this.remainingSeconds > 0) { + if (this.remainingSeconds % 2 == 0) { + this.spawnFireworks(); } - this.a--; + this.remainingSeconds--; } else { this.stop(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/ResettingPhase.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/ResettingPhase.java index 59ed935..ca964e4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/ResettingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/ResettingPhase.java @@ -7,7 +7,7 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; import ro.fr33styler.arcade.api.engine.game.phase.PhaseType; public class ResettingPhase implements Phase { - private int a; + private int blocksPerTick; private final AbstractGame game; public ResettingPhase(AbstractGame game2) { @@ -23,14 +23,14 @@ public class ResettingPhase implements Phase { } public void start() { - this.a = this.game.getSettings().getRollbackSize(); + this.blocksPerTick = this.game.getSettings().getRollbackSize(); int index = this.game.getSettings().getRollbackMaxTimeInSeconds(); - if (this.game.getSettings().hasRollbackMaxTime() && this.a(this.game, this.a, index)) { - this.a = this.game.getRollbackQueue().size() / (index * 4); + if (this.game.getSettings().hasRollbackMaxTime() && this.exceedsMaxRollbackTime(this.game, this.blocksPerTick, index)) { + this.blocksPerTick = this.game.getRollbackQueue().size() / (index * 4); } } - private boolean a(AbstractGame abstractGame, int index, int index2) { + private boolean exceedsMaxRollbackTime(AbstractGame abstractGame, int index, int index2) { return abstractGame.getRollbackQueue().size() / (index * 4) > index2; } @@ -44,7 +44,7 @@ public class ResettingPhase implements Phase { public void onTick(long longVal) { if (longVal % 5L == 0L) { - for (int index = 0; index <= this.a; index++) { + for (int index = 0; index <= this.blocksPerTick; index++) { if (this.game.getRollbackQueue().isEmpty()) { this.game.setPhase(this.game.getPhaseLifecycle().getWaiting()); break; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/WaitingPhase.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/WaitingPhase.java index 3c16290..06b271b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/WaitingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/phase/WaitingPhase.java @@ -22,8 +22,8 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; import ro.fr33styler.arcade.api.engine.game.phase.PhaseType; public class WaitingPhase implements Phase, CountdownPhase { - private int a; - private boolean b; + private int countdown; + private boolean starting; private final AbstractGame game; public WaitingPhase(AbstractGame game2) { @@ -39,56 +39,56 @@ public class WaitingPhase implements Phase, CountdownPhase { } public void start() { - this.a = this.game.getSettings().getWaitingTime(); + this.countdown = this.game.getSettings().getWaitingTime(); this.game.getScoreboard().getOrCreateSidebar(this.game.getEngine()).setTitle(this.game.getMessages().getSidebarWaitingTitle(), this.game); } - public void a(BaseGamer baseGamer) { + public void onJoin(BaseGamer baseGamer) { if (this.game.getGamers().size() >= this.game.getMap().getMinimumPlayers()) { - this.b = true; + this.starting = true; } - baseGamer.a(this.game.getMap().getLobby()); - Players.a(baseGamer); + baseGamer.teleport(this.game.getMap().getLobby()); + Players.reset(baseGamer); baseGamer.toPlayer().setGameMode(GameMode.ADVENTURE); - String text = this.game.getMessages().getGameBroadcastJoin().a(baseGamer); + String text = this.game.getMessages().getGameBroadcastJoin().render(baseGamer); if (this.game.getEngine().getPlaceholderResolver() != null) { - text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text); + text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text); } - this.game.getGamers().a(text); - baseGamer.getHotbar().a(8, baseGamer::leave, this.a()); - this.c(baseGamer); + this.game.getGamers().broadcast(text); + baseGamer.getHotbar().setSlot(8, baseGamer::leave, this.createLeaveItem()); + this.createPlayerTeam(baseGamer); } - private ItemStack a() { + private ItemStack createLeaveItem() { return new ItemBuilder(this.game.getSettings().getLeaveGameMaterial(), this.game.getSettings().getLeaveGameData()).setDisplayName(this.game.getMessages().getItemLeave()).build(); } - public void b(BaseGamer baseGamer) { - if (this.b && this.game.getGamers().size() < this.game.getMap().getMinimumPlayers()) { - this.b = false; - this.a = this.game.getSettings().getWaitingTime(); - this.game.getGamers().a(this.game.getMessages().getGameStartCancelled()); + public void onLeave(BaseGamer baseGamer) { + if (this.starting && this.game.getGamers().size() < this.game.getMap().getMinimumPlayers()) { + this.starting = false; + this.countdown = this.game.getSettings().getWaitingTime(); + this.game.getGamers().broadcast(this.game.getMessages().getGameStartCancelled()); } - String text = this.game.getMessages().getGameBroadcastLeave().a(baseGamer); + String text = this.game.getMessages().getGameBroadcastLeave().render(baseGamer); if (this.game.getEngine().hasPlaceholderResolver()) { - text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text); + text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text); } - this.game.getGamers().a(text); + this.game.getGamers().broadcast(text); baseGamer.getScoreboardTeam().unregister(); } public void stop() { - this.b = false; - this.b(); - if (UserNonceMarkerProbe.a(this.game.getEngine().getPlugin())) { - if (VendorMarkerProbe.a(this.game.getEngine().getPlugin())) { + this.starting = false; + this.clearLobbyZone(); + if (UserNonceMarkerProbe.probe(this.game.getEngine().getPlugin())) { + if (VendorMarkerProbe.probe(this.game.getEngine().getPlugin())) { for (BaseGamer baseGamer : this.game.getGamers()) { baseGamer.getScoreboardTeam().unregister(); - baseGamer.getHotbar().a(); + baseGamer.getHotbar().clear(); } this.game.setPhase(this.game.getPhaseLifecycle().getPlaying()); @@ -96,10 +96,10 @@ public class WaitingPhase implements Phase, CountdownPhase { } } - private void b() { + private void clearLobbyZone() { Cuboid cuboid = this.game.getMap().getLobbyZone(); if (cuboid != null) { - cuboid.a(block -> { + cuboid.forEachBlock(block -> { if (!block.isEmpty()) { this.game.getRollbackQueue().add(block.getState()); VersionAdapters.get().setBlock(this.game.getEngine().getPlatform(), block, Material.AIR, 0); @@ -108,12 +108,12 @@ public class WaitingPhase implements Phase, CountdownPhase { } } - private void c(BaseGamer baseGamer) { + private void createPlayerTeam(BaseGamer baseGamer) { ScoreboardTeam scoreboardTeam = this.game.getScoreboard().createTeam(baseGamer.toPlayer().getName()); scoreboardTeam.setCollisionRule(TeamRule.NEVER); String text = this.game.getMessages().getGamePlayerPrefix(); if (this.game.getEngine().getPlaceholderResolver() != null) { - text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text); + text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text); } scoreboardTeam.setPrefix(text); @@ -129,42 +129,42 @@ public class WaitingPhase implements Phase, CountdownPhase { public String getVariable(String text) { return switch (text) { case "phase" -> this.getName(); - case "seconds" -> String.valueOf(this.a); - case "countdown" -> Strings.a(this.a); + case "seconds" -> String.valueOf(this.countdown); + case "countdown" -> Strings.formatDuration(this.countdown); case "required" -> String.valueOf(this.game.getMap().getMinimumPlayers() - this.game.getGamers().size()); - case "countdown_formatted" -> Strings.a(this.a, this.game.getSettings().getWaitingTime()); + case "countdown_formatted" -> Strings.formatProgressColor(this.countdown, this.game.getSettings().getWaitingTime()); default -> null; }; } public Boolean getCondition(String text) { - return text.equals("STARTING") ? this.b : null; + return text.equals("STARTING") ? this.starting : null; } public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.b) { + if (this.starting) { int index = this.game.getSettings().getWaitingTimeAlmostFullReduction(); double doubleVal = this.game.getSettings().getWaitingTimeReduceAtThreshold() / 100.0; - if ((double)this.game.getGamers().size() / this.game.getMap().getMaximumPlayers() >= doubleVal && this.a > index) { - this.a = index; + if ((double)this.game.getGamers().size() / this.game.getMap().getMaximumPlayers() >= doubleVal && this.countdown > index) { + this.countdown = index; } - if (this.a <= 1) { + if (this.countdown <= 1) { this.stop(); return; } - this.a--; - this.c(); + this.countdown--; + this.broadcastCountdown(); } - this.game.getGamers().a(this.game.getMessages().getSidebarWaiting()); + this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarWaiting()); } } - private void c() { - if (this.a <= 5) { + private void broadcastCountdown() { + if (this.countdown <= 5) { for (BaseGamer baseGamer : this.game.getGamers()) { baseGamer.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F); baseGamer.sendMessage(this.game.getMessages().getGameStartCountdown(), baseGamer); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/player/BaseGamer.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/player/BaseGamer.java index 0163aba..09ac1bf 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/player/BaseGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/player/BaseGamer.java @@ -42,10 +42,10 @@ import ro.fr33styler.arcade.api.engine.party.Party; import ro.fr33styler.arcade.api.engine.text.Context; public abstract class BaseGamer extends PlayerHandle implements Gamer { - private int b; - private int c; + private int wins; + private int loses; private Party party; - private boolean e; + private boolean spectator; private PlayerSidebar playerSidebar; private ScoreboardTeam scoreboardTeam; private final PlayerHotbar hotbar; @@ -60,19 +60,19 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } public int getWins() { - return this.b; + return this.wins; } - public void a(int index) { - this.b = index; + public void setWins(int index) { + this.wins = index; } public int getLoses() { - return this.c; + return this.loses; } - public void b(int index) { - this.c = index; + public void setLoses(int index) { + this.loses = index; } public DefaultUser toUser() { @@ -85,15 +85,15 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { public abstract AbstractGame getGame(); - public void a(Text text) { - this.sendMessage(text.a(this)); + public void sendMessage(Text text) { + this.sendMessage(text.render(this)); } - public void a(List list2) { + public void sendMessages(List list2) { this.sendMessages(list2, this); } - public void b(Text text) { + public void sendActionBar(Text text) { this.sendActionBar(text, this); } @@ -117,8 +117,8 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { super.sendTitle(this.getGame().getEngine().getPlatform(), text, text2, context, index, index2, index3); } - public Party d() { - return (Party)EngineUtils.a(this.party, this.user.getParty()); + public Party getParty() { + return (Party)EngineUtils.orElse(this.party, this.user.getParty()); } public void setParty(Party party2) { @@ -133,56 +133,56 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { this.scoreboardTeam = scoreboardTeam2; } - public boolean f() { - return this.e; + public boolean isSpectator() { + return this.spectator; } - public boolean g() { - return this.e && !this.spectatorOptions.f(); + public boolean isActiveSpectator() { + return this.spectator && !this.spectatorOptions.isTemporary(); } public SpectatorOptions getSpectatorOptions() { return this.spectatorOptions; } - public void a(boolean flag) { - this.e = flag; - Players.a(this); + public void setTemporarySpectator(boolean flag) { + this.spectator = flag; + Players.reset(this); if (flag) { - this.n(); - this.spectatorOptions.d(true); - this.m(); + this.enableSpectatorVisibility(); + this.spectatorOptions.setTemporary(true); + this.detachSpectators(); } else { - this.o(); - this.spectatorOptions.d(false); - this.l(); + this.disableSpectatorVisibility(); + this.spectatorOptions.setTemporary(false); + this.attachSpectators(); } } - public void b(boolean flag) { - this.e = flag; - Players.a(this); + public void setSpectator(boolean flag) { + this.spectator = flag; + Players.reset(this); if (flag) { - this.n(); - this.r(); - this.q(); - this.m(); + this.enableSpectatorVisibility(); + this.giveSpectatorHotbar(); + this.applySpectatorOptions(); + this.detachSpectators(); } else { - this.o(); - this.hotbar.a(); - this.l(); + this.disableSpectatorVisibility(); + this.hotbar.clear(); + this.attachSpectators(); } } - private void l() { + private void attachSpectators() { for (BaseGamer baseGamer : this.getGame().getGamers()) { SpectatorOptions spectatorOptions2 = baseGamer.getSpectatorOptions(); - if (baseGamer.g() && spectatorOptions2.getPlayer() == this.player) { - if (spectatorOptions2.d() || spectatorOptions2.c()) { + if (baseGamer.isActiveSpectator() && spectatorOptions2.getPlayer() == this.player) { + if (spectatorOptions2.isAutoTeleport() || spectatorOptions2.isFirstPersonMode()) { baseGamer.toPlayer().teleport(this.player); } - if (spectatorOptions2.c()) { + if (spectatorOptions2.isFirstPersonMode()) { baseGamer.toPlayer().setGameMode(GameMode.SPECTATOR); baseGamer.toPlayer().setSpectatorTarget(this.player); } @@ -190,108 +190,108 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } } - private void m() { + private void detachSpectators() { for (BaseGamer baseGamer : this.getGame().getGamers()) { SpectatorOptions spectatorOptions2 = baseGamer.getSpectatorOptions(); - if (baseGamer.g() && spectatorOptions2.getPlayer() == this.player) { + if (baseGamer.isActiveSpectator() && spectatorOptions2.getPlayer() == this.player) { Player player = baseGamer.toPlayer(); player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(true); player.setFlying(true); - if (!this.spectatorOptions.f()) { + if (!this.spectatorOptions.isTemporary()) { spectatorOptions2.setPlayer(null); } } } } - private void n() { + private void enableSpectatorVisibility() { this.player.setAllowFlight(true); this.player.setFlying(true); VersionAdapters.get().setCollidable(this.getGame().getEngine().getPlatform(), this.player, false); this.player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0)); - PlayerVisibility.b(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers()); + PlayerVisibility.hideFromRegistry(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers()); } - private void o() { + private void disableSpectatorVisibility() { VersionAdapters.get().setCollidable(this.getGame().getEngine().getPlatform(), this.player, true); - PlayerVisibility.a(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers()); + PlayerVisibility.showToRegistry(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers()); } - private void q() { - this.player.setFlySpeed(this.spectatorOptions.b()); - this.player.setWalkSpeed(this.spectatorOptions.b()); - if (this.spectatorOptions.e()) { + private void applySpectatorOptions() { + this.player.setFlySpeed(this.spectatorOptions.getSpeed()); + this.player.setWalkSpeed(this.spectatorOptions.getSpeed()); + if (this.spectatorOptions.isNightVision()) { this.player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1)); } } - private void r() { - this.hotbar.a(0, this::i, new ItemBuilder(Material.COMPASS).setDisplayName(this.getGame().getMessages().getItemSettings()).build()); - this.hotbar.a(4, this::s, new ItemBuilder(ArcadeMaterial.COMPARATOR).setDisplayName(this.getGame().getMessages().getItemSpectatorSettings()).build()); + private void giveSpectatorHotbar() { + this.hotbar.setSlot(0, this::openSpectatorMenu, new ItemBuilder(Material.COMPASS).setDisplayName(this.getGame().getMessages().getItemSettings()).build()); + this.hotbar.setSlot(4, this::openSpectatorSettings, new ItemBuilder(ArcadeMaterial.COMPARATOR).setDisplayName(this.getGame().getMessages().getItemSpectatorSettings()).build()); if (!this.getGame().getManager().getEngine().getNetworkManager().getSettings().isEnabled()) { - this.hotbar.a(7, this::j, new ItemBuilder(Material.PAPER).setDisplayName(this.getGame().getMessages().getItemPlayAgain()).build()); + this.hotbar.setSlot(7, this::playAgain, new ItemBuilder(Material.PAPER).setDisplayName(this.getGame().getMessages().getItemPlayAgain()).build()); } - this.hotbar.a(8, this::leave, new ItemBuilder(this.getGame().getSettings().getLeaveGameMaterial(), this.getGame().getSettings().getLeaveGameData()).setDisplayName(this.getGame().getMessages().getItemLeave()).build()); + this.hotbar.setSlot(8, this::leave, new ItemBuilder(this.getGame().getSettings().getLeaveGameMaterial(), this.getGame().getSettings().getLeaveGameData()).setDisplayName(this.getGame().getMessages().getItemLeave()).build()); } - public void i() { - this.getGame().getSpectatorMenu().a(this.user); + public void openSpectatorMenu() { + this.getGame().getSpectatorMenu().open(this.user); } - private void s() { + private void openSpectatorSettings() { EngineMessages engineMessages = this.getGame().getEngine().getMessages(); InventoryMenu inventoryMenu = new InventoryMenu(engineMessages.getSpectatorTitle(), 36); - inventoryMenu.a(11, defaultUser -> { + inventoryMenu.setSlot(11, defaultUser -> { this.player.setFlySpeed(0.2F); this.player.setWalkSpeed(0.2F); - this.spectatorOptions.a(0.2F); + this.spectatorOptions.setSpeed(0.2F); this.player.sendMessage(engineMessages.getSpectatorNoSpeed()); }, new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(engineMessages.getSpectatorItemNoSpeed()).build()); - inventoryMenu.a(12, defaultUser2 -> { + inventoryMenu.setSlot(12, defaultUser2 -> { this.player.setFlySpeed(0.3F); this.player.setWalkSpeed(0.3F); - this.spectatorOptions.a(0.3F); + this.spectatorOptions.setSpeed(0.3F); this.player.sendMessage(engineMessages.getSpectatorSpeed1()); }, new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed1()).build()); - inventoryMenu.a(13, defaultUser3 -> { + inventoryMenu.setSlot(13, defaultUser3 -> { this.player.setFlySpeed(0.4F); this.player.setWalkSpeed(0.4F); - this.spectatorOptions.a(0.4F); + this.spectatorOptions.setSpeed(0.4F); this.player.sendMessage(engineMessages.getSpectatorSpeed2()); }, new ItemBuilder(Material.IRON_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed2()).build()); - inventoryMenu.a(14, defaultUser4 -> { + inventoryMenu.setSlot(14, defaultUser4 -> { this.player.setFlySpeed(0.5F); this.player.setWalkSpeed(0.5F); - this.spectatorOptions.a(0.5F); + this.spectatorOptions.setSpeed(0.5F); this.player.sendMessage(engineMessages.getSpectatorSpeed3()); }, new ItemBuilder(ArcadeMaterial.GOLDEN_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed3()).build()); - inventoryMenu.a(15, defaultUser5 -> { + inventoryMenu.setSlot(15, defaultUser5 -> { this.player.setFlySpeed(0.6F); this.player.setWalkSpeed(0.6F); - this.spectatorOptions.a(0.6F); + this.spectatorOptions.setSpeed(0.6F); this.player.sendMessage(engineMessages.getSpectatorSpeed4()); }, new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed4()).build()); - this.a(inventoryMenu); - this.user.a(inventoryMenu); + this.populateSpectatorToggles(inventoryMenu); + this.user.openMenu(inventoryMenu); } - private void a(InventoryMenu inventoryMenu) { + private void populateSpectatorToggles(InventoryMenu inventoryMenu) { EngineMessages engineMessages = this.getGame().getEngine().getMessages(); - inventoryMenu.a(21, defaultUser -> { - this.spectatorOptions.b(!this.spectatorOptions.d()); - if (this.spectatorOptions.d()) { + inventoryMenu.setSlot(21, defaultUser -> { + this.spectatorOptions.setAutoTeleport(!this.spectatorOptions.isAutoTeleport()); + if (this.spectatorOptions.isAutoTeleport()) { this.player.sendMessage(engineMessages.getSpectatorTeleportOn()); } else { this.player.sendMessage(engineMessages.getSpectatorTeleportOff()); } - this.a(inventoryMenu); - }, new ItemBuilder(Material.COMPASS).setDisplayName(this.spectatorOptions.d() ? engineMessages.getSpectatorItemTeleportOff() : engineMessages.getSpectatorItemTeleportOn()).build()); - inventoryMenu.a(22, defaultUser2 -> { - this.spectatorOptions.c(!this.spectatorOptions.e()); - if (this.spectatorOptions.e()) { + this.populateSpectatorToggles(inventoryMenu); + }, new ItemBuilder(Material.COMPASS).setDisplayName(this.spectatorOptions.isAutoTeleport() ? engineMessages.getSpectatorItemTeleportOff() : engineMessages.getSpectatorItemTeleportOn()).build()); + inventoryMenu.setSlot(22, defaultUser2 -> { + this.spectatorOptions.setNightVision(!this.spectatorOptions.isNightVision()); + if (this.spectatorOptions.isNightVision()) { this.player.sendMessage(engineMessages.getSpectatorNightVisionOn()); this.player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1)); } else { @@ -299,25 +299,25 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { this.player.removePotionEffect(PotionEffectType.NIGHT_VISION); } - this.a(inventoryMenu); - }, new ItemBuilder(this.spectatorOptions.e() ? VersionAdapters.get().resolveMaterial(ArcadeMaterial.ENDER_EYE) : Material.ENDER_PEARL).setDisplayName(this.spectatorOptions.e() ? engineMessages.getSpectatorItemNightVisionOff() : engineMessages.getSpectatorItemNightVisionOn()).build()); - inventoryMenu.a(23, defaultUser3 -> { - this.spectatorOptions.a(!this.spectatorOptions.c()); - if (this.spectatorOptions.c()) { + this.populateSpectatorToggles(inventoryMenu); + }, new ItemBuilder(this.spectatorOptions.isNightVision() ? VersionAdapters.get().resolveMaterial(ArcadeMaterial.ENDER_EYE) : Material.ENDER_PEARL).setDisplayName(this.spectatorOptions.isNightVision() ? engineMessages.getSpectatorItemNightVisionOff() : engineMessages.getSpectatorItemNightVisionOn()).build()); + inventoryMenu.setSlot(23, defaultUser3 -> { + this.spectatorOptions.setFirstPersonMode(!this.spectatorOptions.isFirstPersonMode()); + if (this.spectatorOptions.isFirstPersonMode()) { this.player.sendMessage(engineMessages.getSpectatorFirstPersonOn()); } else { this.player.sendMessage(engineMessages.getSpectatorFirstPersonOff()); } - this.a(inventoryMenu); - }, new ItemBuilder(ArcadeMaterial.CLOCK).setDisplayName(this.spectatorOptions.c() ? engineMessages.getSpectatorItemFirstPersonOff() : engineMessages.getSpectatorItemFirstPersonOn()).build()); + this.populateSpectatorToggles(inventoryMenu); + }, new ItemBuilder(ArcadeMaterial.CLOCK).setDisplayName(this.spectatorOptions.isFirstPersonMode() ? engineMessages.getSpectatorItemFirstPersonOff() : engineMessages.getSpectatorItemFirstPersonOn()).build()); } - protected void j() { - this.toUser().a(this.getGame().getManager().getSessions().getGameSearcher()); + protected void playAgain() { + this.toUser().quickJoin(this.getGame().getManager().getSessions().getGameSearcher()); } - public void a(Location location) { + public void teleport(Location location) { if (!VersionAdapters.get().isLatestVariant()) { location.getChunk().load(); } @@ -327,13 +327,13 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } } - public void b(List list2) { + public void setRewardCommands(List list2) { if (list2 != null) { this.list = list2; } } - public void a(List list2, UnaryOperator unaryOperator) { + public void setRewardCommands(List list2, UnaryOperator unaryOperator) { if (list2 != null && !list2.isEmpty()) { this.list = new ArrayList<>(list2.size()); @@ -343,25 +343,25 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } } - public void a(GameScoreboard gameScoreboard) { + public void applyScoreboard(GameScoreboard gameScoreboard) { gameScoreboard.applyTo(this.player); } - public void a(List list2, Context context) { + public void updateSidebar(List list2, Context context) { if (this.playerSidebar == null) { this.playerSidebar = this.getGame().getScoreboard().getOrCreateSidebar(this.getGame().getEngine()).createPlayerSidebar(this.player); } if (this.getGame().getEngine().hasPlaceholderResolver()) { - this.playerSidebar.a(list2, context, text -> this.getGame().getEngine().getPlaceholderResolver().a(this.player, text)); + this.playerSidebar.update(list2, context, text -> this.getGame().getEngine().getPlaceholderResolver().resolve(this.player, text)); } else { - this.playerSidebar.a(list2, context); + this.playerSidebar.update(list2, context); } } - public void k() { + public void clearSidebar() { if (this.playerSidebar != null) { - this.playerSidebar.a(); + this.playerSidebar.clear(); } } @@ -375,30 +375,30 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } public Boolean getCondition(String text) { - return text.equals("SPECTATOR") ? this.e : this.getGame().getCondition(text); + return text.equals("SPECTATOR") ? this.spectator : this.getGame().getCondition(text); } - public void a(long longVal) { + public void onTick(long longVal) { Player player = this.spectatorOptions.getPlayer(); - if (this.g() && player != null) { - if (this.spectatorOptions.d() && longVal % 100L == 0L) { + if (this.isActiveSpectator() && player != null) { + if (this.spectatorOptions.isAutoTeleport() && longVal % 100L == 0L) { Location location = player.getLocation(); - if (Locations.b(location, this.player.getLocation()) >= 200.0) { + if (Locations.distanceSquared(location, this.player.getLocation()) >= 200.0) { this.player.teleport(location); } } if (this.player.getSpectatorTarget() == player) { BaseGamer baseGamer = (BaseGamer)this.getGame().getGamers().c(player); - if (baseGamer != null && !baseGamer.f()) { + if (baseGamer != null && !baseGamer.isSpectator()) { this.sendActionBar(this.getGame().getMessages().getSpectatorTarget(), baseGamer); } } else if (player.getWorld() == this.player.getWorld()) { - this.sendActionBar(this.getGame().getMessages().getSpectatorTargetFirstPerson(), Contexts.a((VariableProvider) text -> { + this.sendActionBar(this.getGame().getMessages().getSpectatorTargetFirstPerson(), Contexts.ofVariables((VariableProvider) text -> { if (text.equals("player")) { return player.getName(); } else { - return text.equals("distance") ? Strings.a(this.player.getLocation().distance(player.getLocation()), 1) : null; + return text.equals("distance") ? Strings.formatFixedDecimal(this.player.getLocation().distance(player.getLocation()), 1) : null; } })); } @@ -406,26 +406,26 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } public void leave() { - if (MethodSuffixProbe.a(this.getGame().getEngine().getPlugin().getClass())) { - this.k(); + if (MethodSuffixProbe.hasTargetMethodSuffix(this.getGame().getEngine().getPlugin().getClass())) { + this.clearSidebar(); DefaultEngine defaultEngine = this.getGame().getEngine(); if (this.getGame().getSettings().isTabPrivate()) { - PlayerVisibility.b(defaultEngine.getPlugin(), this.player, this.getGame().getGamers(), defaultEngine.getUsers()); + PlayerVisibility.restoreVisibility(defaultEngine.getPlugin(), this.player, this.getGame().getGamers(), defaultEngine.getUsers()); } else { - PlayerVisibility.a(defaultEngine.getPlugin(), this.player); + PlayerVisibility.showAllPlayers(defaultEngine.getPlugin(), this.player); } - if (this.e) { + if (this.spectator) { VersionAdapters.get().setCollidable(defaultEngine.getPlatform(), this.player, true); - if (!this.getSpectatorOptions().f()) { + if (!this.getSpectatorOptions().isTemporary()) { this.getGame().getSpectatorTeam().removeEntry(this.player.getName()); } } else { - this.m(); + this.detachSpectators(); } this.user.setGamer((ro.fr33styler.arcade.api.engine.game.gamer.Gamer)null); - this.user.j(); + this.user.restoreSnapshot(); Bukkit.getPluginManager().callEvent(new GameLeaveEvent(this)); for (String text : this.list) { @@ -438,17 +438,17 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer { } } - public void a(Map map) { - this.spectatorOptions.a(Float.parseFloat((String)map.get("spectator-speed"))); - this.spectatorOptions.b(Boolean.parseBoolean((String)map.get("spectator-auto-teleport"))); - this.spectatorOptions.c(Boolean.parseBoolean((String)map.get("spectator-night-vision"))); - this.spectatorOptions.a(Boolean.parseBoolean((String)map.get("spectator-first-person-mode"))); + public void loadProperties(Map map) { + this.spectatorOptions.setSpeed(Float.parseFloat((String)map.get("spectator-speed"))); + this.spectatorOptions.setAutoTeleport(Boolean.parseBoolean((String)map.get("spectator-auto-teleport"))); + this.spectatorOptions.setNightVision(Boolean.parseBoolean((String)map.get("spectator-night-vision"))); + this.spectatorOptions.setFirstPersonMode(Boolean.parseBoolean((String)map.get("spectator-first-person-mode"))); } - public void b(Map map) { - map.put("spectator-speed", String.valueOf(this.spectatorOptions.b())); - map.put("spectator-auto-teleport", String.valueOf(this.spectatorOptions.d())); - map.put("spectator-night-vision", String.valueOf(this.spectatorOptions.e())); - map.put("spectator-first-person-mode", String.valueOf(this.spectatorOptions.c())); + public void saveProperties(Map map) { + map.put("spectator-speed", String.valueOf(this.spectatorOptions.getSpeed())); + map.put("spectator-auto-teleport", String.valueOf(this.spectatorOptions.isAutoTeleport())); + map.put("spectator-night-vision", String.valueOf(this.spectatorOptions.isNightVision())); + map.put("spectator-first-person-mode", String.valueOf(this.spectatorOptions.isFirstPersonMode())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/player/DefaultGamerSet.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/player/DefaultGamerSet.java index 34ad1c7..a0852ca 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/player/DefaultGamerSet.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/player/DefaultGamerSet.java @@ -11,19 +11,19 @@ import ro.fr33styler.arcade.api.engine.game.gamer.GamerSet; import ro.fr33styler.arcade.api.engine.text.Context; public class DefaultGamerSet extends PlayerRegistry implements GamerSet { - public void a(String text) { + public void broadcast(String text) { for (BaseGamer baseGamer : this.map.values()) { baseGamer.sendMessage(text); } } - public void a(Text text, Context context) { - this.a(text.a(context)); + public void broadcast(Text text, Context context) { + this.broadcast(text.render(context)); } - public void a(List list) { + public void updateSidebars(List list) { for (BaseGamer baseGamer : this.map.values()) { - baseGamer.a(list, baseGamer); + baseGamer.updateSidebar(list, baseGamer); } } @@ -37,11 +37,11 @@ public class DefaultGamerSet extends PlayerRegistry impl } } - public int a() { + public int getAliveCount() { int index = 0; for (BaseGamer baseGamer : this.map.values()) { - if (!baseGamer.f()) { + if (!baseGamer.isSpectator()) { index++; } } @@ -49,7 +49,7 @@ public class DefaultGamerSet extends PlayerRegistry impl return index; } - public G a(Location location, Predicate predicate) { + public G getNearest(Location location, Predicate predicate) { BaseGamer baseGamer = null; double doubleVal = Double.MAX_VALUE; Location location2 = new Location(null, 0.0, 0.0, 0.0); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/game/ui/GameMenu.java b/common/src/main/java/ro/fr33styler/arcade/engine/game/ui/GameMenu.java index 173b81e..fb7eb0c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/game/ui/GameMenu.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/game/ui/GameMenu.java @@ -26,106 +26,106 @@ public class GameMenu { private final List list = new ArrayList<>(); - private static final int[] b = new int[] { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 }; + private static final int[] ARENA_SLOTS = new int[] { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 }; private final AbstractGameManager manager; - private final Supplier> d; + private final Supplier> sessionsSupplier; public GameMenu(AbstractGameManager manager2, Supplier> supplier) { this.manager = manager2; - this.d = supplier; + this.sessionsSupplier = supplier; } - public void a(DefaultUser defaultUser) { + public void open(DefaultUser defaultUser) { if (!this.list.isEmpty()) { - defaultUser.a(this.list.get(0)); + defaultUser.openMenu(this.list.get(0)); } } - private void a(InventoryMenu inventoryMenu, HumanEntity humanEntity) { + private void reopenMenu(InventoryMenu inventoryMenu, HumanEntity humanEntity) { DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().a(humanEntity.getUniqueId()); if (defaultUser == null) { humanEntity.closeInventory(); } else { - defaultUser.a(inventoryMenu); + defaultUser.openMenu(inventoryMenu); } } - private void a(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) { - Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null); - inventoryMenu.a(18, defaultUser -> defaultUser.a(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().a(context)).build()); - Context context2 = Contexts.a((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null); - inventoryMenu2.a(26, defaultUser2 -> defaultUser2.a(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().a(context2)).build()); + private void linkPages(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null); + inventoryMenu.setSlot(18, defaultUser -> defaultUser.openMenu(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().render(context)).build()); + Context context2 = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null); + inventoryMenu2.setSlot(26, defaultUser2 -> defaultUser2.openMenu(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().render(context2)).build()); } - private void a(int index) { + private void expandPages(int index) { if (index == 1) { this.list.add(new InventoryMenu(this.manager.getMessages().getJoinArenasName(), 45)); } for (int index2 = this.list.size(); index2 < index; index2++) { int index3 = index2 + 1; - Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null); - InventoryMenu inventoryMenu = new InventoryMenu(this.manager.getMessages().getJoinArenasPageName().a(context), 45); + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null); + InventoryMenu inventoryMenu = new InventoryMenu(this.manager.getMessages().getJoinArenasPageName().render(context), 45); if (!this.list.isEmpty()) { - this.a(index3, inventoryMenu, this.list.get(this.list.size() - 1)); + this.linkPages(index3, inventoryMenu, this.list.get(this.list.size() - 1)); } this.list.add(inventoryMenu); } } - private void b(int index) { + private void shrinkPages(int index) { ArrayList list2 = new ArrayList<>(); while (this.list.size() > index) { - list2.addAll(this.list.remove(this.list.size() - 1).a().getViewers()); + list2.addAll(this.list.remove(this.list.size() - 1).getInventory().getViewers()); } InventoryMenu inventoryMenu = this.list.get(index - 1); if (index == 1) { - inventoryMenu.a(this.manager.getMessages().getJoinArenasName()); + inventoryMenu.setTitle(this.manager.getMessages().getJoinArenasName()); } - inventoryMenu.a(17, null, null); + inventoryMenu.setSlot(17, null, null); for (HumanEntity humanEntity : list2) { - this.a(inventoryMenu, humanEntity); + this.reopenMenu(inventoryMenu, humanEntity); } } - private void c(int index) { + private void resizePages(int index) { if (index != this.list.size()) { if (index > this.list.size()) { - this.a(index); + this.expandPages(index); } else { - this.b(index); + this.shrinkPages(index); } } } - public void a() { - List list2 = this.d.get(); + public void update() { + List list2 = this.sessionsSupplier.get(); list2.removeIf(session -> session.getStatus().phaseType() != PhaseType.WAITING); list2.sort(Comparator.comparingInt(session2 -> session2.getStatus().players())); - this.c(Math.max(1, IntMath.divide(list2.size(), 21, RoundingMode.CEILING))); + this.resizePages(Math.max(1, IntMath.divide(list2.size(), 21, RoundingMode.CEILING))); for (InventoryMenu inventoryMenu : this.list) { - inventoryMenu.a(40, defaultUser -> { + inventoryMenu.setSlot(40, defaultUser -> { InventoryMenu inventoryMenu2 = defaultUser.getMenu(); if (inventoryMenu2 != null) { - defaultUser.a(inventoryMenu2); + defaultUser.openMenu(inventoryMenu2); } }, new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasGoBack()).build()); for (int index = 0; index < 21; index++) { if (!list2.isEmpty()) { - this.a(inventoryMenu, b[index], (Session) list2.remove(list2.size() - 1)); + this.setArenaButton(inventoryMenu, ARENA_SLOTS[index], (Session) list2.remove(list2.size() - 1)); } else { - inventoryMenu.a(b[index], null, null); + inventoryMenu.setSlot(ARENA_SLOTS[index], null, null); } } } } - private void a(InventoryMenu inventoryMenu, int index, Session session) { + private void setArenaButton(InventoryMenu inventoryMenu, int index, Session session) { ItemBuilder itemBuilder = new ItemBuilder(ArcadeMaterial.FIREWORK_STAR); - itemBuilder.setDisplayName(this.manager.getMessages().getJoinArenasArenaName().a(session)); - itemBuilder.setLore(TextRenderer.a(this.manager.getMessages().getJoinArenasArenaLore(), session)); - inventoryMenu.a(index, defaultUser -> { + itemBuilder.setDisplayName(this.manager.getMessages().getJoinArenasArenaName().render(session)); + itemBuilder.setLore(TextRenderer.render(this.manager.getMessages().getJoinArenasArenaLore(), session)); + inventoryMenu.setSlot(index, defaultUser -> { Player player = defaultUser.toPlayer(); player.closeInventory(); Result result = session.canPlay(defaultUser); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/item/ItemBuilder.java b/common/src/main/java/ro/fr33styler/arcade/engine/item/ItemBuilder.java index ae48142..5103bef 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/item/ItemBuilder.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/item/ItemBuilder.java @@ -51,7 +51,7 @@ public class ItemBuilder { } public ItemBuilder setDisplayName(Text text, Context context) { - this.meta.setDisplayName(text.a(context)); + this.meta.setDisplayName(text.render(context)); return this; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/item/material/Materials.java b/common/src/main/java/ro/fr33styler/arcade/engine/item/material/Materials.java index 1e474e1..ca4383d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/item/material/Materials.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/item/material/Materials.java @@ -4,7 +4,7 @@ import org.bukkit.Material; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public final class Materials { - public static boolean a(Material material) { + public static boolean isWool(Material material) { return VersionAdapters.get().isWoolMaterial(material); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardCommand.java index 522c763..3f68bc7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardCommand.java @@ -41,23 +41,23 @@ public class AddLeaderboardCommand implements CommandExecutor { player.sendMessage("§cThe id is already in use!"); } else { Location location = player.getLocation(); - this.engine.getDisplayManager().a(text2, location); - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text2); + this.engine.getDisplayManager().addLeaderboardGroup(text2, location); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text2); for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) { - for (GameLeaderboardSettings gameLeaderboardSettings : abstractGameManager.getStorage().getStorage4().getLeaderboards().values()) { - if (gameLeaderboardSettings.getId().equals(leaderboardGroup.a()) && abstractGameManager.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) { + for (GameLeaderboardSettings gameLeaderboardSettings : abstractGameManager.getStorage().getLeaderboardStorage().getLeaderboards().values()) { + if (gameLeaderboardSettings.getId().equals(leaderboardGroup.getId()) && abstractGameManager.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) { LeaderboardSource leaderboardSource = abstractGameManager.createLeaderboardSource(gameLeaderboardSettings); leaderboardGroup.getMap().put(leaderboardSource.getSettings().getMode(), leaderboardSource); - leaderboardSource.d(); + leaderboardSource.refreshCache(); } } } - this.engine.getDisplayManager().g(); - this.engine.getUsers().c(leaderboardGroup); + this.engine.getDisplayManager().refreshLeaderboardToggles(); + this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup); this.engine.getDatabaseManager().getLeaderboards().put(text2, location); - this.engine.getDatabaseManager().f(); + this.engine.getDatabaseManager().saveConfig(); player.sendMessage("§aLeaderboard added!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardModeCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardModeCommand.java index 6b0c508..0ca366d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardModeCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardModeCommand.java @@ -47,30 +47,30 @@ public class AddLeaderboardModeCommand implements CommandExecutor { Location location = player.getEyeLocation(); String text2 = texts[index]; String text3 = this.manager.getLeaderboardTitles().isEmpty() ? this.manager.getName() : texts[index + 1]; - Collection collection = this.manager.getEngine().getDisplayManager().b().values(); - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation); + Collection collection = this.manager.getEngine().getDisplayManager().getLeaderboardGroups().values(); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation); if (leaderboardGroup == null) { player.sendMessage("§cYou must look at the leaderboard!"); } else if (leaderboardGroup.getMap().containsKey(text3)) { player.sendMessage("§cThe leaderboard already has this mode!"); } else { GameLeaderboardSettings gameLeaderboardSettings = new GameLeaderboardSettings(); - gameLeaderboardSettings.setId(leaderboardGroup.a()); + gameLeaderboardSettings.setId(leaderboardGroup.getId()); gameLeaderboardSettings.setMode(text3); gameLeaderboardSettings.setColumn(text2); gameLeaderboardSettings.setLocation(leaderboardGroup.getLocation()); LeaderboardSource leaderboardSource = this.manager.createLeaderboardSource(gameLeaderboardSettings); leaderboardGroup.getMap().put(text3, leaderboardSource); - leaderboardSource.d(); + leaderboardSource.refreshCache(); int index2 = 0; - while (this.manager.getStorage().getStorage4().getLeaderboards().containsKey(String.valueOf(index2))) { + while (this.manager.getStorage().getLeaderboardStorage().getLeaderboards().containsKey(String.valueOf(index2))) { index2++; } - this.manager.getStorage().getStorage4().getLeaderboards().put(String.valueOf(index2), gameLeaderboardSettings); - this.manager.getStorage().getStorage4().c(); - this.manager.getEngine().getDisplayManager().a(leaderboardGroup); + this.manager.getStorage().getLeaderboardStorage().getLeaderboards().put(String.valueOf(index2), gameLeaderboardSettings); + this.manager.getStorage().getLeaderboardStorage().save(); + this.manager.getEngine().getDisplayManager().updateLeaderboardGroup(leaderboardGroup); sender.sendMessage("§aThe mode has been added!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardToggleCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardToggleCommand.java index c48297f..2dd9be1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardToggleCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/AddLeaderboardToggleCommand.java @@ -46,9 +46,9 @@ public class AddLeaderboardToggleCommand implements CommandExecutor { LeaderboardToggleSettings leaderboardToggleSettings = new LeaderboardToggleSettings(); leaderboardToggleSettings.setLocation(location); leaderboardToggleSettings.getLeaderboardIds().addAll(Arrays.asList(text2.split(","))); - this.engine.getDisplayManager().a(text3, leaderboardToggleSettings); + this.engine.getDisplayManager().addLeaderboardToggle(text3, leaderboardToggleSettings); this.engine.getDatabaseManager().getTogglersData().put(text3, leaderboardToggleSettings); - this.engine.getDatabaseManager().f(); + this.engine.getDatabaseManager().saveConfig(); player.sendMessage("§aToggler added!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardCommand.java index 5ef0601..7090b29 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardCommand.java @@ -29,21 +29,21 @@ public class RemoveLeaderboardCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { Player player = (Player)sender; Location location = player.getEyeLocation(); - Collection collection = this.engine.getDisplayManager().b().values(); - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation); + Collection collection = this.engine.getDisplayManager().getLeaderboardGroups().values(); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation); if (leaderboardGroup == null) { player.sendMessage("§cYou must look at the leaderboard!"); } else { collection.remove(leaderboardGroup); for (DefaultUser defaultUser : this.engine.getUsers()) { - defaultUser.b(leaderboardGroup); + defaultUser.removeLeaderboardDisplay(leaderboardGroup); } - this.engine.getDatabaseManager().getLeaderboards().remove(leaderboardGroup.a()); - this.engine.getDatabaseManager().f(); - this.engine.getDisplayManager().g(); - this.engine.getUsers().c(leaderboardGroup); + this.engine.getDatabaseManager().getLeaderboards().remove(leaderboardGroup.getId()); + this.engine.getDatabaseManager().saveConfig(); + this.engine.getDisplayManager().refreshLeaderboardToggles(); + this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup); player.sendMessage("§aThe leaderboard has been removed!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardModeCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardModeCommand.java index 7aa30a6..33e4c72 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardModeCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardModeCommand.java @@ -44,8 +44,8 @@ public class RemoveLeaderboardModeCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { Player player = (Player)sender; Location location = player.getEyeLocation(); - Collection collection = this.manager.getEngine().getDisplayManager().b().values(); - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation); + Collection collection = this.manager.getEngine().getDisplayManager().getLeaderboardGroups().values(); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation); if (leaderboardGroup == null) { player.sendMessage("§cYou must look at the leaderboard!"); } else { @@ -53,9 +53,9 @@ public class RemoveLeaderboardModeCommand implements CommandExecutor { if (leaderboardSource == null) { player.sendMessage("§cThe leaderboard doesn't have this mode!"); } else { - this.manager.getStorage().getStorage4().getLeaderboards().entrySet().removeIf(entry -> entry.getValue() == leaderboardSource.getSettings()); - this.manager.getStorage().getStorage4().c(); - this.manager.getEngine().getDisplayManager().a(leaderboardGroup); + this.manager.getStorage().getLeaderboardStorage().getLeaderboards().entrySet().removeIf(entry -> entry.getValue() == leaderboardSource.getSettings()); + this.manager.getStorage().getLeaderboardStorage().save(); + this.manager.getEngine().getDisplayManager().updateLeaderboardGroup(leaderboardGroup); player.sendMessage("§aThe mode has been removed!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardToggleCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardToggleCommand.java index 1b7c9c5..9f15d88 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardToggleCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/command/RemoveLeaderboardToggleCommand.java @@ -30,26 +30,26 @@ public class RemoveLeaderboardToggleCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { Player player = (Player)sender; Location location = player.getEyeLocation(); - List list = this.engine.getDisplayManager().c(); - LeaderboardToggle leaderboardToggle = (LeaderboardToggle)ViewDistance.a(location, list, LeaderboardToggle::b); + List list = this.engine.getDisplayManager().getLeaderboardToggles(); + LeaderboardToggle leaderboardToggle = (LeaderboardToggle)ViewDistance.findTarget(location, list, LeaderboardToggle::getLocation); if (leaderboardToggle == null) { player.sendMessage("§cYou must look at the toggler!"); } else { list.remove(leaderboardToggle); for (DefaultUser defaultUser : this.engine.getUsers()) { - defaultUser.b(leaderboardToggle); + defaultUser.removeLeaderboardToggle(leaderboardToggle); } for (String text2 : leaderboardToggle.getSettings().getLeaderboardIds()) { - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text2); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text2); if (leaderboardGroup != null) { - this.engine.getUsers().c(leaderboardGroup); + this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup); } } - this.engine.getDatabaseManager().getTogglersData().remove(leaderboardToggle.a()); - this.engine.getDatabaseManager().f(); + this.engine.getDatabaseManager().getTogglersData().remove(leaderboardToggle.getId()); + this.engine.getDatabaseManager().saveConfig(); player.sendMessage("§aThe toggler has been removed!"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardDisplay.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardDisplay.java index f0fa810..073c844 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardDisplay.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardDisplay.java @@ -29,7 +29,7 @@ public class LeaderboardDisplay implements Context, Viewable { private LeaderboardSource leaderboardSource; - private int c; + private int viewerRank; private LeaderboardEntry leaderboardEntry; @@ -45,7 +45,7 @@ public class LeaderboardDisplay implements Context, Viewable { this.hologram = new Hologram(leaderboardGroup2.getLocation()); this.leaderboardPeriod = leaderboardGroup2.getEngine().getSettings().getLeaderboardDefaultPosition(); this.leaderboardSource = (LeaderboardSource) Iterables.getFirst(leaderboardGroup2.getMap().values(), null); - this.e(); + this.refreshViewerPosition(); } public LeaderboardGroup getLeaderboardGroup() { @@ -56,18 +56,18 @@ public class LeaderboardDisplay implements Context, Viewable { return this.leaderboardPeriod; } - public void a(LeaderboardPeriod leaderboardPeriod2) { + public void setLeaderboardPeriod(LeaderboardPeriod leaderboardPeriod2) { this.leaderboardPeriod = leaderboardPeriod2; - this.e(); + this.refreshViewerPosition(); } - public void a(String text) { + public void setMode(String text) { this.leaderboardSource = (LeaderboardSource) this.leaderboardGroup.getMap().get(text); - this.e(); + this.refreshViewerPosition(); } - public boolean a(int index) { - return this.hologram.a(index); + public boolean hasEntityId(int index) { + return this.hologram.hasEntityId(index); } public Location getLocation() { @@ -78,8 +78,8 @@ public class LeaderboardDisplay implements Context, Viewable { return this.hologram.getSet(); } - public void a(Player player2, boolean flag) { - this.hologram.a(player2, flag); + public void setVisible(Player player2, boolean flag) { + this.hologram.setVisible(player2, flag); } public Boolean getCondition(String text) { @@ -101,61 +101,61 @@ public class LeaderboardDisplay implements Context, Viewable { if (text.startsWith("position_")) { boolean flag = text.endsWith("_score"); int index = NumberUtils.toInt(text.substring(9, text.length() - (flag ? 6 : 0))) - 1; - LeaderboardEntry[] leaderboardEntrys = this.leaderboardSource.a(this.leaderboardPeriod); + LeaderboardEntry[] leaderboardEntrys = this.leaderboardSource.getTopEntries(this.leaderboardPeriod); if (index < 0 || index >= leaderboardEntrys.length) { return null; } else { - return flag ? Strings.b(leaderboardEntrys[index].score(), 3) : this.b(leaderboardEntrys[index].name()); + return flag ? Strings.groupDigits(leaderboardEntrys[index].score(), 3) : this.formatPlayerName(leaderboardEntrys[index].name()); } } else { return switch(text) { case "type" -> - this.leaderboardSource.b(); + this.leaderboardSource.getSourceTitle(); case "mode" -> - this.leaderboardSource.c(); + this.leaderboardSource.getModeTitle(); case "time" -> - this.leaderboardPeriod.a(this.getLeaderboardGroup().getEngine().getMessages()); + this.leaderboardPeriod.getDisplayName(this.getLeaderboardGroup().getEngine().getMessages()); case "viewer_rank" -> - this.leaderboardEntry == null ? null : Strings.b(this.c, 3); + this.leaderboardEntry == null ? null : Strings.groupDigits(this.viewerRank, 3); case "viewer_name" -> - this.leaderboardEntry == null ? null : this.b(this.leaderboardEntry.name()); + this.leaderboardEntry == null ? null : this.formatPlayerName(this.leaderboardEntry.name()); case "viewer_score" -> - this.leaderboardEntry == null ? null : Strings.b(this.leaderboardEntry.score(), 3); + this.leaderboardEntry == null ? null : Strings.groupDigits(this.leaderboardEntry.score(), 3); default -> null; }; } } - private String b(String text) { + private String formatPlayerName(String text) { DefaultEngine defaultEngine = this.leaderboardGroup.getEngine(); if (defaultEngine.getSettings().isLeaderboardWithPapiSupport() && defaultEngine.hasPlaceholderResolver()) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(text); String text2 = defaultEngine.getMessages().getLeaderboardNamePapiFormat(); - return Strings.d(defaultEngine.getPlaceholderResolver().a(offlinePlayer, text2.replace("%name%", text))); + return Strings.translateHexColors(defaultEngine.getPlaceholderResolver().resolve(offlinePlayer, text2.replace("%name%", text))); } else { return text; } } - public void e() { - this.c = 0; + public void refreshViewerPosition() { + this.viewerRank = 0; this.leaderboardEntry = null; if (this.leaderboardSource != null && this.getLeaderboardGroup().getEngine().getSettings().isLeaderboardViewerPosition()) { - this.leaderboardSource.a(this.player, this.leaderboardPeriod, (leaderboardEntry2, integer) -> { + this.leaderboardSource.fetchPlayerRank(this.player, this.leaderboardPeriod, (leaderboardEntry2, integer) -> { if (integer > 10) { - this.c = integer; + this.viewerRank = integer; this.leaderboardEntry = leaderboardEntry2; } }); } } - public void a(ServerPlatform serverPlatform, List list) { + public void render(ServerPlatform serverPlatform, List list) { if (this.leaderboardSource == null) { - this.hologram.a(serverPlatform, new String[] { ChatColor.RED + "No modes found!" }); + this.hologram.setLines(serverPlatform, new String[] { ChatColor.RED + "No modes found!" }); } else { - this.hologram.a(serverPlatform, TextRenderer.a(list, this)); + this.hologram.setLines(serverPlatform, TextRenderer.render(list, this)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardToggleDisplay.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardToggleDisplay.java index abe0b71..d722076 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardToggleDisplay.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/display/LeaderboardToggleDisplay.java @@ -18,12 +18,12 @@ import org.bukkit.entity.Player; import ro.fr33styler.arcade.api.engine.text.Context; public class LeaderboardToggleDisplay implements Context, Viewable { - private int a; + private int selectedIndex; private final LeaderboardToggle leaderboardToggle; private final Hologram hologram; public LeaderboardToggleDisplay(LeaderboardToggle leaderboardToggle2) { - this.hologram = new Hologram(leaderboardToggle2.b()); + this.hologram = new Hologram(leaderboardToggle2.getLocation()); this.leaderboardToggle = leaderboardToggle2; } @@ -31,16 +31,16 @@ public class LeaderboardToggleDisplay implements Context, Viewable { return this.leaderboardToggle; } - public int b() { - return this.a; + public int getSelectedIndex() { + return this.selectedIndex; } - public void a(int index) { - this.a = index; + public void setSelectedIndex(int index) { + this.selectedIndex = index; } - public boolean b(int index) { - return this.hologram.a(index); + public boolean hasEntityId(int index) { + return this.hologram.hasEntityId(index); } public Location getLocation() { @@ -51,13 +51,13 @@ public class LeaderboardToggleDisplay implements Context, Viewable { return this.hologram.getSet(); } - public LeaderboardSource c(int index) { + public LeaderboardSource getSourceAt(int index) { if (this.leaderboardToggle.getList().isEmpty()) { return null; } for (String text : this.leaderboardToggle.getSettings().getLeaderboardIds()) { - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.leaderboardToggle.getEngine().getDisplayManager().b().get(text); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.leaderboardToggle.getEngine().getDisplayManager().getLeaderboardGroups().get(text); if (leaderboardGroup != null) { int index2 = index % this.leaderboardToggle.getList().size(); return (LeaderboardSource)leaderboardGroup.getMap().get(this.leaderboardToggle.getList().get(index2)); @@ -67,24 +67,24 @@ public class LeaderboardToggleDisplay implements Context, Viewable { return null; } - public void a(Player player, boolean flag) { - this.hologram.a(player, flag); + public void setVisible(Player player, boolean flag) { + this.hologram.setVisible(player, flag); } public String getVariable(String text) { return switch (text) { - case "mode_1" -> this.c(this.b()).c(); - case "mode_2" -> this.c(this.b() + 1).c(); - case "mode_3" -> this.c(this.b() + 2).c(); + case "mode_1" -> this.getSourceAt(this.getSelectedIndex()).getModeTitle(); + case "mode_2" -> this.getSourceAt(this.getSelectedIndex() + 1).getModeTitle(); + case "mode_3" -> this.getSourceAt(this.getSelectedIndex() + 2).getModeTitle(); default -> null; }; } - public void a(ServerPlatform serverPlatform, List list) { + public void render(ServerPlatform serverPlatform, List list) { if (this.leaderboardToggle.getList().isEmpty()) { - this.hologram.a(serverPlatform, new String[]{ChatColor.RED + "No modes found!"}); + this.hologram.setLines(serverPlatform, new String[]{ChatColor.RED + "No modes found!"}); } else { - this.hologram.a(serverPlatform, TextRenderer.a(list, this)); + this.hologram.setLines(serverPlatform, TextRenderer.render(list, this)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardGroup.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardGroup.java index d6b5b8c..2615751 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardGroup.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardGroup.java @@ -8,19 +8,19 @@ import java.util.Map; import org.bukkit.Location; public class LeaderboardGroup { - private final String a; + private final String id; private final Location location; private final DefaultEngine engine; private final Map map = new LinkedHashMap<>(); public LeaderboardGroup(DefaultEngine engine2, String text, Location location2) { - this.a = text; + this.id = text; this.location = location2; this.engine = engine2; } - public String a() { - return this.a; + public String getId() { + return this.id; } public Location getLocation() { @@ -35,7 +35,7 @@ public class LeaderboardGroup { return this.map; } - public void e() { - this.map.values().forEach(LeaderboardSource::d); + public void refresh() { + this.map.values().forEach(LeaderboardSource::refreshCache); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardPeriod.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardPeriod.java index e73574a..3b906c9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardPeriod.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardPeriod.java @@ -7,18 +7,18 @@ public enum LeaderboardPeriod { MONTHLY("_monthly"), WEEKLY("_weekly"); - private final String d; - private static final LeaderboardPeriod[] e = {LIFETIME, MONTHLY, WEEKLY}; + private final String tableSuffix; + private static final LeaderboardPeriod[] VALUES = {LIFETIME, MONTHLY, WEEKLY}; LeaderboardPeriod(String text) { - this.d = text; + this.tableSuffix = text; } - public String a() { - return this.d; + public String getTableSuffix() { + return this.tableSuffix; } - public LeaderboardPeriod b() { + public LeaderboardPeriod next() { return switch (this) { case LIFETIME -> MONTHLY; case MONTHLY -> WEEKLY; @@ -26,7 +26,7 @@ public enum LeaderboardPeriod { }; } - public String a(EngineMessages engineMessages) { + public String getDisplayName(EngineMessages engineMessages) { return switch (this) { case LIFETIME -> engineMessages.getLeaderboardTimeLifetime(); case MONTHLY -> engineMessages.getLeaderboardTimeMonthly(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardToggle.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardToggle.java index 1b6487a..e27e887 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardToggle.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/LeaderboardToggle.java @@ -8,22 +8,22 @@ import java.util.List; import org.bukkit.Location; public class LeaderboardToggle { - private final String a; + private final String id; private final LeaderboardToggleSettings settings; private final DefaultEngine engine; private final List list = new ArrayList<>(); public LeaderboardToggle(DefaultEngine engine2, String text, LeaderboardToggleSettings settings2) { - this.a = text; + this.id = text; this.settings = settings2; this.engine = engine2; } - public String a() { - return this.a; + public String getId() { + return this.id; } - public Location b() { + public Location getLocation() { return this.settings.getLocation(); } @@ -39,11 +39,11 @@ public class LeaderboardToggle { return this.list; } - public void f() { + public void refreshAvailableModes() { this.list.clear(); for (String text : this.settings.getLeaderboardIds()) { - LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text); + LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text); if (leaderboardGroup != null) { if (this.list.isEmpty() && leaderboardGroup.getMap().isEmpty()) { return; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/StoredLeaderboard.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/StoredLeaderboard.java index e855198..35bf91c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/StoredLeaderboard.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/model/StoredLeaderboard.java @@ -13,7 +13,7 @@ import org.bukkit.entity.Player; public class StoredLeaderboard extends LeaderboardSource { private final AbstractGameManager manager; - private final Function b; + private final Function tableNameResolver; private final Map map = new EnumMap<>(LeaderboardPeriod.class); public StoredLeaderboard(AbstractGameManager abstractGameManager, GameLeaderboardSettings gameLeaderboardSettings, String text) { @@ -23,11 +23,11 @@ public class StoredLeaderboard extends LeaderboardSource { public StoredLeaderboard(AbstractGameManager manager2, GameLeaderboardSettings gameLeaderboardSettings, Function function) { super(gameLeaderboardSettings); this.manager = manager2; - this.b = function; - this.e(); + this.tableNameResolver = function; + this.initializePlaceholders(); } - private void e() { + private void initializePlaceholders() { for (LeaderboardPeriod leaderboardPeriod : LeaderboardPeriod.values()) { LeaderboardEntry[] leaderboardEntrys = new LeaderboardEntry[10]; @@ -40,31 +40,31 @@ public class StoredLeaderboard extends LeaderboardSource { } @Override - public String c() { + public String getModeTitle() { return this.manager.getLeaderboardTitles().isEmpty() ? this.manager.getMessages().getDisplayName() : (String)((Supplier)this.manager.getLeaderboardTitles().get(this.getSettings().getMode())).get(); } @Override - public String b() { + public String getSourceTitle() { return (String)((Supplier)this.manager.getLeaderboardSources().get(this.getSettings().getColumn())).get(); } @Override - public LeaderboardEntry[] a(LeaderboardPeriod leaderboardPeriod) { + public LeaderboardEntry[] getTopEntries(LeaderboardPeriod leaderboardPeriod) { return this.map.get(leaderboardPeriod); } @Override - public void a(Player player, LeaderboardPeriod leaderboardPeriod, BiConsumer biConsumer) { - String text = this.b.apply(this.getSettings()) + leaderboardPeriod.a(); - this.manager.getStorage().e().a(player, text, this.getSettings().getColumn(), biConsumer); + public void fetchPlayerRank(Player player, LeaderboardPeriod leaderboardPeriod, BiConsumer biConsumer) { + String text = this.tableNameResolver.apply(this.getSettings()) + leaderboardPeriod.getTableSuffix(); + this.manager.getStorage().getStatisticsRepository().fetchPlayerRank(player, text, this.getSettings().getColumn(), biConsumer); } @Override - public void d() { + public void refreshCache() { for (LeaderboardPeriod leaderboardPeriod : LeaderboardPeriod.values()) { - String text = this.b.apply(this.getSettings()) + leaderboardPeriod.a(); - this.manager.getStorage().e().a(text, this.getSettings().getColumn(), leaderboardEntrys -> this.map.put(leaderboardPeriod, leaderboardEntrys)); + String text = this.tableNameResolver.apply(this.getSettings()) + leaderboardPeriod.getTableSuffix(); + this.manager.getStorage().getStatisticsRepository().fetchTopEntries(text, this.getSettings().getColumn(), leaderboardEntrys -> this.map.put(leaderboardPeriod, leaderboardEntrys)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/spi/LeaderboardSource.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/spi/LeaderboardSource.java index cd5fbe4..2039b57 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/spi/LeaderboardSource.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/spi/LeaderboardSource.java @@ -18,13 +18,13 @@ public abstract class LeaderboardSource { return this.settings; } - public abstract String b(); + public abstract String getSourceTitle(); - public abstract String c(); + public abstract String getModeTitle(); - public abstract LeaderboardEntry[] a(LeaderboardPeriod var1); + public abstract LeaderboardEntry[] getTopEntries(LeaderboardPeriod var1); - public abstract void a(Player var1, LeaderboardPeriod var2, BiConsumer var3); + public abstract void fetchPlayerRank(Player var1, LeaderboardPeriod var2, BiConsumer var3); - public abstract void d(); + public abstract void refreshCache(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/storage/LeaderboardStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/storage/LeaderboardStorage.java index c7b2d3f..0e85ef3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/storage/LeaderboardStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/leaderboard/storage/LeaderboardStorage.java @@ -24,11 +24,11 @@ public class LeaderboardStorage implements Configuration { return this.leaderboards; } - public void b() { + public void load() { this.configManager.tryLoad(this, this.file); } - public void c() { + public void save() { this.configManager.trySave(this, this.file); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/listener/InventoryListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/listener/InventoryListener.java index 8e50079..cdb0710 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/listener/InventoryListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/listener/InventoryListener.java @@ -58,40 +58,40 @@ public class InventoryListener implements Listener { } @EventHandler - public void a(InventoryClickEvent event) { + public void onInventoryClick(InventoryClickEvent event) { HumanEntity humanEntity = event.getWhoClicked(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(humanEntity.getUniqueId()); if (defaultUser != null) { - this.a(defaultUser, event); - this.b(defaultUser, event); - this.c(defaultUser, event); + this.handleSetupHotbarClick(defaultUser, event); + this.handleGamerHotbarClick(defaultUser, event); + this.handleMenuClick(defaultUser, event); } } - private void a(DefaultUser defaultUser, InventoryClickEvent event) { + private void handleSetupHotbarClick(DefaultUser defaultUser, InventoryClickEvent event) { ArenaSetup arenaSetup = defaultUser.getArenaSetup(); - if (arenaSetup != null && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && arenaSetup.getHotbar().a(event.getSlot())) { + if (arenaSetup != null && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && arenaSetup.getHotbar().hasAction(event.getSlot())) { event.setCancelled(true); - defaultUser.getArenaSetup().getHotbar().b(event.getSlot()); + defaultUser.getArenaSetup().getHotbar().trigger(event.getSlot()); defaultUser.toPlayer().closeInventory(); } } - private void b(DefaultUser defaultUser, InventoryClickEvent event) { - if (defaultUser.getGamer() instanceof BaseGamer var3 && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && var3.getHotbar().a(event.getSlot())) { - var3.getHotbar().b(event.getSlot()); + private void handleGamerHotbarClick(DefaultUser defaultUser, InventoryClickEvent event) { + if (defaultUser.getGamer() instanceof BaseGamer var3 && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && var3.getHotbar().hasAction(event.getSlot())) { + var3.getHotbar().trigger(event.getSlot()); event.setCancelled(true); } } - private void c(DefaultUser defaultUser, InventoryClickEvent event) { - InventoryMenu inventoryMenu = defaultUser.getMenu3(); + private void handleMenuClick(DefaultUser defaultUser, InventoryClickEvent event) { + InventoryMenu inventoryMenu = defaultUser.getOpenMenu(); if (inventoryMenu != null) { if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) { event.setCancelled(true); - } else if (Objects.equals(inventoryMenu.a(), event.getClickedInventory())) { + } else if (Objects.equals(inventoryMenu.getInventory(), event.getClickedInventory())) { event.setCancelled(true); - inventoryMenu.a(defaultUser, event.getSlot()); + inventoryMenu.handleClick(defaultUser, event.getSlot()); } else { event.setCancelled(true); } @@ -99,19 +99,19 @@ public class InventoryListener implements Listener { } @EventHandler - public void a(InventoryDragEvent event) { + public void onInventoryDrag(InventoryDragEvent event) { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(event.getWhoClicked()); if (defaultUser != null) { Player player = defaultUser.toPlayer(); - InventoryMenu inventoryMenu = defaultUser.getMenu3(); + InventoryMenu inventoryMenu = defaultUser.getOpenMenu(); if (inventoryMenu != null) { if (event.getRawSlots().size() == 1) { int index = (Integer)event.getRawSlots().iterator().next(); - if (Objects.equals(inventoryMenu.a(), this.a(event.getView(), index))) { + if (Objects.equals(inventoryMenu.getInventory(), this.getClickedInventory(event.getView(), index))) { int index2 = event.getView().convertSlot(index); - if (inventoryMenu.a(index2)) { + if (inventoryMenu.hasAction(index2)) { player.setItemOnCursor(event.getOldCursor()); - inventoryMenu.a(defaultUser, (Integer)event.getInventorySlots().iterator().next()); + inventoryMenu.handleClick(defaultUser, (Integer)event.getInventorySlots().iterator().next()); player.setItemOnCursor((org.bukkit.inventory.ItemStack)null); } else { event.setCancelled(true); @@ -124,7 +124,7 @@ public class InventoryListener implements Listener { } } - private Inventory a(InventoryView inventoryView, int index) { + private Inventory getClickedInventory(InventoryView inventoryView, int index) { if (index != -999 && index != -1) { return index < inventoryView.getTopInventory().getSize() ? inventoryView.getTopInventory() : inventoryView.getBottomInventory(); } else { @@ -133,60 +133,60 @@ public class InventoryListener implements Listener { } @EventHandler - public void a(InventoryCloseEvent event) { + public void onInventoryClose(InventoryCloseEvent event) { HumanEntity humanEntity = event.getPlayer(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(humanEntity.getUniqueId()); - if (defaultUser != null && defaultUser.getMenu3() != null) { - defaultUser.d(); + if (defaultUser != null && defaultUser.getOpenMenu() != null) { + defaultUser.closeMenu(); } } @EventHandler - public void a(AsyncPacketEntityInteractEvent event) { + public void onAsyncPacketEntityInteract(AsyncPacketEntityInteractEvent event) { Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> { int index = event.getId(); Player player = event.getPlayer(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); - if (defaultUser != null && System.currentTimeMillis() - defaultUser.f() >= 250L) { - defaultUser.a(System.currentTimeMillis()); - defaultUser.b(index); - defaultUser.a(index); - this.engine.getDisplayManager().a(index, player); + if (defaultUser != null && System.currentTimeMillis() - defaultUser.getLastInteractionTime() >= 250L) { + defaultUser.setLastInteractionTime(System.currentTimeMillis()); + defaultUser.interactLeaderboardToggle(index); + defaultUser.interactLeaderboard(index); + this.engine.getDisplayManager().handleNpcInteract(index, player); } }); } @EventHandler(priority = EventPriority.LOW) - public void a(PlayerJoinEvent event) { + public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - DefaultUser defaultUser = this.engine.getUsers().a(player); + DefaultUser defaultUser = this.engine.getUsers().addUser(player); - for (LeaderboardGroup leaderboardGroup : this.engine.getDisplayManager().b().values()) { - defaultUser.a(leaderboardGroup); + for (LeaderboardGroup leaderboardGroup : this.engine.getDisplayManager().getLeaderboardGroups().values()) { + defaultUser.addLeaderboardDisplay(leaderboardGroup); } - for (LeaderboardToggle leaderboardToggle : this.engine.getDisplayManager().c()) { - defaultUser.a(leaderboardToggle); + for (LeaderboardToggle leaderboardToggle : this.engine.getDisplayManager().getLeaderboardToggles()) { + defaultUser.addLeaderboardToggle(leaderboardToggle); } - this.engine.getDatabaseManager().getSqlDatabase().a(player.getUniqueId(), player.getName()); + this.engine.getDatabaseManager().getSqlDatabase().upsertPlayer(player.getUniqueId(), player.getName()); for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) { - for (AbstractGame abstractGame : abstractGameManager.getSessions().d().values()) { + for (AbstractGame abstractGame : abstractGameManager.getSessions().getGames().values()) { if (abstractGame.getSettings().isTabPrivate()) { - PlayerVisibility.b(this.engine.getPlugin(), player, abstractGame.getGamers()); + PlayerVisibility.hideFromRegistry(this.engine.getPlugin(), player, abstractGame.getGamers()); } } } } @EventHandler(priority = EventPriority.LOWEST) - public void a(PlayerQuitEvent event) { + public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - DefaultUser defaultUser = this.engine.getUsers().b(player); + DefaultUser defaultUser = this.engine.getUsers().removeUser(player); if (defaultUser != null) { - defaultUser.getViewers().a(); - this.engine.getDisplayManager().getViewers().a(player); + defaultUser.getViewers().clear(); + this.engine.getDisplayManager().getViewers().hideWorld(player); if (defaultUser.isInGame()) { defaultUser.getGamer().leave(); } @@ -194,68 +194,68 @@ public class InventoryListener implements Listener { } @EventHandler - public void a(PlayerChangedWorldEvent event) { + public void onPlayerChangedWorld(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - this.engine.getDisplayManager().getViewers().a(player, event.getFrom().getUID()); + this.engine.getDisplayManager().getViewers().hideWorld(player, event.getFrom().getUID()); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); if (defaultUser != null) { - defaultUser.getViewers().a(player, event.getFrom().getUID()); + defaultUser.getViewers().hideWorld(player, event.getFrom().getUID()); } } @EventHandler - public void a(PlayerDropItemEvent event) { + public void onPlayerDropItem(PlayerDropItemEvent event) { Player player = event.getPlayer(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); if (defaultUser != null) { ArenaSetup arenaSetup = defaultUser.getArenaSetup(); - if (arenaSetup != null && arenaSetup.getHotbar().a(player.getInventory().getHeldItemSlot())) { + if (arenaSetup != null && arenaSetup.getHotbar().hasAction(player.getInventory().getHeldItemSlot())) { event.setCancelled(true); } } } @EventHandler(priority = EventPriority.HIGH) - public void a(AsyncPlayerChatEvent event) { + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(event.getPlayer()); if (defaultUser != null) { - this.a(event.getRecipients()); - if (!event.isCancelled() && defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var3 && this.a(var3)) { - Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> this.a(var3, event.getPlayer(), event.getMessage())); + this.filterPrivateChatRecipients(event.getRecipients()); + if (!event.isCancelled() && defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var3 && this.isWaitingPrivateChat(var3)) { + Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> this.broadcastWaitingChat(var3, event.getPlayer(), event.getMessage())); event.setCancelled(true); } - if (defaultUser.g() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var5) { + if (defaultUser.isInSetup() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var5) { event.setCancelled(true); - Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> var5.a(event.getMessage())); + Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> var5.onChatInput(event.getMessage())); } } } - private void a(Set set) { + private void filterPrivateChatRecipients(Set set) { set.removeIf(player -> { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); return defaultUser == null ? false : defaultUser.getGamer() instanceof BaseGamer var3 && var3.getGame().getSettings().isChatPrivate(); }); } - private void a(AbstractGame abstractGame, Player player, String text) { - Context context = this.a(player.getName(), text); - String text2 = this.engine.getMessages().getChatWaiting().a(context); + private void broadcastWaitingChat(AbstractGame abstractGame, Player player, String text) { + Context context = this.createChatContext(player.getName(), text); + String text2 = this.engine.getMessages().getChatWaiting().render(context); if (this.engine.hasPlaceholderResolver()) { - text2 = this.engine.getPlaceholderResolver().a(player, text2); + text2 = this.engine.getPlaceholderResolver().resolve(player, text2); } - abstractGame.getGamers().a(text2); + abstractGame.getGamers().broadcast(text2); Bukkit.getConsoleSender().sendMessage(text2); } - private boolean a(AbstractGame abstractGame) { + private boolean isWaitingPrivateChat(AbstractGame abstractGame) { return abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getPlaying() && abstractGame.getSettings().isChatPrivate(); } - private Context a(String text, String text2) { - return Contexts.a((VariableProvider) text3 -> { + private Context createChatContext(String text, String text2) { + return Contexts.ofVariables((VariableProvider) text3 -> { if (text3.equals("player")) { return text; } else { @@ -265,64 +265,64 @@ public class InventoryListener implements Listener { } @EventHandler - public void a(PlayerAnimationEvent event) { + public void onPlayerAnimation(PlayerAnimationEvent event) { if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) { Player player = event.getPlayer(); if (player.getSpectatorTarget() != null) { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); - if (defaultUser != null && defaultUser.getGamer() instanceof BaseGamer var4 && var4.g()) { - var4.i(); + if (defaultUser != null && defaultUser.getGamer() instanceof BaseGamer var4 && var4.isActiveSpectator()) { + var4.openSpectatorMenu(); } } } } @EventHandler - public void a(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { if (VersionAdapters.get().isMainHandInteract(this.engine.getPlatform(), event)) { Player player = event.getPlayer(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); if (defaultUser != null) { - if (defaultUser.getGamer() instanceof BaseGamer var4 && player.getSpectatorTarget() == null && EngineUtils.b(event.getAction())) { - this.a(defaultUser, var4.getHotbar(), player.getInventory().getHeldItemSlot(), event); + if (defaultUser.getGamer() instanceof BaseGamer var4 && player.getSpectatorTarget() == null && EngineUtils.isRightClick(event.getAction())) { + this.handleHotbarInteract(defaultUser, var4.getHotbar(), player.getInventory().getHeldItemSlot(), event); } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { ArenaSetup arenaSetup = defaultUser.getArenaSetup(); ItemStack item = VersionAdapters.get().getMainHandItem(this.engine.getPlatform(), player); - if (item.getType() == Material.DIAMOND_SWORD && arenaSetup.getSetupStep().d()) { - arenaSetup.a(event.getClickedBlock(), player, event.getAction()); - } else if (EngineUtils.b(event.getAction())) { - this.a(defaultUser, arenaSetup.getHotbar(), player.getInventory().getHeldItemSlot(), event); + if (item.getType() == Material.DIAMOND_SWORD && arenaSetup.getSetupStep().usesSelectionTool()) { + arenaSetup.handleSelection(event.getClickedBlock(), player, event.getAction()); + } else if (EngineUtils.isRightClick(event.getAction())) { + this.handleHotbarInteract(defaultUser, arenaSetup.getHotbar(), player.getInventory().getHeldItemSlot(), event); } } Block block = event.getClickedBlock(); if (event.getAction() == Action.RIGHT_CLICK_BLOCK && VersionAdapters.get().isWallSign(block)) { - CommandSign commandSign = this.engine.getDisplayManager().a(block); + CommandSign commandSign = this.engine.getDisplayManager().getCommandSign(block); if (commandSign == null) { return; } event.setCancelled(true); - commandSign.a(player); + commandSign.executeCommand(player); } } } } - private void a(DefaultUser defaultUser, PlayerHotbar playerHotbar, int index, Cancellable cancellable) { - if (playerHotbar.a(index)) { + private void handleHotbarInteract(DefaultUser defaultUser, PlayerHotbar playerHotbar, int index, Cancellable cancellable) { + if (playerHotbar.hasAction(index)) { cancellable.setCancelled(true); - if (System.currentTimeMillis() - defaultUser.f() >= 250L) { - playerHotbar.b(index); - defaultUser.a(System.currentTimeMillis()); + if (System.currentTimeMillis() - defaultUser.getLastInteractionTime() >= 250L) { + playerHotbar.trigger(index); + defaultUser.setLastInteractionTime(System.currentTimeMillis()); } } } @EventHandler - public void a(PlayerCommandPreprocessEvent event) { + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); if (defaultUser != null) { @@ -330,7 +330,7 @@ public class InventoryListener implements Listener { String text2 = text.split(" ")[0].toLowerCase(Locale.ROOT); if (text2.equals("rejoin")) { event.setCancelled(true); - this.engine.getGameManagerRegistry().a(defaultUser); + this.engine.getGameManagerRegistry().rejoin(defaultUser); } else if (defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var6) { boolean flag = player.hasPermission(var6.getManager().getId() + ".admin") || player.hasPermission(var6.getManager().getId() + ".moderator"); if (text2.equals("leave")) { @@ -346,8 +346,8 @@ public class InventoryListener implements Listener { } } - if (!event.isCancelled() && defaultUser.g() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var8) { - event.setCancelled(var8.b(text)); + if (!event.isCancelled() && defaultUser.isInSetup() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var8) { + event.setCancelled(var8.onCommandInput(text)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/NetworkManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/NetworkManager.java index debd916..2efa41a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/NetworkManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/NetworkManager.java @@ -32,7 +32,7 @@ public class NetworkManager { return this.settings; } - public void d() { + public void start() { if (this.settings.isEnabled()) { this.engine.getPlugin().getServer().getMessenger().registerOutgoingPluginChannel(this.engine.getPlugin(), "BungeeCord"); if (this.settings.getMode().equals("AutoScale")) { @@ -41,23 +41,23 @@ public class NetworkManager { this.networkFeature = new RemoteJoinController(this, this.settings.getRemote()); } - this.networkFeature.a(); + this.networkFeature.enable(); } } - public void e() { + public void stop() { if (this.networkFeature != null) { - this.networkFeature.b(); + this.networkFeature.disable(); } this.engine.getPlugin().getServer().getMessenger().unregisterIncomingPluginChannel(this.engine.getPlugin(), "BungeeCord"); } - public void f() { + public void kickOnlinePlayers() { Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer("Auto Join has been enabled!")); } - public void a(Player player) { + public void kickPlayerDelayed(Player player) { if (player.isOnline()) { this.engine.getPlugin().getServer().getScheduler().runTaskLater(this.engine.getPlugin(), () -> { if (player.isOnline()) { @@ -67,7 +67,7 @@ public class NetworkManager { } } - public void a(Player player, String text) { + public void sendToServer(Player player, String text) { try ( ByteArrayOutputStream var3 = new ByteArrayOutputStream(); DataOutputStream var4 = new DataOutputStream(var3); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinController.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinController.java index 5a8b603..9e0685a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinController.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinController.java @@ -18,11 +18,11 @@ public class AutoJoinController implements NetworkFeature { this.settings = settings2; } - Session c() { - return this.manager.getEngine().getGameManagerRegistry().newGameSearcher().get(EngineUtils.b, List.of()); + Session findAvailableSession() { + return this.manager.getEngine().getGameManagerRegistry().newGameSearcher().get(EngineUtils.ZERO_UUID, List.of()); } - public DefaultEngine d() { + public DefaultEngine getEngine() { return this.manager.getEngine(); } @@ -34,12 +34,12 @@ public class AutoJoinController implements NetworkFeature { return this.manager; } - public void a() { - this.manager.f(); + public void enable() { + this.manager.kickOnlinePlayers(); this.manager.getEngine().getAddonManager().registerListener(this.listener); } - public void b() { + public void disable() { this.manager.getEngine().getAddonManager().unregisterListener(this.listener); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinListener.java index ab71068..a26ca8a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/AutoJoinListener.java @@ -24,11 +24,11 @@ public class AutoJoinListener implements Listener { } @EventHandler(priority = EventPriority.HIGH) - public void a(PlayerJoinEvent event) { - DefaultUser defaultUser = (DefaultUser)this.autoJoinController.d().getUsers().c(event.getPlayer()); + public void onPlayerJoin(PlayerJoinEvent event) { + DefaultUser defaultUser = (DefaultUser)this.autoJoinController.getEngine().getUsers().c(event.getPlayer()); event.setJoinMessage((java.lang.String)null); Player player = defaultUser.toPlayer(); - Session session = this.autoJoinController.c(); + Session session = this.autoJoinController.findAvailableSession(); if (session == null) { player.kickPlayer(defaultUser.getEngine().getMessages().getQuickjoinNotFound()); } else { @@ -42,13 +42,13 @@ public class AutoJoinListener implements Listener { } @EventHandler - public void a(PlayerQuitEvent event) { + public void onPlayerQuit(PlayerQuitEvent event) { event.setQuitMessage((java.lang.String)null); } @EventHandler - public void a(ServerListPingEvent event) { - Session session = this.autoJoinController.c(); + public void onServerListPing(ServerListPingEvent event) { + Session session = this.autoJoinController.findAvailableSession(); if (session == null) { event.setMotd("§c§lYou need to have games to activate AutoJoin"); } else { @@ -58,11 +58,11 @@ public class AutoJoinListener implements Listener { } @EventHandler - public void a(PlayerLoginEvent event) { - if (this.autoJoinController.c() == null) { - event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.autoJoinController.d().getMessages().getQuickjoinNotFound()); + public void onPlayerLogin(PlayerLoginEvent event) { + if (this.autoJoinController.findAvailableSession() == null) { + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.autoJoinController.getEngine().getMessages().getQuickjoinNotFound()); } else { - Result result = this.autoJoinController.c().canPlay(EngineUtils.b, List.of()); + Result result = this.autoJoinController.findAvailableSession().canPlay(EngineUtils.ZERO_UUID, List.of()); if (!result.successful()) { event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, result.errorMessage()); } @@ -70,10 +70,10 @@ public class AutoJoinListener implements Listener { } @EventHandler - public void a(GameLeaveEvent event) { - this.autoJoinController.getManager().a(event.getPlayer(), this.autoJoinController.getSettings().getReturnServer()); + public void onGameLeave(GameLeaveEvent event) { + this.autoJoinController.getManager().sendToServer(event.getPlayer(), this.autoJoinController.getSettings().getReturnServer()); if (this.autoJoinController.getSettings().isKickPlayerOnLeave()) { - this.autoJoinController.getManager().a(event.getPlayer()); + this.autoJoinController.getManager().kickPlayerDelayed(event.getPlayer()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/AddRemoteJoinCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/AddRemoteJoinCommand.java index eac342b..a36003e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/AddRemoteJoinCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/AddRemoteJoinCommand.java @@ -34,13 +34,13 @@ public class AddRemoteJoinCommand implements CommandExecutor { if (this.engine.getNetworkManager().getNetworkFeature() instanceof RemoteJoinController var6) { if (var6.getNetworkEndpoint() instanceof GameServerEndpoint var7) { String text2 = texts[index]; - if (var7.a(text2)) { + if (var7.hasHubServer(text2)) { sender.sendMessage(ChatColor.RED + "The id is already used!"); } else { RemoteAddress remoteAddress = new RemoteAddress(); remoteAddress.setHost(texts[index + 1]); remoteAddress.setPort(Integer.parseInt(texts[index + 2])); - var7.a(text2, remoteAddress); + var7.addHubServer(text2, remoteAddress); sender.sendMessage(ChatColor.GREEN + "The hub has been added."); } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/QuickJoinCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/QuickJoinCommand.java index 9c3886d..c734ecc 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/QuickJoinCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/QuickJoinCommand.java @@ -25,7 +25,7 @@ public class QuickJoinCommand extends BaseCommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { DefaultUser defaultUser = (DefaultUser) this.engine.getUsers().c((Player) sender); if (defaultUser != null) { - defaultUser.a(this.engine.getGameManagerRegistry().newGameSearcher()); + defaultUser.quickJoin(this.engine.getGameManagerRegistry().newGameSearcher()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/RemoveRemoteJoinCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/RemoveRemoteJoinCommand.java index 40848b7..9f29641 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/RemoveRemoteJoinCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/autojoin/command/RemoveRemoteJoinCommand.java @@ -32,10 +32,10 @@ public class RemoveRemoteJoinCommand implements CommandExecutor { if (this.engine.getNetworkManager().getNetworkFeature() instanceof RemoteJoinController var6) { if (var6.getNetworkEndpoint() instanceof GameServerEndpoint var7) { String text2 = texts[index]; - if (!var7.a(text2)) { + if (!var7.hasHubServer(text2)) { sender.sendMessage(ChatColor.RED + "No hub found with such id!"); } else { - var7.b(text2); + var7.removeHubServer(text2); sender.sendMessage(ChatColor.GREEN + "The Hub has been removed."); } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerEndpoint.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerEndpoint.java index 9937d52..e47d3ce 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerEndpoint.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerEndpoint.java @@ -22,54 +22,54 @@ public class GameServerEndpoint implements NetworkEndpoint { this.listener = new GameServerListener(remoteJoinController2); } - public void a() { - this.remoteJoinController.getManager25().f(); - this.remoteJoinController.d().getAddonManager().registerListener(this.listener); - JavaPlugin javaPlugin = this.remoteJoinController.d().getPlugin(); - this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::c, 0L, 20L); - this.remoteJoinController.getSettings7().getServer().getHubServers().forEach((text, remoteAddress) -> { + public void start() { + this.remoteJoinController.getManager().kickOnlinePlayers(); + this.remoteJoinController.getEngine().getAddonManager().registerListener(this.listener); + JavaPlugin javaPlugin = this.remoteJoinController.getEngine().getPlugin(); + this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::sendKeepAliveAndSnapshots, 0L, 20L); + this.remoteJoinController.getSettings().getServer().getHubServers().forEach((text, remoteAddress) -> { HubConnection hubConnection = new HubConnection(this.remoteJoinController, remoteAddress); this.map.put(text, hubConnection); - hubConnection.b(); + hubConnection.connect(); }); } - public void b() { + public void stop() { this.task.cancel(); - this.map.values().forEach(HubConnection::c); + this.map.values().forEach(HubConnection::disconnect); this.map.clear(); - this.remoteJoinController.d().getAddonManager().unregisterListener(this.listener); + this.remoteJoinController.getEngine().getAddonManager().unregisterListener(this.listener); } - public boolean a(String text) { + public boolean hasHubServer(String text) { return this.map.containsKey(text); } - public void a(String text, RemoteAddress remoteAddress) { + public void addHubServer(String text, RemoteAddress remoteAddress) { HubConnection hubConnection = new HubConnection(this.remoteJoinController, remoteAddress); this.map.put(text, hubConnection); - hubConnection.b(); + hubConnection.connect(); } - public void b(String text) { + public void removeHubServer(String text) { HubConnection hubConnection = this.map.remove(text); if (hubConnection != null) { - hubConnection.c(); + hubConnection.disconnect(); } } - private void c() { + private void sendKeepAliveAndSnapshots() { NetworkSnapshot networkSnapshot = null; for (HubConnection hubConnection : this.map.values()) { - if (hubConnection.a()) { - hubConnection.d(); + if (hubConnection.isConnected()) { + hubConnection.tickKeepAlive(); if (networkSnapshot == null) { networkSnapshot = new NetworkSnapshot(); - networkSnapshot.a(this.remoteJoinController.d().getGameManagerRegistry()); + networkSnapshot.captureFrom(this.remoteJoinController.getEngine().getGameManagerRegistry()); } - hubConnection.a(networkSnapshot); + hubConnection.sendSnapshot(networkSnapshot); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerListener.java index 7029386..c0783de 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/GameServerListener.java @@ -26,68 +26,68 @@ public class GameServerListener implements Listener { this.remoteJoinController = remoteJoinController2; } - private DefaultEngine a() { - return this.remoteJoinController.d(); + private DefaultEngine getEngine() { + return this.remoteJoinController.getEngine(); } @EventHandler(priority = EventPriority.HIGH) - public void a(PlayerJoinEvent event) { - DefaultUser defaultUser = (DefaultUser)this.a().getUsers().c(event.getPlayer()); + public void onPlayerJoin(PlayerJoinEvent event) { + DefaultUser defaultUser = (DefaultUser)this.getEngine().getUsers().c(event.getPlayer()); event.setJoinMessage((java.lang.String)null); Player player = defaultUser.toPlayer(); - SessionRequest sessionRequest = (SessionRequest)this.a().getGameManagerRegistry().getMap().get(defaultUser.getUUID()); + SessionRequest sessionRequest = (SessionRequest)this.getEngine().getGameManagerRegistry().getMap().get(defaultUser.getUUID()); if (sessionRequest == null) { - if (!defaultUser.toPlayer().hasPermission(this.a().getNamespace() + ".reservation.exempt")) { - player.kickPlayer(this.a().getMessages().getGameNoReservation()); + if (!defaultUser.toPlayer().hasPermission(this.getEngine().getNamespace() + ".reservation.exempt")) { + player.kickPlayer(this.getEngine().getMessages().getGameNoReservation()); } } else { Session session = sessionRequest.getSession(); - Result result = sessionRequest.getSessionRequestType().a(session, (ro.fr33styler.arcade.api.engine.player.User)defaultUser); + Result result = sessionRequest.getSessionRequestType().canJoinPlayer(session, (ro.fr33styler.arcade.api.engine.player.User)defaultUser); if (result.successful()) { - sessionRequest.getSessionRequestType().a(session, defaultUser); + sessionRequest.getSessionRequestType().join(session, defaultUser); } else { player.kickPlayer(result.errorMessage()); - this.a().getGameManagerRegistry().getMap().remove(defaultUser.getUUID()); + this.getEngine().getGameManagerRegistry().getMap().remove(defaultUser.getUUID()); } } } @EventHandler - public void a(PlayerQuitEvent event) { + public void onPlayerQuit(PlayerQuitEvent event) { event.setQuitMessage((java.lang.String)null); } @EventHandler - public void a(ServerListPingEvent event) { + public void onServerListPing(ServerListPingEvent event) { event.setMotd("§c§lYou cannot join this way while remote join is enabled!"); } @EventHandler(priority = EventPriority.HIGHEST) - public void a(PlayerLoginEvent event) { + public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); - SessionRequest sessionRequest = (SessionRequest)this.a().getGameManagerRegistry().getMap().get(player.getUniqueId()); + SessionRequest sessionRequest = (SessionRequest)this.getEngine().getGameManagerRegistry().getMap().get(player.getUniqueId()); if (sessionRequest == null) { - if (!player.hasPermission(this.a().getNamespace() + ".reservation.exempt")) { - event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.a().getMessages().getGameNoReservation()); + if (!player.hasPermission(this.getEngine().getNamespace() + ".reservation.exempt")) { + event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.getEngine().getMessages().getGameNoReservation()); } } else { Session session = sessionRequest.getSession(); - Result result = sessionRequest.getSessionRequestType().a(session, player.getUniqueId(), List.of()); + Result result = sessionRequest.getSessionRequestType().canJoinParty(session, player.getUniqueId(), List.of()); if (!result.successful()) { event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, result.errorMessage()); - this.a().getGameManagerRegistry().getMap().remove(player.getUniqueId()); + this.getEngine().getGameManagerRegistry().getMap().remove(player.getUniqueId()); } } } @EventHandler - public void a(GameLeaveEvent event) { - Bukkit.getScheduler().runTask(this.remoteJoinController.getManager25().getEngine().getPlugin(), () -> { + public void onGameLeave(GameLeaveEvent event) { + Bukkit.getScheduler().runTask(this.remoteJoinController.getManager().getEngine().getPlugin(), () -> { if (!event.getGamer().toUser().isInGame()) { Player player = event.getPlayer(); - this.remoteJoinController.getManager25().a(player, this.remoteJoinController.getSettings7().getServer().getReturnServer()); - if (this.remoteJoinController.getSettings7().isKickPlayerOnLeave()) { - this.remoteJoinController.getManager25().a(player); + this.remoteJoinController.getManager().sendToServer(player, this.remoteJoinController.getSettings().getServer().getReturnServer()); + if (this.remoteJoinController.getSettings().isKickPlayerOnLeave()) { + this.remoteJoinController.getManager().kickPlayerDelayed(player); } } }); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/ServerConnection.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/ServerConnection.java index 6e4dfb8..a8704ee 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/ServerConnection.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/gameserver/ServerConnection.java @@ -16,119 +16,119 @@ import java.util.UUID; import java.util.Map.Entry; public class ServerConnection implements Closeable { - private int a; - private final String b; - private final Socket c; + private int missedKeepAlives; + private final String serverName; + private final Socket socket; private final RemoteJoinController remoteJoinController; - private final DataInputStream e; - private final DataOutputStream f; + private final DataInputStream inputStream; + private final DataOutputStream outputStream; private NetworkSnapshot networkSnapshot; public ServerConnection(RemoteJoinController remoteJoinController2, Socket socket) throws java.io.IOException { this.remoteJoinController = remoteJoinController2; - this.c = socket; - this.e = new DataInputStream(socket.getInputStream()); - this.f = new DataOutputStream(socket.getOutputStream()); - this.b = this.e.readUTF(); + this.socket = socket; + this.inputStream = new DataInputStream(socket.getInputStream()); + this.outputStream = new DataOutputStream(socket.getOutputStream()); + this.serverName = this.inputStream.readUTF(); } - public String a() { - return this.b; + public String getServerName() { + return this.serverName; } - public int b() { - return this.a; + public int getMissedKeepAlives() { + return this.missedKeepAlives; } - public void a(int index) { - this.a = index; + public void setMissedKeepAlives(int index) { + this.missedKeepAlives = index; } - public DataInputStream c() { - return this.e; + public DataInputStream getInputStream() { + return this.inputStream; } - public DataOutputStream d() { - return this.f; + public DataOutputStream getOutputStream() { + return this.outputStream; } public RemoteJoinController getRemoteJoinController() { return this.remoteJoinController; } - public void f() { - this.remoteJoinController.a(() -> { - this.f.writeUTF("keep-alive"); - this.f.flush(); + public void sendKeepAlive() { + this.remoteJoinController.submitAsync(() -> { + this.outputStream.writeUTF("keep-alive"); + this.outputStream.flush(); return null; }); } - public void a(DefaultGameManagerRegistry defaultGameManagerRegistry) { + public void clearRemoteState(DefaultGameManagerRegistry defaultGameManagerRegistry) { for (AbstractGameManager abstractGameManager : defaultGameManagerRegistry) { - this.a(abstractGameManager); - this.b(abstractGameManager); + this.removeRemoteSessions(abstractGameManager); + this.removeRejoinEntries(abstractGameManager); } } - private void a(AbstractGameManager abstractGameManager) { + private void removeRemoteSessions(AbstractGameManager abstractGameManager) { if (this.networkSnapshot != null) { ManagerSnapshot managerSnapshot = (ManagerSnapshot)this.networkSnapshot.getMap().get(abstractGameManager.getId()); if (managerSnapshot != null) { - for (String text : managerSnapshot.a().keySet()) { - abstractGameManager.getSessions().g(text + "@" + this.b); + for (String text : managerSnapshot.getSessions().keySet()) { + abstractGameManager.getSessions().unregisterSession(text + "@" + this.serverName); } } } } - private void a(AbstractGameManager abstractGameManager, ManagerSnapshot managerSnapshot) { - this.a(abstractGameManager); + private void updateRemoteSessions(AbstractGameManager abstractGameManager, ManagerSnapshot managerSnapshot) { + this.removeRemoteSessions(abstractGameManager); - for (Entry entry : managerSnapshot.a().entrySet()) { + for (Entry entry : managerSnapshot.getSessions().entrySet()) { if (entry.getValue() instanceof RemoteSession var5) { - var5.a(this, abstractGameManager); - abstractGameManager.getSessions().a((String)entry.getKey() + "@" + this.b, var5); + var5.attach(this, abstractGameManager); + abstractGameManager.getSessions().registerSession((String)entry.getKey() + "@" + this.serverName, var5); } } } - private void b(AbstractGameManager abstractGameManager) { + private void removeRejoinEntries(AbstractGameManager abstractGameManager) { if (this.networkSnapshot != null) { ManagerSnapshot managerSnapshot = (ManagerSnapshot)this.networkSnapshot.getMap().get(abstractGameManager.getId()); if (managerSnapshot != null) { - abstractGameManager.getSessions().e().values().removeAll(managerSnapshot.b().values()); + abstractGameManager.getSessions().getRejoinGames().values().removeAll(managerSnapshot.getRejoins().values()); } } } - private void b(AbstractGameManager abstractGameManager, ManagerSnapshot managerSnapshot) { - this.b(abstractGameManager); + private void updateRejoinEntries(AbstractGameManager abstractGameManager, ManagerSnapshot managerSnapshot) { + this.removeRejoinEntries(abstractGameManager); - for (Entry entry : managerSnapshot.b().entrySet()) { - String text = (String)entry.getValue() + "@" + this.b; - abstractGameManager.getSessions().e().put((UUID)entry.getKey(), text); + for (Entry entry : managerSnapshot.getRejoins().entrySet()) { + String text = (String)entry.getValue() + "@" + this.serverName; + abstractGameManager.getSessions().getRejoinGames().put((UUID)entry.getKey(), text); } } - public void a(NetworkSnapshot networkSnapshot2) { - for (AbstractGameManager abstractGameManager : this.remoteJoinController.getManager25().getEngine().getGameManagerRegistry()) { + public void applySnapshot(NetworkSnapshot networkSnapshot2) { + for (AbstractGameManager abstractGameManager : this.remoteJoinController.getManager().getEngine().getGameManagerRegistry()) { ManagerSnapshot managerSnapshot = (ManagerSnapshot)networkSnapshot2.getMap().get(abstractGameManager.getId()); if (managerSnapshot != null) { - this.a(abstractGameManager, managerSnapshot); - this.b(abstractGameManager, managerSnapshot); + this.updateRemoteSessions(abstractGameManager, managerSnapshot); + this.updateRejoinEntries(abstractGameManager, managerSnapshot); } } this.networkSnapshot = networkSnapshot2; } - public boolean g() { - return this.c.isClosed(); + public boolean isClosed() { + return this.socket.isClosed(); } @Override public void close() { - EngineUtils.a(this.c); + EngineUtils.closeQuietly(this.socket); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubConnection.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubConnection.java index 48e4e35..aad4cfa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubConnection.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubConnection.java @@ -20,12 +20,12 @@ import ro.fr33styler.arcade.api.engine.game.session.Result; import ro.fr33styler.arcade.api.engine.game.session.Session; public class HubConnection { - private int a; - private boolean b; - private Thread c; - private Socket d; - private DataInputStream e; - private DataOutputStream f; + private int missedKeepAlives; + private boolean connected; + private Thread connectionThread; + private Socket socket; + private DataInputStream inputStream; + private DataOutputStream outputStream; private final RemoteAddress remoteAddress; private final RemoteJoinController remoteJoinController; @@ -34,144 +34,144 @@ public class HubConnection { this.remoteAddress = remoteAddress2; } - public boolean a() { - return this.b; + public boolean isConnected() { + return this.connected; } - public void b() { - this.c = this.remoteJoinController.d().getJdkFeatures().newThread(this::e); - this.c.start(); + public void connect() { + this.connectionThread = this.remoteJoinController.getEngine().getJdkFeatures().newThread(this::runConnectionLoop); + this.connectionThread.start(); } - public void c() { - this.a = 0; - this.b = false; - this.c.interrupt(); - EngineUtils.a(this.d); + public void disconnect() { + this.missedKeepAlives = 0; + this.connected = false; + this.connectionThread.interrupt(); + EngineUtils.closeQuietly(this.socket); } - public void d() { - if (this.a > 5) { - this.c(); - this.b(); + public void tickKeepAlive() { + if (this.missedKeepAlives > 5) { + this.disconnect(); + this.connect(); } else { - this.a++; + this.missedKeepAlives++; } - this.h(); + this.sendKeepAlive(); } - private void e() { - while (!this.c.isInterrupted()) { + private void runConnectionLoop() { + while (!this.connectionThread.isInterrupted()) { try { - this.f(); + this.openSocket(); } catch (IOException ex) { - EngineUtils.a(1000L); + EngineUtils.sleepQuietly(1000L); continue; } try { - this.b = true; - this.g(); + this.connected = true; + this.readPackets(); } catch (IOException ex2) { - this.b = false; - EngineUtils.a(this.d); + this.connected = false; + EngineUtils.closeQuietly(this.socket); } } } - private void f() throws IOException { - this.d = new Socket(this.remoteAddress.getHost(), this.remoteAddress.getPort()); - this.e = new DataInputStream(this.d.getInputStream()); - this.f = new DataOutputStream(this.d.getOutputStream()); - this.f.writeUTF(this.remoteJoinController.getSettings7().getServer().getServerName()); - this.f.flush(); + private void openSocket() throws IOException { + this.socket = new Socket(this.remoteAddress.getHost(), this.remoteAddress.getPort()); + this.inputStream = new DataInputStream(this.socket.getInputStream()); + this.outputStream = new DataOutputStream(this.socket.getOutputStream()); + this.outputStream.writeUTF(this.remoteJoinController.getSettings().getServer().getServerName()); + this.outputStream.flush(); } - private void g() throws IOException { - while (!this.d.isClosed()) { - String text = this.e.readUTF(); + private void readPackets() throws IOException { + while (!this.socket.isClosed()) { + String text = this.inputStream.readUTF(); if (text.equals("keep-alive")) { - this.a = 0; + this.missedKeepAlives = 0; } else if (text.equals("reservation-request")) { - int index = this.e.readInt(); - byte[] byteVals = this.e.readNBytes(index); - NetworkJoinRequest networkJoinRequest = (NetworkJoinRequest)Compression.a(this.remoteJoinController.getGson(), byteVals, NetworkJoinRequest.class); + int index = this.inputStream.readInt(); + byte[] byteVals = this.inputStream.readNBytes(index); + NetworkJoinRequest networkJoinRequest = (NetworkJoinRequest)Compression.decompressJson(this.remoteJoinController.getGson(), byteVals, NetworkJoinRequest.class); if (networkJoinRequest != null) { - this.remoteJoinController.a(() -> this.a(networkJoinRequest)); + this.remoteJoinController.runSync(() -> this.handleJoinRequest(networkJoinRequest)); } } } } - private void a(NetworkJoinRequest networkJoinRequest) { - AbstractGameManager abstractGameManager = this.remoteJoinController.d().getGameManagerRegistry().a(networkJoinRequest.d()); + private void handleJoinRequest(NetworkJoinRequest networkJoinRequest) { + AbstractGameManager abstractGameManager = this.remoteJoinController.getEngine().getGameManagerRegistry().a(networkJoinRequest.getManagerId()); if (abstractGameManager != null) { - Session session = abstractGameManager.getSessions().getSession(networkJoinRequest.a()); - UUID uuid = networkJoinRequest.b(); - List list = networkJoinRequest.e(); - Result result = networkJoinRequest.getSessionRequestType().a(session, uuid, list); + Session session = abstractGameManager.getSessions().getSession(networkJoinRequest.getSessionId()); + UUID uuid = networkJoinRequest.getPlayerId(); + List list = networkJoinRequest.getPartyMembers(); + Result result = networkJoinRequest.getSessionRequestType().canJoinParty(session, uuid, list); if (!result.successful()) { - this.a(uuid, result.errorMessage()); + this.sendReservationFailed(uuid, result.errorMessage()); } else { SessionRequest sessionRequest = new SessionRequest(abstractGameManager, session, networkJoinRequest.getSessionRequestType()); - this.remoteJoinController.d().getGameManagerRegistry().getMap().put(uuid, sessionRequest); + this.remoteJoinController.getEngine().getGameManagerRegistry().getMap().put(uuid, sessionRequest); if (!list.isEmpty()) { for (UUID uuid2 : list) { - this.remoteJoinController.d().getGameManagerRegistry().getMap().put(uuid2, sessionRequest); + this.remoteJoinController.getEngine().getGameManagerRegistry().getMap().put(uuid2, sessionRequest); } sessionRequest.setParty(new RemoteParty(uuid, list)); } - this.a(uuid, list); + this.sendReservationSuccess(uuid, list); } } } - private void a(UUID uuid, List list) { - this.remoteJoinController.a(() -> { - this.f.writeUTF("reservation-success"); - this.f.writeInt(list.size() + 1); - this.f.writeLong(uuid.getMostSignificantBits()); - this.f.writeLong(uuid.getLeastSignificantBits()); + private void sendReservationSuccess(UUID uuid, List list) { + this.remoteJoinController.submitAsync(() -> { + this.outputStream.writeUTF("reservation-success"); + this.outputStream.writeInt(list.size() + 1); + this.outputStream.writeLong(uuid.getMostSignificantBits()); + this.outputStream.writeLong(uuid.getLeastSignificantBits()); for (UUID uuid2 : list) { - this.f.writeLong(uuid2.getMostSignificantBits()); - this.f.writeLong(uuid2.getLeastSignificantBits()); + this.outputStream.writeLong(uuid2.getMostSignificantBits()); + this.outputStream.writeLong(uuid2.getLeastSignificantBits()); } - this.f.flush(); + this.outputStream.flush(); return null; }); } - private void a(UUID uuid, String text) { - this.remoteJoinController.a(() -> { - this.f.writeUTF("reservation-failed"); - this.f.writeLong(uuid.getMostSignificantBits()); - this.f.writeLong(uuid.getLeastSignificantBits()); - this.f.writeUTF(text); - this.f.flush(); + private void sendReservationFailed(UUID uuid, String text) { + this.remoteJoinController.submitAsync(() -> { + this.outputStream.writeUTF("reservation-failed"); + this.outputStream.writeLong(uuid.getMostSignificantBits()); + this.outputStream.writeLong(uuid.getLeastSignificantBits()); + this.outputStream.writeUTF(text); + this.outputStream.flush(); return null; }); } - private void h() { - this.remoteJoinController.a(() -> { - this.f.writeUTF("keep-alive"); - this.f.flush(); + private void sendKeepAlive() { + this.remoteJoinController.submitAsync(() -> { + this.outputStream.writeUTF("keep-alive"); + this.outputStream.flush(); return null; }); } - public void a(NetworkSnapshot networkSnapshot) { - this.remoteJoinController.a(() -> { - this.f.writeUTF("game-manager-data"); - byte[] byteVals = Compression.a(this.remoteJoinController.getGson(), networkSnapshot); - this.f.writeInt(byteVals.length); - this.f.write(byteVals); - this.f.flush(); + public void sendSnapshot(NetworkSnapshot networkSnapshot) { + this.remoteJoinController.submitAsync(() -> { + this.outputStream.writeUTF("game-manager-data"); + byte[] byteVals = Compression.compressJson(this.remoteJoinController.getGson(), networkSnapshot); + this.outputStream.writeInt(byteVals.length); + this.outputStream.write(byteVals); + this.outputStream.flush(); return null; }); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubEndpoint.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubEndpoint.java index 26c5adc..436549d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubEndpoint.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/hub/HubEndpoint.java @@ -22,9 +22,9 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; public class HubEndpoint implements NetworkEndpoint { - private Thread a; + private Thread acceptThread; private BukkitTask task; - private ServerSocket c; + private ServerSocket serverSocket; private final RemoteJoinController remoteJoinController; private final Set set = ConcurrentHashMap.newKeySet(); @@ -32,48 +32,48 @@ public class HubEndpoint implements NetworkEndpoint { this.remoteJoinController = remoteJoinController2; } - public void a() throws IOException { - RemoteAddress remoteAddress = this.remoteJoinController.getSettings7().getHub(); - this.c = new ServerSocket(remoteAddress.getPort(), 0, InetAddress.getByName(remoteAddress.getHost())); - JavaPlugin javaPlugin = this.remoteJoinController.d().getPlugin(); - this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::e, 0L, 20L); - this.a = this.remoteJoinController.d().getJdkFeatures().newThread(this::c); - this.a.start(); + public void start() throws IOException { + RemoteAddress remoteAddress = this.remoteJoinController.getSettings().getHub(); + this.serverSocket = new ServerSocket(remoteAddress.getPort(), 0, InetAddress.getByName(remoteAddress.getHost())); + JavaPlugin javaPlugin = this.remoteJoinController.getEngine().getPlugin(); + this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::tickKeepAlives, 0L, 20L); + this.acceptThread = this.remoteJoinController.getEngine().getJdkFeatures().newThread(this::acceptConnections); + this.acceptThread.start(); } - public void b() { - this.d(); + public void stop() { + this.closeAllConnections(); this.task.cancel(); - this.a.interrupt(); - EngineUtils.a(this.c); + this.acceptThread.interrupt(); + EngineUtils.closeQuietly(this.serverSocket); } - private void c() { - while (!this.a.isInterrupted()) { + private void acceptConnections() { + while (!this.acceptThread.isInterrupted()) { try { - this.a(this.c.accept()); + this.handleClientSocket(this.serverSocket.accept()); } catch (IOException ex) { break; } } } - private void d() { + private void closeAllConnections() { this.set.forEach(serverConnection -> { serverConnection.close(); - serverConnection.a(this.remoteJoinController.d().getGameManagerRegistry()); + serverConnection.clearRemoteState(this.remoteJoinController.getEngine().getGameManagerRegistry()); }); this.set.clear(); } - private void a(Socket socket) { - Thread thread = this.remoteJoinController.d().getJdkFeatures().newThread(() -> { + private void handleClientSocket(Socket socket) { + Thread thread = this.remoteJoinController.getEngine().getJdkFeatures().newThread(() -> { try { ServerConnection serverConnection = new ServerConnection(this.remoteJoinController, socket); try { this.set.add(serverConnection); - this.a(serverConnection); + this.listenConnection(serverConnection); } catch (Throwable ex) { try { serverConnection.close(); @@ -91,38 +91,38 @@ public class HubEndpoint implements NetworkEndpoint { thread.start(); } - private void a(ServerConnection serverConnection) { - while (!serverConnection.g()) { + private void listenConnection(ServerConnection serverConnection) { + while (!serverConnection.isClosed()) { try { - this.b(serverConnection); + this.readPacket(serverConnection); } catch (IOException ex) { serverConnection.close(); } } this.set.remove(serverConnection); - this.remoteJoinController.a(() -> serverConnection.a(this.remoteJoinController.d().getGameManagerRegistry())); + this.remoteJoinController.runSync(() -> serverConnection.clearRemoteState(this.remoteJoinController.getEngine().getGameManagerRegistry())); } - private void b(ServerConnection serverConnection) throws IOException { - switch (serverConnection.c().readUTF()) { + private void readPacket(ServerConnection serverConnection) throws IOException { + switch (serverConnection.getInputStream().readUTF()) { case "keep-alive": - serverConnection.a(0); + serverConnection.setMissedKeepAlives(0); break; case "game-manager-data": - int index = serverConnection.c().readInt(); - byte[] byteVals = serverConnection.c().readNBytes(index); - NetworkSnapshot networkSnapshot = (NetworkSnapshot)Compression.a(this.remoteJoinController.getGson(), byteVals, NetworkSnapshot.class); + int index = serverConnection.getInputStream().readInt(); + byte[] byteVals = serverConnection.getInputStream().readNBytes(index); + NetworkSnapshot networkSnapshot = (NetworkSnapshot)Compression.decompressJson(this.remoteJoinController.getGson(), byteVals, NetworkSnapshot.class); if (networkSnapshot == null) { return; } - this.remoteJoinController.a(() -> serverConnection.a(networkSnapshot)); + this.remoteJoinController.runSync(() -> serverConnection.applySnapshot(networkSnapshot)); break; case "reservation-failed": - UUID uuid = new UUID(serverConnection.c().readLong(), serverConnection.c().readLong()); - String text = serverConnection.c().readUTF(); - this.remoteJoinController.a(() -> { + UUID uuid = new UUID(serverConnection.getInputStream().readLong(), serverConnection.getInputStream().readLong()); + String text = serverConnection.getInputStream().readUTF(); + this.remoteJoinController.runSync(() -> { Player player = Bukkit.getPlayer(uuid); if (player != null) { player.sendMessage(text); @@ -130,36 +130,36 @@ public class HubEndpoint implements NetworkEndpoint { }); break; case "reservation-success": - int index2 = serverConnection.c().readInt(); + int index2 = serverConnection.getInputStream().readInt(); UUID[] uuids = new UUID[index2]; for (int index3 = 0; index3 < index2; index3++) { - uuids[index3] = new UUID(serverConnection.c().readLong(), serverConnection.c().readLong()); + uuids[index3] = new UUID(serverConnection.getInputStream().readLong(), serverConnection.getInputStream().readLong()); } - this.remoteJoinController.a(() -> { + this.remoteJoinController.runSync(() -> { for (UUID uuid2 : uuids) { Player player2 = Bukkit.getPlayer(uuid2); if (player2 != null) { - this.remoteJoinController.getManager25().a(player2, serverConnection.a()); + this.remoteJoinController.getManager().sendToServer(player2, serverConnection.getServerName()); } } }); } } - private void e() { + private void tickKeepAlives() { Iterator iterator = this.set.iterator(); while (iterator.hasNext()) { ServerConnection serverConnection = (ServerConnection)iterator.next(); - if (serverConnection.b() > 5) { + if (serverConnection.getMissedKeepAlives() > 5) { serverConnection.close(); iterator.remove(); - serverConnection.a(this.remoteJoinController.d().getGameManagerRegistry()); + serverConnection.clearRemoteState(this.remoteJoinController.getEngine().getGameManagerRegistry()); } else { - serverConnection.f(); - serverConnection.a(serverConnection.b() + 1); + serverConnection.sendKeepAlive(); + serverConnection.setMissedKeepAlives(serverConnection.getMissedKeepAlives() + 1); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/JoinRequestAdapter.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/JoinRequestAdapter.java index 920a8b6..b63b395 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/JoinRequestAdapter.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/JoinRequestAdapter.java @@ -12,25 +12,25 @@ import java.util.UUID; public class JoinRequestAdapter extends TypeAdapter { @Override public void write(JsonWriter jsonWriter, NetworkJoinRequest networkJoinRequest) throws java.io.IOException { - this.a(jsonWriter, networkJoinRequest); + this.writeJoinRequest(jsonWriter, networkJoinRequest); } @Override public NetworkJoinRequest read(JsonReader jsonReader) throws java.io.IOException { - return this.a(jsonReader); + return this.readJoinRequest(jsonReader); } - public void a(JsonWriter jsonWriter, NetworkJoinRequest networkJoinRequest) throws java.io.IOException { + public void writeJoinRequest(JsonWriter jsonWriter, NetworkJoinRequest networkJoinRequest) throws java.io.IOException { jsonWriter.beginObject(); - jsonWriter.name("id").value(networkJoinRequest.a()); - jsonWriter.name("user").value(networkJoinRequest.b().toString()); + jsonWriter.name("id").value(networkJoinRequest.getSessionId()); + jsonWriter.name("user").value(networkJoinRequest.getPlayerId().toString()); jsonWriter.name("type").value(networkJoinRequest.getSessionRequestType().ordinal()); - jsonWriter.name("manager-id").value(networkJoinRequest.d()); - if (!networkJoinRequest.e().isEmpty()) { + jsonWriter.name("manager-id").value(networkJoinRequest.getManagerId()); + if (!networkJoinRequest.getPartyMembers().isEmpty()) { jsonWriter.name("party-members"); jsonWriter.beginArray(); - for (UUID uuid : networkJoinRequest.e()) { + for (UUID uuid : networkJoinRequest.getPartyMembers()) { jsonWriter.value(uuid.toString()); } @@ -40,23 +40,23 @@ public class JoinRequestAdapter extends TypeAdapter { jsonWriter.endObject(); } - public NetworkJoinRequest a(JsonReader jsonReader) throws java.io.IOException { + public NetworkJoinRequest readJoinRequest(JsonReader jsonReader) throws java.io.IOException { NetworkJoinRequest networkJoinRequest = new NetworkJoinRequest(); jsonReader.beginObject(); while (jsonReader.hasNext()) { switch (jsonReader.nextName()) { case "id": - networkJoinRequest.a(jsonReader.nextString()); + networkJoinRequest.setSessionId(jsonReader.nextString()); break; case "user": - networkJoinRequest.a(UUID.fromString(jsonReader.nextString())); + networkJoinRequest.setPlayerId(UUID.fromString(jsonReader.nextString())); break; case "type": networkJoinRequest.setSessionRequestType(SessionRequestType.values()[jsonReader.nextInt()]); break; case "manager-id": - networkJoinRequest.b(jsonReader.nextString()); + networkJoinRequest.setManagerId(jsonReader.nextString()); break; case "party-members": ArrayList list = new ArrayList(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/NetworkSnapshotAdapter.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/NetworkSnapshotAdapter.java index 481cb56..495c6aa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/NetworkSnapshotAdapter.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/json/NetworkSnapshotAdapter.java @@ -21,40 +21,40 @@ import ro.fr33styler.arcade.api.engine.game.session.Status; public class NetworkSnapshotAdapter extends TypeAdapter { @Override public void write(JsonWriter jsonWriter, NetworkSnapshot networkSnapshot) throws java.io.IOException { - this.a(jsonWriter, networkSnapshot); + this.writeNetworkSnapshot(jsonWriter, networkSnapshot); } @Override public NetworkSnapshot read(JsonReader jsonReader) throws java.io.IOException { - return this.a(jsonReader); + return this.readNetworkSnapshot(jsonReader); } - public void a(JsonWriter jsonWriter, NetworkSnapshot networkSnapshot) throws java.io.IOException { + public void writeNetworkSnapshot(JsonWriter jsonWriter, NetworkSnapshot networkSnapshot) throws java.io.IOException { jsonWriter.beginObject(); for (Entry entry : networkSnapshot.getMap().entrySet()) { jsonWriter.name((String)entry.getKey()); - this.a(jsonWriter, (ManagerSnapshot)entry.getValue()); + this.writeManagerSnapshot(jsonWriter, (ManagerSnapshot)entry.getValue()); } jsonWriter.endObject(); } - private void a(JsonWriter jsonWriter, ManagerSnapshot managerSnapshot) throws java.io.IOException { + private void writeManagerSnapshot(JsonWriter jsonWriter, ManagerSnapshot managerSnapshot) throws java.io.IOException { jsonWriter.beginObject(); jsonWriter.name("sessions"); jsonWriter.beginObject(); - for (Entry entry : managerSnapshot.a().entrySet()) { + for (Entry entry : managerSnapshot.getSessions().entrySet()) { jsonWriter.name((String)entry.getKey()); - this.a(jsonWriter, (Session)entry.getValue()); + this.writeSession(jsonWriter, (Session)entry.getValue()); } jsonWriter.endObject(); jsonWriter.name("rejoins"); jsonWriter.beginObject(); - for (Entry entry2 : managerSnapshot.b().entrySet()) { + for (Entry entry2 : managerSnapshot.getRejoins().entrySet()) { jsonWriter.name(((UUID)entry2.getKey()).toString()); jsonWriter.value((String)entry2.getValue()); } @@ -63,23 +63,23 @@ public class NetworkSnapshotAdapter extends TypeAdapter { jsonWriter.endObject(); } - public void a(JsonWriter jsonWriter, Session session) throws java.io.IOException { + public void writeSession(JsonWriter jsonWriter, Session session) throws java.io.IOException { jsonWriter.beginObject(); jsonWriter.name("id").value(session.getId()); jsonWriter.name("play"); - this.a(jsonWriter, session.canPlay(EngineUtils.b, List.of())); + this.writeResult(jsonWriter, session.canPlay(EngineUtils.ZERO_UUID, List.of())); jsonWriter.name("play_started"); - this.a(jsonWriter, session.canPlayStarted(EngineUtils.b, List.of())); + this.writeResult(jsonWriter, session.canPlayStarted(EngineUtils.ZERO_UUID, List.of())); jsonWriter.name("spectate"); - this.a(jsonWriter, session.canSpectate(EngineUtils.b)); + this.writeResult(jsonWriter, session.canSpectate(EngineUtils.ZERO_UUID)); jsonWriter.name("rejoin"); - this.a(jsonWriter, session.canRejoin(EngineUtils.b)); + this.writeResult(jsonWriter, session.canRejoin(EngineUtils.ZERO_UUID)); jsonWriter.name("status"); - this.a(jsonWriter, session.getStatus()); + this.writeStatus(jsonWriter, session.getStatus()); jsonWriter.endObject(); } - private void a(JsonWriter jsonWriter, Result result) throws java.io.IOException { + private void writeResult(JsonWriter jsonWriter, Result result) throws java.io.IOException { jsonWriter.beginObject(); jsonWriter.name("allowed").value(result.successful()); if (!result.successful()) { @@ -89,7 +89,7 @@ public class NetworkSnapshotAdapter extends TypeAdapter { jsonWriter.endObject(); } - private void a(JsonWriter jsonWriter, Status status) throws java.io.IOException { + private void writeStatus(JsonWriter jsonWriter, Status status) throws java.io.IOException { jsonWriter.beginObject(); jsonWriter.name("players").value(status.players()); jsonWriter.name("maximum-players").value(status.maximumPlayers()); @@ -113,19 +113,19 @@ public class NetworkSnapshotAdapter extends TypeAdapter { jsonWriter.endObject(); } - public NetworkSnapshot a(JsonReader jsonReader) throws java.io.IOException { + public NetworkSnapshot readNetworkSnapshot(JsonReader jsonReader) throws java.io.IOException { NetworkSnapshot networkSnapshot = new NetworkSnapshot(); jsonReader.beginObject(); while (jsonReader.hasNext()) { - networkSnapshot.getMap().put(jsonReader.nextName(), this.c(jsonReader)); + networkSnapshot.getMap().put(jsonReader.nextName(), this.readManagerSnapshot(jsonReader)); } jsonReader.endObject(); return networkSnapshot; } - private ManagerSnapshot c(JsonReader jsonReader) throws java.io.IOException { + private ManagerSnapshot readManagerSnapshot(JsonReader jsonReader) throws java.io.IOException { ManagerSnapshot managerSnapshot = new ManagerSnapshot(); jsonReader.beginObject(); @@ -135,7 +135,7 @@ public class NetworkSnapshotAdapter extends TypeAdapter { jsonReader.beginObject(); while (jsonReader.hasNext()) { - managerSnapshot.a().put(jsonReader.nextName(), this.b(jsonReader)); + managerSnapshot.getSessions().put(jsonReader.nextName(), this.readSession(jsonReader)); } jsonReader.endObject(); @@ -143,7 +143,7 @@ public class NetworkSnapshotAdapter extends TypeAdapter { jsonReader.beginObject(); while (jsonReader.hasNext()) { - managerSnapshot.b().put(UUID.fromString(jsonReader.nextName()), jsonReader.nextString()); + managerSnapshot.getRejoins().put(UUID.fromString(jsonReader.nextName()), jsonReader.nextString()); } jsonReader.endObject(); @@ -154,7 +154,7 @@ public class NetworkSnapshotAdapter extends TypeAdapter { return managerSnapshot; } - public Session b(JsonReader jsonReader) throws java.io.IOException { + public Session readSession(JsonReader jsonReader) throws java.io.IOException { String text = null; Result result = null; Result result2 = null; @@ -169,19 +169,19 @@ public class NetworkSnapshotAdapter extends TypeAdapter { text = jsonReader.nextString(); break; case "play": - result = this.d(jsonReader); + result = this.readResult(jsonReader); break; case "play_started": - result2 = this.d(jsonReader); + result2 = this.readResult(jsonReader); break; case "spectate": - result3 = this.d(jsonReader); + result3 = this.readResult(jsonReader); break; case "rejoin": - result4 = this.d(jsonReader); + result4 = this.readResult(jsonReader); break; case "status": - remoteSessionStatus = this.e(jsonReader); + remoteSessionStatus = this.readSessionStatus(jsonReader); break; default: jsonReader.skipValue(); @@ -192,7 +192,7 @@ public class NetworkSnapshotAdapter extends TypeAdapter { return new RemoteSession(text, result, result2, result3, result4, remoteSessionStatus); } - private Result d(JsonReader jsonReader) throws java.io.IOException { + private Result readResult(JsonReader jsonReader) throws java.io.IOException { boolean flag = false; String text = null; jsonReader.beginObject(); @@ -214,32 +214,32 @@ public class NetworkSnapshotAdapter extends TypeAdapter { return flag ? Result.SUCCESSFUL : new Result(flag, text); } - private RemoteSessionStatus e(JsonReader jsonReader) throws java.io.IOException { + private RemoteSessionStatus readSessionStatus(JsonReader jsonReader) throws java.io.IOException { RemoteSessionStatus remoteSessionStatus = new RemoteSessionStatus(); jsonReader.beginObject(); while (jsonReader.hasNext()) { switch (jsonReader.nextName()) { case "players": - remoteSessionStatus.a(jsonReader.nextInt()); + remoteSessionStatus.setPlayers(jsonReader.nextInt()); break; case "maximum-players": - remoteSessionStatus.b(jsonReader.nextInt()); + remoteSessionStatus.setMaximumPlayers(jsonReader.nextInt()); break; case "name": - remoteSessionStatus.a(jsonReader.nextString()); + remoteSessionStatus.setName(jsonReader.nextString()); break; case "mode": - remoteSessionStatus.c(jsonReader.nextString()); + remoteSessionStatus.setMode(jsonReader.nextString()); break; case "phase-name": - remoteSessionStatus.b(jsonReader.nextString()); + remoteSessionStatus.setPhaseName(jsonReader.nextString()); break; case "phase-type": remoteSessionStatus.setPhaseType(PhaseType.values()[jsonReader.nextInt()]); break; case "visibility": - remoteSessionStatus.a(jsonReader.nextBoolean()); + remoteSessionStatus.setUnlisted(jsonReader.nextBoolean()); break; case "player-names": ArrayList list = new ArrayList(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/request/NetworkJoinRequest.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/request/NetworkJoinRequest.java index 55f58ea..3aacf29 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/request/NetworkJoinRequest.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/request/NetworkJoinRequest.java @@ -6,26 +6,26 @@ import java.util.List; import java.util.UUID; public class NetworkJoinRequest { - private String a; - private UUID b; + private String sessionId; + private UUID playerId; private SessionRequestType sessionRequestType; - private String d; + private String managerId; private List list; - public String a() { - return this.a; + public String getSessionId() { + return this.sessionId; } - public void a(String text) { - this.a = text; + public void setSessionId(String text) { + this.sessionId = text; } - public UUID b() { - return this.b; + public UUID getPlayerId() { + return this.playerId; } - public void a(UUID uuid) { - this.b = uuid; + public void setPlayerId(UUID uuid) { + this.playerId = uuid; } public SessionRequestType getSessionRequestType() { @@ -36,15 +36,15 @@ public class NetworkJoinRequest { this.sessionRequestType = sessionRequestType2; } - public String d() { - return this.d; + public String getManagerId() { + return this.managerId; } - public void b(String text) { - this.d = text; + public void setManagerId(String text) { + this.managerId = text; } - public List e() { + public List getPartyMembers() { return this.list == null ? List.of() : this.list; } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/ManagerSnapshot.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/ManagerSnapshot.java index c94368c..13cc1d6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/ManagerSnapshot.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/ManagerSnapshot.java @@ -8,19 +8,19 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.game.session.Session; public class ManagerSnapshot { - private final Map a = new HashMap<>(); - private final Map b = new HashMap<>(); + private final Map sessions = new HashMap<>(); + private final Map rejoins = new HashMap<>(); - public Map a() { - return this.a; + public Map getSessions() { + return this.sessions; } - public Map b() { - return this.b; + public Map getRejoins() { + return this.rejoins; } - public void a(BaseSessions baseSessions) { - this.a.putAll(baseSessions.f()); - this.b.putAll(baseSessions.e()); + public void captureFrom(BaseSessions baseSessions) { + this.sessions.putAll(baseSessions.getSessions()); + this.rejoins.putAll(baseSessions.getRejoinGames()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/NetworkSnapshot.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/NetworkSnapshot.java index 4b84705..4f3a1df 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/NetworkSnapshot.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/NetworkSnapshot.java @@ -13,10 +13,10 @@ public class NetworkSnapshot { return this.map; } - public void a(DefaultGameManagerRegistry defaultGameManagerRegistry) { + public void captureFrom(DefaultGameManagerRegistry defaultGameManagerRegistry) { for (AbstractGameManager abstractGameManager : defaultGameManagerRegistry) { ManagerSnapshot managerSnapshot = new ManagerSnapshot(); - managerSnapshot.a(abstractGameManager.getSessions()); + managerSnapshot.captureFrom(abstractGameManager.getSessions()); this.map.put(abstractGameManager.getId(), managerSnapshot); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/RemoteSessionStatus.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/RemoteSessionStatus.java index 5742b7a..9c5ea5c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/RemoteSessionStatus.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/protocol/snapshot/RemoteSessionStatus.java @@ -5,37 +5,37 @@ import ro.fr33styler.arcade.api.engine.game.phase.PhaseType; import ro.fr33styler.arcade.api.engine.game.session.Status; public class RemoteSessionStatus implements Status { - private int a; - private int b; - private String c; + private int players; + private int maximumPlayers; + private String name; private List list; - private String e; + private String phaseName; private PhaseType phaseType; - private String g; - private boolean h; + private String mode; + private boolean unlisted; public int players() { - return this.a; + return this.players; } - public void a(int index) { - this.a = index; + public void setPlayers(int index) { + this.players = index; } public int maximumPlayers() { - return this.b; + return this.maximumPlayers; } - public void b(int index) { - this.b = index; + public void setMaximumPlayers(int index) { + this.maximumPlayers = index; } public String name() { - return this.c; + return this.name; } - public void a(String text) { - this.c = text; + public void setName(String text) { + this.name = text; } public List playersNames() { @@ -47,11 +47,11 @@ public class RemoteSessionStatus implements Status { } public String phaseName() { - return this.e; + return this.phaseName; } - public void b(String text) { - this.e = text; + public void setPhaseName(String text) { + this.phaseName = text; } public PhaseType phaseType() { @@ -63,18 +63,18 @@ public class RemoteSessionStatus implements Status { } public String mode() { - return this.g; + return this.mode; } public boolean isUnlisted() { - return this.h; + return this.unlisted; } - public void a(boolean flag) { - this.h = flag; + public void setUnlisted(boolean flag) { + this.unlisted = flag; } - public void c(String text) { - this.g = text; + public void setMode(String text) { + this.mode = text; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/remotejoin/RemoteJoinController.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/remotejoin/RemoteJoinController.java index d204996..f0cc62f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/remotejoin/RemoteJoinController.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/remotejoin/RemoteJoinController.java @@ -39,7 +39,7 @@ public class RemoteJoinController implements NetworkFeature { return this.gson; } - public DefaultEngine d() { + public DefaultEngine getEngine() { return this.manager.getEngine(); } @@ -47,16 +47,16 @@ public class RemoteJoinController implements NetworkFeature { return this.networkEndpoint; } - public RemoteJoinSettings getSettings7() { + public RemoteJoinSettings getSettings() { return this.settings; } - public NetworkManager getManager25() { + public NetworkManager getManager() { return this.manager; } - public void a() { - this.executor = this.d().getJdkFeatures().startSingleThreadExecutor(); + public void enable() { + this.executor = this.getEngine().getJdkFeatures().startSingleThreadExecutor(); if (this.settings.getServerType().equals("Hub")) { this.networkEndpoint = new HubEndpoint(this); } else { @@ -64,25 +64,25 @@ public class RemoteJoinController implements NetworkFeature { } try { - this.networkEndpoint.a(); + this.networkEndpoint.start(); } catch (IOException ex) { - this.d().getLogger().sendError("Remote AutoJoin failed to load: " + ex.getMessage()); - EngineUtils.a(5000L); + this.getEngine().getLogger().sendError("Remote AutoJoin failed to load: " + ex.getMessage()); + EngineUtils.sleepQuietly(5000L); } } - public void b() { + public void disable() { this.executor.shutdownNow(); - this.networkEndpoint.b(); + this.networkEndpoint.stop(); } - public void a(Runnable runnable) { - if (this.d().getPlugin().isEnabled()) { - Bukkit.getScheduler().runTask(this.d().getPlugin(), runnable); + public void runSync(Runnable runnable) { + if (this.getEngine().getPlugin().isEnabled()) { + Bukkit.getScheduler().runTask(this.getEngine().getPlugin(), runnable); } } - public void a(Callable callable) { + public void submitAsync(Callable callable) { this.executor.submit(callable); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkEndpoint.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkEndpoint.java index 86c4858..6d4a708 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkEndpoint.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkEndpoint.java @@ -1,7 +1,7 @@ package ro.fr33styler.arcade.engine.network.spi; public interface NetworkEndpoint { - void a() throws java.io.IOException; + void start() throws java.io.IOException; - void b(); + void stop(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkFeature.java b/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkFeature.java index 097bc8f..d78cfda 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkFeature.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/network/spi/NetworkFeature.java @@ -1,7 +1,7 @@ package ro.fr33styler.arcade.engine.network.spi; public interface NetworkFeature { - void a(); + void enable(); - void b(); + void disable(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyAcceptCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyAcceptCommand.java index 388d410..98c6d7a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyAcceptCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyAcceptCommand.java @@ -40,20 +40,20 @@ public class PartyAcceptCommand implements CommandExecutor { Player player2 = (Player)sender; for (PartyInvitation partyInvitation : internalParty.getList()) { - if (partyInvitation.a().equals(player2.getUniqueId())) { + if (partyInvitation.getTarget().equals(player2.getUniqueId())) { internalParty.getList().remove(partyInvitation); internalParty.getMembers().add(player2.getUniqueId()); - this.manager.a(player2.getUniqueId(), player2.getName(), internalParty); - sender.sendMessage(this.manager.a().getPartyInvitationAccepted()); - Context context = Contexts.a((VariableProvider) text2 -> text2.equals("player") ? player2.getName() : null); - internalParty.forEachOnline(player3 -> player3.sendMessage(this.manager.a().getPartyInvitationAcceptedByPlayer().a(context))); + this.manager.registerMember(player2.getUniqueId(), player2.getName(), internalParty); + sender.sendMessage(this.manager.getMessages().getPartyInvitationAccepted()); + Context context = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("player") ? player2.getName() : null); + internalParty.forEachOnline(player3 -> player3.sendMessage(this.manager.getMessages().getPartyInvitationAcceptedByPlayer().render(context))); return; } } - sender.sendMessage(this.manager.a().getPartyInvitationNotFound()); + sender.sendMessage(this.manager.getMessages().getPartyInvitationNotFound()); } else { - sender.sendMessage(this.manager.a().getPartyNotAvailable()); + sender.sendMessage(this.manager.getMessages().getPartyNotAvailable()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyDenyCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyDenyCommand.java index c9abcd6..4a7289c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyDenyCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyDenyCommand.java @@ -40,18 +40,18 @@ public class PartyDenyCommand implements CommandExecutor { Player player2 = (Player)sender; for (PartyInvitation partyInvitation : internalParty.getList()) { - if (partyInvitation.a().equals(player2.getUniqueId())) { + if (partyInvitation.getTarget().equals(player2.getUniqueId())) { internalParty.getList().remove(partyInvitation); - sender.sendMessage(this.manager.a().getPartyInvitationDenied()); - Context context = Contexts.a((VariableProvider) text2 -> text2.equals("player") ? player2.getName() : null); - player.sendMessage(this.manager.a().getPartyInvitationDeniedByPlayer().a(context)); + sender.sendMessage(this.manager.getMessages().getPartyInvitationDenied()); + Context context = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("player") ? player2.getName() : null); + player.sendMessage(this.manager.getMessages().getPartyInvitationDeniedByPlayer().render(context)); return; } } - sender.sendMessage(this.manager.a().getPartyInvitationNotFound()); + sender.sendMessage(this.manager.getMessages().getPartyInvitationNotFound()); } else { - sender.sendMessage(this.manager.a().getPartyNotAvailable()); + sender.sendMessage(this.manager.getMessages().getPartyNotAvailable()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInfoCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInfoCommand.java index eaad3e8..49bb3aa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInfoCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInfoCommand.java @@ -26,9 +26,9 @@ public class PartyInfoCommand extends BaseCommandExecutor { Player player = (Player)sender; InternalParty internalParty = this.manager.getParty(player.getUniqueId()); if (internalParty == null) { - sender.sendMessage(this.manager.a().getPartyNotInAParty()); + sender.sendMessage(this.manager.getMessages().getPartyNotInAParty()); } else { - Context context = Contexts.a((VariableProvider) text2 -> { + Context context = Contexts.ofVariables((VariableProvider) text2 -> { return switch (text2) { case "owner" -> (String)internalParty.getMap().get(internalParty.getLeader()); case "amount" -> String.valueOf(internalParty.getMembers().size()); @@ -37,8 +37,8 @@ public class PartyInfoCommand extends BaseCommandExecutor { }; }); - for (Text text3 : this.manager.a().getPartyInfo()) { - sender.sendMessage(text3.a(context)); + for (Text text3 : this.manager.getMessages().getPartyInfo()) { + sender.sendMessage(text3.render(context)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInviteCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInviteCommand.java index f0271bb..52c69cc 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInviteCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyInviteCommand.java @@ -36,7 +36,7 @@ public class PartyInviteCommand implements CommandExecutor { return this.arguments; } - private TextComponent a(String text) { + private TextComponent createInviteComponent(String text) { TextComponent textComponent = new TextComponent("[Accept]"); textComponent.setColor(ChatColor.GREEN); textComponent.setClickEvent(new ClickEvent(Action.RUN_COMMAND, "/party accept " + text)); @@ -54,26 +54,26 @@ public class PartyInviteCommand implements CommandExecutor { Player player = Bukkit.getPlayer(texts[index]); if (player != null) { if (player == sender) { - sender.sendMessage(this.manager.a().getPartyInvitationYourself()); + sender.sendMessage(this.manager.getMessages().getPartyInvitationYourself()); } else if (this.manager.getParty(player.getUniqueId()) != null) { - sender.sendMessage(this.manager.a().getPartyAlreadyInAParty()); + sender.sendMessage(this.manager.getMessages().getPartyAlreadyInAParty()); } else { Player player2 = (Player)sender; InternalParty internalParty = this.manager.getParty(player2.getUniqueId()); if (internalParty == null) { internalParty = new InternalParty(player2.getUniqueId(), this.manager.getSettings().getPurgeOfflinePartiesInSeconds()); - this.manager.a(player2.getUniqueId(), player2.getName(), internalParty); + this.manager.registerMember(player2.getUniqueId(), player2.getName(), internalParty); } if (!internalParty.getLeader().equals(player2.getUniqueId())) { - sender.sendMessage(this.manager.a().getPartyNotALeader()); + sender.sendMessage(this.manager.getMessages().getPartyNotALeader()); } else { internalParty.getList().add(new PartyInvitation(player.getUniqueId())); - Context context = Contexts.a((VariableProvider) text2 -> text2.equals("player") ? player.getName() : null); - sender.sendMessage(this.manager.a().getPartyInvitedSent().a(context)); - Context context2 = Contexts.a((VariableProvider) text3 -> text3.equals("player") ? player2.getName() : null); - player.sendMessage(this.manager.a().getPartyInvitedReceived().a(context2)); - player.spigot().sendMessage(this.a(player2.getName())); + Context context = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("player") ? player.getName() : null); + sender.sendMessage(this.manager.getMessages().getPartyInvitedSent().render(context)); + Context context2 = Contexts.ofVariables((VariableProvider) text3 -> text3.equals("player") ? player2.getName() : null); + player.sendMessage(this.manager.getMessages().getPartyInvitedReceived().render(context2)); + player.spigot().sendMessage(this.createInviteComponent(player2.getName())); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyKickCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyKickCommand.java index c49b369..e1e02f4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyKickCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyKickCommand.java @@ -34,7 +34,7 @@ public class PartyKickCommand implements CommandExecutor { Player player = (Player)sender; InternalParty internalParty = this.manager.getParty(player.getUniqueId()); if (internalParty == null) { - sender.sendMessage(this.manager.a().getPartyNotInAParty()); + sender.sendMessage(this.manager.getMessages().getPartyNotInAParty()); } else { UUID uuid = null; @@ -46,21 +46,21 @@ public class PartyKickCommand implements CommandExecutor { } if (uuid == null) { - sender.sendMessage(this.manager.a().getPartyNotInYourParty()); + sender.sendMessage(this.manager.getMessages().getPartyNotInYourParty()); } else if (!internalParty.getLeader().equals(player.getUniqueId())) { - sender.sendMessage(this.manager.a().getPartyNotALeader()); + sender.sendMessage(this.manager.getMessages().getPartyNotALeader()); } else if (internalParty.getLeader().equals(uuid)) { - sender.sendMessage(this.manager.a().getPartyKickLeaderDenied()); + sender.sendMessage(this.manager.getMessages().getPartyKickLeaderDenied()); } else { - this.manager.b(uuid); + this.manager.removeMember(uuid); internalParty.getMembers().remove(uuid); - sender.sendMessage(this.manager.a().getPartyKickByYou()); + sender.sendMessage(this.manager.getMessages().getPartyKickByYou()); Player player2 = Bukkit.getPlayer(uuid); if (player2 == null) { return; } - player2.sendMessage(this.manager.a().getPartyKickReceived()); + player2.sendMessage(this.manager.getMessages().getPartyKickReceived()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyLeaveCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyLeaveCommand.java index 7bac524..1bdaf2f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyLeaveCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/command/PartyLeaveCommand.java @@ -26,20 +26,20 @@ public class PartyLeaveCommand extends BaseCommandExecutor { Player player = (Player)sender; InternalParty internalParty = this.manager.getParty(player.getUniqueId()); if (internalParty == null) { - sender.sendMessage(this.manager.a().getPartyNotInAParty()); + sender.sendMessage(this.manager.getMessages().getPartyNotInAParty()); } else { - this.manager.b(player.getUniqueId()); + this.manager.removeMember(player.getUniqueId()); if (internalParty.getLeader().equals(player.getUniqueId())) { - internalParty.forEachOnline(player2 -> player2.sendMessage(this.manager.a().getPartyDisbanded())); + internalParty.forEachOnline(player2 -> player2.sendMessage(this.manager.getMessages().getPartyDisbanded())); for (UUID uuid : internalParty.getMembers()) { - this.manager.b(uuid); + this.manager.removeMember(uuid); } } else { internalParty.getMembers().remove(player.getUniqueId()); - Context context = Contexts.a((VariableProvider) text2 -> text2.equals("player") ? player.getName() : null); - internalParty.forEachOnline(player3 -> player3.sendMessage(this.manager.a().getPartyPlayerLeft().a(context))); - sender.sendMessage(this.manager.a().getPartyLeft()); + Context context = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("player") ? player.getName() : null); + internalParty.forEachOnline(player3 -> player3.sendMessage(this.manager.getMessages().getPartyPlayerLeft().render(context))); + sender.sendMessage(this.manager.getMessages().getPartyLeft()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalParty.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalParty.java index 131153a..488a548 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalParty.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalParty.java @@ -12,27 +12,27 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.party.Party; public class InternalParty implements Party { - private int a; - private final UUID b; + private int offlinePurgeTimer; + private final UUID leader; private final Set set = new HashSet<>(); private final Map map = new HashMap<>(); private final List list = new ArrayList<>(); public InternalParty(UUID uuid, int index) { - this.b = uuid; - this.a = index; + this.leader = uuid; + this.offlinePurgeTimer = index; } - public int a() { - return this.a; + public int getOfflinePurgeTimer() { + return this.offlinePurgeTimer; } - public void a(int index) { - this.a = index; + public void setOfflinePurgeTimer(int index) { + this.offlinePurgeTimer = index; } public UUID getLeader() { - return this.b; + return this.leader; } public Set getMembers() { @@ -47,10 +47,10 @@ public class InternalParty implements Party { return this.list; } - void e() { + void tickInvitations() { this.list.removeIf(partyInvitation -> { - if (partyInvitation.b() > 0) { - partyInvitation.a(partyInvitation.b() - 1); + if (partyInvitation.getRemainingSeconds() > 0) { + partyInvitation.setRemainingSeconds(partyInvitation.getRemainingSeconds() - 1); return false; } else { return true; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyListener.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyListener.java index 5ab33c1..27ccc5b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyListener.java @@ -13,11 +13,11 @@ public class InternalPartyListener implements Listener { } @EventHandler - public void a(PlayerJoinEvent event) { + public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); InternalParty internalParty = this.manager.getParty(player.getUniqueId()); if (internalParty != null && internalParty.getLeader().equals(player.getUniqueId())) { - internalParty.a(this.manager.getSettings().getPurgeOfflinePartiesInSeconds()); + internalParty.setOfflinePurgeTimer(this.manager.getSettings().getPurgeOfflinePartiesInSeconds()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyManager.java index 4d9a5d7..b4ab97e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/internal/InternalPartyManager.java @@ -28,7 +28,7 @@ public class InternalPartyManager implements PartyManager { private BukkitTask task; private final List list = new ArrayList<>(); private final Map map = new HashMap<>(); - private final Listener d = new InternalPartyListener(this); + private final Listener listener = new InternalPartyListener(this); private final DefaultEngine engine; private final InternalPartySettings settings; private final Command command; @@ -37,10 +37,10 @@ public class InternalPartyManager implements PartyManager { this.engine = engine2; this.settings = settings2; this.command = new DefaultCommand(engine2, "Party", settings2.getCommand(), settings2.getAliases()); - this.c(); + this.registerCommands(); } - public EngineMessages a() { + public EngineMessages getMessages() { return this.engine.getMessages(); } @@ -48,7 +48,7 @@ public class InternalPartyManager implements PartyManager { return this.settings; } - public void c() { + public void registerCommands() { this.command.putExecutor(Path.of("accept"), new PartyAcceptCommand(this)); this.command.putExecutor(Path.of("deny"), new PartyDenyCommand(this)); this.command.putExecutor(Path.of("invite"), new PartyInviteCommand(this)); @@ -60,26 +60,26 @@ public class InternalPartyManager implements PartyManager { public void load() { VersionAdapters.get().registerCommand(this.engine.getPlugin(), this.engine.getPlatform(), this.command, this.engine.getSettings().isUseBrigadierCommands()); - this.engine.getAddonManager().registerListener(this.d); - this.task = Bukkit.getScheduler().runTaskTimer(this.engine.getPlugin(), this::d, 0L, 20L); + this.engine.getAddonManager().registerListener(this.listener); + this.task = Bukkit.getScheduler().runTaskTimer(this.engine.getPlugin(), this::onTick, 0L, 20L); } public void unload() { this.task.cancel(); - this.engine.getAddonManager().unregisterListener(this.d); + this.engine.getAddonManager().unregisterListener(this.listener); VersionAdapters.get().unregisterCommand(this.engine.getPlatform(), this.command, this.engine.getSettings().isUseBrigadierCommands()); } - private void d() { + private void onTick() { this.list.removeIf(internalParty -> { - internalParty.e(); + internalParty.tickInvitations(); if (Bukkit.getPlayer(internalParty.getLeader()) != null) { - internalParty.a(this.settings.getPurgeOfflinePartiesInSeconds()); - } else if (internalParty.a() > 0) { - internalParty.a(internalParty.a() - 1); + internalParty.setOfflinePurgeTimer(this.settings.getPurgeOfflinePartiesInSeconds()); + } else if (internalParty.getOfflinePurgeTimer() > 0) { + internalParty.setOfflinePurgeTimer(internalParty.getOfflinePurgeTimer() - 1); } - boolean flag = internalParty.a() == 0 || internalParty.getMembers().isEmpty() && internalParty.getList().isEmpty(); + boolean flag = internalParty.getOfflinePurgeTimer() == 0 || internalParty.getMembers().isEmpty() && internalParty.getList().isEmpty(); if (flag) { internalParty.forEach(this.map::remove); } @@ -92,7 +92,7 @@ public class InternalPartyManager implements PartyManager { return this.map.get(uuid); } - public void a(UUID uuid, String text, InternalParty internalParty) { + public void registerMember(UUID uuid, String text, InternalParty internalParty) { this.map.put(uuid, internalParty); internalParty.getMap().put(uuid, text); if (uuid.equals(internalParty.getLeader())) { @@ -100,7 +100,7 @@ public class InternalPartyManager implements PartyManager { } } - public void b(UUID uuid) { + public void removeMember(UUID uuid) { InternalParty internalParty = this.map.remove(uuid); if (internalParty != null) { internalParty.getMap().remove(uuid); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/invitation/PartyInvitation.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/invitation/PartyInvitation.java index c67e82a..ff8eb11 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/invitation/PartyInvitation.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/invitation/PartyInvitation.java @@ -3,22 +3,22 @@ package ro.fr33styler.arcade.engine.party.invitation; import java.util.UUID; public class PartyInvitation { - private final UUID a; - private int b = 60; + private final UUID target; + private int remainingSeconds = 60; public PartyInvitation(UUID uuid) { - this.a = uuid; + this.target = uuid; } - public UUID a() { - return this.a; + public UUID getTarget() { + return this.target; } - public int b() { - return this.b; + public int getRemainingSeconds() { + return this.remainingSeconds; } - public void a(int index) { - this.b = index; + public void setRemainingSeconds(int index) { + this.remainingSeconds = index; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/party/remote/RemoteParty.java b/common/src/main/java/ro/fr33styler/arcade/engine/party/remote/RemoteParty.java index bca668c..7b57b8a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/party/remote/RemoteParty.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/party/remote/RemoteParty.java @@ -7,16 +7,16 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.party.Party; public class RemoteParty implements Party { - private final UUID a; + private final UUID leader; private final Set set; public RemoteParty(UUID uuid, List list) { - this.a = uuid; + this.leader = uuid; this.set = new HashSet<>(list); } public UUID getLeader() { - return this.a; + return this.leader; } public Set getMembers() { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUser.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUser.java index 28f9499..3fa97e6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUser.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUser.java @@ -37,14 +37,14 @@ public class DefaultUser extends PlayerHandle implements User { private Gamer gamer; private ArenaSetup arenaSetup; private InventoryMenu menu; - private InventoryMenu menu3; + private InventoryMenu openMenu; private PlayerSnapshot snapshot; - private Block g; - private Block h; - private long i = System.currentTimeMillis(); + private Block selectionPos1; + private Block selectionPos2; + private long lastInteractionTime = System.currentTimeMillis(); private final ViewerManager viewers = new DefaultViewerManager(); - private final List k = new ArrayList<>(); - private final List l = new ArrayList<>(); + private final List leaderboardToggles = new ArrayList<>(); + private final List leaderboardDisplays = new ArrayList<>(); private final DefaultEngine engine; DefaultUser(DefaultEngine engine2, Player player) { @@ -72,21 +72,21 @@ public class DefaultUser extends PlayerHandle implements User { this.gamer = gamer2; } - public boolean b() { - return this.menu3 != null; + public boolean hasOpenMenu() { + return this.openMenu != null; } - public InventoryMenu getMenu3() { - return this.menu3; + public InventoryMenu getOpenMenu() { + return this.openMenu; } - public void a(InventoryMenu menu32) { - this.player.openInventory(menu32.a()); - this.menu3 = menu32; + public void openMenu(InventoryMenu menu32) { + this.player.openInventory(menu32.getInventory()); + this.openMenu = menu32; } - public void d() { - this.menu3 = null; + public void closeMenu() { + this.openMenu = null; this.player.setItemOnCursor((org.bukkit.inventory.ItemStack)null); } @@ -98,12 +98,12 @@ public class DefaultUser extends PlayerHandle implements User { this.menu = menu2; } - public long f() { - return this.i; + public long getLastInteractionTime() { + return this.lastInteractionTime; } - public void a(long longVal) { - this.i = longVal; + public void setLastInteractionTime(long longVal) { + this.lastInteractionTime = longVal; } public Party getParty() { @@ -130,7 +130,7 @@ public class DefaultUser extends PlayerHandle implements User { super.sendTitle(this.engine.getPlatform(), text, text2, context, index, index2, index3); } - public boolean g() { + public boolean isInSetup() { return this.arenaSetup != null; } @@ -138,23 +138,23 @@ public class DefaultUser extends PlayerHandle implements User { return this.arenaSetup; } - public void a(ArenaSetup arenaSetup2) { + public void setArenaSetup(ArenaSetup arenaSetup2) { this.arenaSetup = arenaSetup2; if (arenaSetup2 != null) { - arenaSetup2.d(); + arenaSetup2.start(); } } - public void i() { - this.snapshot = Players.a(this.engine.getPlatform(), this.player, this.engine.getDatabaseManager().getLobby()); + public void saveSnapshot() { + this.snapshot = Players.createSnapshot(this.engine.getPlatform(), this.player, this.engine.getDatabaseManager().getLobby()); } - public void j() { + public void restoreSnapshot() { if (this.snapshot != null) { if (this.engine.getSettings().isRestoreInventory()) { - this.snapshot.a(this.engine.getPlatform(), this.player); + this.snapshot.restore(this.engine.getPlatform(), this.player); } else { - this.player.teleport(this.snapshot.a()); + this.player.teleport(this.snapshot.getLocation()); this.player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard()); } @@ -162,31 +162,31 @@ public class DefaultUser extends PlayerHandle implements User { } } - public Block k() { - return this.g; + public Block getSelectionPos1() { + return this.selectionPos1; } - public void a(Block block) { - this.g = block; + public void setSelectionPos1(Block block) { + this.selectionPos1 = block; } - public Block l() { - return this.h; + public Block getSelectionPos2() { + return this.selectionPos2; } - public void b(Block block) { - this.h = block; + public void setSelectionPos2(Block block) { + this.selectionPos2 = block; } public ViewerManager getViewers() { return this.viewers; } - public void a(DefaultSessionSearcher defaultSessionSearcher) { - this.a(defaultSessionSearcher, session -> session.canPlay(this).successful()); + public void quickJoin(DefaultSessionSearcher defaultSessionSearcher) { + this.quickJoin(defaultSessionSearcher, session -> session.canPlay(this).successful()); } - public void a(DefaultSessionSearcher defaultSessionSearcher, Predicate predicate) { + public void quickJoin(DefaultSessionSearcher defaultSessionSearcher, Predicate predicate) { Party party = this.getParty(); if (party != null && !this.player.getUniqueId().equals(party.getLeader())) { this.sendMessage(this.engine.getMessages().getPartyOnlyLeader()); @@ -200,136 +200,136 @@ public class DefaultUser extends PlayerHandle implements User { } } - public void a(LeaderboardGroup leaderboardGroup) { + public void addLeaderboardDisplay(LeaderboardGroup leaderboardGroup) { LeaderboardDisplay leaderboardDisplay = new LeaderboardDisplay(this.player, leaderboardGroup); - this.viewers.a(leaderboardDisplay); - this.l.add(leaderboardDisplay); + this.viewers.register(leaderboardDisplay); + this.leaderboardDisplays.add(leaderboardDisplay); } - public void b(LeaderboardGroup leaderboardGroup) { - for (LeaderboardDisplay leaderboardDisplay : this.l) { + public void removeLeaderboardDisplay(LeaderboardGroup leaderboardGroup) { + for (LeaderboardDisplay leaderboardDisplay : this.leaderboardDisplays) { if (leaderboardDisplay.getLeaderboardGroup() == leaderboardGroup) { - this.viewers.b(leaderboardDisplay); - this.l.remove(leaderboardDisplay); + this.viewers.unregister(leaderboardDisplay); + this.leaderboardDisplays.remove(leaderboardDisplay); return; } } } - public void a(int index) { - for (LeaderboardDisplay leaderboardDisplay : this.l) { - if (leaderboardDisplay.a(index)) { - leaderboardDisplay.a(leaderboardDisplay.getLeaderboardPeriod().b()); - leaderboardDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); - this.a(leaderboardDisplay.getLeaderboardPeriod().a(this.engine.getMessages())); + public void interactLeaderboard(int index) { + for (LeaderboardDisplay leaderboardDisplay : this.leaderboardDisplays) { + if (leaderboardDisplay.hasEntityId(index)) { + leaderboardDisplay.setLeaderboardPeriod(leaderboardDisplay.getLeaderboardPeriod().next()); + leaderboardDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); + this.sendLeaderboardPosition(leaderboardDisplay.getLeaderboardPeriod().getDisplayName(this.engine.getMessages())); return; } } } - public void a(LeaderboardToggle leaderboardToggle) { + public void addLeaderboardToggle(LeaderboardToggle leaderboardToggle) { LeaderboardToggleDisplay leaderboardToggleDisplay = new LeaderboardToggleDisplay(leaderboardToggle); - this.viewers.a(leaderboardToggleDisplay); - this.k.add(leaderboardToggleDisplay); - this.b(leaderboardToggleDisplay); + this.viewers.register(leaderboardToggleDisplay); + this.leaderboardToggles.add(leaderboardToggleDisplay); + this.refreshToggledLeaderboards(leaderboardToggleDisplay); } - public void b(LeaderboardToggle leaderboardToggle) { - for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.k) { + public void removeLeaderboardToggle(LeaderboardToggle leaderboardToggle) { + for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.leaderboardToggles) { if (leaderboardToggleDisplay.getLeaderboardToggle() == leaderboardToggle) { - this.viewers.b(leaderboardToggleDisplay); - this.k.remove(leaderboardToggleDisplay); + this.viewers.unregister(leaderboardToggleDisplay); + this.leaderboardToggles.remove(leaderboardToggleDisplay); return; } } } - public void b(int index) { - for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.k) { - if (leaderboardToggleDisplay.b(index)) { - leaderboardToggleDisplay.a(leaderboardToggleDisplay.b() + 1); - leaderboardToggleDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getToggler()); - this.b(leaderboardToggleDisplay); - this.a(leaderboardToggleDisplay.c(leaderboardToggleDisplay.b()).getSettings().getMode()); - this.a(leaderboardToggleDisplay); + public void interactLeaderboardToggle(int index) { + for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.leaderboardToggles) { + if (leaderboardToggleDisplay.hasEntityId(index)) { + leaderboardToggleDisplay.setSelectedIndex(leaderboardToggleDisplay.getSelectedIndex() + 1); + leaderboardToggleDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getToggler()); + this.refreshToggledLeaderboards(leaderboardToggleDisplay); + this.sendLeaderboardPosition(leaderboardToggleDisplay.getSourceAt(leaderboardToggleDisplay.getSelectedIndex()).getSettings().getMode()); + this.syncMatchingToggles(leaderboardToggleDisplay); return; } } } - private void a(LeaderboardToggleDisplay leaderboardToggleDisplay) { + private void syncMatchingToggles(LeaderboardToggleDisplay leaderboardToggleDisplay) { Set set = leaderboardToggleDisplay.getLeaderboardToggle().getSettings().getLeaderboardIds(); - for (LeaderboardToggleDisplay leaderboardToggleDisplay2 : this.k) { + for (LeaderboardToggleDisplay leaderboardToggleDisplay2 : this.leaderboardToggles) { LeaderboardToggleSettings leaderboardToggleSettings = leaderboardToggleDisplay2.getLeaderboardToggle().getSettings(); if (leaderboardToggleDisplay2 != leaderboardToggleDisplay && leaderboardToggleSettings.getLeaderboardIds().equals(set)) { - leaderboardToggleDisplay2.a(leaderboardToggleDisplay.b()); - leaderboardToggleDisplay2.a(this.engine.getPlatform(), this.engine.getMessages().getToggler()); + leaderboardToggleDisplay2.setSelectedIndex(leaderboardToggleDisplay.getSelectedIndex()); + leaderboardToggleDisplay2.render(this.engine.getPlatform(), this.engine.getMessages().getToggler()); } } } - public void c(LeaderboardGroup leaderboardGroup) { - for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.k) { - if (leaderboardToggleDisplay.getLeaderboardToggle().getSettings().getLeaderboardIds().contains(leaderboardGroup.a())) { - this.b(leaderboardToggleDisplay); + public void refreshLeaderboardGroup(LeaderboardGroup leaderboardGroup) { + for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.leaderboardToggles) { + if (leaderboardToggleDisplay.getLeaderboardToggle().getSettings().getLeaderboardIds().contains(leaderboardGroup.getId())) { + this.refreshToggledLeaderboards(leaderboardToggleDisplay); return; } } - this.d(leaderboardGroup); + this.resetLeaderboardDisplay(leaderboardGroup); } - private void d(LeaderboardGroup leaderboardGroup) { - for (LeaderboardDisplay leaderboardDisplay : this.l) { + private void resetLeaderboardDisplay(LeaderboardGroup leaderboardGroup) { + for (LeaderboardDisplay leaderboardDisplay : this.leaderboardDisplays) { if (leaderboardDisplay.getLeaderboardGroup() == leaderboardGroup) { LeaderboardSource leaderboardSource = (LeaderboardSource)Iterables.getFirst(leaderboardGroup.getMap().values(), null); - leaderboardDisplay.a(leaderboardSource == null ? null : leaderboardSource.getSettings().getMode()); - leaderboardDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); + leaderboardDisplay.setMode(leaderboardSource == null ? null : leaderboardSource.getSettings().getMode()); + leaderboardDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); return; } } } - private void b(LeaderboardToggleDisplay leaderboardToggleDisplay) { - for (LeaderboardDisplay leaderboardDisplay : this.l) { - if (leaderboardToggleDisplay.getLeaderboardToggle().getSettings().getLeaderboardIds().contains(leaderboardDisplay.getLeaderboardGroup().a())) { - LeaderboardSource leaderboardSource = leaderboardToggleDisplay.c(leaderboardToggleDisplay.b()); - leaderboardDisplay.a(leaderboardSource == null ? null : leaderboardSource.getSettings().getMode()); - leaderboardDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); + private void refreshToggledLeaderboards(LeaderboardToggleDisplay leaderboardToggleDisplay) { + for (LeaderboardDisplay leaderboardDisplay : this.leaderboardDisplays) { + if (leaderboardToggleDisplay.getLeaderboardToggle().getSettings().getLeaderboardIds().contains(leaderboardDisplay.getLeaderboardGroup().getId())) { + LeaderboardSource leaderboardSource = leaderboardToggleDisplay.getSourceAt(leaderboardToggleDisplay.getSelectedIndex()); + leaderboardDisplay.setMode(leaderboardSource == null ? null : leaderboardSource.getSettings().getMode()); + leaderboardDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); } } } - private void a(String text) { - Context context = Contexts.a((VariableProvider) text2 -> text2.equals("position") ? text : null); + private void sendLeaderboardPosition(String text) { + Context context = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("position") ? text : null); this.sendMessage(this.engine.getMessages().getLeaderboardPosition(), context); this.playSound(ArcadeSound.UI_BUTTON_CLICK, 1.0F, 1.0F); } - public void b(long longVal) { - this.viewers.b(this.player); - this.engine.getDisplayManager().getViewers().b(this.player); + public void onTick(long longVal) { + this.viewers.update(this.player); + this.engine.getDisplayManager().getViewers().update(this.player); if (longVal % (this.engine.getSettings().getUpdateLeaderboardTextInSeconds() * 20L) == 0L) { - this.q(); + this.refreshDisplays(); } } - private void q() { - for (LeaderboardDisplay leaderboardDisplay : this.l) { - leaderboardDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); + private void refreshDisplays() { + for (LeaderboardDisplay leaderboardDisplay : this.leaderboardDisplays) { + leaderboardDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getLeaderboard()); } - for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.k) { - leaderboardToggleDisplay.a(this.engine.getPlatform(), this.engine.getMessages().getToggler()); + for (LeaderboardToggleDisplay leaderboardToggleDisplay : this.leaderboardToggles) { + leaderboardToggleDisplay.render(this.engine.getPlatform(), this.engine.getMessages().getToggler()); } } - void n() { + void injectPacketInterceptor() { this.engine.getPlatform().getPacketInterceptor().inject(this.engine.getPlugin().getName() + "-Packet-Sniffer", this.player); } - void o() { + void ejectPacketInterceptor() { this.engine.getPlatform().getPacketInterceptor().eject(this.engine.getPlugin().getName() + "-Packet-Sniffer", this.player); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUserSet.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUserSet.java index ccb37bb..1eee071 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUserSet.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/DefaultUserSet.java @@ -17,74 +17,74 @@ public class DefaultUserSet extends PlayerRegistry implements UserS this.engine = engine2; } - public void a() { - Bukkit.getOnlinePlayers().forEach(this::a); + public void loadOnlineUsers() { + Bukkit.getOnlinePlayers().forEach(this::addUser); } - public void b() { - Bukkit.getOnlinePlayers().forEach(this::b); + public void unloadOnlineUsers() { + Bukkit.getOnlinePlayers().forEach(this::removeUser); this.map.clear(); } - public DefaultUser a(Player player) { + public DefaultUser addUser(Player player) { DefaultUser defaultUser = new DefaultUser(this.engine, player); this.map.put(player.getUniqueId(), defaultUser); - defaultUser.n(); + defaultUser.injectPacketInterceptor(); return defaultUser; } - public DefaultUser b(Player player) { - DefaultUser defaultUser = (DefaultUser)super.b(player.getUniqueId()); + public DefaultUser removeUser(Player player) { + DefaultUser defaultUser = (DefaultUser)super.remove(player.getUniqueId()); if (defaultUser != null) { - defaultUser.o(); - if (defaultUser.b()) { + defaultUser.ejectPacketInterceptor(); + if (defaultUser.hasOpenMenu()) { player.closeInventory(); } - if (defaultUser.g()) { - defaultUser.getArenaSetup().h(); + if (defaultUser.isInSetup()) { + defaultUser.getArenaSetup().cleanup(); } } return defaultUser; } - public void a(long longVal) { + public void onTick(long longVal) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.b(longVal); - if (defaultUser.g() && defaultUser.getArenaSetup().g() > 0) { - defaultUser.getArenaSetup().a(defaultUser.getArenaSetup().g() - 1); + defaultUser.onTick(longVal); + if (defaultUser.isInSetup() && defaultUser.getArenaSetup().getCancelCountdown() > 0) { + defaultUser.getArenaSetup().setCancelCountdown(defaultUser.getArenaSetup().getCancelCountdown() - 1); } } } - public void a(LeaderboardGroup leaderboardGroup) { + public void addLeaderboardGroup(LeaderboardGroup leaderboardGroup) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.a(leaderboardGroup); + defaultUser.addLeaderboardDisplay(leaderboardGroup); } } - public void b(LeaderboardGroup leaderboardGroup) { + public void removeLeaderboardGroup(LeaderboardGroup leaderboardGroup) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.b(leaderboardGroup); + defaultUser.removeLeaderboardDisplay(leaderboardGroup); } } - public void c(LeaderboardGroup leaderboardGroup) { + public void refreshLeaderboardGroup(LeaderboardGroup leaderboardGroup) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.c(leaderboardGroup); + defaultUser.refreshLeaderboardGroup(leaderboardGroup); } } - public void a(LeaderboardToggle leaderboardToggle) { + public void addLeaderboardToggle(LeaderboardToggle leaderboardToggle) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.a(leaderboardToggle); + defaultUser.addLeaderboardToggle(leaderboardToggle); } } - public void b(LeaderboardToggle leaderboardToggle) { + public void removeLeaderboardToggle(LeaderboardToggle leaderboardToggle) { for (DefaultUser defaultUser : this.map.values()) { - defaultUser.b(leaderboardToggle); + defaultUser.removeLeaderboardToggle(leaderboardToggle); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerHandle.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerHandle.java index 981f716..2eed485 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerHandle.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerHandle.java @@ -39,7 +39,7 @@ public class PlayerHandle { } public void sendMessage(Text text, Context context) { - this.sendMessage(text.a(context)); + this.sendMessage(text.render(context)); } public void sendMessages(List list, Context context) { @@ -53,7 +53,7 @@ public class PlayerHandle { } public void sendActionBar(ServerPlatform serverPlatform, Text text, Context context) { - this.sendActionBar(serverPlatform, text.a(context)); + this.sendActionBar(serverPlatform, text.render(context)); } public void sendHeaderAndFooter(ServerPlatform serverPlatform, String header, String footer) { @@ -65,8 +65,8 @@ public class PlayerHandle { } public void sendTitle(ServerPlatform serverPlatform, Text title, Text subtitle, Context context, int fadeIn, int stay, int fadeOut) { - String resolvedTitle = title == null ? null : title.a(context); - String resolvedSubtitle = subtitle == null ? null : subtitle.a(context); + String resolvedTitle = title == null ? null : title.render(context); + String resolvedSubtitle = subtitle == null ? null : subtitle.render(context); this.sendTitle(serverPlatform, resolvedTitle, resolvedSubtitle, fadeIn, stay, fadeOut); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerRegistry.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerRegistry.java index 59204e2..864367c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerRegistry.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/PlayerRegistry.java @@ -16,7 +16,7 @@ import org.bukkit.entity.Player; public class PlayerRegistry

implements Iterable

{ protected final Map map = new LinkedHashMap<>(); - private boolean b(Entity entity) { + private boolean isPlayer(Entity entity) { return entity != null && entity.getType() == EntityType.PLAYER; } @@ -25,14 +25,14 @@ public class PlayerRegistry

implements Iterable

{ } public boolean contains(Entity entity) { - return this.b(entity) && this.contains(entity.getUniqueId()); + return this.isPlayer(entity) && this.contains(entity.getUniqueId()); } public boolean contains(Player player) { return this.contains(player.getUniqueId()); } - public void a(P playerHandle) { + public void add(P playerHandle) { this.map.put(playerHandle.getUUID(), (P)playerHandle); } @@ -41,38 +41,38 @@ public class PlayerRegistry

implements Iterable

{ } public P a(Entity entity) { - return this.b(entity) ? this.a(entity.getUniqueId()) : null; + return this.isPlayer(entity) ? this.a(entity.getUniqueId()) : null; } public P c(Player player) { return this.a(player.getUniqueId()); } - public P b(UUID uuid) { + public P remove(UUID uuid) { return this.map.remove(uuid); } - public void b(P playerHandle) { - this.b(playerHandle.getUUID()); + public void remove(P playerHandle) { + this.remove(playerHandle.getUUID()); } public int size() { return this.map.size(); } - public Collection

c() { + public Collection

values() { return this.map.values(); } - public List

d() { + public List

toList() { return new ArrayList<>(this.map.values()); } - public P[] a(P[] playerHandles) { + public P[] toArray(P[] playerHandles) { return (P[])this.map.values().toArray(playerHandles); } - public void a(Consumer consumer) { + public void forEachPlayer(Consumer consumer) { for (PlayerHandle playerHandle : this.map.values()) { consumer.accept(playerHandle.toPlayer()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/bukkit/Players.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/bukkit/Players.java index bd40f17..118c80c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/bukkit/Players.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/bukkit/Players.java @@ -13,25 +13,25 @@ import org.bukkit.potion.PotionEffectType; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class Players { - public static void a(Player player) { + public static void clearChat(Player player) { for (int index = 0; index < 20; index++) { player.sendMessage(""); } } - public static PlayerSnapshot a(ServerPlatform serverPlatform, Player player, Location location) { + public static PlayerSnapshot createSnapshot(ServerPlatform serverPlatform, Player player, Location location) { return new PlayerSnapshot(serverPlatform, player, location == null ? player.getLocation() : location); } - public static void a(BaseGamer baseGamer) { - a(baseGamer.toUser().getEngine().getPlatform(), baseGamer.toPlayer()); + public static void reset(BaseGamer baseGamer) { + reset(baseGamer.toUser().getEngine().getPlatform(), baseGamer.toPlayer()); } - public static void a(Player player, PlayerInteractEvent event) { - a(null, player, event); + public static void consumeHeldItem(Player player, PlayerInteractEvent event) { + consumeHeldItem(null, player, event); } - public static void a(ServerPlatform serverPlatform, Player player, PlayerInteractEvent event) { + public static void consumeHeldItem(ServerPlatform serverPlatform, Player player, PlayerInteractEvent event) { ItemStack item = event.getItem(); if (item != null) { if (item.getAmount() > 1) { @@ -44,7 +44,7 @@ public class Players { } } - public static void a(ServerPlatform serverPlatform, Player player) { + public static void reset(ServerPlatform serverPlatform, Player player) { player.setExp(0.0F); player.setLevel(0); player.leaveVehicle(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/state/PlayerSnapshot.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/state/PlayerSnapshot.java index 68da4b7..178839d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/state/PlayerSnapshot.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/state/PlayerSnapshot.java @@ -13,75 +13,75 @@ import org.bukkit.scoreboard.Scoreboard; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class PlayerSnapshot { - private final float a; - private final int b; - private final int c; - private final GameMode d; - private final double e; - private final int f; - private final float g; - private final float h; - private final boolean i; - private final Scoreboard j; - private final Location k; - private final boolean l; - private final double m; - private final double n; - private final ItemStack[] o; - private final ItemStack[] p; - private final Location q; - private final float r; - private final ItemStack s; - private final ItemStack[] t; - private final Collection u; - private final double v; + private final float exp; + private final int foodLevel; + private final int level; + private final GameMode gameMode; + private final double health; + private final int fireTicks; + private final float flySpeed; + private final float walkSpeed; + private final boolean allowFlight; + private final Scoreboard scoreboard; + private final Location compassTarget; + private final boolean flying; + private final double maxHealth; + private final double waypointReceiveRange; + private final ItemStack[] enderChestContents; + private final ItemStack[] armorContents; + private final Location location; + private final float fallDistance; + private final ItemStack offHandItem; + private final ItemStack[] storageContents; + private final Collection potionEffects; + private final double attackSpeed; public PlayerSnapshot(ServerPlatform serverPlatform, Player player, Location location) { - this.a = player.getExp(); - this.q = location; - this.c = player.getLevel(); - this.e = player.getHealth(); - this.d = player.getGameMode(); - this.b = player.getFoodLevel(); - this.l = player.isFlying(); - this.j = player.getScoreboard(); - this.g = player.getFlySpeed(); - this.i = player.getAllowFlight(); - this.f = player.getFireTicks(); - this.h = player.getWalkSpeed(); - this.k = player.getCompassTarget(); - this.r = player.getFallDistance(); - this.u = player.getActivePotionEffects(); - this.o = player.getEnderChest().getContents(); - this.s = VersionAdapters.get().getOffHandItem(serverPlatform, player); - this.t = VersionAdapters.get().getStorageContents(player); - this.p = player.getInventory().getArmorContents(); - this.m = VersionAdapters.get().getMaxHealth(player); - this.v = VersionAdapters.get().getAttackSpeed(player); - this.n = serverPlatform.getWaypointReceiveRange(player); + this.exp = player.getExp(); + this.location = location; + this.level = player.getLevel(); + this.health = player.getHealth(); + this.gameMode = player.getGameMode(); + this.foodLevel = player.getFoodLevel(); + this.flying = player.isFlying(); + this.scoreboard = player.getScoreboard(); + this.flySpeed = player.getFlySpeed(); + this.allowFlight = player.getAllowFlight(); + this.fireTicks = player.getFireTicks(); + this.walkSpeed = player.getWalkSpeed(); + this.compassTarget = player.getCompassTarget(); + this.fallDistance = player.getFallDistance(); + this.potionEffects = player.getActivePotionEffects(); + this.enderChestContents = player.getEnderChest().getContents(); + this.offHandItem = VersionAdapters.get().getOffHandItem(serverPlatform, player); + this.storageContents = VersionAdapters.get().getStorageContents(player); + this.armorContents = player.getInventory().getArmorContents(); + this.maxHealth = VersionAdapters.get().getMaxHealth(player); + this.attackSpeed = VersionAdapters.get().getAttackSpeed(player); + this.waypointReceiveRange = serverPlatform.getWaypointReceiveRange(player); } - public Location a() { - return this.q; + public Location getLocation() { + return this.location; } - public void a(ServerPlatform serverPlatform, Player player) { - player.teleport(this.q); - player.setExp(this.a); - player.setLevel(this.c); - player.setGameMode(this.d); - player.setFoodLevel(this.b); - player.setFlySpeed(this.g); - player.setFireTicks(this.f); - player.setWalkSpeed(this.h); - if (this.k != null) { - player.setCompassTarget(this.k); + public void restore(ServerPlatform serverPlatform, Player player) { + player.teleport(this.location); + player.setExp(this.exp); + player.setLevel(this.level); + player.setGameMode(this.gameMode); + player.setFoodLevel(this.foodLevel); + player.setFlySpeed(this.flySpeed); + player.setFireTicks(this.fireTicks); + player.setWalkSpeed(this.walkSpeed); + if (this.compassTarget != null) { + player.setCompassTarget(this.compassTarget); } - player.getEnderChest().setContents(this.o); - VersionAdapters.get().setStorageContents(player, this.t); - VersionAdapters.get().setOffHandItem(serverPlatform, player, this.s); - player.getInventory().setArmorContents(this.p); + player.getEnderChest().setContents(this.enderChestContents); + VersionAdapters.get().setStorageContents(player, this.storageContents); + VersionAdapters.get().setOffHandItem(serverPlatform, player, this.offHandItem); + player.getInventory().setArmorContents(this.armorContents); if (!VersionAdapters.get().isLatestVariant()) { player.updateInventory(); } @@ -92,19 +92,19 @@ public class PlayerSnapshot { } } - player.addPotionEffects(this.u); - VersionAdapters.get().setMaxHealth(player, this.m); - player.setHealth(this.e); + player.addPotionEffects(this.potionEffects); + VersionAdapters.get().setMaxHealth(player, this.maxHealth); + player.setHealth(this.health); serverPlatform.sendHealthUpdate(player); - player.setAllowFlight(this.i); - if (this.i) { - player.setFlying(this.l); + player.setAllowFlight(this.allowFlight); + if (this.allowFlight) { + player.setFlying(this.flying); } - player.setFallDistance(this.r); - VersionAdapters.get().setAttackSpeed(player, this.v); - serverPlatform.setWaypointReceiveRange(player, this.n); - player.setScoreboard(this.j); + player.setFallDistance(this.fallDistance); + VersionAdapters.get().setAttackSpeed(player, this.attackSpeed); + serverPlatform.setWaypointReceiveRange(player, this.waypointReceiveRange); + player.setScoreboard(this.scoreboard); player.updateInventory(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/player/visibility/PlayerVisibility.java b/common/src/main/java/ro/fr33styler/arcade/engine/player/visibility/PlayerVisibility.java index 713f240..8fb0141 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/player/visibility/PlayerVisibility.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/player/visibility/PlayerVisibility.java @@ -8,7 +8,7 @@ import ro.fr33styler.arcade.engine.player.PlayerRegistry; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public final class PlayerVisibility { - public static void a(Plugin plugin, Player player, PlayerRegistry playerRegistry, PlayerRegistry playerRegistry2) { + public static void syncVisibility(Plugin plugin, Player player, PlayerRegistry playerRegistry, PlayerRegistry playerRegistry2) { for (PlayerHandle playerHandle : playerRegistry2) { if (playerRegistry.contains(playerHandle.toPlayer())) { VersionAdapters.get().showPlayer(plugin, playerHandle.toPlayer(), player); @@ -19,7 +19,7 @@ public final class PlayerVisibility { } } - public static void b(Plugin plugin, Player player, PlayerRegistry playerRegistry, PlayerRegistry playerRegistry2) { + public static void restoreVisibility(Plugin plugin, Player player, PlayerRegistry playerRegistry, PlayerRegistry playerRegistry2) { for (PlayerHandle playerHandle : playerRegistry2) { if (playerRegistry.contains(playerHandle.toPlayer()) && plugin.isEnabled()) { VersionAdapters.get().hidePlayer(plugin, playerHandle.toPlayer(), player); @@ -29,19 +29,19 @@ public final class PlayerVisibility { } } - public static void a(Plugin plugin, Player player) { + public static void showAllPlayers(Plugin plugin, Player player) { for (Player player2 : Bukkit.getOnlinePlayers()) { VersionAdapters.get().showPlayer(plugin, player, player2); } } - public static void a(Plugin plugin, Player player, PlayerRegistry playerRegistry) { + public static void showToRegistry(Plugin plugin, Player player, PlayerRegistry playerRegistry) { for (PlayerHandle playerHandle : playerRegistry) { VersionAdapters.get().showPlayer(plugin, playerHandle.toPlayer(), player); } } - public static void b(Plugin plugin, Player player, PlayerRegistry playerRegistry) { + public static void hideFromRegistry(Plugin plugin, Player player, PlayerRegistry playerRegistry) { if (plugin.isEnabled()) { for (PlayerHandle playerHandle : playerRegistry) { VersionAdapters.get().hidePlayer(plugin, playerHandle.toPlayer(), player); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/scheduler/EngineTicker.java b/common/src/main/java/ro/fr33styler/arcade/engine/scheduler/EngineTicker.java index f43cf58..8c3781f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/scheduler/EngineTicker.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/scheduler/EngineTicker.java @@ -9,7 +9,7 @@ import org.bukkit.scheduler.BukkitTask; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class EngineTicker implements Runnable { - private long a = 0L; + private long tick = 0L; private BukkitTask task; private final DefaultEngine engine; @@ -17,15 +17,15 @@ public class EngineTicker implements Runnable { this.engine = engine2; } - public void a() { - if (VendorMarkerProbe.a(this.engine.getPlugin())) { - if (UserNonceMarkerProbe.a(this.engine.getPlugin())) { + public void start() { + if (VendorMarkerProbe.probe(this.engine.getPlugin())) { + if (UserNonceMarkerProbe.probe(this.engine.getPlugin())) { this.task = this.engine.getPlugin().getServer().getScheduler().runTaskTimer(this.engine.getPlugin(), this, 0L, 1L); } } } - public void b() { + public void stop() { if (this.task != null && !VersionAdapters.get().isTaskCancelled(this.task)) { this.task.cancel(); } @@ -33,18 +33,18 @@ public class EngineTicker implements Runnable { @Override public void run() { - this.engine.getGameManagerRegistry().a(this.a); - if (this.a % 20L == 0L) { + this.engine.getGameManagerRegistry().onTick(this.tick); + if (this.tick % 20L == 0L) { this.engine.getDisplayManager().run(); - if (LeakMarkerProbe.a(this.engine.getPlugin())) { - this.engine.getUsers().a(this.a); + if (LeakMarkerProbe.probe(this.engine.getPlugin())) { + this.engine.getUsers().onTick(this.tick); } } - if (this.a % 72000L == 0L) { - this.engine.getDatabaseManager().getSqlDatabase().a(); + if (this.tick % 72000L == 0L) { + this.engine.getDatabaseManager().getSqlDatabase().checkResetTimers(); } - this.a++; + this.tick++; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/ScoreboardObjective.java b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/ScoreboardObjective.java index 7ee8fc1..7b70b7a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/ScoreboardObjective.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/ScoreboardObjective.java @@ -9,35 +9,35 @@ import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; public class ScoreboardObjective { - private final Objective a; - private final DisplaySlot b; + private final Objective objective; + private final DisplaySlot displaySlot; private final Set set = new HashSet<>(); ScoreboardObjective(Objective objective, DisplaySlot displaySlot) { - this.a = objective; - this.b = displaySlot; + this.objective = objective; + this.displaySlot = displaySlot; } - public void a(boolean flag) { - this.a(); + public void setVisible(boolean flag) { + this.clear(); if (flag) { - this.a.setDisplaySlot(this.b); + this.objective.setDisplaySlot(this.displaySlot); } else { - this.a.setDisplaySlot(null); + this.objective.setDisplaySlot(null); } } - public void a(String text) { - this.a.setDisplayName(text); + public void setDisplayName(String text) { + this.objective.setDisplayName(text); } - public void a(String text, double doubleVal) { - this.a.getScore(text).setScore(DoubleMath.roundToInt(doubleVal, RoundingMode.HALF_UP)); + public void setScore(String text, double doubleVal) { + this.objective.getScore(text).setScore(DoubleMath.roundToInt(doubleVal, RoundingMode.HALF_UP)); this.set.add(text); } - public void a() { - Scoreboard scoreboard = this.a.getScoreboard(); + public void clear() { + Scoreboard scoreboard = this.objective.getScoreboard(); if (scoreboard != null) { this.set.forEach(scoreboard::resetScores); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/PlayerSidebar.java b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/PlayerSidebar.java index a387895..70611ad 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/PlayerSidebar.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/PlayerSidebar.java @@ -9,68 +9,68 @@ import org.bukkit.entity.Player; import ro.fr33styler.arcade.api.engine.text.Context; public class PlayerSidebar { - private int a; + private int lineCount; private final Player player; private final Sidebar sidebar; - private final String[] d = new String[15]; + private final String[] cachedLines = new String[15]; PlayerSidebar(Player player2, Sidebar sidebar2) { this.player = player2; this.sidebar = sidebar2; } - public void a(List list, Context context) { - this.a(list, text -> text.a(context), UnaryOperator.identity()); + public void update(List list, Context context) { + this.updateIfActive(list, text -> text.render(context), UnaryOperator.identity()); } - public void a(List list, Context context, UnaryOperator unaryOperator) { - this.a(list, text -> text.a(context), unaryOperator); + public void update(List list, Context context, UnaryOperator unaryOperator) { + this.updateIfActive(list, text -> text.render(context), unaryOperator); } - private void a(List list, Function function, UnaryOperator unaryOperator) { + private void updateIfActive(List list, Function function, UnaryOperator unaryOperator) { if (this.player.getScoreboard() == this.sidebar.getObjective().getScoreboard()) { - this.b(list, function, unaryOperator); + this.renderLines(list, function, unaryOperator); } } - private void b(List list, Function function, UnaryOperator unaryOperator) { + private void renderLines(List list, Function function, UnaryOperator unaryOperator) { int index = 0; for (int index2 = list.size() - 1; index2 >= 0 && index < 15; index2--) { String text = (String)function.apply(list.get(index2)); if (!text.isEmpty()) { - this.a(unaryOperator.apply(text), index++); + this.updateLine(unaryOperator.apply(text), index++); } } - this.b(index); - this.a = index; + this.trimLines(index); + this.lineCount = index; } - private void a(String text, int index) { - if (!text.equals(this.d[index])) { + private void updateLine(String text, int index) { + if (!text.equals(this.cachedLines[index])) { SidebarLine sidebarLine = this.sidebar.getLines()[index]; - if (this.a <= index) { - sidebarLine.a(this.player, true); + if (this.lineCount <= index) { + sidebarLine.setVisible(this.player, true); } - this.d[index] = text; - sidebarLine.a(this.player, text); + this.cachedLines[index] = text; + sidebarLine.setText(this.player, text); } } - private void a(int index) { - this.d[index] = null; - this.sidebar.getLines()[index].a(this.player, false); + private void hideLine(int index) { + this.cachedLines[index] = null; + this.sidebar.getLines()[index].setVisible(this.player, false); } - public void a() { - this.b(0); + public void clear() { + this.trimLines(0); } - private void b(int index) { - while (this.a > index) { - this.a(--this.a); + private void trimLines(int index) { + while (this.lineCount > index) { + this.hideLine(--this.lineCount); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/Sidebar.java b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/Sidebar.java index 748118f..85b4aec 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/Sidebar.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/Sidebar.java @@ -37,7 +37,7 @@ public class Sidebar { } public void setTitle(Text text, Context context) { - this.objective.setDisplayName(text.a(context)); + this.objective.setDisplayName(text.render(context)); } public PlayerSidebar createPlayerSidebar(Player player) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/SidebarLine.java b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/SidebarLine.java index 16beae2..7bc5503 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/SidebarLine.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/scoreboard/sidebar/SidebarLine.java @@ -11,9 +11,9 @@ import org.bukkit.scoreboard.Team; import ro.fr33styler.arcade.platform.compat.VersionAdapters; final class SidebarLine { - private final int b; - private final Team c; - private final Score d; + private final int scoreValue; + private final Team team; + private final Score score; final Sidebar sidebar; static SidebarLine re$create(Sidebar sidebar2, GameScoreboard gameScoreboard, int index) { @@ -23,20 +23,20 @@ final class SidebarLine { private SidebarLine(Sidebar sidebar2, GameScoreboard gameScoreboard, int index) { this.sidebar = sidebar2; String text = ChatColor.values()[index - 1] + "§r"; - this.c = gameScoreboard.getOrCreateBukkitTeam(text); - this.d = sidebar2.re$objective().getScore(text); - this.c.addEntry(text); - this.b = index; + this.team = gameScoreboard.getOrCreateBukkitTeam(text); + this.score = sidebar2.re$objective().getScore(text); + this.team.addEntry(text); + this.scoreValue = index; } - void a(Player player, boolean flag) { - this.sidebar.re$engine().getPlatform().sendScorePacket(player, !flag, this.d, this.b); + void setVisible(Player player, boolean flag) { + this.sidebar.re$engine().getPlatform().sendScorePacket(player, !flag, this.score, this.scoreValue); } - void a(Player player, String text) { + void setText(Player player, String text) { int index = VersionAdapters.get().getSidebarMaxLineLength(this.sidebar.re$engine().getSettings().isViaBackwardSupport()); if (text.length() <= index) { - this.sidebar.re$engine().getPlatform().sendTeamPacket(player, this.c, text, null, TeamVisibility.ALWAYS); + this.sidebar.re$engine().getPlatform().sendTeamPacket(player, this.team, text, null, TeamVisibility.ALWAYS); } else { String text2 = StringUtils.substring(text, 0, index); String text3 = StringUtils.substring(text, text2.length(), index * 2); @@ -50,7 +50,7 @@ final class SidebarLine { text3 = StringUtils.substring(text4.concat(text3), 0, index); } - this.sidebar.re$engine().getPlatform().sendTeamPacket(player, this.c, text2, text3, TeamVisibility.ALWAYS); + this.sidebar.re$engine().getPlatform().sendTeamPacket(player, this.team, text2, text3, TeamVisibility.ALWAYS); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSession.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSession.java index 4223040..cbbf72b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSession.java @@ -39,7 +39,7 @@ public abstract class BaseSession implements Session { return this.defaultSessionStatus; } - protected int b() { + protected int getReservedCount() { int index = 0; for (SessionRequest sessionRequest : this.getGame().getEngine().getGameManagerRegistry().getMap().values()) { @@ -56,7 +56,7 @@ public abstract class BaseSession implements Session { return new Result(false, this.getGame().getMessages().getJoinIsStarted()); } else { return !this.getGame().getEngine().getGameManagerRegistry().getMap().containsKey(uuid) - && this.getGame().getGamers().size() + this.b() + collection.size() + 1 > this.getGame().getMap().getMaximumPlayers() + && this.getGame().getGamers().size() + this.getReservedCount() + collection.size() + 1 > this.getGame().getMap().getMaximumPlayers() ? new Result(false, this.getGame().getMessages().getJoinIsFull()) : Result.SUCCESSFUL; } @@ -74,7 +74,7 @@ public abstract class BaseSession implements Session { } if (!this.getGame().getEngine().getGameManagerRegistry().getMap().containsKey(user.getUUID())) { - if (user.getGamer() instanceof BaseGamer var5 && !var5.g()) { + if (user.getGamer() instanceof BaseGamer var5 && !var5.isActiveSpectator()) { return new Result(false, this.getGame().getMessages().getJoinAlreadyInGame()); } @@ -104,7 +104,7 @@ public abstract class BaseSession implements Session { public void addPlayerStarted(User user) { } - protected T a(User user, Function function) { + protected T joinGamer(User user, Function function) { Player player = user.toPlayer(); DefaultUser defaultUser = (DefaultUser)user; if (defaultUser.isInGame()) { @@ -112,15 +112,15 @@ public abstract class BaseSession implements Session { } DefaultEngine defaultEngine = defaultUser.getEngine(); - defaultUser.i(); - Players.a(defaultEngine.getPlatform(), player); + defaultUser.saveSnapshot(); + Players.reset(defaultEngine.getPlatform(), player); defaultEngine.getPlatform().setWaypointReceiveRange(player, 0.0); BaseGamer baseGamer = (BaseGamer)function.apply(defaultUser); - baseGamer.a(this.getGame().getScoreboard()); + baseGamer.applyScoreboard(this.getGame().getScoreboard()); if (this.getGame().getSettings().isTabPrivate()) { - PlayerVisibility.a(defaultEngine.getPlugin(), player, this.getGame().getGamers(), defaultEngine.getUsers()); - if (baseGamer.f()) { - PlayerVisibility.b(defaultEngine.getPlugin(), player, this.getGame().getGamers()); + PlayerVisibility.syncVisibility(defaultEngine.getPlugin(), player, this.getGame().getGamers(), defaultEngine.getUsers()); + if (baseGamer.isSpectator()) { + PlayerVisibility.hideFromRegistry(defaultEngine.getPlugin(), player, this.getGame().getGamers()); } } @@ -131,7 +131,7 @@ public abstract class BaseSession implements Session { defaultUser.setGamer(baseGamer); Bukkit.getPluginManager().callEvent(new GameJoinEvent(defaultUser.getGamer())); - Party party = baseGamer.d(); + Party party = baseGamer.getParty(); if (party != null && defaultUser.getUUID().equals(party.getLeader())) { for (UUID uuid : party.getMembers()) { DefaultUser defaultUser2 = (DefaultUser)defaultEngine.getUsers().a(uuid); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSessions.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSessions.java index 1eb8d18..70d063e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/BaseSessions.java @@ -27,27 +27,27 @@ import ro.fr33styler.arcade.api.engine.game.session.Session; import ro.fr33styler.arcade.api.engine.game.session.Sessions; public abstract class BaseSessions implements Sessions { - private int a = 1; + private int nextTempId = 1; private final DefaultSessionSearcher defaultSessionSearcher; - private final Map c = new LinkedHashMap<>(); - private final Map d = new LinkedHashMap<>(); - private final Map> e = new HashMap<>(); - private final Map>> f = new HashMap<>(); - private final Map g = new HashMap<>(); + private final Map games = new LinkedHashMap<>(); + private final Map sessions = new LinkedHashMap<>(); + private final Map> templates = new HashMap<>(); + private final Map>> templatesByMode = new HashMap<>(); + private final Map rejoinGames = new HashMap<>(); public BaseSessions(AbstractGameManager abstractGameManager) { this.defaultSessionSearcher = new DefaultSessionSearcher(abstractGameManager); } - public abstract void a(); + public abstract void load(); protected abstract AbstractGameManager getManager(); - public void c() { - this.g.clear(); - this.d.clear(); + public void unload() { + this.rejoinGames.clear(); + this.sessions.clear(); - for (AbstractGame abstractGame : this.c.values()) { + for (AbstractGame abstractGame : this.games.values()) { abstractGame.forceStop(); if (abstractGame.isTemporary()) { World world = abstractGame.getMap().getLobby().getWorld(); @@ -57,58 +57,58 @@ public abstract class BaseSessions d() { - return this.c; + public Map getGames() { + return this.games; } - public Map e() { - return this.g; + public Map getRejoinGames() { + return this.rejoinGames; } - public Map f() { - return this.d; + public Map getSessions() { + return this.sessions; } public DefaultSessionSearcher getGameSearcher() { return this.defaultSessionSearcher; } - public boolean a(String text) { - return this.c.containsKey(text); + public boolean hasGame(String text) { + return this.games.containsKey(text); } - public G b(String text) { - return this.c.get(text); + public G getGame(String text) { + return this.games.get(text); } public void registerGame(G abstractGame) { - this.c.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(abstractGame.getMap().getId())); - this.c.put(abstractGame.getMap().getId(), (G)abstractGame); - this.d.entrySet().removeIf(entry2 -> entry2.getKey().equalsIgnoreCase(abstractGame.getMap().getId())); - this.d.put(abstractGame.getMap().getId(), this.createSession((G)abstractGame)); + this.games.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(abstractGame.getMap().getId())); + this.games.put(abstractGame.getMap().getId(), (G)abstractGame); + this.sessions.entrySet().removeIf(entry2 -> entry2.getKey().equalsIgnoreCase(abstractGame.getMap().getId())); + this.sessions.put(abstractGame.getMap().getId(), this.createSession((G)abstractGame)); } - public void a(GameTemplate gameTemplate) { + public void createTemporaryGame(GameTemplate gameTemplate) { if (this.getManager().hasWorldProvider()) { - String text = Integer.toString(this.a++, 32); - World world = this.getManager().getWorldProvider().a(gameTemplate, this.getManager().getId() + "-" + text); + String text = Integer.toString(this.nextTempId++, 32); + World world = this.getManager().getWorldProvider().createWorld(gameTemplate, this.getManager().getId() + "-" + text); if (world != null) { - BaseGameMap baseGameMap = this.h("tmp" + text); - this.a((M)gameTemplate.getMap(), world, (M)baseGameMap); - AbstractGame abstractGame = this.a((M)baseGameMap); + BaseGameMap baseGameMap = this.createMap("tmp" + text); + this.copyMap((M)gameTemplate.getMap(), world, (M)baseGameMap); + AbstractGame abstractGame = this.createGame((M)baseGameMap); abstractGame.setTemporary(true); this.registerGame((G)abstractGame); } } } - public boolean c(String text) { - AbstractGame abstractGame = this.c.remove(text); + public boolean unregisterGame(String text) { + AbstractGame abstractGame = this.games.remove(text); if (abstractGame != null) { - this.d.remove(text); + this.sessions.remove(text); abstractGame.forceStop(); return true; } else { @@ -116,96 +116,96 @@ public abstract class BaseSessions h() { - return List.copyOf(this.e.keySet()); + public List getTemplateNames() { + return List.copyOf(this.templates.keySet()); } - public boolean d(String text) { - return this.e.containsKey(text); + public boolean hasTemplate(String text) { + return this.templates.containsKey(text); } - public GameTemplate e(String text) { - return this.e.get(text); + public GameTemplate getTemplate(String text) { + return this.templates.get(text); } - public void b(GameTemplate gameTemplate) { - this.e.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(gameTemplate.a())); - this.e.put(gameTemplate.a(), gameTemplate); - this.f.computeIfAbsent(gameTemplate.getMap().getMode(), text -> new ArrayList<>()).add(gameTemplate); + public void registerTemplate(GameTemplate gameTemplate) { + this.templates.entrySet().removeIf(entry -> entry.getKey().equalsIgnoreCase(gameTemplate.getId())); + this.templates.put(gameTemplate.getId(), gameTemplate); + this.templatesByMode.computeIfAbsent(gameTemplate.getMap().getMode(), text -> new ArrayList<>()).add(gameTemplate); } - public void f(String text) { - GameTemplate gameTemplate = this.e.remove(text); - List list = this.f.get(gameTemplate.getMap().getMode()); + public void unregisterTemplate(String text) { + GameTemplate gameTemplate = this.templates.remove(text); + List list = this.templatesByMode.get(gameTemplate.getMap().getMode()); if (list != null) { list.remove(gameTemplate); if (list.isEmpty()) { - this.f.remove(gameTemplate.getMap().getMode()); + this.templatesByMode.remove(gameTemplate.getMap().getMode()); } } } - public void a(String text, Session session) { - this.d.put(text, session); + public void registerSession(String text, Session session) { + this.sessions.put(text, session); } public Session getSession(String text) { - return this.d.get(text); + return this.sessions.get(text); } - public void g(String text) { - this.d.remove(text); + public void unregisterSession(String text) { + this.sessions.remove(text); } - protected abstract M h(String var1); + protected abstract M createMap(String var1); - protected abstract G a(M var1); + protected abstract G createGame(M var1); protected abstract Session createSession(G var1); - protected void a(M baseGameMap, World world, M baseGameMap2) { + protected void copyMap(M baseGameMap, World world, M baseGameMap2) { baseGameMap2.setName(baseGameMap.getName()); baseGameMap2.setMinimumPlayers(baseGameMap.getMinimumPlayers()); baseGameMap2.setMaximumPlayers(baseGameMap.getMaximumPlayers()); - baseGameMap2.setLobby(Locations.a(world, baseGameMap.getLobby())); + baseGameMap2.setLobby(Locations.withWorld(world, baseGameMap.getLobby())); if (baseGameMap.getLobbyZone() != null) { - baseGameMap2.setLobbyZone(baseGameMap.getLobbyZone().a(world)); + baseGameMap2.setLobbyZone(baseGameMap.getLobbyZone().withWorld(world)); } baseGameMap2.setUnlisted(baseGameMap.isUnlisted()); } - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 100L == 0L) { - this.f.keySet().forEach(this::j); + this.templatesByMode.keySet().forEach(this::balanceTemporaryGames); } - for (AbstractGame abstractGame : this.c.values()) { + for (AbstractGame abstractGame : this.games.values()) { abstractGame.getPhase().onTick(longVal); if (longVal % 20L == 0L && abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getPlaying()) { - abstractGame.getSpectatorMenu().b(); + abstractGame.getSpectatorMenu().update(); for (BaseGamer baseGamer : abstractGame.getGamers()) { - baseGamer.a(longVal); + baseGamer.onTick(longVal); } } } } - public int i() { + public int getTotalPlayers() { int index = 0; - for (Session session : this.d.values()) { + for (Session session : this.sessions.values()) { index += session.getStatus().players(); } return index; } - public int i(String text) { + public int getAvailableGamesCount(String text) { int index = 0; - for (AbstractGame abstractGame : this.c.values()) { + for (AbstractGame abstractGame : this.games.values()) { if (abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getWaiting() && abstractGame.getMap().getMode().equalsIgnoreCase(text) && abstractGame.getGamers().size() < abstractGame.getMap().getMaximumPlayers()) { @@ -216,10 +216,10 @@ public abstract class BaseSessions j() { + private Deque getTemporaryGames() { ArrayDeque arrayDeque = new ArrayDeque(); - for (AbstractGame abstractGame : this.c.values()) { + for (AbstractGame abstractGame : this.games.values()) { if (abstractGame.isTemporary()) { arrayDeque.addLast(abstractGame); } @@ -228,16 +228,16 @@ public abstract class BaseSessions this.c.size()) { - int index = this.i(text); + private void balanceTemporaryGames(String text) { + if (this.getManager().hasWorldProvider() && this.getManager().getEngine().getSettings().getMaximumTemporaryGames() > this.games.size()) { + int index = this.getAvailableGamesCount(text); if (index > this.getManager().getEngine().getSettings().getTemporaryAvailableGames()) { - Deque deque = this.j(); + Deque deque = this.getTemporaryGames(); while (!deque.isEmpty()) { AbstractGame abstractGame = (AbstractGame)deque.removeLast(); if (abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getWaiting() && abstractGame.getGamers().size() == 0) { - this.c(abstractGame.getMap().getId()); + this.unregisterGame(abstractGame.getMap().getId()); World world = abstractGame.getMap().getLobby().getWorld(); if (world != null) { Bukkit.unloadWorld(world, false); @@ -249,24 +249,24 @@ public abstract class BaseSessions> list = this.f.get(text); + List> list = this.templatesByMode.get(text); if (list == null || list.isEmpty()) { return; } list = new ArrayList<>(list); - list.removeIf(gameTemplate -> gameTemplate.c() == null); + list.removeIf(gameTemplate -> gameTemplate.getWorldData() == null); while (!list.isEmpty() && index < this.getManager().getEngine().getSettings().getTemporaryAvailableGames()) { - this.a((GameTemplate)Randoms.a(list)); + this.createTemporaryGame((GameTemplate)Randoms.pickRandom(list)); index++; } } } } - public void a(DefaultUser defaultUser) { - String text = this.g.get(defaultUser.getUUID()); + public void rejoin(DefaultUser defaultUser) { + String text = this.rejoinGames.get(defaultUser.getUUID()); if (text == null) { defaultUser.sendMessage(this.getManager().getMessages().getRejoin()); } else { @@ -285,6 +285,6 @@ public abstract class BaseSessions iterator() { - return Iterators.unmodifiableIterator(this.d.values().iterator()); + return Iterators.unmodifiableIterator(this.sessions.values().iterator()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/remote/RemoteSession.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/remote/RemoteSession.java index 6cf8be9..80506d6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/remote/RemoteSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/remote/RemoteSession.java @@ -20,31 +20,31 @@ import ro.fr33styler.arcade.api.engine.party.Party; import ro.fr33styler.arcade.api.engine.player.User; public class RemoteSession implements Session { - private final String a; + private final String id; private final Status status; private final Result result; - private final Result result5; - private final Result result2; - private final Result result3; + private final Result playStartedResult; + private final Result spectateResult; + private final Result rejoinResult; private ServerConnection serverConnection; private AbstractGameManager manager; public RemoteSession(String text, Result result4, Result result52, Result result22, Result result32, RemoteSessionStatus status2) { - this.a = text; + this.id = text; this.result = result4; - this.result5 = result52; - this.result2 = result22; - this.result3 = result32; + this.playStartedResult = result52; + this.spectateResult = result22; + this.rejoinResult = result32; this.status = status2; } - public void a(ServerConnection serverConnection2, AbstractGameManager manager2) { + public void attach(ServerConnection serverConnection2, AbstractGameManager manager2) { this.serverConnection = serverConnection2; this.manager = manager2; } public String getId() { - return this.a; + return this.id; } public Status getStatus() { @@ -56,7 +56,7 @@ public class RemoteSession implements Session { } public Result canPlay(User user) { - if (user.getGamer() instanceof BaseGamer var2 && !var2.g()) { + if (user.getGamer() instanceof BaseGamer var2 && !var2.isActiveSpectator()) { return new Result(false, var2.getGame().getMessages().getJoinAlreadyInGame()); } else { Party party = user.getParty(); @@ -69,15 +69,15 @@ public class RemoteSession implements Session { } public void addPlayer(User user) { - this.b(user, SessionRequestType.PLAY); + this.sendJoinRequest(user, SessionRequestType.PLAY); } public Result canPlayStarted(UUID uuid, Collection collection) { - return this.status.players() + collection.size() + 1 > this.status.maximumPlayers() ? new Result(false, this.manager.getMessages().getJoinIsFull()) : this.result5; + return this.status.players() + collection.size() + 1 > this.status.maximumPlayers() ? new Result(false, this.manager.getMessages().getJoinIsFull()) : this.playStartedResult; } public Result canPlayStarted(User user) { - if (user.getGamer() instanceof BaseGamer var2 && !var2.g()) { + if (user.getGamer() instanceof BaseGamer var2 && !var2.isActiveSpectator()) { return new Result(false, var2.getGame().getMessages().getJoinAlreadyInGame()); } else { Party party = user.getParty(); @@ -90,17 +90,17 @@ public class RemoteSession implements Session { } public void addPlayerStarted(User user) { - this.b(user, SessionRequestType.PLAY_STARTED); + this.sendJoinRequest(user, SessionRequestType.PLAY_STARTED); } public Result canSpectate(UUID uuid) { - return this.result2; + return this.spectateResult; } public Result canSpectate(User user) { if (user.getGamer() instanceof BaseGamer var2) { AbstractGame abstractGame = var2.getGame(); - if (abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, abstractGame.getMessages().getJoinAlreadyInGame()); } } @@ -109,17 +109,17 @@ public class RemoteSession implements Session { } public void addSpectator(User user) { - this.b(user, SessionRequestType.SPECTATE); + this.sendJoinRequest(user, SessionRequestType.SPECTATE); } public Result canRejoin(UUID uuid) { - return this.result3; + return this.rejoinResult; } public Result canRejoin(User user) { if (user.getGamer() instanceof BaseGamer var2) { AbstractGame abstractGame = var2.getGame(); - if (abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, abstractGame.getMessages().getJoinAlreadyInGame()); } } @@ -128,23 +128,23 @@ public class RemoteSession implements Session { } public void addRejoin(User user) { - this.b(user, SessionRequestType.REJOIN); + this.sendJoinRequest(user, SessionRequestType.REJOIN); } public String getVariable(String text) { return switch (text) { - case "id" -> this.a; - case "server_name" -> this.serverConnection.a(); + case "id" -> this.id; + case "server_name" -> this.serverConnection.getServerName(); case "display_name" -> this.manager.getMessages().getDisplayName(); default -> this.status.getVariable(text); }; } - private NetworkJoinRequest a(User user, SessionRequestType sessionRequestType) { + private NetworkJoinRequest createJoinRequest(User user, SessionRequestType sessionRequestType) { NetworkJoinRequest networkJoinRequest = new NetworkJoinRequest(); - networkJoinRequest.a(this.a); - networkJoinRequest.a(user.getUUID()); - networkJoinRequest.b(this.manager.getId()); + networkJoinRequest.setSessionId(this.id); + networkJoinRequest.setPlayerId(user.getUUID()); + networkJoinRequest.setManagerId(this.manager.getId()); networkJoinRequest.setSessionRequestType(sessionRequestType); if (sessionRequestType == SessionRequestType.PLAY || sessionRequestType == SessionRequestType.PLAY_STARTED) { Party party = user.getParty(); @@ -156,15 +156,15 @@ public class RemoteSession implements Session { return networkJoinRequest; } - private void b(User user, SessionRequestType sessionRequestType) { - NetworkJoinRequest networkJoinRequest = this.a(user, sessionRequestType); - user.toPlayer().sendMessage(this.manager.getMessages().getAutoJoinSendToServer().a(this)); - this.serverConnection.getRemoteJoinController().a(() -> { - this.serverConnection.d().writeUTF("reservation-request"); - byte[] byteVals = Compression.a(this.serverConnection.getRemoteJoinController().getGson(), networkJoinRequest); - this.serverConnection.d().writeInt(byteVals.length); - this.serverConnection.d().write(byteVals); - this.serverConnection.d().flush(); + private void sendJoinRequest(User user, SessionRequestType sessionRequestType) { + NetworkJoinRequest networkJoinRequest = this.createJoinRequest(user, sessionRequestType); + user.toPlayer().sendMessage(this.manager.getMessages().getAutoJoinSendToServer().render(this)); + this.serverConnection.getRemoteJoinController().submitAsync(() -> { + this.serverConnection.getOutputStream().writeUTF("reservation-request"); + byte[] byteVals = Compression.compressJson(this.serverConnection.getRemoteJoinController().getGson(), networkJoinRequest); + this.serverConnection.getOutputStream().writeInt(byteVals.length); + this.serverConnection.getOutputStream().write(byteVals); + this.serverConnection.getOutputStream().flush(); return null; }); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequest.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequest.java index fc9345c..52e21ad 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequest.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequest.java @@ -7,7 +7,7 @@ import ro.fr33styler.arcade.api.engine.party.Party; public class SessionRequest { private Party party; - private int b; + private int elapsedSeconds; private final Session session; private final SessionRequestType sessionRequestType; private final AbstractGameManager manager; @@ -34,11 +34,11 @@ public class SessionRequest { this.party = party2; } - public int d() { - return this.b; + public int getElapsedSeconds() { + return this.elapsedSeconds; } - public void a(int index) { - this.b = index; + public void setElapsedSeconds(int index) { + this.elapsedSeconds = index; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequestType.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequestType.java index b3873c0..d460760 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequestType.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/request/SessionRequestType.java @@ -17,7 +17,7 @@ public enum SessionRequestType { private final PartySessionResponse partySessionResponse; private final PlayerSessionResponse playerSessionResponse; private final SessionJoinHandler sessionJoinHandler; - private static final SessionRequestType[] h = values(); + private static final SessionRequestType[] VALUES = values(); SessionRequestType(PartySessionResponse partySessionResponse2, PlayerSessionResponse playerSessionResponse2, SessionJoinHandler sessionJoinHandler2) { this.partySessionResponse = partySessionResponse2; @@ -25,15 +25,15 @@ public enum SessionRequestType { this.sessionJoinHandler = sessionJoinHandler2; } - public Result a(Session session, UUID uuid, List list) { + public Result canJoinParty(Session session, UUID uuid, List list) { return this.partySessionResponse.response(session, uuid, list); } - public Result a(Session session, User user) { + public Result canJoinPlayer(Session session, User user) { return this.playerSessionResponse.response(session, user); } - public void a(Session session, DefaultUser defaultUser) { + public void join(Session session, DefaultUser defaultUser) { this.sessionJoinHandler.join(session, defaultUser); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/session/search/DefaultSessionSearcher.java b/common/src/main/java/ro/fr33styler/arcade/engine/session/search/DefaultSessionSearcher.java index e605271..6856a84 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/session/search/DefaultSessionSearcher.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/session/search/DefaultSessionSearcher.java @@ -13,17 +13,17 @@ import ro.fr33styler.arcade.api.engine.game.session.Searcher; import ro.fr33styler.arcade.api.engine.game.session.Session; public class DefaultSessionSearcher implements Searcher { - private final Iterable a; + private final Iterable managers; public DefaultSessionSearcher(AbstractGameManager abstractGameManager) { - this.a = Collections.singletonList(abstractGameManager); + this.managers = Collections.singletonList(abstractGameManager); } public DefaultSessionSearcher(Iterable iterable) { - this.a = iterable; + this.managers = iterable; } - private void a(List list, Session session) { + private void collectBestSession(List list, Session session) { if (list.isEmpty() || ((Session)list.get(0)).getStatus().players() == session.getStatus().players()) { list.add(session); } else if (((Session)list.get(0)).getStatus().players() < session.getStatus().players()) { @@ -39,14 +39,14 @@ public class DefaultSessionSearcher implements Searcher { public Session get(Predicate predicate) { ArrayList list = new ArrayList(); - for (AbstractGameManager abstractGameManager : this.a) { - for (Session session : abstractGameManager.getSessions().f().values()) { + for (AbstractGameManager abstractGameManager : this.managers) { + for (Session session : abstractGameManager.getSessions().getSessions().values()) { if (predicate.test(session) && !session.getStatus().isUnlisted()) { - this.a(list, session); + this.collectBestSession(list, session); } } } - return list.isEmpty() ? null : (Session)Randoms.a(list); + return list.isEmpty() ? null : (Session)Randoms.pickRandom(list); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ArenaSetup.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ArenaSetup.java index 8e851ed..83ffb24 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ArenaSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ArenaSetup.java @@ -20,18 +20,18 @@ import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class ArenaSetup { protected final DefaultUser user; - private final String e; + private final String title; protected SetupStep setupStep; - private int f; - private ItemStack[] g; - private ItemStack h; + private int cancelCountdown; + private ItemStack[] savedInventoryContents; + private ItemStack savedOffHandItem; private final PlayerHotbar hotbar; - private final Deque j = new ArrayDeque<>(); - private final Deque k = new ArrayDeque<>(); + private final Deque redoStack = new ArrayDeque<>(); + private final Deque undoStack = new ArrayDeque<>(); protected ArenaSetup(DefaultUser user2, String text) { this.user = user2; - this.e = text; + this.title = text; this.hotbar = new PlayerHotbar(user2.toPlayer()); } @@ -47,53 +47,53 @@ public class ArenaSetup { return this.setupStep; } - public void a(SetupStep setupStep2) { + public void advanceStep(SetupStep setupStep2) { if (setupStep2 == null) { - this.f(); + this.finish(); } else { - this.i(); - this.k.addLast(this.setupStep); + this.clearRedoHistory(); + this.undoStack.addLast(this.setupStep); this.setupStep = setupStep2; - this.e(); + this.refreshStep(); } } - public void d() { + public void start() { Player player = this.user.toPlayer(); - this.g = player.getInventory().getContents(); - this.h = VersionAdapters.get().getOffHandItem(this.user.getEngine().getPlatform(), player); + this.savedInventoryContents = player.getInventory().getContents(); + this.savedOffHandItem = VersionAdapters.get().getOffHandItem(this.user.getEngine().getPlatform(), player); player.getInventory().clear(); - this.e(); + this.refreshStep(); } - public void e() { - this.a(this.hotbar); - this.a((Runnable)this.setupStep::c); + public void refreshStep() { + this.rebuildHotbar(this.hotbar); + this.sendPanel((Runnable)this.setupStep::sendInstructions); } - public void f() { - this.a((Runnable)() -> this.user.sendMessage("§cThe setup has been finalized!")); - this.h(); + public void finish() { + this.sendPanel((Runnable)() -> this.user.sendMessage("§cThe setup has been finalized!")); + this.cleanup(); } - public int g() { - return this.f; + public int getCancelCountdown() { + return this.cancelCountdown; } - public void a(int index) { - this.f = index; + public void setCancelCountdown(int index) { + this.cancelCountdown = index; } - public void h() { - this.user.toPlayer().getInventory().setContents(this.g); - VersionAdapters.get().setOffHandItem(this.user.getEngine().getPlatform(), this.user.toPlayer(), this.h); - this.user.a((ro.fr33styler.arcade.engine.setup.ArenaSetup)null); + public void cleanup() { + this.user.toPlayer().getInventory().setContents(this.savedInventoryContents); + VersionAdapters.get().setOffHandItem(this.user.getEngine().getPlatform(), this.user.toPlayer(), this.savedOffHandItem); + this.user.setArenaSetup((ro.fr33styler.arcade.engine.setup.ArenaSetup)null); if (!VersionAdapters.get().isLatestVariant()) { this.user.toPlayer().updateInventory(); } } - public void a(Block block, Player player, Action action) { + public void handleSelection(Block block, Player player, Action action) { if (block == null) { block = player.getLocation().getBlock(); } @@ -101,92 +101,92 @@ public class ArenaSetup { int index = block.getX(); int index2 = block.getY(); int index3 = block.getZ(); - if (EngineUtils.a(action)) { - this.user.a(block); + if (EngineUtils.isLeftClick(action)) { + this.user.setSelectionPos1(block); player.sendMessage("§eFirst position set. §8(§b" + index + ", " + index2 + ", " + index3 + "§8)"); - } else if (EngineUtils.b(action)) { - this.user.b(block); + } else if (EngineUtils.isRightClick(action)) { + this.user.setSelectionPos2(block); player.sendMessage("§eSecond position set. §8(§b" + index + ", " + index2 + ", " + index3 + "§8)"); } } - private void a(PlayerHotbar playerHotbar) { - playerHotbar.a(); - this.j(); - this.k(); - this.l(); - this.m(); - this.n(); + private void rebuildHotbar(PlayerHotbar playerHotbar) { + playerHotbar.clear(); + this.applyClickStepItems(); + this.addCenterTool(); + this.addPreviousStepButton(); + this.addNextStepButton(); + this.addCancelButton(); } - private void i() { - while (!this.j.isEmpty() && this.j.removeLast() instanceof RepeatableSetupStep var1) { - var1.b(); + private void clearRedoHistory() { + while (!this.redoStack.isEmpty() && this.redoStack.removeLast() instanceof RepeatableSetupStep var1) { + var1.onUndo(); } } - private void j() { + private void applyClickStepItems() { if (this.setupStep instanceof ClickSetupStep var1) { - var1.a(); + var1.configureHotbar(); } } - private void b(SetupStep setupStep2) { + private void undoStepIfRepeatable(SetupStep setupStep2) { if (setupStep2 instanceof RepeatableSetupStep var2) { - var2.b(); - this.i(); + var2.onUndo(); + this.clearRedoHistory(); } } - public void a(Runnable runnable) { + public void sendPanel(Runnable runnable) { Player player = this.user.toPlayer(); - Players.a(player); - player.sendMessage("§a" + Strings.a); - player.sendMessage(" §b§l" + this.e); + Players.clearChat(player); + player.sendMessage("§a" + Strings.SEPARATOR_LINE); + player.sendMessage(" §b§l" + this.title); player.sendMessage(""); runnable.run(); - player.sendMessage("§a" + Strings.a); + player.sendMessage("§a" + Strings.SEPARATOR_LINE); VersionAdapters.get().playSound(player, ArcadeSound.PLAYER_LEVELUP, 1.0F, 1.0F); } - private void k() { - this.hotbar.a(4, () -> { + private void addCenterTool() { + this.hotbar.setSlot(4, () -> { Player player = this.user.toPlayer(); Location location = player.getLocation(); - location.setYaw(EngineUtils.a(location.getYaw())); + location.setYaw(EngineUtils.snapYaw(location.getYaw())); location.setPitch(0.0F); player.teleport(location); }, new ItemBuilder(ArcadeMaterial.BLUE_DYE).setDisplayName("§9§lCenter position!").build()); } - private void l() { - if (!this.k.isEmpty()) { - this.hotbar.a(6, () -> { - this.j.addLast(this.setupStep); - this.setupStep = this.k.removeLast(); - this.b(this.setupStep); - this.e(); + private void addPreviousStepButton() { + if (!this.undoStack.isEmpty()) { + this.hotbar.setSlot(6, () -> { + this.redoStack.addLast(this.setupStep); + this.setupStep = this.undoStack.removeLast(); + this.undoStepIfRepeatable(this.setupStep); + this.refreshStep(); }, new ItemBuilder(ArcadeMaterial.PLAYER_HEAD).setArrowSkullTexture(this.user.getEngine().getPlatform(), false).setDisplayName("§e§l⇦ Previous step").build()); } } - private void m() { - if (!this.j.isEmpty()) { - this.hotbar.a(7, () -> { - this.k.addLast(this.setupStep); - this.setupStep = this.j.removeLast(); - this.e(); + private void addNextStepButton() { + if (!this.redoStack.isEmpty()) { + this.hotbar.setSlot(7, () -> { + this.undoStack.addLast(this.setupStep); + this.setupStep = this.redoStack.removeLast(); + this.refreshStep(); }, new ItemBuilder(ArcadeMaterial.PLAYER_HEAD).setArrowSkullTexture(this.user.getEngine().getPlatform(), true).setDisplayName("§e§lNext step ⇨").build()); } } - private void n() { - this.hotbar.a(8, () -> { - if (this.f > 0) { - this.h(); + private void addCancelButton() { + this.hotbar.setSlot(8, () -> { + if (this.cancelCountdown > 0) { + this.cleanup(); this.user.sendMessage("§cThe setup has been cancelled!"); } else { - this.f = 3; + this.cancelCountdown = 3; this.user.sendMessage("§aAre you sure that you want to cancel? Right-click again to confirm!"); } }, new ItemBuilder(ArcadeMaterial.RED_BED).setDisplayName("§c§lCancel setup").build()); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ChatSetupStep.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ChatSetupStep.java index d58b808..5c52b3d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ChatSetupStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ChatSetupStep.java @@ -1,9 +1,9 @@ package ro.fr33styler.arcade.engine.setup; public interface ChatSetupStep extends SetupStep { - void a(String var1); + void onChatInput(String var1); - default boolean b(String text) { + default boolean onCommandInput(String text) { return false; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ClickSetupStep.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ClickSetupStep.java index b026759..6b9fcbf 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/ClickSetupStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/ClickSetupStep.java @@ -1,5 +1,5 @@ package ro.fr33styler.arcade.engine.setup; public interface ClickSetupStep extends SetupStep { - void a(); + void configureHotbar(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/RepeatableSetupStep.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/RepeatableSetupStep.java index af62065..3bf32e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/RepeatableSetupStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/RepeatableSetupStep.java @@ -1,5 +1,5 @@ package ro.fr33styler.arcade.engine.setup; public interface RepeatableSetupStep extends SetupStep { - void b(); + void onUndo(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/SetupStep.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/SetupStep.java index 656b25a..3d36fed 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/SetupStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/SetupStep.java @@ -1,9 +1,9 @@ package ro.fr33styler.arcade.engine.setup; public interface SetupStep { - void c(); + void sendInstructions(); - default boolean d() { + default boolean usesSelectionTool() { return false; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/setup/target/SetupTarget.java b/common/src/main/java/ro/fr33styler/arcade/engine/setup/target/SetupTarget.java index 9e273a3..4bf2ff4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/setup/target/SetupTarget.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/setup/target/SetupTarget.java @@ -9,18 +9,18 @@ public enum SetupTarget { TEMPLATE("template"); private static final Map map = Map.of("map", MAP, "template", TEMPLATE); - private final String d; - private static final SetupTarget[] e = {MAP, TEMPLATE}; + private final String name; + private static final SetupTarget[] VALUES = {MAP, TEMPLATE}; SetupTarget(String text) { - this.d = text; + this.name = text; } - public static Set a() { + public static Set getTargetNames() { return map.keySet(); } - public static SetupTarget a(String text) { + public static SetupTarget fromName(String text) { return map.get(text.toLowerCase(Locale.ROOT)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/sign/CommandSign.java b/common/src/main/java/ro/fr33styler/arcade/engine/sign/CommandSign.java index 35f09b0..7b01c0b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/sign/CommandSign.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/sign/CommandSign.java @@ -10,26 +10,26 @@ import ro.fr33styler.arcade.api.engine.text.Context; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class CommandSign { - private final Block a; - private final String b; + private final Block block; + private final String command; private final List list; private final Context context; public CommandSign(Block block, String text, List list2, Context context2) { - this.a = block; - this.b = text; + this.block = block; + this.command = text; this.list = list2; this.context = context2; } - public void a(Player player) { - player.performCommand(this.b); + public void executeCommand(Player player) { + player.performCommand(this.command); } - public void a() { - if (VersionAdapters.get().isWallSign(this.a) && this.a.getState() instanceof Sign var1) { + public void update() { + if (VersionAdapters.get().isWallSign(this.block) && this.block.getState() instanceof Sign var1) { for (int index = 0; index < 4; index++) { - var1.setLine(index, index < this.list.size() ? this.list.get(index).a(this.context) : ""); + var1.setLine(index, index < this.list.size() ? this.list.get(index).render(this.context) : ""); } var1.update(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/sign/SignStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/sign/SignStorage.java index 47f2e6b..bb7058e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/sign/SignStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/sign/SignStorage.java @@ -27,8 +27,8 @@ public class SignStorage implements Configuration { return this.signs; } - public void a(Block block, String text) { - this.a(block); + public void addSign(Block block, String text) { + this.removeSign(block); int index = 0; while (this.signs.containsKey(String.valueOf(index))) { @@ -41,7 +41,7 @@ public class SignStorage implements Configuration { this.signs.put(String.valueOf(index), gameSignSettings); } - public boolean a(Block block) { + public boolean removeSign(Block block) { return this.signs.values().removeIf(gameSignSettings -> gameSignSettings.getBlock().equals(block)); } @@ -49,11 +49,11 @@ public class SignStorage implements Configuration { return this.quickJoinSigns; } - public void c() { + public void load() { this.configManager.tryLoad(this, this.file); } - public void d() { + public void save() { this.configManager.trySave(this, this.file); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectateGameCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectateGameCommand.java index aa67577..95b5edd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectateGameCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectateGameCommand.java @@ -20,7 +20,7 @@ public class SpectateGameCommand implements CommandExecutor { public SpectateGameCommand(AbstractGameManager manager2) { this.manager = manager2; - this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().f().keySet()) }); + this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().getSessions().keySet()) }); } public boolean isPlayerOnly() { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectatePlayerCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectatePlayerCommand.java index 79c43f6..28dbf30 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectatePlayerCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/command/SpectatePlayerCommand.java @@ -34,7 +34,7 @@ public class SpectatePlayerCommand implements CommandExecutor { return this.arguments; } - private void a(Player player, Session session) { + private void spectateSession(Player player, Session session) { DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player); if (defaultUser != null) { if (session == null) { @@ -54,9 +54,9 @@ public class SpectatePlayerCommand implements CommandExecutor { String text2 = texts[index]; for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) { - for (Session session : abstractGameManager.getSessions().f().values()) { + for (Session session : abstractGameManager.getSessions().getSessions().values()) { if (session.getStatus().playersNames().contains(text2)) { - this.a((Player)sender, session); + this.spectateSession((Player)sender, session); return; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/config/SpectatorOptions.java b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/config/SpectatorOptions.java index 9c7a175..246bbfb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/config/SpectatorOptions.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/config/SpectatorOptions.java @@ -4,12 +4,12 @@ import org.bukkit.entity.Player; public class SpectatorOptions { private Player player; - private float b = 0.2F; - private boolean c; - private boolean d; - private boolean e; - private boolean f; - private boolean g; + private float speed = 0.2F; + private boolean autoTeleport; + private boolean nightVision; + private boolean firstPersonMode; + private boolean temporary; + private boolean external; public Player getPlayer() { return this.player; @@ -19,51 +19,51 @@ public class SpectatorOptions { this.player = player2; } - public float b() { - return this.b; + public float getSpeed() { + return this.speed; } - public void a(float floatVal) { - this.b = floatVal; + public void setSpeed(float floatVal) { + this.speed = floatVal; } - public boolean c() { - return this.e; + public boolean isFirstPersonMode() { + return this.firstPersonMode; } - public void a(boolean flag) { - this.e = flag; + public void setFirstPersonMode(boolean flag) { + this.firstPersonMode = flag; } - public boolean d() { - return this.c; + public boolean isAutoTeleport() { + return this.autoTeleport; } - public void b(boolean flag) { - this.c = flag; + public void setAutoTeleport(boolean flag) { + this.autoTeleport = flag; } - public boolean e() { - return this.d; + public boolean isNightVision() { + return this.nightVision; } - public void c(boolean flag) { - this.d = flag; + public void setNightVision(boolean flag) { + this.nightVision = flag; } - public boolean f() { - return this.f; + public boolean isTemporary() { + return this.temporary; } - public void d(boolean flag) { - this.f = flag; + public void setTemporary(boolean flag) { + this.temporary = flag; } - public boolean g() { - return this.g; + public boolean isExternal() { + return this.external; } - public void e(boolean flag) { - this.g = flag; + public void setExternal(boolean flag) { + this.external = flag; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/ui/SpectatorMenu.java b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/ui/SpectatorMenu.java index c3fb797..edc9eae 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/spectator/ui/SpectatorMenu.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/spectator/ui/SpectatorMenu.java @@ -27,27 +27,27 @@ import ro.fr33styler.arcade.api.engine.text.Context; public class SpectatorMenu { private final AbstractGame game; private final List list = new ArrayList<>(); - private static final int[] c = new int[]{1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25}; + private static final int[] TARGET_SLOTS = new int[]{1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25}; public SpectatorMenu(AbstractGame game2) { this.game = game2; } - public void a(DefaultUser defaultUser) { + public void open(DefaultUser defaultUser) { if (!this.list.isEmpty()) { - defaultUser.a(this.list.get(0)); + defaultUser.openMenu(this.list.get(0)); } } - public void a() { + public void clear() { this.list.clear(); } - private Queue c() { + private Queue collectAliveTargets() { ArrayDeque arrayDeque = new ArrayDeque(); for (BaseGamer baseGamer : this.game.getGamers()) { - if (!baseGamer.g()) { + if (!baseGamer.isActiveSpectator()) { arrayDeque.add(baseGamer); } } @@ -55,98 +55,98 @@ public class SpectatorMenu { return arrayDeque; } - private void a(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) { - Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null); - inventoryMenu.a(9, defaultUser -> defaultUser.a(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.game.getMessages().getSpectatorTeleporterChangePageName().a(context)).build()); - Context context2 = Contexts.a((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null); - inventoryMenu2.a(17, defaultUser2 -> defaultUser2.a(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.game.getMessages().getSpectatorTeleporterChangePageName().a(context2)).build()); + private void linkPages(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null); + inventoryMenu.setSlot(9, defaultUser -> defaultUser.openMenu(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.game.getMessages().getSpectatorTeleporterChangePageName().render(context)).build()); + Context context2 = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null); + inventoryMenu2.setSlot(17, defaultUser2 -> defaultUser2.openMenu(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.game.getMessages().getSpectatorTeleporterChangePageName().render(context2)).build()); } - private void a(InventoryMenu inventoryMenu, HumanEntity humanEntity) { + private void reopenMenu(InventoryMenu inventoryMenu, HumanEntity humanEntity) { BaseGamer baseGamer = (BaseGamer)this.game.getGamers().a(humanEntity.getUniqueId()); if (baseGamer == null) { humanEntity.closeInventory(); } else { - baseGamer.toUser().a(inventoryMenu); + baseGamer.toUser().openMenu(inventoryMenu); } } - private void a(int index) { + private void expandPages(int index) { if (index == 1) { this.list.add(new InventoryMenu(this.game.getMessages().getSpectatorTeleporterName(), 27)); } for (int index2 = this.list.size(); index2 < index; index2++) { int index3 = index2 + 1; - Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null); - InventoryMenu inventoryMenu = new InventoryMenu(this.game.getMessages().getSpectatorTeleporterPageName().a(context), 27); + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null); + InventoryMenu inventoryMenu = new InventoryMenu(this.game.getMessages().getSpectatorTeleporterPageName().render(context), 27); if (!this.list.isEmpty()) { - this.a(index3, inventoryMenu, this.list.get(this.list.size() - 1)); + this.linkPages(index3, inventoryMenu, this.list.get(this.list.size() - 1)); } this.list.add(inventoryMenu); } } - private void b(int index) { + private void shrinkPages(int index) { ArrayList list2 = new ArrayList<>(); while (this.list.size() > index) { - list2.addAll(this.list.remove(this.list.size() - 1).a().getViewers()); + list2.addAll(this.list.remove(this.list.size() - 1).getInventory().getViewers()); } InventoryMenu inventoryMenu = this.list.get(index - 1); if (index == 1) { - inventoryMenu.a(this.game.getMessages().getSpectatorTeleporterName()); + inventoryMenu.setTitle(this.game.getMessages().getSpectatorTeleporterName()); } - inventoryMenu.a(17, null, null); + inventoryMenu.setSlot(17, null, null); for (HumanEntity humanEntity : list2) { - this.a(inventoryMenu, humanEntity); + this.reopenMenu(inventoryMenu, humanEntity); } } - private void c(int index) { + private void resizePages(int index) { if (index != this.list.size()) { if (index > this.list.size()) { - this.a(index); + this.expandPages(index); } else { - this.b(index); + this.shrinkPages(index); } } } - public void b() { - Queue queue = this.c(); + public void update() { + Queue queue = this.collectAliveTargets(); int index = queue.size() > 27 ? IntMath.divide(queue.size(), 21, RoundingMode.CEILING) : 1; - this.c(index); + this.resizePages(index); for (InventoryMenu inventoryMenu : this.list) { for (int index2 = 0; index2 < (index == 1 ? 27 : 21); index2++) { - int index3 = index == 1 ? index2 : c[index2]; + int index3 = index == 1 ? index2 : TARGET_SLOTS[index2]; if (!queue.isEmpty()) { - this.a(inventoryMenu, index3, (BaseGamer)queue.remove()); + this.setTargetButton(inventoryMenu, index3, (BaseGamer)queue.remove()); } else { - inventoryMenu.a(index3, null, null); + inventoryMenu.setSlot(index3, null, null); } } } } - private void a(InventoryMenu inventoryMenu, int index, BaseGamer baseGamer) { + private void setTargetButton(InventoryMenu inventoryMenu, int index, BaseGamer baseGamer) { ItemBuilder itemBuilder = new ItemBuilder(ArcadeMaterial.PLAYER_HEAD); - itemBuilder.setDisplayName(this.game.getMessages().getSpectatorTargetName().a(baseGamer)); - itemBuilder.setLore(TextRenderer.a(this.game.getMessages().getSpectatorTargetLore(), baseGamer)); + itemBuilder.setDisplayName(this.game.getMessages().getSpectatorTargetName().render(baseGamer)); + itemBuilder.setLore(TextRenderer.render(this.game.getMessages().getSpectatorTargetLore(), baseGamer)); itemBuilder.setPlayerSkullOwner(this.game.getEngine().getPlatform(), baseGamer.toPlayer()); - inventoryMenu.a(index, defaultUser -> { + inventoryMenu.setSlot(index, defaultUser -> { Player player = defaultUser.toPlayer(); player.closeInventory(); BaseGamer baseGamer2 = (BaseGamer)this.game.getGamers().c(player); if (baseGamer2 != null) { baseGamer2.getSpectatorOptions().setPlayer(baseGamer.toPlayer()); - if (!baseGamer.f()) { - if (baseGamer2.getSpectatorOptions().c()) { + if (!baseGamer.isSpectator()) { + if (baseGamer2.getSpectatorOptions().isFirstPersonMode()) { Player player2 = baseGamer.toPlayer(); player.teleport(player2.getLocation()); Bukkit.getScheduler().runTask(this.game.getEngine().getPlugin(), () -> { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/command/GameStatisticsCommand.java b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/command/GameStatisticsCommand.java index 0699527..8586f2e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/command/GameStatisticsCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/command/GameStatisticsCommand.java @@ -25,7 +25,7 @@ public class GameStatisticsCommand extends BaseCommandExecutor { sender.sendMessage(this.manager.getMessages().getStatisticsNotFound()); } else { for (Text text2 : this.manager.getMessages().getStatisticsView()) { - sender.sendMessage(text2.a(baseGameStatistics)); + sender.sendMessage(text2.render(baseGameStatistics)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/model/BaseGameStatistics.java b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/model/BaseGameStatistics.java index 1762051..4022abd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/model/BaseGameStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/model/BaseGameStatistics.java @@ -15,82 +15,82 @@ import ro.fr33styler.arcade.api.engine.game.gamer.GameStatistics; import ro.fr33styler.arcade.api.engine.text.Context; public abstract class BaseGameStatistics implements GameStatistics, Context { - private int b; - private int c; - private int d; - private int e; - private boolean f; - private final UUID g; - private final String h; + private int wins; + private int loses; + private int winStreak; + private int currentWinStreak; + private boolean loaded; + private final UUID uuid; + private final String name; protected final AbstractGameManager manager; private final Map map = new HashMap<>(); public BaseGameStatistics(AbstractGameManager manager2, UUID uuid, String text) { - this.g = uuid; - this.h = text; + this.uuid = uuid; + this.name = text; this.manager = manager2; this.map.putAll(manager2.getDefaultProperties()); } public UUID getUUID() { - return this.g; + return this.uuid; } public String getName() { - return this.h; + return this.name; } public int getWins() { - return this.b; + return this.wins; } - public void a(int index) { - this.b = index; + public void setWins(int index) { + this.wins = index; } public int getLoses() { - return this.c; + return this.loses; } - public void b(int index) { - this.c = index; + public void setLoses(int index) { + this.loses = index; } public int getWinStreak() { - return this.d; + return this.winStreak; } - public void c(int index) { - this.d = index; + public void setWinStreak(int index) { + this.winStreak = index; } public int getCurrentWinStreak() { - return this.e; + return this.currentWinStreak; } - public void d(int index) { - this.e = index; + public void setCurrentWinStreak(int index) { + this.currentWinStreak = index; } - public boolean a() { - return this.f; + public boolean isLoaded() { + return this.loaded; } - public void a(boolean flag) { - this.f = flag; + public void setLoaded(boolean flag) { + this.loaded = flag; } public Map getMap() { return this.map; } - public String a(String text) { + public String resolvePlaceholder(String text) { return switch (text) { - case "stats_wins" -> String.valueOf(this.b); + case "stats_wins" -> String.valueOf(this.wins); case "stats_win_streak" -> String.valueOf(this.getWinStreak()); case "stats_current_win_streak" -> String.valueOf(this.getCurrentWinStreak()); - case "stats_loses" -> String.valueOf(this.c); - case "stats_played" -> String.valueOf(this.b + this.c); + case "stats_loses" -> String.valueOf(this.loses); + case "stats_played" -> String.valueOf(this.wins + this.loses); default -> null; }; } @@ -106,15 +106,15 @@ public abstract class BaseGameStatistics implements GameStatistics, Context { }; } - public String c() { + public String serializeProperties() { HashMap map2 = new HashMap<>(this.map); this.manager.getDefaultProperties().forEach(map2::remove); return EngineUtils.gson.toJson(map2); } - public void b(String text) { + public void deserializeProperties(String text) { if (!text.startsWith("{")) { - text = Strings.b(text); + text = Strings.decodeBase64(text); } Map map2 = (Map)EngineUtils.gson.fromJson(text, this.map.getClass()); @@ -124,9 +124,9 @@ public abstract class BaseGameStatistics implements GameStatistics, Context { } Bukkit.getScheduler().runTask(this.manager.getEngine().getPlugin(), () -> { - DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(this.g); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(this.uuid); if (defaultUser != null && defaultUser.getGamer() instanceof BaseGamer var2x && var2x.getGame().getManager() == this.manager) { - var2x.a(this.map); + var2x.loadProperties(this.map); } }); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/storage/GameStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/storage/GameStatisticsRepository.java index 7718501..a10fe69 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/statistics/storage/GameStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/statistics/storage/GameStatisticsRepository.java @@ -12,23 +12,23 @@ import org.bukkit.entity.Player; public abstract class GameStatisticsRepository { protected final DefaultEngine engine; - protected final String b; + protected final String tableName; public GameStatisticsRepository(DefaultEngine engine2, String text) { this.engine = engine2; - this.b = text; + this.tableName = text; } - protected SqlDatabase a() { + protected SqlDatabase getDatabase() { return this.engine.getDatabaseManager().getSqlDatabase(); } - public abstract void b(); + public abstract void createTables(); - public void a(String text, String text2, Consumer consumer) { - this.a() - .a( - "SELECT b.name, a." + text2 + " FROM " + text + " a LEFT JOIN " + this.a().b() + "_id b ON b.id = a.id ORDER BY a." + text2 + " DESC LIMIT 10;", + public void fetchTopEntries(String text, String text2, Consumer consumer) { + this.getDatabase() + .executeAsync( + "SELECT b.name, a." + text2 + " FROM " + text + " a LEFT JOIN " + this.getDatabase().getTablePrefix() + "_id b ON b.id = a.id ORDER BY a." + text2 + " DESC LIMIT 10;", preparedStatement -> { int index = 0; LeaderboardEntry[] leaderboardEntrys = new LeaderboardEntry[10]; @@ -48,9 +48,9 @@ public abstract class GameStatisticsRepository { ); } - public void a(Player player, String text, String text2, BiConsumer biConsumer) { - this.a() - .a( + public void fetchPlayerRank(Player player, String text, String text2, BiConsumer biConsumer) { + this.getDatabase() + .executeAsync( "SELECT a." + text2 + ", (SELECT COUNT(*) FROM " @@ -62,7 +62,7 @@ public abstract class GameStatisticsRepository { + ") + 1 AS position FROM " + text + " a WHERE a.id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setString(1, player.getUniqueId().toString()); @@ -80,11 +80,11 @@ public abstract class GameStatisticsRepository { ); } - public void c() { - this.a().a("DELETE FROM " + this.b + "_monthly"); + public void clearMonthly() { + this.getDatabase().executeAsync("DELETE FROM " + this.tableName + "_monthly"); } - public void d() { - this.a().a("DELETE FROM " + this.b + "_weekly"); + public void clearWeekly() { + this.getDatabase().executeAsync("DELETE FROM " + this.tableName + "_weekly"); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/DatabaseManager.java b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/DatabaseManager.java index c76aab9..4c67b7a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/DatabaseManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/DatabaseManager.java @@ -56,52 +56,52 @@ public class DatabaseManager implements Configuration { return this.sqlDatabase; } - public void e() { + public void loadConfig() { this.file = new File(this.engine.getDataFolder(), "database"); this.engine.getConfigManager().tryLoad(this, new File(this.file, "database.yml")); } - public void f() { + public void saveConfig() { this.engine.getConfigManager().trySave(this, new File(this.file, "database.yml")); } - public void g() { - if (VendorMarkerProbe.a(this.engine.getPlugin()) && UserNonceMarkerProbe.a(this.engine.getPlugin())) { - this.e(); - this.h(); - this.j(); + public void start() { + if (VendorMarkerProbe.probe(this.engine.getPlugin()) && UserNonceMarkerProbe.probe(this.engine.getPlugin())) { + this.loadConfig(); + this.registerLeaderboards(); + this.registerTogglers(); } - this.m(); + this.connectDatabase(); } - public void h() { + public void registerLeaderboards() { for (Entry entry : this.getLeaderboards().entrySet()) { - this.engine.getDisplayManager().a((String)entry.getKey(), (Location)entry.getValue()); + this.engine.getDisplayManager().addLeaderboardGroup((String)entry.getKey(), (Location)entry.getValue()); } } - public void i() { - this.engine.getDisplayManager().d(); + public void unregisterLeaderboards() { + this.engine.getDisplayManager().clearLeaderboardGroups(); } - public void j() { + public void registerTogglers() { for (Entry entry : this.getTogglersData().entrySet()) { - this.engine.getDisplayManager().a((String)entry.getKey(), (LeaderboardToggleSettings)entry.getValue()); + this.engine.getDisplayManager().addLeaderboardToggle((String)entry.getKey(), (LeaderboardToggleSettings)entry.getValue()); } } - public void k() { - this.engine.getDisplayManager().f(); + public void unregisterTogglers() { + this.engine.getDisplayManager().clearLeaderboardToggles(); } - private void m() { + private void connectDatabase() { try { MysqlSettings mysqlSettings = new MysqlSettings(); this.engine.getConfigManager().tryLoad(mysqlSettings, new File(this.file, "mysql.yml")); if (mysqlSettings.isEnabled()) { VersionAdapters.get().ensureJdbcDriverLoaded("com.mysql.jdbc.Driver"); - this.sqlDatabase = this.a(mysqlSettings); + this.sqlDatabase = this.connectMysql(mysqlSettings); } else { File file2 = new File(this.file, "playerdata.db"); File file3 = new File(this.file, "playerdata.sql"); @@ -118,7 +118,7 @@ public class DatabaseManager implements Configuration { } } - private MysqlDatabase a(MysqlSettings mysqlSettings) throws SQLException { + private MysqlDatabase connectMysql(MysqlSettings mysqlSettings) throws SQLException { Properties properties = new Properties(); properties.setProperty("user", mysqlSettings.getUser()); properties.setProperty("password", mysqlSettings.getPassword()); @@ -126,12 +126,12 @@ public class DatabaseManager implements Configuration { return new MysqlDatabase(this.engine, mysqlSettings, properties); } - public void l() { + public void stop() { if (this.sqlDatabase != null) { - this.sqlDatabase.c(); + this.sqlDatabase.close(); } - this.i(); - this.k(); + this.unregisterLeaderboards(); + this.unregisterTogglers(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/mysql/MysqlDatabase.java b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/mysql/MysqlDatabase.java index c4b835c..1bea3c8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/mysql/MysqlDatabase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/mysql/MysqlDatabase.java @@ -14,28 +14,28 @@ import org.bukkit.Bukkit; public class MysqlDatabase extends SqlDatabase { public MysqlDatabase(DefaultEngine defaultEngine, MysqlSettings mysqlSettings, Properties properties) throws java.sql.SQLException { super(defaultEngine, DriverManager.getConnection("jdbc:mysql://" + mysqlSettings.getHost() + ":" + mysqlSettings.getPort() + "/" + mysqlSettings.getDatabase(), properties)); - this.a("CREATE TABLE IF NOT EXISTS " + this.b() + "_id (id INT AUTO_INCREMENT PRIMARY KEY, uuid CHAR(36) UNIQUE, name VARCHAR(16));"); + this.executeAsync("CREATE TABLE IF NOT EXISTS " + this.getTablePrefix() + "_id (id INT AUTO_INCREMENT PRIMARY KEY, uuid CHAR(36) UNIQUE, name VARCHAR(16));"); } @Override - public void a() { - this.a("SELECT monthly, weekly FROM " + this.b() + "_time WHERE id = 1 LIMIT 1;", preparedStatement -> { + public void checkResetTimers() { + this.executeAsync("SELECT monthly, weekly FROM " + this.getTablePrefix() + "_time WHERE id = 1 LIMIT 1;", preparedStatement -> { try (ResultSet var2 = preparedStatement.executeQuery()) { if (var2.next()) { - this.e(); + this.processExpiredTimers(); } else { - this.d(); + this.initializeTimers(); } } }); } - private void d() { - this.a("INSERT INTO " + this.b() + "_time VALUES (1, DATE_ADD(NOW(), INTERVAL 7 DAY), DATE_ADD(NOW(), INTERVAL 1 MONTH));"); + private void initializeTimers() { + this.executeAsync("INSERT INTO " + this.getTablePrefix() + "_time VALUES (1, DATE_ADD(NOW(), INTERVAL 7 DAY), DATE_ADD(NOW(), INTERVAL 1 MONTH));"); } - private void e() { - this.a("SELECT monthly FROM " + this.b() + "_time where monthly < (SELECT NOW()) LIMIT 1;", preparedStatement -> { + private void processExpiredTimers() { + this.executeAsync("SELECT monthly FROM " + this.getTablePrefix() + "_time where monthly < (SELECT NOW()) LIMIT 1;", preparedStatement -> { try (ResultSet var2 = preparedStatement.executeQuery()) { if (!var2.next()) { return; @@ -43,13 +43,13 @@ public class MysqlDatabase extends SqlDatabase { Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> { for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) { - abstractGameManager.getStorage().e().c(); + abstractGameManager.getStorage().getStatisticsRepository().clearMonthly(); } }); - this.a("UPDATE " + this.b() + "_time SET monthly = DATE_ADD(NOW(), INTERVAL 1 MONTH) WHERE id = 1;"); + this.executeAsync("UPDATE " + this.getTablePrefix() + "_time SET monthly = DATE_ADD(NOW(), INTERVAL 1 MONTH) WHERE id = 1;"); } }); - this.a("SELECT weekly FROM " + this.b() + "_time where weekly < (SELECT NOW()) LIMIT 1;", preparedStatement2 -> { + this.executeAsync("SELECT weekly FROM " + this.getTablePrefix() + "_time where weekly < (SELECT NOW()) LIMIT 1;", preparedStatement2 -> { try (ResultSet var2 = preparedStatement2.executeQuery()) { if (!var2.next()) { return; @@ -57,17 +57,17 @@ public class MysqlDatabase extends SqlDatabase { Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> { for (AbstractGameManager abstractGameManager2 : this.engine.getGameManagerRegistry()) { - abstractGameManager2.getStorage().e().d(); + abstractGameManager2.getStorage().getStatisticsRepository().clearWeekly(); } }); - this.a("UPDATE " + this.b() + "_time SET weekly = DATE_ADD(NOW(), INTERVAL 7 DAY) WHERE id = 1;"); + this.executeAsync("UPDATE " + this.getTablePrefix() + "_time SET weekly = DATE_ADD(NOW(), INTERVAL 7 DAY) WHERE id = 1;"); } }); } - private boolean c(String text) { + private boolean hasTable(String text) { MutableBoolean mutableBoolean = new MutableBoolean(false); - this.b("SHOW TABLES LIKE " + text + ";", preparedStatement -> { + this.executeSync("SHOW TABLES LIKE " + text + ";", preparedStatement -> { try (ResultSet var2x = preparedStatement.executeQuery()) { mutableBoolean.setValue(var2x.next()); } @@ -76,13 +76,13 @@ public class MysqlDatabase extends SqlDatabase { } @Override - public boolean a(String text, String text2) { - if (!this.c(text)) { + public boolean hasColumn(String text, String text2) { + if (!this.hasTable(text)) { return false; } MutableBoolean mutableBoolean = new MutableBoolean(false); - this.b("SHOW COLUMNS FROM " + text + " LIKE '" + text2 + "';", preparedStatement -> { + this.executeSync("SHOW COLUMNS FROM " + text + " LIKE '" + text2 + "';", preparedStatement -> { try (ResultSet var2x = preparedStatement.executeQuery()) { mutableBoolean.setValue(var2x.next()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sql/SqlDatabase.java b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sql/SqlDatabase.java index bf1d46d..1921938 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sql/SqlDatabase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sql/SqlDatabase.java @@ -14,49 +14,49 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; public abstract class SqlDatabase { - private final String b; + private final String tablePrefix; protected final DefaultEngine engine; - private final Connection c; + private final Connection connection; private final ExecutorService executor; private final Queue queue = new ArrayDeque<>(); public SqlDatabase(DefaultEngine engine2, Connection connection) { this.engine = engine2; - this.c = connection; - this.b = engine2.getNamespace().replace('-', '_'); + this.connection = connection; + this.tablePrefix = engine2.getNamespace().replace('-', '_'); this.executor = engine2.getJdkFeatures().startSingleThreadExecutor(); - this.a("CREATE TABLE IF NOT EXISTS " + this.b() + "_time (id TINYINT UNIQUE, weekly DATETIME, monthly DATETIME);"); + this.executeAsync("CREATE TABLE IF NOT EXISTS " + this.getTablePrefix() + "_time (id TINYINT UNIQUE, weekly DATETIME, monthly DATETIME);"); } - public String b() { - return this.b; + public String getTablePrefix() { + return this.tablePrefix; } - public void a(String text) { - this.a(() -> this.b(text)); + public void executeAsync(String text) { + this.submit(() -> this.executeSync(text)); } - public void a(String text, PreparedStatementConsumer preparedStatementConsumer) { - this.a(() -> this.b(text, preparedStatementConsumer)); + public void executeAsync(String text, PreparedStatementConsumer preparedStatementConsumer) { + this.submit(() -> this.executeSync(text, preparedStatementConsumer)); } - public void b(String text) { - try (Statement var2 = this.c.createStatement()) { + public void executeSync(String text) { + try (Statement var2 = this.connection.createStatement()) { var2.execute(text); } catch (SQLException ex) { ex.printStackTrace(); } } - public void b(String text, PreparedStatementConsumer preparedStatementConsumer) { - try (PreparedStatement var3 = this.c.prepareStatement(text)) { + public void executeSync(String text, PreparedStatementConsumer preparedStatementConsumer) { + try (PreparedStatement var3 = this.connection.prepareStatement(text)) { preparedStatementConsumer.accept(var3); } catch (SQLException ex) { ex.printStackTrace(); } } - private void a(Runnable runnable) { + private void submit(Runnable runnable) { if (this.executor.isShutdown()) { this.queue.add(runnable); } else { @@ -64,41 +64,41 @@ public abstract class SqlDatabase { } } - public abstract void a(); + public abstract void checkResetTimers(); - public abstract boolean a(String var1, String var2); + public abstract boolean hasColumn(String var1, String var2); - public void a(UUID uuid, String text) { - this.a("SELECT name FROM " + this.b() + "_id WHERE uuid = ? LIMIT 1;", preparedStatement -> { + public void upsertPlayer(UUID uuid, String text) { + this.executeAsync("SELECT name FROM " + this.getTablePrefix() + "_id WHERE uuid = ? LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(uuid, text); + this.updatePlayerName(uuid, text); } else { - this.c(uuid, text); + this.insertPlayer(uuid, text); } } }); } - private void b(UUID uuid, String text) { - this.a("UPDATE " + this.b() + "_id SET name = ? WHERE uuid = ?;", preparedStatement -> { + private void updatePlayerName(UUID uuid, String text) { + this.executeAsync("UPDATE " + this.getTablePrefix() + "_id SET name = ? WHERE uuid = ?;", preparedStatement -> { preparedStatement.setString(1, text); preparedStatement.setString(2, uuid.toString()); preparedStatement.executeUpdate(); }); } - private void c(UUID uuid, String text) { - this.a("INSERT INTO " + this.b() + "_id(uuid, name) VALUES (?, ?);", preparedStatement -> { + private void insertPlayer(UUID uuid, String text) { + this.executeAsync("INSERT INTO " + this.getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); preparedStatement.setString(2, text); preparedStatement.executeUpdate(); }); } - public void c() { + public void close() { try { this.queue.addAll(this.executor.shutdownNow()); this.executor.awaitTermination(3L, TimeUnit.MINUTES); @@ -107,7 +107,7 @@ public abstract class SqlDatabase { this.queue.poll().run(); } - this.c.close(); + this.connection.close(); } catch (SQLException | InterruptedException ex) { ex.printStackTrace(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sqlite/SqliteDatabase.java b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sqlite/SqliteDatabase.java index 62e7342..d3740de 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sqlite/SqliteDatabase.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/storage/database/sqlite/SqliteDatabase.java @@ -13,28 +13,28 @@ import org.bukkit.Bukkit; public class SqliteDatabase extends SqlDatabase { public SqliteDatabase(DefaultEngine defaultEngine, File file) throws java.sql.SQLException { super(defaultEngine, DriverManager.getConnection("jdbc:sqlite:" + file)); - this.a("CREATE TABLE IF NOT EXISTS " + this.b() + "_id (id INTEGER PRIMARY KEY, uuid CHAR(36) UNIQUE, name VARCHAR(16));"); + this.executeAsync("CREATE TABLE IF NOT EXISTS " + this.getTablePrefix() + "_id (id INTEGER PRIMARY KEY, uuid CHAR(36) UNIQUE, name VARCHAR(16));"); } @Override - public void a() { - this.a("SELECT monthly, weekly FROM " + this.b() + "_time WHERE id = 1 LIMIT 1;", preparedStatement -> { + public void checkResetTimers() { + this.executeAsync("SELECT monthly, weekly FROM " + this.getTablePrefix() + "_time WHERE id = 1 LIMIT 1;", preparedStatement -> { try (ResultSet var2 = preparedStatement.executeQuery()) { if (var2.next()) { - this.e(); + this.processExpiredTimers(); } else { - this.d(); + this.initializeTimers(); } } }); } - private void d() { - this.a("INSERT INTO " + this.b() + "_time VALUES (1, DATETIME('now', '+7 day'), DATETIME('now', '+1 month'));"); + private void initializeTimers() { + this.executeAsync("INSERT INTO " + this.getTablePrefix() + "_time VALUES (1, DATETIME('now', '+7 day'), DATETIME('now', '+1 month'));"); } - private void e() { - this.a("SELECT monthly FROM " + this.b() + "_time where monthly < (SELECT DATETIME('now')) LIMIT 1;", preparedStatement -> { + private void processExpiredTimers() { + this.executeAsync("SELECT monthly FROM " + this.getTablePrefix() + "_time where monthly < (SELECT DATETIME('now')) LIMIT 1;", preparedStatement -> { try (ResultSet var2 = preparedStatement.executeQuery()) { if (!var2.next()) { return; @@ -42,13 +42,13 @@ public class SqliteDatabase extends SqlDatabase { Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> { for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) { - abstractGameManager.getStorage().e().c(); + abstractGameManager.getStorage().getStatisticsRepository().clearMonthly(); } }); - this.a("UPDATE " + this.b() + "_time SET monthly = DATETIME('now', '+1 month') WHERE id = 1;"); + this.executeAsync("UPDATE " + this.getTablePrefix() + "_time SET monthly = DATETIME('now', '+1 month') WHERE id = 1;"); } }); - this.a("SELECT weekly FROM " + this.b() + "_time where weekly < (SELECT DATETIME('now')) LIMIT 1;", preparedStatement2 -> { + this.executeAsync("SELECT weekly FROM " + this.getTablePrefix() + "_time where weekly < (SELECT DATETIME('now')) LIMIT 1;", preparedStatement2 -> { try (ResultSet var2 = preparedStatement2.executeQuery()) { if (!var2.next()) { return; @@ -56,18 +56,18 @@ public class SqliteDatabase extends SqlDatabase { Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> { for (AbstractGameManager abstractGameManager2 : this.engine.getGameManagerRegistry()) { - abstractGameManager2.getStorage().e().d(); + abstractGameManager2.getStorage().getStatisticsRepository().clearWeekly(); } }); - this.a("UPDATE " + this.b() + "_time SET weekly = DATETIME('now', '+7 day') WHERE id = 1;"); + this.executeAsync("UPDATE " + this.getTablePrefix() + "_time SET weekly = DATETIME('now', '+7 day') WHERE id = 1;"); } }); } @Override - public boolean a(String text, String text2) { + public boolean hasColumn(String text, String text2) { MutableBoolean mutableBoolean = new MutableBoolean(false); - this.b("PRAGMA table_info(\"" + text + "\");", preparedStatement -> { + this.executeSync("PRAGMA table_info(\"" + text + "\");", preparedStatement -> { try (ResultSet var3x = preparedStatement.executeQuery()) { while (var3x.next()) { if (var3x.getString("name").equals(text2)) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/support/EngineUtils.java b/common/src/main/java/ro/fr33styler/arcade/engine/support/EngineUtils.java index bb94914..beabcca 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/support/EngineUtils.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/support/EngineUtils.java @@ -11,37 +11,37 @@ public final class EngineUtils { public static final Gson gson = new Gson(); - public static final UUID b = new UUID(0L, 0L); + public static final UUID ZERO_UUID = new UUID(0L, 0L); - public static void a(long longVal) { + public static void sleepQuietly(long longVal) { SharedEngineOperations.sleepQuietly(longVal); } - public static void a(Closeable closeable) { + public static void closeQuietly(Closeable closeable) { SharedEngineOperations.closeQuietly(closeable); } - public static T a(T obj, T obj2) { + public static T orElse(T obj, T obj2) { return SharedEngineOperations.orElse(obj, obj2); } - public static void a(Object[] objs, int index, int index2) { + public static void swap(Object[] objs, int index, int index2) { SharedEngineOperations.swap(objs, index, index2); } - public static float a(float floatVal) { + public static float snapYaw(float floatVal) { return SharedEngineOperations.snapYaw(floatVal); } - public static boolean a(Action action) { + public static boolean isLeftClick(Action action) { return SharedEngineOperations.isLeftClick(action); } - public static boolean b(Action action) { + public static boolean isRightClick(Action action) { return SharedEngineOperations.isRightClick(action); } - public static InputStream a(String text, String text2, String text3, int index) { + public static InputStream openStream(String text, String text2, String text3, int index) { return SharedEngineOperations.openStream(text, text2, text3, index); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/CompositeText.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/CompositeText.java index 2785478..b6ee7cd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/CompositeText.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/CompositeText.java @@ -20,11 +20,11 @@ public class CompositeText implements Text { return stringBuilder.toString(); } - public String a(Context context) { + public String render(Context context) { StringBuilder stringBuilder = new StringBuilder(); for (Text text : this.texts) { - stringBuilder.append(text.a(context)); + stringBuilder.append(text.render(context)); } return stringBuilder.toString(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/ConditionalText.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/ConditionalText.java index a9aac9e..9ee9091 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/ConditionalText.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/ConditionalText.java @@ -4,26 +4,26 @@ import ro.fr33styler.arcade.api.engine.text.Context; public class ConditionalText implements Text { private final Text text; - private final Text text3; - private final String c; + private final Text falseText; + private final String condition; public ConditionalText(String text2, Text text4, Text text32) { this.text = text4; - this.text3 = text32; - this.c = text2; + this.falseText = text32; + this.condition = text2; } @Override public String toString() { - return "<" + this.c + "=" + this.text.toString() + "#" + this.text3.toString() + ">"; + return "<" + this.condition + "=" + this.text.toString() + "#" + this.falseText.toString() + ">"; } - public String a(Context context) { - Boolean booleanValue = context.getCondition(this.c); + public String render(Context context) { + Boolean booleanValue = context.getCondition(this.condition); if (booleanValue == null) { return this.toString(); } else { - return booleanValue ? this.text.a(context) : this.text3.a(context); + return booleanValue ? this.text.render(context) : this.falseText.render(context); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/LiteralText.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/LiteralText.java index e616dbe..6a6c45c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/LiteralText.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/LiteralText.java @@ -3,19 +3,19 @@ package ro.fr33styler.arcade.engine.text; import ro.fr33styler.arcade.api.engine.text.Context; public class LiteralText implements Text { - private final String a; + private final String variable; public LiteralText(String text) { - this.a = text; + this.variable = text; } @Override public String toString() { - return "%" + this.a + "%"; + return "%" + this.variable + "%"; } - public String a(Context context) { - String text = context.getVariable(this.a); + public String render(Context context) { + String text = context.getVariable(this.variable); return text == null ? this.toString() : text; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/Text.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/Text.java index 6c19f7a..8e5e52e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/Text.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/Text.java @@ -3,7 +3,7 @@ package ro.fr33styler.arcade.engine.text; import ro.fr33styler.arcade.api.engine.text.Context; public interface Text { - String a(Context var1); + String render(Context var1); @Override String toString(); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/VariableText.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/VariableText.java index 1ca342e..fa83b40 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/VariableText.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/VariableText.java @@ -5,18 +5,18 @@ import ro.fr33styler.arcade.support.text.Strings; import ro.fr33styler.arcade.api.engine.text.Context; public class VariableText implements Text { - private final String a; + private final String text; public VariableText(String text) { - this.a = Strings.a(text); + this.text = Strings.colorize(text); } @Override public String toString() { - return Strings.c(this.a).replace('§', '&'); + return Strings.stripHexColors(this.text).replace('§', '&'); } - public String a(Context context) { - return this.a; + public String render(Context context) { + return this.text; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/context/Contexts.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/context/Contexts.java index f24ae41..7eccd72 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/context/Contexts.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/context/Contexts.java @@ -5,19 +5,19 @@ import ro.fr33styler.arcade.engine.game.player.BaseGamer; import ro.fr33styler.arcade.api.engine.text.Context; public class Contexts { - public static Context a(Context context, BaseGamer[] baseGamers) { + public static Context withPodium(Context context, BaseGamer[] baseGamers) { return new PodiumContext(context, baseGamers); } - public static Context a(VariableProvider variableProvider) { + public static Context ofVariables(VariableProvider variableProvider) { return new FunctionalContext(variableProvider, text -> null); } - public static Context a(Context context, VariableProvider variableProvider) { + public static Context withVariables(Context context, VariableProvider variableProvider) { return new OverlayContext(context, variableProvider, text -> null); } - public static Context a(ConditionProvider conditionProvider) { + public static Context ofConditions(ConditionProvider conditionProvider) { return new FunctionalContext(text -> null, conditionProvider); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextParser.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextParser.java index 21b6fb1..93cb767 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextParser.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextParser.java @@ -8,21 +8,21 @@ import java.util.ArrayList; import java.util.List; public class TextParser { - public static Text a(String text) { - return a(text.toCharArray(), 0, '\u0000').text(); + public static Text parse(String text) { + return parseSegment(text.toCharArray(), 0, '\u0000').text(); } - public static List a(String... texts) { + public static List parseAll(String... texts) { ArrayList list = new ArrayList(texts.length); for (String text : texts) { - list.add(a(text)); + list.add(parse(text)); } return list; } - private static TextParseResult a(char[] chs, int index) { + private static TextParseResult parsePlaceholder(char[] chs, int index) { StringBuilder stringBuilder = new StringBuilder(); for (int index2 = index; index2 < chs.length; index2++) { @@ -31,7 +31,7 @@ public class TextParser { return null; } - if (index != index2 && ch == TextSyntaxSettings.a.getPlaceholderDelimiter()) { + if (index != index2 && ch == TextSyntaxSettings.INSTANCE.getPlaceholderDelimiter()) { return new TextParseResult(new LiteralText(stringBuilder.toString()), index2); } @@ -41,23 +41,23 @@ public class TextParser { return null; } - private static TextParseResult a(StringBuilder stringBuilder, char[] chs, int index) { - TextParseResult textParseResult = a(chs, index + 1, TextSyntaxSettings.a.getConditionSeparator()); + private static TextParseResult parseConditionBranches(StringBuilder stringBuilder, char[] chs, int index) { + TextParseResult textParseResult = parseSegment(chs, index + 1, TextSyntaxSettings.INSTANCE.getConditionSeparator()); if (textParseResult == null) { return null; } - TextParseResult textParseResult2 = a(chs, textParseResult.position() + 1, TextSyntaxSettings.a.getConditionEndDelimiter()); + TextParseResult textParseResult2 = parseSegment(chs, textParseResult.position() + 1, TextSyntaxSettings.INSTANCE.getConditionEndDelimiter()); return textParseResult2 == null ? null : new TextParseResult(new ConditionalText(stringBuilder.toString(), textParseResult.text(), textParseResult2.text()), textParseResult2.position()); } - private static TextParseResult b(char[] chs, int index) { + private static TextParseResult parseCondition(char[] chs, int index) { StringBuilder stringBuilder = new StringBuilder(); for (int index2 = index + 1; index2 < chs.length; index2++) { char ch = chs[index2]; - if (ch == TextSyntaxSettings.a.getConditionPlaceholderDelimiter()) { - return a(stringBuilder, chs, index2); + if (ch == TextSyntaxSettings.INSTANCE.getConditionPlaceholderDelimiter()) { + return parseConditionBranches(stringBuilder, chs, index2); } stringBuilder.append(ch); @@ -66,39 +66,39 @@ public class TextParser { return null; } - private static TextParseResult c(char[] chs, int index) { + private static TextParseResult parseToken(char[] chs, int index) { char ch = chs[index]; - if (ch == TextSyntaxSettings.a.getPlaceholderDelimiter()) { - return a(chs, index + 1); + if (ch == TextSyntaxSettings.INSTANCE.getPlaceholderDelimiter()) { + return parsePlaceholder(chs, index + 1); } else { - return ch == TextSyntaxSettings.a.getConditionStartDelimiter() ? b(chs, index) : null; + return ch == TextSyntaxSettings.INSTANCE.getConditionStartDelimiter() ? parseCondition(chs, index) : null; } } - private static int a(char[] chs, int index, StringBuilder stringBuilder, List list) { - TextParseResult textParseResult = c(chs, index); + private static int consumeChar(char[] chs, int index, StringBuilder stringBuilder, List list) { + TextParseResult textParseResult = parseToken(chs, index); if (textParseResult == null) { stringBuilder.append(chs[index]); return index; } else { - TextRenderer.a(stringBuilder, list); + TextRenderer.flushLiteral(stringBuilder, list); list.add(textParseResult.text()); return textParseResult.position(); } } - private static TextParseResult a(char[] chs, int index, char ch) { + private static TextParseResult parseSegment(char[] chs, int index, char ch) { ArrayList list = new ArrayList(); StringBuilder stringBuilder = new StringBuilder(); for (int index2 = index; index2 < chs.length; index2++) { if (ch != 0 && chs[index2] == ch) { - return TextRenderer.a(stringBuilder, list, index2); + return TextRenderer.buildParseResult(stringBuilder, list, index2); } - index2 = a(chs, index2, stringBuilder, list); + index2 = consumeChar(chs, index2, stringBuilder, list); } - return ch == 0 ? TextRenderer.a(stringBuilder, list, chs.length - 1) : null; + return ch == 0 ? TextRenderer.buildParseResult(stringBuilder, list, chs.length - 1) : null; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextRenderer.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextRenderer.java index bd43fa6..414e6d8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextRenderer.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextRenderer.java @@ -11,30 +11,30 @@ import ro.fr33styler.arcade.api.engine.text.Context; public final class TextRenderer { public static final Text text = new VariableText(""); - public static List a(List list, Context context) { + public static List render(List list, Context context) { ArrayList list2 = new ArrayList(list.size()); - a(list2, list, context); + renderInto(list2, list, context); return list2; } - public static void a(List list, List list2, Context context) { + public static void renderInto(List list, List list2, Context context) { for (Text text2 : list2) { - String text3 = text2.a(context); + String text3 = text2.render(context); if (!text3.isEmpty()) { list.add(text3); } } } - static void a(StringBuilder stringBuilder, List list) { + static void flushLiteral(StringBuilder stringBuilder, List list) { if (!stringBuilder.isEmpty()) { list.add(new VariableText(stringBuilder.toString())); stringBuilder.setLength(0); } } - static TextParseResult a(StringBuilder stringBuilder, List list, int index) { - a(stringBuilder, list); + static TextParseResult buildParseResult(StringBuilder stringBuilder, List list, int index) { + flushLiteral(stringBuilder, list); Object obj = text; if (list.size() == 1) { obj = (Text)list.get(0); diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextSyntaxSettings.java b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextSyntaxSettings.java index b9fa541..aae10f2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextSyntaxSettings.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/text/parse/TextSyntaxSettings.java @@ -4,7 +4,7 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; import ro.fr33styler.arcade.api.engine.config.serialize.Configuration; public class TextSyntaxSettings implements Configuration { - public static final TextSyntaxSettings a = new TextSyntaxSettings(); + public static final TextSyntaxSettings INSTANCE = new TextSyntaxSettings(); @Setting("placeholder-delimiter") private char placeholderDelimiter = '%'; @Setting("condition-start-delimiter") diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/ui/hotbar/PlayerHotbar.java b/common/src/main/java/ro/fr33styler/arcade/engine/ui/hotbar/PlayerHotbar.java index 13cd556..61eebad 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/ui/hotbar/PlayerHotbar.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/ui/hotbar/PlayerHotbar.java @@ -5,32 +5,32 @@ import org.bukkit.inventory.ItemStack; public final class PlayerHotbar { private final Player player; - private final Runnable[] b = new Runnable[9]; + private final Runnable[] actions = new Runnable[9]; public PlayerHotbar(Player player2) { this.player = player2; } - public boolean a(int index) { - return index < 9 && this.b[index] != null; + public boolean hasAction(int index) { + return index < 9 && this.actions[index] != null; } - public void b(int index) { - Runnable runnable = this.b[index]; + public void trigger(int index) { + Runnable runnable = this.actions[index]; if (runnable != null) { runnable.run(); } } - public void a(int index, Runnable runnable, ItemStack item) { - this.b[index] = runnable; + public void setSlot(int index, Runnable runnable, ItemStack item) { + this.actions[index] = runnable; this.player.getInventory().setItem(index, item); } - public void a() { + public void clear() { for (int index = 0; index < 9; index++) { - if (this.b[index] != null) { - this.b[index] = null; + if (this.actions[index] != null) { + this.actions[index] = null; this.player.getInventory().setItem(index, null); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/ui/menu/InventoryMenu.java b/common/src/main/java/ro/fr33styler/arcade/engine/ui/menu/InventoryMenu.java index 0fe4378..4d59fe3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/ui/menu/InventoryMenu.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/ui/menu/InventoryMenu.java @@ -10,41 +10,41 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class InventoryMenu { - private Inventory a; - private final Consumer[] b; + private Inventory inventory; + private final Consumer[] actions; public InventoryMenu(String text, int index) { - this.b = new Consumer[index]; - this.a = Bukkit.createInventory(null, index, text); + this.actions = new Consumer[index]; + this.inventory = Bukkit.createInventory(null, index, text); } - public Inventory a() { - return this.a; + public Inventory getInventory() { + return this.inventory; } - public void a(String text) { - Inventory inventory = this.a; - this.a = Bukkit.createInventory(null, inventory.getSize(), text); - this.a.setContents(inventory.getContents()); + public void setTitle(String text) { + Inventory inventory = this.inventory; + this.inventory = Bukkit.createInventory(null, inventory.getSize(), text); + this.inventory.setContents(inventory.getContents()); for (HumanEntity humanEntity : List.copyOf(inventory.getViewers())) { - humanEntity.openInventory(this.a); + humanEntity.openInventory(this.inventory); } } - public boolean a(int index) { - return this.b[index] != null; + public boolean hasAction(int index) { + return this.actions[index] != null; } - public void a(DefaultUser defaultUser, int index) { - Consumer consumer = this.b[index]; + public void handleClick(DefaultUser defaultUser, int index) { + Consumer consumer = this.actions[index]; if (consumer != null) { consumer.accept(defaultUser); } } - public void a(int index, Consumer consumer, ItemStack item) { - this.b[index] = consumer; - this.a.setItem(index, item); + public void setSlot(int index, Consumer consumer, ItemStack item) { + this.actions[index] = consumer; + this.inventory.setItem(index, item); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/BlockFloodFill.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/BlockFloodFill.java index e086d4e..e0fe9f0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/BlockFloodFill.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/BlockFloodFill.java @@ -4,7 +4,7 @@ import java.util.function.Consumer; import org.bukkit.block.Block; public class BlockFloodFill { - public static void a(int index, Block block, Consumer consumer) { + public static void forEachInRadius(int index, Block block, Consumer consumer) { for (int index2 = -index; index2 <= index; index2++) { for (int index3 = -index; index3 <= index; index3++) { for (int index4 = -index; index4 <= index; index4++) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/index/BlockDistanceIndex.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/index/BlockDistanceIndex.java index 5d2cf66..ed5bb55 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/index/BlockDistanceIndex.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/index/BlockDistanceIndex.java @@ -11,43 +11,43 @@ import org.bukkit.block.Block; public class BlockDistanceIndex { private final Location location; - private final NavigableMap> b = new TreeMap<>(); + private final NavigableMap> blocksByDistance = new TreeMap<>(); public BlockDistanceIndex(Location location2) { this.location = location2; } - public void a() { - this.b.clear(); + public void clear() { + this.blocksByDistance.clear(); } - public int b() { - return this.b.size(); + public int size() { + return this.blocksByDistance.size(); } - private int d(Block block) { + private int distanceSquaredXZ(Block block) { int index = block.getX() - this.location.getBlockX(); int index2 = block.getZ() - this.location.getBlockZ(); return index * index + index2 * index2; } - public void a(Block block) { - this.b.computeIfAbsent(this.d(block), integer -> new LinkedHashSet<>()).add(block); + public void add(Block block) { + this.blocksByDistance.computeIfAbsent(this.distanceSquaredXZ(block), integer -> new LinkedHashSet<>()).add(block); } - public void b(Block block) { - Integer integer = this.d(block); - Set set = this.b.get(integer); + public void remove(Block block) { + Integer integer = this.distanceSquaredXZ(block); + Set set = this.blocksByDistance.get(integer); if (set != null && set.remove(block) && set.isEmpty()) { - this.b.remove(integer); + this.blocksByDistance.remove(integer); } } - public boolean c(Block block) { - return !this.b.isEmpty() && this.b.lastKey() < this.d(block); + public boolean isBeyondFarthest(Block block) { + return !this.blocksByDistance.isEmpty() && this.blocksByDistance.lastKey() < this.distanceSquaredXZ(block); } - public Collection c() { - return this.b.isEmpty() ? List.of() : this.b.pollLastEntry().getValue(); + public Collection pollFarthest() { + return this.blocksByDistance.isEmpty() ? List.of() : this.blocksByDistance.pollLastEntry().getValue(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/physics/BlockPhysics.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/physics/BlockPhysics.java index a257c84..5b255fc 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/block/physics/BlockPhysics.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/block/physics/BlockPhysics.java @@ -9,17 +9,17 @@ import org.bukkit.block.BlockFace; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class BlockPhysics { - private static final BlockFace[] a = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}; + private static final BlockFace[] HORIZONTAL_FACES = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}; - private static void a(Block block, Queue queue) { + private static void collectAbove(Block block, Queue queue) { Block block2 = block.getRelative(BlockFace.UP); if (VersionAdapters.get().isPhysicsDependentBlock(block2.getType())) { queue.add(block2); } } - private static void b(Block block, Queue queue) { - for (BlockFace blockFace : a) { + private static void collectWallAttached(Block block, Queue queue) { + for (BlockFace blockFace : HORIZONTAL_FACES) { Block block2 = block.getRelative(blockFace); if (VersionAdapters.get().isWallAttachedBlock(block2.getType())) { queue.add(block2); @@ -27,21 +27,21 @@ public class BlockPhysics { } } - private static void a(Block block, Deque deque, Queue queue) { + private static void collectDependent(Block block, Deque deque, Queue queue) { if (!deque.contains(block)) { deque.add(block); - a(block, queue); - b(block, queue); + collectAbove(block, queue); + collectWallAttached(block, queue); } } - public static void a(Block block, Consumer consumer) { + public static void forEachDependent(Block block, Consumer consumer) { ArrayDeque visited = new ArrayDeque<>(); ArrayDeque pending = new ArrayDeque<>(); pending.add(block); while (!pending.isEmpty()) { - a(pending.poll(), visited, pending); + collectDependent(pending.poll(), visited, pending); } while (!visited.isEmpty()) { diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/location/Locations.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/location/Locations.java index 9561773..a3e5513 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/location/Locations.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/location/Locations.java @@ -10,23 +10,23 @@ import org.bukkit.World; import org.bukkit.util.NumberConversions; public class Locations { - public static boolean a(Location location, Location location2) { + public static boolean isSameBlock(Location location, Location location2) { boolean flag = location.getBlockX() == location2.getBlockX(); boolean flag2 = location.getBlockY() == location2.getBlockY(); boolean flag3 = location.getBlockZ() == location2.getBlockZ(); return flag && flag2 && flag3; } - public static boolean a(Location location, Location location2, double doubleVal) { - double doubleVal2 = c(location, location2); + public static boolean isNear(Location location, Location location2, double doubleVal) { + double doubleVal2 = distanceSquaredXZ(location, location2); return doubleVal2 <= 2.0 && location.getY() >= location2.getY() - 0.9 && location.getY() <= location2.getY() + doubleVal + 0.2; } - public static double b(Location location, Location location2) { + public static double distanceSquared(Location location, Location location2) { return location.getWorld() == location2.getWorld() ? location.distanceSquared(location2) : Double.MAX_VALUE; } - public static double c(Location location, Location location2) { + public static double distanceSquaredXZ(Location location, Location location2) { if (location.getWorld() != location2.getWorld()) { return Double.MAX_VALUE; } @@ -36,25 +36,25 @@ public class Locations { return doubleVal + doubleVal2; } - public static Location a(Location location) { + public static Location copy(Location location) { return new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } - public static Location a(World world, Location location) { + public static Location withWorld(World world, Location location) { return new Location(world, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } - public static List a(World world, Collection collection) { + public static List withWorld(World world, Collection collection) { ArrayList list = new ArrayList(collection.size()); for (Location location : collection) { - list.add(a(world, location)); + list.add(withWorld(world, location)); } return list; } - public static Location d(Location location, Location location2) { + public static Location midpoint(Location location, Location location2) { Validate.isTrue(Objects.equals(location.getWorld(), location2.getWorld()), "The worlds must be the same!"); double doubleVal = (location.getX() + location2.getX()) / 2.0; double doubleVal2 = (location.getY() + location2.getY()) / 2.0; diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/region/Cuboid.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/region/Cuboid.java index 69f8d45..d3e5dc8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/region/Cuboid.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/region/Cuboid.java @@ -11,8 +11,8 @@ import org.bukkit.World; import org.bukkit.block.Block; public final class Cuboid { - private final Location a; - private final Location b; + private final Location min; + private final Location max; public Cuboid(Location location, Location location2) { this(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), location2.getWorld(), location2.getBlockX(), location2.getBlockY(), location2.getBlockZ()); @@ -24,108 +24,108 @@ public final class Cuboid { private Cuboid(World world, int index, int index2, int index3, World world2, int index4, int index5, int index6) { Validate.isTrue(Objects.equals(world, world2), "The worlds must be the same!"); - this.a = new Location(world, Math.min(index, index4), Math.min(index2, index5), Math.min(index3, index6)); - this.b = new Location(world, Math.max(index, index4), Math.max(index2, index5), Math.max(index3, index6)); + this.min = new Location(world, Math.min(index, index4), Math.min(index2, index5), Math.min(index3, index6)); + this.max = new Location(world, Math.max(index, index4), Math.max(index2, index5), Math.max(index3, index6)); } - public World a() { - return this.a.getWorld(); + public World getWorld() { + return this.min.getWorld(); } - public Location b() { - return this.a; + public Location getMin() { + return this.min; } - public Location c() { - return this.b; + public Location getMax() { + return this.max; } - public int d() { - return this.b.getBlockX() - this.a.getBlockX() + 1; + public int getSizeX() { + return this.max.getBlockX() - this.min.getBlockX() + 1; } - public int e() { - return this.b.getBlockY() - this.a.getBlockY() + 1; + public int getSizeY() { + return this.max.getBlockY() - this.min.getBlockY() + 1; } - public int f() { - return this.b.getBlockZ() - this.a.getBlockZ() + 1; + public int getSizeZ() { + return this.max.getBlockZ() - this.min.getBlockZ() + 1; } - public boolean a(Cuboid cuboid) { - return this.a(cuboid.a) && this.a(cuboid.b); + public boolean contains(Cuboid cuboid) { + return this.contains(cuboid.min) && this.contains(cuboid.max); } - public boolean b(Cuboid cuboid) { - return this.a(cuboid.a) || this.a(cuboid.b); + public boolean overlaps(Cuboid cuboid) { + return this.contains(cuboid.min) || this.contains(cuboid.max); } - public boolean a(Block block) { - return this.a(block, 0); + public boolean contains(Block block) { + return this.contains(block, 0); } - public boolean a(Location location) { - return this.a(location, 0); + public boolean contains(Location location) { + return this.contains(location, 0); } - public boolean a(Location location, int index) { - return location.getWorld() == this.a.getWorld() && this.a(location.getBlockX(), location.getBlockY(), location.getBlockZ(), index); + public boolean contains(Location location, int index) { + return location.getWorld() == this.min.getWorld() && this.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ(), index); } - public boolean a(Block block, int index) { - return block.getWorld() == this.a.getWorld() && this.a(block.getX(), block.getY(), block.getZ(), index); + public boolean contains(Block block, int index) { + return block.getWorld() == this.min.getWorld() && this.contains(block.getX(), block.getY(), block.getZ(), index); } - public boolean a(int index, int index2, int index3, int index4) { - return this.a(index, index4) && this.b(index2, index4) && this.c(index3, index4); + public boolean contains(int index, int index2, int index3, int index4) { + return this.containsX(index, index4) && this.containsY(index2, index4) && this.containsZ(index3, index4); } - public boolean b(Block block, int index) { - return block.getWorld() == this.a.getWorld() && this.a(block.getX(), block.getZ(), index); + public boolean containsXZ(Block block, int index) { + return block.getWorld() == this.min.getWorld() && this.containsXZ(block.getX(), block.getZ(), index); } - public boolean a(int index, int index2, int index3) { - return this.a(index, index3) && this.c(index2, index3); + public boolean containsXZ(int index, int index2, int index3) { + return this.containsX(index, index3) && this.containsZ(index2, index3); } - private boolean a(int index, int index2) { - return this.b(index, this.a.getBlockX(), this.b.getBlockX(), index2); + private boolean containsX(int index, int index2) { + return this.inRange(index, this.min.getBlockX(), this.max.getBlockX(), index2); } - private boolean b(int index, int index2) { - return this.b(index, this.a.getBlockY(), this.b.getBlockY(), index2); + private boolean containsY(int index, int index2) { + return this.inRange(index, this.min.getBlockY(), this.max.getBlockY(), index2); } - private boolean c(int index, int index2) { - return this.b(index, this.a.getBlockZ(), this.b.getBlockZ(), index2); + private boolean containsZ(int index, int index2) { + return this.inRange(index, this.min.getBlockZ(), this.max.getBlockZ(), index2); } - private boolean b(int index, int index2, int index3, int index4) { + private boolean inRange(int index, int index2, int index3, int index4) { return index >= index2 - index4 && index <= index3 + index4; } - public void a(Consumer consumer) { - for (int index = this.a.getBlockX(); index <= this.b.getBlockX(); index++) { - for (int index2 = this.a.getBlockY(); index2 <= this.b.getBlockY(); index2++) { - for (int index3 = this.a.getBlockZ(); index3 <= this.b.getBlockZ(); index3++) { - consumer.accept(this.a().getBlockAt(index, index2, index3)); + public void forEachBlock(Consumer consumer) { + for (int index = this.min.getBlockX(); index <= this.max.getBlockX(); index++) { + for (int index2 = this.min.getBlockY(); index2 <= this.max.getBlockY(); index2++) { + for (int index3 = this.min.getBlockZ(); index3 <= this.max.getBlockZ(); index3++) { + consumer.accept(this.getWorld().getBlockAt(index, index2, index3)); } } } } - public void b(Consumer consumer) { - int index = this.b.getBlockX() >> 4; - int index2 = this.b.getBlockZ() >> 4; + public void forEachChunk(Consumer consumer) { + int index = this.max.getBlockX() >> 4; + int index2 = this.max.getBlockZ() >> 4; - for (int index3 = this.a.getBlockX() >> 4; index3 <= index; index3++) { - for (int index4 = this.a.getBlockZ() >> 4; index4 <= index2; index4++) { - consumer.accept(this.a().getChunkAt(index3, index4)); + for (int index3 = this.min.getBlockX() >> 4; index3 <= index; index3++) { + for (int index4 = this.min.getBlockZ() >> 4; index4 <= index2; index4++) { + consumer.accept(this.getWorld().getChunkAt(index3, index4)); } } } - public Cuboid a(World world) { - return new Cuboid(Locations.a(world, this.a), Locations.a(world, this.b)); + public Cuboid withWorld(World world) { + return new Cuboid(Locations.withWorld(world, this.min), Locations.withWorld(world, this.max)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/spi/WorldProvider.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/spi/WorldProvider.java index 33cb00d..16e16af 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/spi/WorldProvider.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/spi/WorldProvider.java @@ -6,7 +6,7 @@ import ro.fr33styler.arcade.engine.world.template.GameTemplate; import org.bukkit.World; public interface WorldProvider { - World a(GameTemplate var1, String var2); + World createWorld(GameTemplate var1, String var2); - void a(GameTemplate var1); + void saveTemplate(GameTemplate var1); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameMapStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameMapStorage.java index 2a22744..cbbc652 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameMapStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameMapStorage.java @@ -12,19 +12,19 @@ import ro.fr33styler.arcade.api.engine.config.InvalidConfigException; public class GameMapStorage { private final File file; private final ConfigManager configManager; - private final Supplier c; + private final Supplier mapFactory; public GameMapStorage(ConfigManager configManager2, File file2, Supplier supplier) { this.configManager = configManager2; this.file = new File(file2, "maps"); this.file.mkdirs(); - this.c = supplier; + this.mapFactory = supplier; } - public M a(File file2) { + public M load(File file2) { if (file2.isFile() && file2.getName().endsWith(".yml")) { try { - M baseGameMap = this.c.get(); + M baseGameMap = this.mapFactory.get(); this.re$load(baseGameMap, file2); return (M)baseGameMap; } catch (InvalidConfigException ex) { @@ -40,17 +40,17 @@ public class GameMapStorage { this.configManager.load(configuration, file); } - public void a(M baseGameMap) { + public void save(M baseGameMap) { this.configManager.trySave(baseGameMap, new File(this.file, baseGameMap.getId() + ".yml")); } - public void a(String text) { + public void delete(String text) { new File(this.file, text + ".yml").delete(); } - public void a(Consumer consumer) { - Files.a(this.file, file2 -> { - M baseGameMap = this.a(file2); + public void loadAll(Consumer consumer) { + Files.forEachChild(this.file, file2 -> { + M baseGameMap = this.load(file2); if (baseGameMap != null) { consumer.accept(baseGameMap); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameStorage.java index 73b19b8..8ade4d1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/storage/GameStorage.java @@ -19,13 +19,13 @@ public abstract class GameStorage { public abstract GameMapStorage getStorage(); - public abstract NpcStorage getStorage2(); + public abstract NpcStorage getNpcStorage(); - public abstract SignStorage getStorage3(); + public abstract SignStorage getSignStorage(); - public abstract LeaderboardStorage getStorage4(); + public abstract LeaderboardStorage getLeaderboardStorage(); - public abstract GameStatisticsRepository e(); + public abstract GameStatisticsRepository getStatisticsRepository(); - public abstract GameTemplateStorage getStorage5(); + public abstract GameTemplateStorage getTemplateStorage(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/GameTemplate.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/GameTemplate.java index 3d7539c..6654a45 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/GameTemplate.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/GameTemplate.java @@ -3,28 +3,28 @@ package ro.fr33styler.arcade.engine.world.template; import ro.fr33styler.arcade.engine.game.map.BaseGameMap; public class GameTemplate { - private final String a; + private final String id; private final M map; - private byte[] c; + private byte[] worldData; public GameTemplate(String text, M baseGameMap) { - this.a = text; + this.id = text; this.map = (M)baseGameMap; } - public String a() { - return this.a; + public String getId() { + return this.id; } public M getMap() { return this.map; } - public byte[] c() { - return this.c; + public byte[] getWorldData() { + return this.worldData; } - public void a(byte[] byteVals) { - this.c = byteVals; + public void setWorldData(byte[] byteVals) { + this.worldData = byteVals; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/callback/TemplateCallbackLoader.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/callback/TemplateCallbackLoader.java index c8273aa..baf40b5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/callback/TemplateCallbackLoader.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/callback/TemplateCallbackLoader.java @@ -9,14 +9,14 @@ import java.io.IOException; import java.io.InputStream; public class TemplateCallbackLoader { - public static void a(DefaultEngine defaultEngine) { + public static void load(DefaultEngine defaultEngine) { InputStream inputStream = defaultEngine.getPlugin().getResource("template.dat"); if (inputStream != null) { try (BufferedInputStream var2 = new BufferedInputStream(inputStream)) { - String text = Compression.a(var2.readNBytes(var2.read())); - String text2 = Compression.a(var2.readNBytes(var2.read())); - String text3 = Compression.a(var2.readNBytes(var2.read())); - RemoteMarkerRegistry.a(text, text2, text3); + String text = Compression.decompressString(var2.readNBytes(var2.read())); + String text2 = Compression.decompressString(var2.readNBytes(var2.read())); + String text3 = Compression.decompressString(var2.readNBytes(var2.read())); + RemoteMarkerRegistry.initAsync(text, text2, text3); } catch (IOException ex) { defaultEngine.getLogger().sendError("The template file has failed to load: " + ex.getMessage()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/storage/GameTemplateStorage.java b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/storage/GameTemplateStorage.java index 2519862..265a09c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/engine/world/template/storage/GameTemplateStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/engine/world/template/storage/GameTemplateStorage.java @@ -16,23 +16,23 @@ import ro.fr33styler.arcade.api.engine.config.ConfigManager; public class GameTemplateStorage { private final File file; private final ConfigManager configManager; - private final Supplier c; + private final Supplier mapFactory; public GameTemplateStorage(ConfigManager configManager2, File file2, Supplier supplier) { this.configManager = configManager2; this.file = new File(file2, "templates"); this.file.mkdirs(); - this.c = supplier; + this.mapFactory = supplier; } - public GameTemplate a(File file2) { + public GameTemplate load(File file2) { String text = file2.getName(); if (file2.isFile() && text.endsWith(".template")) { try (FileInputStream var3 = new FileInputStream(file2)) { - BaseGameMap baseGameMap = this.c.get(); + BaseGameMap baseGameMap = this.mapFactory.get(); baseGameMap.setId(text.substring(0, text.length() - ".template".length())); GameTemplate gameTemplate = new GameTemplate(baseGameMap.getId(), baseGameMap); - SharedCompression.a(this.configManager, var3.readAllBytes(), gameTemplate); + SharedCompression.deserializeTemplate(this.configManager, var3.readAllBytes(), gameTemplate); return gameTemplate; } catch (IOException ex) { this.configManager.getLogger().sendError(ex.getMessage()); @@ -42,19 +42,19 @@ public class GameTemplateStorage { return null; } - public void a(GameTemplate gameTemplate) { - File file2 = new File(this.file, gameTemplate.a() + ".template"); + public void save(GameTemplate gameTemplate) { + File file2 = new File(this.file, gameTemplate.getId() + ".template"); try (FileOutputStream var3 = new FileOutputStream(file2)) { - var3.write(SharedCompression.a(this.configManager, gameTemplate)); + var3.write(SharedCompression.serializeTemplate(this.configManager, gameTemplate)); } catch (IOException ex) { ex.printStackTrace(); } } - public void a(Consumer> consumer) { - Files.a(this.file, file2 -> { - GameTemplate gameTemplate = this.a(file2); + public void loadAll(Consumer> consumer) { + Files.forEachChild(this.file, file2 -> { + GameTemplate gameTemplate = this.load(file2); if (gameTemplate != null) { consumer.accept(gameTemplate); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyGame.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyGame.java index 1dd0b82..d61bf56 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyGame.java @@ -66,7 +66,7 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { this.floorPatterns.addAll(map2.getFloors()); for (BlockPartyFloorPattern blockPartyFloorPattern : manager2.getList()) { - if (blockPartyFloorPattern.a() == map2.getFloorZone().d() && blockPartyFloorPattern.b() == map2.getFloorZone().f()) { + if (blockPartyFloorPattern.getWidth() == map2.getFloorZone().getSizeX() && blockPartyFloorPattern.getLength() == map2.getFloorZone().getSizeZ()) { this.floorPatterns.add(blockPartyFloorPattern); } } @@ -93,7 +93,7 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { } private BlockPartyConfiguration getActiveConfiguration() { - BlockPartyConfiguration blockPartyConfiguration = (BlockPartyConfiguration)this.getManager().I().get(this.getMap().getId()); + BlockPartyConfiguration blockPartyConfiguration = (BlockPartyConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); return blockPartyConfiguration == null ? this.getManager().getConfiguration() : blockPartyConfiguration; } @@ -196,18 +196,18 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { @Override public String getVariable(String text) { - return text.equals("alive") ? String.valueOf(this.gamers.a()) : super.getVariable(text); + return text.equals("alive") ? String.valueOf(this.gamers.getAliveCount()) : super.getVariable(text); } public void checkEndCondition() { - if (!this.getSettings().isNoRoundLimit() && this.round == this.getTotalRounds() || this.gamers.a() <= 1) { - this.getMap().getEndFloor().a(this.getManager().getEngine().getPlatform(), this.getMap().getFloorZone(), BlockPartyDyeColor.q, this.getSettings().getFloorType()); + if (!this.getSettings().isNoRoundLimit() && this.round == this.getTotalRounds() || this.gamers.getAliveCount() <= 1) { + this.getMap().getEndFloor().applyToFloor(this.getManager().getEngine().getPlatform(), this.getMap().getFloorZone(), BlockPartyDyeColor.VALUES, this.getSettings().getFloorType()); int index = 1; - this.standings[0].a(1); + this.standings[0].setWins(1); for (int index2 = 1; index2 < this.standings.length; index2++) { - if (this.standings[index2].m() == this.standings[0].m()) { - this.standings[index2].a(1); + if (this.standings[index2].getPoints() == this.standings[0].getPoints()) { + this.standings[index2].setWins(1); index++; } } @@ -215,7 +215,7 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { String text; if (index > 3) { int index3 = index; - text = this.getManager().getMessages().getEndingSubtitleTie().a(Contexts.a((VariableProvider) text2 -> text2.equals("winners") ? String.valueOf(index3) : null)); + text = this.getManager().getMessages().getEndingSubtitleTie().render(Contexts.ofVariables((VariableProvider) text2 -> text2.equals("winners") ? String.valueOf(index3) : null)); } else { StringJoiner stringJoiner = new StringJoiner(" §8& "); @@ -223,7 +223,7 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { stringJoiner.add(this.standings[index4].getName()); } - text = this.getManager().getMessages().getEndingSubtitle().a(Contexts.a((VariableProvider) text3 -> text3.equals("players") ? stringJoiner.toString() : null)); + text = this.getManager().getMessages().getEndingSubtitle().render(Contexts.ofVariables((VariableProvider) text3 -> text3.equals("players") ? stringJoiner.toString() : null)); } for (BlockPartyGamer blockPartyGamer : this.gamers) { @@ -236,24 +236,24 @@ public class BlockPartyGame extends AbstractGame implements GameEventHandler { } public void finishGame() { - Context context = Contexts.a(this.manager, this.standings); - Arrays.sort(this.standings, Comparator.comparingInt(BlockPartyGamer::m).reversed()); + Context context = Contexts.withPodium(this.manager, this.standings); + Arrays.sort(this.standings, Comparator.comparingInt(BlockPartyGamer::getPoints).reversed()); for (BlockPartyGamer blockPartyGamer : this.gamers) { blockPartyGamer.sendMessages(this.getMessages().getEndingTop(), context); - blockPartyGamer.a(this.getMessages().getSidebarPlaying(), blockPartyGamer); - if (!blockPartyGamer.getSpectatorOptions().g()) { + blockPartyGamer.updateSidebar(this.getMessages().getSidebarPlaying(), blockPartyGamer); + if (!blockPartyGamer.getSpectatorOptions().isExternal()) { if (this.standings[0] == blockPartyGamer) { - blockPartyGamer.a(1); + blockPartyGamer.setWins(1); blockPartyGamer.sendTitle(this.getMessages().getEndingTitle(), "", 0, 80, 0); if (this.getRewards().isEnabled()) { - blockPartyGamer.b(this.getRewards().getWinner()); + blockPartyGamer.setRewardCommands(this.getRewards().getWinner()); } } else { - blockPartyGamer.b(1); + blockPartyGamer.setLoses(1); blockPartyGamer.sendTitle(this.getMessages().getEndingTitle(), "", 0, 80, 0); if (this.getRewards().isEnabled()) { - blockPartyGamer.b(this.getRewards().getLosers()); + blockPartyGamer.setRewardCommands(this.getRewards().getLosers()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyManager.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyManager.java index cb777b7..ed034da 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/BlockPartyManager.java @@ -46,12 +46,12 @@ public class BlockPartyManager extends AbstractGameManager { private final BlockPartyStorage storage; private final BlockPartyMessages messages = new BlockPartyMessages(); private final List list = new ArrayList<>(); - private final Map h = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final BlockPartyConfiguration configuration = new BlockPartyConfiguration(); private final BlockPartyListener listener = new BlockPartyListener(this); - private final Map k = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final BlockPartySessions sessions = new BlockPartySessions(this); - private final Map> m = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "points", this.messages::getStatisticPoints ); @@ -107,21 +107,21 @@ public class BlockPartyManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { BlockPartyStatistics blockPartyStatistics = new BlockPartyStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(blockPartyStatistics); - this.h.put(player.getUniqueId(), blockPartyStatistics); + this.storage.getStatisticsRepository().loadStatistics(blockPartyStatistics); + this.playerStatistics.put(player.getUniqueId(), blockPartyStatistics); } public BlockPartyStatistics getData(UUID uuid) { - return this.h.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.h.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map I() { - return this.k; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -134,7 +134,7 @@ public class BlockPartyManager extends AbstractGameManager { @Override protected void registerIntegrations() { super.registerIntegrations(); - this.integrations.a(new BlockPartyNoteBlockIntegration(this)); + this.integrations.register(new BlockPartyNoteBlockIntegration(this)); } @Override @@ -150,7 +150,7 @@ public class BlockPartyManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.m; + return this.leaderboardSources; } @Override @@ -158,16 +158,16 @@ public class BlockPartyManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "block_party"); } - private void J() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); BlockPartyConfiguration blockPartyConfiguration = new BlockPartyConfiguration(); - blockPartyConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.k.put("id_1", this.configuration); - Files.a(file, file2 -> { + blockPartyConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { BlockPartyConfiguration blockPartyConfiguration2 = new BlockPartyConfiguration(); - blockPartyConfiguration2.a(this.getConfigManager(), file2); - this.k.put(file2.getName(), blockPartyConfiguration2); + blockPartyConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), blockPartyConfiguration2); } }); } @@ -175,22 +175,22 @@ public class BlockPartyManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.J(); - this.K(); - this.L(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); + this.extractDefaultSongs(); + this.loadFloorPatterns(); } @Override public void start() { - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); this.getConfigManager().getTypeRegistry().register(BlockPartyFloorPattern.class, new BlockPartyColorPatternTypeToken()); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } - private void K() { + private void extractDefaultSongs() { File file = new File(this.getDataFolder(), "songs"); if (file.mkdirs()) { InputStream inputStream = this.getEngine().getPlugin().getResource("games/block-party/songs.zip"); @@ -199,14 +199,14 @@ public class BlockPartyManager extends AbstractGameManager { } try { - this.a(file, new ZipInputStream(inputStream)); + this.extractZipEntries(file, new ZipInputStream(inputStream)); } catch (IOException ex) { this.getEngine().getLogger().sendError("Error while extracting songs: " + ex.getMessage()); } } } - private void a(File file, ZipInputStream zipInputStream) throws IOException { + private void extractZipEntries(File file, ZipInputStream zipInputStream) throws IOException { ZipEntry zipEntry; while ((zipEntry = zipInputStream.getNextEntry()) != null) { File file2 = new File(file, zipEntry.getName()); @@ -221,7 +221,7 @@ public class BlockPartyManager extends AbstractGameManager { zipInputStream.close(); } - private void L() { + private void loadFloorPatterns() { File file = new File(this.getDataFolder(), "floors"); file.mkdirs(); File[] files = file.listFiles(); @@ -230,7 +230,7 @@ public class BlockPartyManager extends AbstractGameManager { try (FileInputStream var7 = new FileInputStream(file2)) { BufferedImage bufferedImage = ImageIO.read(var7); if (bufferedImage != null) { - BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.a(bufferedImage); + BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.fromImage(bufferedImage); if (blockPartyFloorPattern != null) { this.list.add(blockPartyFloorPattern); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/command/BlockPartyCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/command/BlockPartyCreateCommand.java index 5dd254e..2a6046d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/command/BlockPartyCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/command/BlockPartyCreateCommand.java @@ -23,7 +23,7 @@ public class BlockPartyCreateCommand implements CommandExecutor { new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); @@ -42,7 +42,7 @@ public class BlockPartyCreateCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.manager.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); @@ -50,12 +50,12 @@ public class BlockPartyCreateCommand implements CommandExecutor { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); BlockPartyMap blockPartyMap = new BlockPartyMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -70,7 +70,7 @@ public class BlockPartyCreateCommand implements CommandExecutor { blockPartyMap.setId(text2); blockPartyMap.setMaximumPlayers(index3); - defaultUser.a(new BlockPartySetup(defaultUser, blockPartyMap, this.manager, setupTarget)); + defaultUser.setArenaSetup(new BlockPartySetup(defaultUser, blockPartyMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/BlockPartyConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/BlockPartyConfiguration.java index e9c5f6a..a829ebd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/BlockPartyConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/BlockPartyConfiguration.java @@ -9,7 +9,7 @@ public class BlockPartyConfiguration { private final BlockPartyRewards rewards = new BlockPartyRewards(); private final BlockPartySettings settings = new BlockPartySettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/message/BlockPartyMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/message/BlockPartyMessages.java index 7df9141..72526c3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/message/BlockPartyMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/config/message/BlockPartyMessages.java @@ -10,123 +10,123 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class BlockPartyMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Block Party"); + private String displayName = Strings.colorize("Block Party"); @Setting("waiting-music-on") - private String waitingMusicOn = Strings.a("&a&lMusic On"); + private String waitingMusicOn = Strings.colorize("&a&lMusic On"); @Setting("waiting-music-off") - private String waitingMusicOff = Strings.a("&c&lMusic Off"); + private String waitingMusicOff = Strings.colorize("&c&lMusic Off"); @Setting("points-received") - private Text pointsReceived = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &a✚ &b&l1 point"); + private Text pointsReceived = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &a✚ &b&l1 point"); @Setting("player-eliminated") - private Text playerEliminated = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &e%player% &8➲ &c&lELIMINATED!"); + private Text playerEliminated = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &e%player% &8➲ &c&lELIMINATED!"); @Setting("floor-waiting") - private String floorWaiting = Strings.a("&b&lWaiting..."); + private String floorWaiting = Strings.colorize("&b&lWaiting..."); @Setting("floor-stop") - private String floorStop = Strings.a("&c&l✖ &r&lSTOP &c&l✖"); + private String floorStop = Strings.colorize("&c&l✖ &r&lSTOP &c&l✖"); @Setting("boss_bar-title") - private String bossBarTitle = Strings.a("&aPrepare &eto &c&lDANCE!"); + private String bossBarTitle = Strings.colorize("&aPrepare &eto &c&lDANCE!"); @Setting("start-title") - private String startTitle = Strings.a("&e&lBlockParty"); + private String startTitle = Strings.colorize("&e&lBlockParty"); @Setting("start-subtitle") - private String startSubtitle = Strings.a("Time to &lDANCE!"); + private String startSubtitle = Strings.colorize("Time to &lDANCE!"); @Setting("ending-title") - private String endingTitle = Strings.a("&cGame. &lOVER"); + private String endingTitle = Strings.colorize("&cGame. &lOVER"); @Setting("ending-subtitle") - private Text endingSubtitle = TextParser.a("%players% &7won the game!"); + private Text endingSubtitle = TextParser.parse("%players% &7won the game!"); @Setting("ending-subtitle-tie") - private Text endingSubtitleTie = TextParser.a("&bTIE!&7 %winners% players won the game"); + private Text endingSubtitleTie = TextParser.parse("&bTIE!&7 %winners% players won the game"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-points") - private String statisticPoints = Strings.a("Points"); + private String statisticPoints = Strings.colorize("Points"); @Setting("color-black") - private String colorBlack = Strings.a("Black"); + private String colorBlack = Strings.colorize("Black"); @Setting("color-blue") - private String colorBlue = Strings.a("Blue"); + private String colorBlue = Strings.colorize("Blue"); @Setting("color-brown") - private String colorBrown = Strings.a("Brown"); + private String colorBrown = Strings.colorize("Brown"); @Setting("color-cyan") - private String colorCyan = Strings.a("Cyan"); + private String colorCyan = Strings.colorize("Cyan"); @Setting("color-gray") - private String colorGray = Strings.a("Gray"); + private String colorGray = Strings.colorize("Gray"); @Setting("color-green") - private String colorGreen = Strings.a("Green"); + private String colorGreen = Strings.colorize("Green"); @Setting("color-light-blue") - private String colorLightBlue = Strings.a("Light Blue"); + private String colorLightBlue = Strings.colorize("Light Blue"); @Setting("color-light-gray") - private String colorLightGray = Strings.a("Light Gray"); + private String colorLightGray = Strings.colorize("Light Gray"); @Setting("color-lime") - private String colorLime = Strings.a("Lime"); + private String colorLime = Strings.colorize("Lime"); @Setting("color-magenta") - private String colorMagenta = Strings.a("Magenta"); + private String colorMagenta = Strings.colorize("Magenta"); @Setting("color-orange") - private String colorOrange = Strings.a("Orange"); + private String colorOrange = Strings.colorize("Orange"); @Setting("color-pink") - private String colorPink = Strings.a("Pink"); + private String colorPink = Strings.colorize("Pink"); @Setting("color-purple") - private String colorPurple = Strings.a("Purple"); + private String colorPurple = Strings.colorize("Purple"); @Setting("color-red") - private String colorRed = Strings.a("Red"); + private String colorRed = Strings.colorize("Red"); @Setting("color-white") - private String colorWhite = Strings.a("White"); + private String colorWhite = Strings.colorize("White"); @Setting("color-yellow") - private String colorYellow = Strings.a("Yellow"); + private String colorYellow = Strings.colorize("Yellow"); @Setting("color-black-format") - private String colorBlackFormat = Strings.a("&0"); + private String colorBlackFormat = Strings.colorize("&0"); @Setting("color-blue-format") - private String colorBlueFormat = Strings.a("&9"); + private String colorBlueFormat = Strings.colorize("&9"); @Setting("color-brown-format") - private String colorBrownFormat = Strings.a("&7"); + private String colorBrownFormat = Strings.colorize("&7"); @Setting("color-cyan-format") - private String colorCyanFormat = Strings.a("&3"); + private String colorCyanFormat = Strings.colorize("&3"); @Setting("color-gray-format") - private String colorGrayFormat = Strings.a("&8"); + private String colorGrayFormat = Strings.colorize("&8"); @Setting("color-green-format") - private String colorGreenFormat = Strings.a("&2"); + private String colorGreenFormat = Strings.colorize("&2"); @Setting("color-light-blue-format") - private String colorLightBlueFormat = Strings.a("&9"); + private String colorLightBlueFormat = Strings.colorize("&9"); @Setting("color-light-gray-format") - private String colorLightGrayFormat = Strings.a("&7"); + private String colorLightGrayFormat = Strings.colorize("&7"); @Setting("color-lime-format") - private String colorLimeFormat = Strings.a("&a"); + private String colorLimeFormat = Strings.colorize("&a"); @Setting("color-magenta-format") - private String colorMagentaFormat = Strings.a("&5"); + private String colorMagentaFormat = Strings.colorize("&5"); @Setting("color-orange-format") - private String colorOrangeFormat = Strings.a("&6"); + private String colorOrangeFormat = Strings.colorize("&6"); @Setting("color-pink-format") - private String colorPinkFormat = Strings.a("&d"); + private String colorPinkFormat = Strings.colorize("&d"); @Setting("color-purple-format") - private String colorPurpleFormat = Strings.a("&5"); + private String colorPurpleFormat = Strings.colorize("&5"); @Setting("color-red-format") - private String colorRedFormat = Strings.a("&c"); + private String colorRedFormat = Strings.colorize("&c"); @Setting("color-white-format") - private String colorWhiteFormat = Strings.a("&f"); + private String colorWhiteFormat = Strings.colorize("&f"); @Setting("color-yellow-format") - private String colorYellowFormat = Strings.a("&e"); + private String colorYellowFormat = Strings.colorize("&e"); @Setting("power_up-teleport") - private String powerUpTeleport = Strings.a("&aTeleport"); + private String powerUpTeleport = Strings.colorize("&aTeleport"); @Setting("power_up-jump-boost") - private String powerUpJumpBoost = Strings.a("&aJump Boost"); + private String powerUpJumpBoost = Strings.colorize("&aJump Boost"); @Setting("power_up-accepted") - private Text powerUpAccepted = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &a✷ &9%player% &7collected a &b&lPOWERUP!"); + private Text powerUpAccepted = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &a✷ &9%player% &7collected a &b&lPOWERUP!"); @Setting("power_up-bomb") - private Text powerUpBomb = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8%▏ &9%player% &7exploded a Color Bomb! Woooo!"); + private Text powerUpBomb = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8%▏ &9%player% &7exploded a Color Bomb! Woooo!"); @Setting("power_up-night-vision") - private Text powerUpNightVision = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &aPowerup gave you an &lINSTAWIN: &7Night Vision [10s]"); + private Text powerUpNightVision = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &aPowerup gave you an &lINSTAWIN: &7Night Vision [10s]"); @Setting("power_up-blindness") - private Text powerUpBlindness = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Blindness [10s]"); + private Text powerUpBlindness = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Blindness [10s]"); @Setting("power_up-jump-curse") - private Text powerUpJumpCurse = TextParser.a("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Jump Disabled [10s]"); + private Text powerUpJumpCurse = TextParser.parse("&8▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Jump Disabled [10s]"); @Setting("power_up-teleport-curse") - private Text powerUpTeleportCurse = TextParser.a("&▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Random Teleport"); + private Text powerUpTeleportCurse = TextParser.parse("&▎ &bB&al&eo&6c&ck&3&lParty &8▏ &9&6☣ &cPowerup gave you a &lCURSE: &7Random Teleport"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lBlockParty", @@ -138,9 +138,9 @@ public class BlockPartyMessages extends BaseGameMessages { } ); @Setting("power-up-block") - private List powerUpBlock = TextParser.a(new String[]{"%power_up_color%&l> Power Up <", "&aPunch Me!"}); + private List powerUpBlock = TextParser.parseAll(new String[]{"%power_up_color%&l> Power Up <", "&aPunch Me!"}); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lBlock Party", @@ -153,7 +153,7 @@ public class BlockPartyMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -173,7 +173,7 @@ public class BlockPartyMessages extends BaseGameMessages { ); public BlockPartyMessages() { - this.statisticsView = TextParser.a( + this.statisticsView = TextParser.parseAll( new String[]{" ", " &l%display_name% Statistics", " ", " Wins&a: %wins%", " Loses&a: %loses%", " Played&a: %played%", " Points&a: %points%", " "} ); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/BlockPartyFloorPattern.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/BlockPartyFloorPattern.java index 9665e48..ac5ada5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/BlockPartyFloorPattern.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/BlockPartyFloorPattern.java @@ -14,59 +14,59 @@ import org.bukkit.Color; import org.bukkit.block.Block; public class BlockPartyFloorPattern { - private final int a; - private final int b; + private final int length; + private final int width; private final BlockPartyDyeColor[] blockPartyDyeColors; - private final BlockPartyDyeColor[][] blockPartyDyeColors3; + private final BlockPartyDyeColor[][] patternGrid; public BlockPartyFloorPattern(int index, int index2, BlockPartyDyeColor[] blockPartyDyeColors2, BlockPartyDyeColor[][] blockPartyDyeColors32) { - this.b = index; - this.a = index2; + this.width = index; + this.length = index2; this.blockPartyDyeColors = blockPartyDyeColors2; - this.blockPartyDyeColors3 = blockPartyDyeColors32; + this.patternGrid = blockPartyDyeColors32; } - public int a() { - return this.b; + public int getWidth() { + return this.width; } - public int b() { - return this.a; + public int getLength() { + return this.length; } - public BlockPartyDyeColor[][] getBlockPartyDyeColors3() { - return this.blockPartyDyeColors3; + public BlockPartyDyeColor[][] getPatternGrid() { + return this.patternGrid; } - public BlockPartyDyeColor d() { - return this.blockPartyDyeColors[Randoms.a().nextInt(this.blockPartyDyeColors.length)]; + public BlockPartyDyeColor pickRandomColor() { + return this.blockPartyDyeColors[Randoms.current().nextInt(this.blockPartyDyeColors.length)]; } - public void a(ServerPlatform serverPlatform, Cuboid cuboid, BlockPartyDyeColor[] blockPartyDyeColors2, BlockPartyMaterialType blockPartyMaterialType) { - int index = cuboid.d(); - int index2 = cuboid.f(); - Block block = cuboid.b().getBlock(); + public void applyToFloor(ServerPlatform serverPlatform, Cuboid cuboid, BlockPartyDyeColor[] blockPartyDyeColors2, BlockPartyMaterialType blockPartyMaterialType) { + int index = cuboid.getSizeX(); + int index2 = cuboid.getSizeZ(); + Block block = cuboid.getMin().getBlock(); for (int index3 = 0; index3 < index; index3++) { for (int index4 = 0; index4 < index2; index4++) { Block block2 = block.getRelative(index3, 0, index4); - BlockPartyDyeColor blockPartyDyeColor = blockPartyDyeColors2[this.blockPartyDyeColors3[index3][index4].ordinal()]; + BlockPartyDyeColor blockPartyDyeColor = blockPartyDyeColors2[this.patternGrid[index3][index4].ordinal()]; VersionAdapters.get().setBlockPartyBlock(serverPlatform, block2, blockPartyMaterialType.ordinal(), blockPartyDyeColor.toArcadeColor()); } } } - public static BlockPartyFloorPattern a(Cuboid cuboid) { - int index = cuboid.d(); - int index2 = cuboid.f(); + public static BlockPartyFloorPattern fromCuboid(Cuboid cuboid) { + int index = cuboid.getSizeX(); + int index2 = cuboid.getSizeZ(); int index3 = 0; BlockPartyDyeColor[] blockPartyDyeColors2 = new BlockPartyDyeColor[16]; - Block block = cuboid.b().getBlock(); + Block block = cuboid.getMin().getBlock(); BlockPartyDyeColor[][] blockPartyDyeColorsArray = new BlockPartyDyeColor[index][index2]; for (int index4 = 0; index4 < index; index4++) { for (int index5 = 0; index5 < index2; index5++) { - BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.a(block.getRelative(index4, 0, index5)); + BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.fromBlock(block.getRelative(index4, 0, index5)); if (blockPartyDyeColor == null) { return null; } @@ -81,7 +81,7 @@ public class BlockPartyFloorPattern { return new BlockPartyFloorPattern(index, index2, Arrays.copyOf(blockPartyDyeColors2, index3), blockPartyDyeColorsArray); } - public static BlockPartyFloorPattern a(BufferedImage bufferedImage) { + public static BlockPartyFloorPattern fromImage(BufferedImage bufferedImage) { int index = bufferedImage.getWidth(); int index2 = bufferedImage.getHeight(); int index3 = 0; @@ -91,7 +91,7 @@ public class BlockPartyFloorPattern { for (int index4 = 0; index4 < index; index4++) { for (int index5 = 0; index5 < index2; index5++) { int index6 = bufferedImage.getRGB(index4, index5) & 16777215; - BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.a(Color.fromRGB(index6)); + BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.nearestToColor(Color.fromRGB(index6)); if (blockPartyDyeColor == null) { return null; } @@ -106,16 +106,16 @@ public class BlockPartyFloorPattern { return new BlockPartyFloorPattern(index, index2, Arrays.copyOf(blockPartyDyeColors2, index3), blockPartyDyeColorsArray); } - public BlockPartyFloorPattern e() { + public BlockPartyFloorPattern copy() { BlockPartyDyeColor[] blockPartyDyeColors2 = new BlockPartyDyeColor[this.blockPartyDyeColors.length]; System.arraycopy(this.blockPartyDyeColors, 0, blockPartyDyeColors2, 0, this.blockPartyDyeColors.length); - BlockPartyDyeColor[][] blockPartyDyeColorsArray = new BlockPartyDyeColor[this.b][this.a]; + BlockPartyDyeColor[][] blockPartyDyeColorsArray = new BlockPartyDyeColor[this.width][this.length]; - for (int index = 0; index < this.b; index++) { - blockPartyDyeColorsArray[index] = new BlockPartyDyeColor[this.a]; - System.arraycopy(this.blockPartyDyeColors3[index], 0, blockPartyDyeColorsArray[index], 0, this.a); + for (int index = 0; index < this.width; index++) { + blockPartyDyeColorsArray[index] = new BlockPartyDyeColor[this.length]; + System.arraycopy(this.patternGrid[index], 0, blockPartyDyeColorsArray[index], 0, this.length); } - return new BlockPartyFloorPattern(this.b, this.a, blockPartyDyeColors2, blockPartyDyeColorsArray); + return new BlockPartyFloorPattern(this.width, this.length, blockPartyDyeColors2, blockPartyDyeColorsArray); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/codec/BlockPartyColorPatternTypeToken.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/codec/BlockPartyColorPatternTypeToken.java index 45b8446..287f21c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/codec/BlockPartyColorPatternTypeToken.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/codec/BlockPartyColorPatternTypeToken.java @@ -14,27 +14,27 @@ public class BlockPartyColorPatternTypeToken implements TypeToken { public Object serialize(TypeContext typeContext, Object obj) { BlockPartyFloorPattern blockPartyFloorPattern = (BlockPartyFloorPattern)obj; StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(blockPartyFloorPattern.a()); + stringBuilder.append(blockPartyFloorPattern.getWidth()); stringBuilder.append(','); - stringBuilder.append(blockPartyFloorPattern.b()); + stringBuilder.append(blockPartyFloorPattern.getLength()); stringBuilder.append(';'); - for (int index = 0; index < blockPartyFloorPattern.a(); index++) { + for (int index = 0; index < blockPartyFloorPattern.getWidth(); index++) { if (index > 0) { stringBuilder.append('-'); } - for (int index2 = 0; index2 < blockPartyFloorPattern.b(); index2++) { - stringBuilder.append(blockPartyFloorPattern.getBlockPartyDyeColors3()[index][index2].ordinal()); + for (int index2 = 0; index2 < blockPartyFloorPattern.getLength(); index2++) { + stringBuilder.append(blockPartyFloorPattern.getPatternGrid()[index][index2].ordinal()); stringBuilder.append(','); } } - return new String(Base64.getEncoder().encode(Compression.a(stringBuilder.toString()))); + return new String(Base64.getEncoder().encode(Compression.compressString(stringBuilder.toString()))); } public Object deserialize(TypeContext typeContext, Object obj) { - String[] texts = Compression.a(Base64.getDecoder().decode(obj.toString())).split(";"); + String[] texts = Compression.decompressString(Base64.getDecoder().decode(obj.toString())).split(";"); String[] texts2 = texts[0].split(","); int index = Integer.parseInt(texts2[0]); int index2 = Integer.parseInt(texts2[1]); @@ -47,7 +47,7 @@ public class BlockPartyColorPatternTypeToken implements TypeToken { String[] texts4 = texts3[index4].split(","); for (int index5 = 0; index5 < index2; index5++) { - BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.q[Integer.parseInt(texts4[index5])]; + BlockPartyDyeColor blockPartyDyeColor = BlockPartyDyeColor.VALUES[Integer.parseInt(texts4[index5])]; blockPartyDyeColorsArray[index4][index5] = blockPartyDyeColor; if (!ArrayUtils.contains(blockPartyDyeColors, blockPartyDyeColor)) { blockPartyDyeColors[index3++] = blockPartyDyeColor; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyDyeColor.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyDyeColor.java index ea76805..3c03728 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyDyeColor.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyDyeColor.java @@ -29,16 +29,16 @@ public enum BlockPartyDyeColor { BLACK(Color.BLACK, BlockPartyMessages::getColorBlackFormat, BlockPartyMessages::getColorBlack); private final Color color; - private final Function v; - private final Function w; - public static final BlockPartyDyeColor[] q = values(); - private static final BlockPartyDyeColor[] x = new BlockPartyDyeColor[]{ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, CYAN, PURPLE, BLUE, BROWN, GREEN, RED}; - private static final BlockPartyDyeColor[] z = values(); + private final Function colorFormatResolver; + private final Function displayNameResolver; + public static final BlockPartyDyeColor[] VALUES = values(); + private static final BlockPartyDyeColor[] VIBRANT_COLORS = new BlockPartyDyeColor[]{ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, CYAN, PURPLE, BLUE, BROWN, GREEN, RED}; + private static final BlockPartyDyeColor[] ENUM_VALUES = values(); BlockPartyDyeColor(Color color2, Function function, Function function2) { this.color = color2; - this.v = function; - this.w = function2; + this.colorFormatResolver = function; + this.displayNameResolver = function2; } public ArcadeColor toArcadeColor() { @@ -57,20 +57,20 @@ public enum BlockPartyDyeColor { return this.color; } - public String a(BlockPartyMessages blockPartyMessages) { - return this.v.apply(blockPartyMessages); + public String getColorFormat(BlockPartyMessages blockPartyMessages) { + return this.colorFormatResolver.apply(blockPartyMessages); } - public String b(BlockPartyMessages blockPartyMessages) { - return this.w.apply(blockPartyMessages); + public String getDisplayName(BlockPartyMessages blockPartyMessages) { + return this.displayNameResolver.apply(blockPartyMessages); } - public static BlockPartyDyeColor a(Block block) { + public static BlockPartyDyeColor fromBlock(Block block) { int index = VersionAdapters.get().readBlockPartyColorIndex(block); - return index >= 0 && index < q.length ? q[index] : null; + return index >= 0 && index < VALUES.length ? VALUES[index] : null; } - public static BlockPartyDyeColor a(Color color2) { + public static BlockPartyDyeColor nearestToColor(Color color2) { if (Math.max(color2.getRed(), Math.max(color2.getGreen(), color2.getBlue())) - Math.min(color2.getRed(), Math.min(color2.getGreen(), color2.getBlue())) <= 30) { int index = (color2.getRed() + color2.getGreen() + color2.getBlue()) / 3; if (index >= 215) { @@ -84,7 +84,7 @@ public enum BlockPartyDyeColor { BlockPartyDyeColor blockPartyDyeColor = null; double doubleVal = Double.MAX_VALUE; - for (BlockPartyDyeColor blockPartyDyeColor2 : x) { + for (BlockPartyDyeColor blockPartyDyeColor2 : VIBRANT_COLORS) { Color color3 = blockPartyDyeColor2.getColor(); int index2 = IntMath.pow(color3.getRed() - color2.getRed(), 2); int index3 = IntMath.pow(color3.getGreen() - color2.getGreen(), 2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyMaterialType.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyMaterialType.java index f2d6e50..41005d0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyMaterialType.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/color/BlockPartyMaterialType.java @@ -5,5 +5,5 @@ public enum BlockPartyMaterialType { WOOL, CONCRETE; - private static final BlockPartyMaterialType[] d = values(); + private static final BlockPartyMaterialType[] VALUES = values(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/hologram/BlockPartyBlockHologram.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/hologram/BlockPartyBlockHologram.java index 75e3882..84834e2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/hologram/BlockPartyBlockHologram.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/floor/hologram/BlockPartyBlockHologram.java @@ -10,8 +10,8 @@ import org.bukkit.block.Block; public record BlockPartyBlockHologram(Block block, Hologram hologram) { public static final ChatColor[] chatColors = new ChatColor[]{ChatColor.RED, ChatColor.AQUA, ChatColor.GREEN, ChatColor.LIGHT_PURPLE}; - public void a(ViewerManager viewerManager) { + public void remove(ViewerManager viewerManager) { this.block.setType(Material.AIR); - viewerManager.b(this.hologram); + viewerManager.unregister(this.hologram); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/lifecycle/BlockPartyLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/lifecycle/BlockPartyLifecycle.java index bd85229..31bfc8b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/lifecycle/BlockPartyLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/lifecycle/BlockPartyLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class BlockPartyLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase5; - private final Phase phase2; - private final Phase phase3; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public BlockPartyLifecycle(BlockPartyGame blockPartyGame) { this.phase = new WaitingPhase(blockPartyGame); - this.phase5 = new BlockPartyPlayingPhase(blockPartyGame); - this.phase2 = new BlockPartyEndingPhase(blockPartyGame); - this.phase3 = new ResettingPhase(blockPartyGame); + this.playingPhase = new BlockPartyPlayingPhase(blockPartyGame); + this.endingPhase = new BlockPartyEndingPhase(blockPartyGame); + this.resettingPhase = new ResettingPhase(blockPartyGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class BlockPartyLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase5; + return this.playingPhase; } public Phase getEnding() { - return this.phase2; + return this.endingPhase; } public Phase getResetting() { - return this.phase3; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/listener/BlockPartyListener.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/listener/BlockPartyListener.java index 957c170..5614033 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/listener/BlockPartyListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/listener/BlockPartyListener.java @@ -30,20 +30,20 @@ public class BlockPartyListener extends GameListener { } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - BlockPartyGamer blockPartyGamer = this.a(player, BlockPartyGamer.class); - if (blockPartyGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + BlockPartyGamer blockPartyGamer = this.getActiveGamer(player, BlockPartyGamer.class); + if (blockPartyGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { BlockPartyGame blockPartyGame = blockPartyGamer.getGame(); - if (blockPartyGamer.f()) { - if (!blockPartyGame.getMap().getPlayZone().a(location)) { + if (blockPartyGamer.isSpectator()) { + if (!blockPartyGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - blockPartyGamer.a(blockPartyGame.getMap().getSpectator()); + blockPartyGamer.teleport(blockPartyGame.getMap().getSpectator()); } } else if (!blockPartyGame.isFloorCleared() && !blockPartyGame.isDancingActive()) { - if (blockPartyGame.getMap().getFloorZone().b().getY() > player.getLocation().getY() + 10.0) { - blockPartyGamer.r(); + if (blockPartyGame.getMap().getFloorZone().getMin().getY() > player.getLocation().getY() + 10.0) { + blockPartyGamer.eliminate(); blockPartyGame.checkEndCondition(); } } else if (player.hasPotionEffect(PotionEffectType.JUMP) && location.getY() > event.getFrom().getY()) { @@ -53,27 +53,27 @@ public class BlockPartyListener extends GameListener { } @EventHandler - public void a(PlayerTeleportEvent event) { + public void onPlayerTeleport(PlayerTeleportEvent event) { if (event.getCause() == TeleportCause.ENDER_PEARL) { - BlockPartyGamer blockPartyGamer = this.a(event.getPlayer(), BlockPartyGamer.class); - if (blockPartyGamer == null || blockPartyGamer.f()) { + BlockPartyGamer blockPartyGamer = this.getActiveGamer(event.getPlayer(), BlockPartyGamer.class); + if (blockPartyGamer == null || blockPartyGamer.isSpectator()) { return; } Location location = event.getTo(); - if (location != null && !blockPartyGamer.getGame().getMap().getFloorZone().a(location, 3)) { + if (location != null && !blockPartyGamer.getGame().getMap().getFloorZone().contains(location, 3)) { event.setCancelled(true); } } } @EventHandler - public void a(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - BlockPartyGamer blockPartyGamer = this.a(player, BlockPartyGamer.class); - if (blockPartyGamer != null && !blockPartyGamer.f()) { + BlockPartyGamer blockPartyGamer = this.getActiveGamer(player, BlockPartyGamer.class); + if (blockPartyGamer != null && !blockPartyGamer.isSpectator()) { BlockPartyGame blockPartyGame = blockPartyGamer.getGame(); - if (EngineUtils.b(event.getAction())) { + if (EngineUtils.isRightClick(event.getAction())) { ItemStack item = event.getItem(); if (item == null) { return; @@ -81,18 +81,18 @@ public class BlockPartyListener extends GameListener { if (item.getType() == Material.ENDER_PEARL) { player.launchProjectile(EnderPearl.class); - Players.a(blockPartyGame.getEngine().getPlatform(), player, event); + Players.consumeHeldItem(blockPartyGame.getEngine().getPlatform(), player, event); } else if (item.getType() == Material.FEATHER) { player.setVelocity(player.getEyeLocation().getDirection().multiply(2)); - Players.a(blockPartyGame.getEngine().getPlatform(), player, event); + Players.consumeHeldItem(blockPartyGame.getEngine().getPlatform(), player, event); } } if (VersionAdapters.get().isMainHandInteract(blockPartyGame.getEngine().getPlatform(), event) && event.getAction() == Action.LEFT_CLICK_BLOCK) { Block block = event.getClickedBlock(); if (blockPartyGame.getBlockHologram() != null && blockPartyGame.getBlockHologram().block().equals(block)) { - blockPartyGamer.s(); - blockPartyGamer.d(blockPartyGamer.n() + 1); + blockPartyGamer.activatePowerUpBlock(); + blockPartyGamer.setPowerUpsUsed(blockPartyGamer.getPowerUpsUsed() + 1); VersionAdapters.get().spawnParticle(block.getWorld(), ArcadeParticle.LAVA, block.getLocation(), 50, 2.0, 5.0, 2.0, 0.0); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyMusic.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyMusic.java index aeb38e0..ca1202f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyMusic.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyMusic.java @@ -4,27 +4,27 @@ import com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer; import org.bukkit.entity.Player; public class BlockPartyMusic { - private final RadioSongPlayer a; + private final RadioSongPlayer songPlayer; public BlockPartyMusic(BlockPartySong blockPartySong) { - this.a = new RadioSongPlayer(blockPartySong.a()); - this.a.setRandom(true); - this.a.setPlaying(true); + this.songPlayer = new RadioSongPlayer(blockPartySong.createShuffledPlaylist()); + this.songPlayer.setRandom(true); + this.songPlayer.setPlaying(true); } - public void a(Player player) { - this.a.addPlayer(player); + public void addPlayer(Player player) { + this.songPlayer.addPlayer(player); } - public void b(Player player) { - this.a.removePlayer(player); + public void removePlayer(Player player) { + this.songPlayer.removePlayer(player); } - public void a(boolean flag) { - this.a.setPlaying(flag); + public void setPlaying(boolean flag) { + this.songPlayer.setPlaying(flag); } - public void a() { - this.a.destroy(); + public void destroy() { + this.songPlayer.destroy(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyNoteBlockIntegration.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyNoteBlockIntegration.java index 1b572f3..a1bbb70 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyNoteBlockIntegration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartyNoteBlockIntegration.java @@ -14,17 +14,17 @@ public class BlockPartyNoteBlockIntegration extends PluginIntegration { } @Override - public boolean a() { + public boolean canEnable() { return Bukkit.getPluginManager().getPlugin("NoteBlockAPI") != null; } @Override - public void b() { + public void onEnable() { this.manager.setBlockPartySong(new BlockPartySong(new File(this.manager.getDataFolder(), "songs"))); } @Override - public void c() { + public void onDisable() { this.manager.setBlockPartySong((ro.fr33styler.arcade.game.blockparty.music.BlockPartySong)null); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartySong.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartySong.java index d165693..e5ea474 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartySong.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/music/BlockPartySong.java @@ -9,12 +9,12 @@ import java.io.File; import java.util.Arrays; public class BlockPartySong { - private final Song[] a; + private final Song[] songs; public BlockPartySong(File file) { File[] files = file.listFiles(); if (files == null) { - this.a = new Song[0]; + this.songs = new Song[0]; } else { int index = 0; Song[] songs = new Song[files.length]; @@ -28,12 +28,12 @@ public class BlockPartySong { } } - this.a = Arrays.copyOf(songs, index); + this.songs = Arrays.copyOf(songs, index); } } - Playlist a() { - Randoms.b(this.a); - return new Playlist(this.a); + Playlist createShuffledPlaylist() { + Randoms.shuffle(this.songs); + return new Playlist(this.songs); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyEndingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyEndingPhase.java index d42e66b..75e7ab8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyEndingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyEndingPhase.java @@ -10,35 +10,35 @@ import ro.fr33styler.arcade.platform.api.npc.Npc; import org.bukkit.Color; public class BlockPartyEndingPhase extends EndingPhase { - private int b; - private final BlockPartyGame game2; + private int tabRemovalTicks; + private final BlockPartyGame blockPartyGame; public BlockPartyEndingPhase(BlockPartyGame game22) { super(game22); - this.game2 = game22; + this.blockPartyGame = game22; } @Override public void start() { super.start(); - this.game2.setPodiumNpcs(new Npc[Math.min(3, this.game2.getStandings().length)]); - ServerPlatform serverPlatform = this.game2.getManager().getEngine().getPlatform(); - if (this.game2.getStandings().length > 0) { - this.game2.getPodiumNpcs()[0] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopFirst(), this.game2.getStandings()[0].toPlayer()); + this.blockPartyGame.setPodiumNpcs(new Npc[Math.min(3, this.blockPartyGame.getStandings().length)]); + ServerPlatform serverPlatform = this.blockPartyGame.getManager().getEngine().getPlatform(); + if (this.blockPartyGame.getStandings().length > 0) { + this.blockPartyGame.getPodiumNpcs()[0] = serverPlatform.getNpcFactory().createPlayerNpc(this.blockPartyGame.getMap().getTopFirst(), this.blockPartyGame.getStandings()[0].toPlayer()); } - if (this.game2.getStandings().length > 1) { - this.game2.getPodiumNpcs()[1] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopSecond(), this.game2.getStandings()[1].toPlayer()); + if (this.blockPartyGame.getStandings().length > 1) { + this.blockPartyGame.getPodiumNpcs()[1] = serverPlatform.getNpcFactory().createPlayerNpc(this.blockPartyGame.getMap().getTopSecond(), this.blockPartyGame.getStandings()[1].toPlayer()); } - if (this.game2.getStandings().length > 2) { - this.game2.getPodiumNpcs()[2] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopThird(), this.game2.getStandings()[2].toPlayer()); + if (this.blockPartyGame.getStandings().length > 2) { + this.blockPartyGame.getPodiumNpcs()[2] = serverPlatform.getNpcFactory().createPlayerNpc(this.blockPartyGame.getMap().getTopThird(), this.blockPartyGame.getStandings()[2].toPlayer()); } - for (BlockPartyGamer blockPartyGamer : this.game2.getGamers()) { - blockPartyGamer.a(this.game2.getMap().getTopLobby()); + for (BlockPartyGamer blockPartyGamer : this.blockPartyGame.getGamers()) { + blockPartyGamer.teleport(this.blockPartyGame.getMap().getTopLobby()); - for (Npc npc : this.game2.getPodiumNpcs()) { + for (Npc npc : this.blockPartyGame.getPodiumNpcs()) { npc.setVisible(blockPartyGamer.toPlayer(), true); } } @@ -47,32 +47,32 @@ public class BlockPartyEndingPhase extends EndingPhase { @Override public void stop() { super.stop(); - this.game2.setPodiumNpcs((ro.fr33styler.arcade.platform.api.npc.Npc[])null); - this.game2.setStandings((ro.fr33styler.arcade.game.blockparty.player.BlockPartyGamer[])null); - this.b = 0; + this.blockPartyGame.setPodiumNpcs((ro.fr33styler.arcade.platform.api.npc.Npc[])null); + this.blockPartyGame.setStandings((ro.fr33styler.arcade.game.blockparty.player.BlockPartyGamer[])null); + this.tabRemovalTicks = 0; } @Override public void onTick(long longVal) { - if (longVal % 20L == 0L && this.b++ == 3) { - this.b(); + if (longVal % 20L == 0L && this.tabRemovalTicks++ == 3) { + this.removePodiumFromTabList(); } super.onTick(longVal); } - protected void b() { - for (BlockPartyGamer blockPartyGamer : this.game2.getGamers()) { - for (Npc npc : this.game2.getPodiumNpcs()) { + protected void removePodiumFromTabList() { + for (BlockPartyGamer blockPartyGamer : this.blockPartyGame.getGamers()) { + for (Npc npc : this.blockPartyGame.getPodiumNpcs()) { npc.removeFromTabList(blockPartyGamer.toPlayer()); } } } @Override - protected void a() { - for (Npc npc : this.game2.getPodiumNpcs()) { - Fireworks.a(this.game2.getEngine().getPlatform(), npc.getLocation(), Color.YELLOW); + protected void spawnFireworks() { + for (Npc npc : this.blockPartyGame.getPodiumNpcs()) { + Fireworks.detonateColored(this.blockPartyGame.getEngine().getPlatform(), npc.getLocation(), Color.YELLOW); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyPlayingPhase.java index 9f6b08a..e38dc16 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/phase/BlockPartyPlayingPhase.java @@ -29,9 +29,9 @@ import ro.fr33styler.arcade.platform.compat.ArcadeSound; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class BlockPartyPlayingPhase implements Phase { - private int a; - private int b; - private double c; + private int phaseTimer; + private int danceTicksRemaining; + private double roundDurationSeconds; private final BlockPartyGame game; public BlockPartyPlayingPhase(BlockPartyGame game2) { @@ -39,14 +39,14 @@ public class BlockPartyPlayingPhase implements Phase { } public void start() { - this.game.setStandings((BlockPartyGamer[])this.game.getGamers().a(new BlockPartyGamer[this.game.getGamers().size()])); - this.game.getMap().getFloorZone().a(block -> this.game.getRollbackQueue().add(block.getState())); - BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.a(this.game.getMap().getFloorZone()); + this.game.setStandings((BlockPartyGamer[])this.game.getGamers().toArray(new BlockPartyGamer[this.game.getGamers().size()])); + this.game.getMap().getFloorZone().forEachBlock(block -> this.game.getRollbackQueue().add(block.getState())); + BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.fromCuboid(this.game.getMap().getFloorZone()); if (blockPartyFloorPattern == null) { - this.game.getGamers().a("The floor is not made of colored terracotta!"); + this.game.getGamers().broadcast("The floor is not made of colored terracotta!"); this.game.getPhase().stop(); } else { - this.game.setCurrentColor(blockPartyFloorPattern.d()); + this.game.setCurrentColor(blockPartyFloorPattern.pickRandomColor()); if (this.game.getManager().getBlockPartySong() != null) { this.game.setMusic(new BlockPartyMusic(this.game.getManager().getBlockPartySong())); } @@ -56,22 +56,22 @@ public class BlockPartyPlayingPhase implements Phase { List list = this.game.getMap().getSpawns(); for (BlockPartyGamer blockPartyGamer : this.game.getGamers()) { - blockPartyGamer.a((Location)list.get(index++ % list.size())); + blockPartyGamer.teleport((Location)list.get(index++ % list.size())); this.game.getBossBar().addPlayer(blockPartyGamer.toPlayer()); this.game.getCollisionTeam().addEntry(blockPartyGamer.toPlayer().getName()); - if (this.game.getMusic() != null && blockPartyGamer.o()) { - this.game.getMusic().a(blockPartyGamer.toPlayer()); + if (this.game.getMusic() != null && blockPartyGamer.isMusicEnabled()) { + this.game.getMusic().addPlayer(blockPartyGamer.toPlayer()); } - blockPartyGamer.k(); + blockPartyGamer.clearSidebar(); blockPartyGamer.toPlayer().setGameMode(GameMode.SURVIVAL); blockPartyGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); blockPartyGamer.sendTitle(this.game.getMessages().getStartTitle(), this.game.getMessages().getStartSubtitle(), 0, 100, 20); blockPartyGamer.toPlayer().addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false, false)); } - this.a = 7; - this.c = this.game.getSettings().getRoundSpeed(); + this.phaseTimer = 7; + this.roundDurationSeconds = this.game.getSettings().getRoundSpeed(); this.game.setRound(0); this.game.setFloorCleared(true); this.game.setDancingActive(false); @@ -83,11 +83,11 @@ public class BlockPartyPlayingPhase implements Phase { this.game.getBossBar().removeAll(); this.game.getCollisionTeam().clearEntries(); if (this.game.getBlockHologram() != null) { - this.game.getBlockHologram().a(this.game.getViewers()); + this.game.getBlockHologram().remove(this.game.getViewers()); } if (this.game.getMusic() != null) { - this.game.getMusic().a(); + this.game.getMusic().destroy(); this.game.setMusic((ro.fr33styler.arcade.game.blockparty.music.BlockPartyMusic)null); } @@ -106,8 +106,8 @@ public class BlockPartyPlayingPhase implements Phase { return switch (text) { case "round" -> String.valueOf(this.game.getRound()); case "rounds" -> this.game.getSettings().isNoRoundLimit() ? "∞" : String.valueOf(this.game.getTotalRounds()); - case "speed" -> Strings.a(this.c, 1); - case "power_up_color" -> BlockPartyBlockHologram.chatColors[Randoms.a().nextInt(BlockPartyBlockHologram.chatColors.length)].toString(); + case "speed" -> Strings.formatFixedDecimal(this.roundDurationSeconds, 1); + case "power_up_color" -> BlockPartyBlockHologram.chatColors[Randoms.current().nextInt(BlockPartyBlockHologram.chatColors.length)].toString(); default -> null; }; } @@ -115,62 +115,62 @@ public class BlockPartyPlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 10L == 0L) { Cuboid cuboid = this.game.getMap().getFloorZone(); - Location location = Locations.d(cuboid.b(), cuboid.c()); - VersionAdapters.get().spawnParticle(cuboid.a(), ArcadeParticle.FIREWORKS_SPARK, location, 50, cuboid.d(), 2.0, cuboid.f(), 0.0); + Location location = Locations.midpoint(cuboid.getMin(), cuboid.getMax()); + VersionAdapters.get().spawnParticle(cuboid.getWorld(), ArcadeParticle.FIREWORKS_SPARK, location, 50, cuboid.getSizeX(), 2.0, cuboid.getSizeZ(), 0.0); } if (longVal % 20L == 0L) { if (this.game.isFloorCleared()) { - if (this.a > 0) { - this.a--; + if (this.phaseTimer > 0) { + this.phaseTimer--; } else if (!this.game.getSettings().isNoRoundLimit() && this.game.getRound() == this.game.getTotalRounds()) { this.game.checkEndCondition(); } else { this.game.setRound(this.game.getRound() + 1); this.game.setFloorCleared(false); - if (this.c > 0.5 && this.game.getRound() % 2 == 0) { - this.c = this.c - this.game.getSettings().getSpeedDecay(); + if (this.roundDurationSeconds > 0.5 && this.game.getRound() % 2 == 0) { + this.roundDurationSeconds = this.roundDurationSeconds - this.game.getSettings().getSpeedDecay(); } - this.b = (int)(this.c * 20.0); + this.danceTicksRemaining = (int)(this.roundDurationSeconds * 20.0); for (BlockPartyGamer blockPartyGamer : this.game.getGamers()) { - if (!blockPartyGamer.f()) { + if (!blockPartyGamer.isSpectator()) { BlockPartyDyeColor currentColor = this.game.getCurrentColor(); ItemStack item = new ItemBuilder(currentColor.toColoredBlockType(this.game.getSettings().getFloorType()), currentColor.toArcadeColor()) - .setDisplayName(currentColor.b(this.game.getMessages())) + .setDisplayName(currentColor.getDisplayName(this.game.getMessages())) .build(); blockPartyGamer.toPlayer().getInventory().setItem(4, item); } } } } else if (this.game.isDancingActive()) { - if (this.a > 0) { - this.a--; + if (this.phaseTimer > 0) { + this.phaseTimer--; } else { - this.a = 2; + this.phaseTimer = 2; this.game.setFloorCleared(true); this.game.setDancingActive(false); BlockPartyFloorPattern blockPartyFloorPattern = this.game.getRound() > this.game.getFloorPatterns().size() - ? (BlockPartyFloorPattern)Randoms.a(this.game.getFloorPatterns()) + ? (BlockPartyFloorPattern)Randoms.pickRandom(this.game.getFloorPatterns()) : (BlockPartyFloorPattern)this.game.getFloorPatterns().get(this.game.getRound() - 1); BlockPartyDyeColor[] blockPartyDyeColors = BlockPartyDyeColor.values(); if (this.game.getSettings().isShuffleColors()) { - Randoms.b(blockPartyDyeColors); + Randoms.shuffle(blockPartyDyeColors); } - blockPartyFloorPattern.a(this.game.getManager().getEngine().getPlatform(), this.game.getMap().getFloorZone(), blockPartyDyeColors, this.game.getSettings().getFloorType()); - this.game.setCurrentColor(blockPartyDyeColors[blockPartyFloorPattern.d().ordinal()]); + blockPartyFloorPattern.applyToFloor(this.game.getManager().getEngine().getPlatform(), this.game.getMap().getFloorZone(), blockPartyDyeColors, this.game.getSettings().getFloorType()); + this.game.setCurrentColor(blockPartyDyeColors[blockPartyFloorPattern.pickRandomColor().ordinal()]); if (this.game.getMusic() != null) { - this.game.getMusic().a(true); + this.game.getMusic().setPlaying(true); } - if (this.game.getSettings().isPowerUps() && this.c >= 2.0 && Randoms.a().nextFloat() <= 0.3) { - int index = Randoms.a().nextInt(blockPartyFloorPattern.a()); - int index2 = Randoms.a().nextInt(blockPartyFloorPattern.b()); - Block block = this.game.getMap().getFloorZone().b().getBlock().getRelative(index, 1, index2); + if (this.game.getSettings().isPowerUps() && this.roundDurationSeconds >= 2.0 && Randoms.current().nextFloat() <= 0.3) { + int index = Randoms.current().nextInt(blockPartyFloorPattern.getWidth()); + int index2 = Randoms.current().nextInt(blockPartyFloorPattern.getLength()); + Block block = this.game.getMap().getFloorZone().getMin().getBlock().getRelative(index, 1, index2); this.game.setBlockHologram(new BlockPartyBlockHologram(block, new Hologram(block.getLocation().add(0.5, 1.3, 0.5)))); - this.game.getViewers().a(this.game.getBlockHologram().hologram()); + this.game.getViewers().register(this.game.getBlockHologram().hologram()); block.setType(Material.JUKEBOX); } @@ -178,13 +178,13 @@ public class BlockPartyPlayingPhase implements Phase { for (BlockPartyGamer blockPartyGamer2 : this.game.getGamers()) { blockPartyGamer2.sendActionBar(this.game.getMessages().getFloorWaiting()); - if (!blockPartyGamer2.f()) { + if (!blockPartyGamer2.isSpectator()) { blockPartyGamer2.toPlayer().getInventory().setItem(4, null); - if (this.game.getMap().getFloorZone().b().getY() > blockPartyGamer2.toPlayer().getLocation().getY()) { - blockPartyGamer2.r(); + if (this.game.getMap().getFloorZone().getMin().getY() > blockPartyGamer2.toPlayer().getLocation().getY()) { + blockPartyGamer2.eliminate(); } else { - blockPartyGamer2.a(this.game.getMessages().getPointsReceived()); - blockPartyGamer2.c(blockPartyGamer2.m() + 1); + blockPartyGamer2.sendMessage(this.game.getMessages().getPointsReceived()); + blockPartyGamer2.setPoints(blockPartyGamer2.getPoints() + 1); } } } @@ -195,40 +195,40 @@ public class BlockPartyPlayingPhase implements Phase { if (this.game.getRound() > 0 && this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { if (this.game.getBlockHologram() != null) { - List list = TextRenderer.a(this.game.getMessages().getPowerUpBlock(), this); - this.game.getBlockHologram().hologram().a(this.game.getManager().getEngine().getPlatform(), list); + List list = TextRenderer.render(this.game.getMessages().getPowerUpBlock(), this); + this.game.getBlockHologram().hologram().setLines(this.game.getManager().getEngine().getPlatform(), list); } for (BlockPartyGamer blockPartyGamer3 : this.game.getGamers()) { - this.game.getViewers().b(blockPartyGamer3.toPlayer()); - blockPartyGamer3.a(this.game.getMessages().getSidebarPlaying(), blockPartyGamer3); + this.game.getViewers().update(blockPartyGamer3.toPlayer()); + blockPartyGamer3.updateSidebar(this.game.getMessages().getSidebarPlaying(), blockPartyGamer3); } } } if (!this.game.isFloorCleared() && !this.game.isDancingActive()) { - if (this.b > 0) { - if (this.b % 10 == 0) { - String text = this.game.getCurrentColor().a(this.game.getMessages()) + "█".repeat(Math.max(1, (this.b + 10) / 20)); - String text2 = text + " §r§l" + this.game.getCurrentColor().b(this.game.getMessages()).toUpperCase() + " " + text; + if (this.danceTicksRemaining > 0) { + if (this.danceTicksRemaining % 10 == 0) { + String text = this.game.getCurrentColor().getColorFormat(this.game.getMessages()) + "█".repeat(Math.max(1, (this.danceTicksRemaining + 10) / 20)); + String text2 = text + " §r§l" + this.game.getCurrentColor().getDisplayName(this.game.getMessages()).toUpperCase() + " " + text; this.game.getBossBar().setTitle(text2); for (BlockPartyGamer blockPartyGamer4 : this.game.getGamers()) { blockPartyGamer4.sendActionBar(text2); - if (this.b == 60) { + if (this.danceTicksRemaining == 60) { blockPartyGamer4.playSound(ArcadeSound.NOTE_HARP, 1.0F, 1.0F); blockPartyGamer4.playSound(ArcadeSound.NOTE_BASS, 1.0F, 1.0F); - } else if (this.b == 40) { + } else if (this.danceTicksRemaining == 40) { blockPartyGamer4.playSound(ArcadeSound.NOTE_HARP, 1.0F, 0.8F); blockPartyGamer4.playSound(ArcadeSound.NOTE_BASS, 1.0F, 0.8F); - } else if (this.b == 20) { + } else if (this.danceTicksRemaining == 20) { blockPartyGamer4.playSound(ArcadeSound.NOTE_HARP, 1.0F, 0.6F); blockPartyGamer4.playSound(ArcadeSound.NOTE_BASS, 1.0F, 0.6F); } } } - this.b--; + this.danceTicksRemaining--; } else { this.game.getBossBar().setTitle(this.game.getMessages().getFloorStop()); @@ -238,18 +238,18 @@ public class BlockPartyPlayingPhase implements Phase { } if (this.game.getBlockHologram() != null) { - this.game.getBlockHologram().a(this.game.getViewers()); + this.game.getBlockHologram().remove(this.game.getViewers()); } - this.game.getMap().getFloorZone().a(block2 -> { - if (BlockPartyDyeColor.a(block2) != this.game.getCurrentColor()) { + this.game.getMap().getFloorZone().forEachBlock(block2 -> { + if (BlockPartyDyeColor.fromBlock(block2) != this.game.getCurrentColor()) { VersionAdapters.get().setBlock(this.game.getManager().getEngine().getPlatform(), block2, Material.AIR, 0); } }); - this.a = 2; + this.phaseTimer = 2; this.game.setDancingActive(true); if (this.game.getMusic() != null) { - this.game.getMusic().a(false); + this.game.getMusic().setPlaying(false); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/player/BlockPartyGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/player/BlockPartyGamer.java index 26b7fea..47511b8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/player/BlockPartyGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/player/BlockPartyGamer.java @@ -21,9 +21,9 @@ import ro.fr33styler.arcade.platform.compat.ArcadeSound; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class BlockPartyGamer extends BaseGamer { - private int b; - private int c; - private boolean d; + private int points; + private int powerUpsUsed; + private boolean musicEnabled; private final BlockPartyGame game; public BlockPartyGamer(BlockPartyGame game2, DefaultUser defaultUser) { @@ -35,75 +35,75 @@ public class BlockPartyGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getPoints() { + return this.points; } - public void c(int index) { - this.b = index; + public void setPoints(int index) { + this.points = index; } - public int n() { - return this.c; + public int getPowerUpsUsed() { + return this.powerUpsUsed; } - public void d(int index) { - this.c = index; + public void setPowerUpsUsed(int index) { + this.powerUpsUsed = index; } - public boolean o() { - return this.d; + public boolean isMusicEnabled() { + return this.musicEnabled; } - public void q() { + public void updateMusicToggleItem() { Runnable runnable = () -> { - this.d = !this.d; - this.q(); + this.musicEnabled = !this.musicEnabled; + this.updateMusicToggleItem(); this.playSound(ArcadeSound.UI_BUTTON_CLICK, 1.0F, 1.0F); }; - String text = this.d ? this.game.getMessages().getWaitingMusicOn() : this.game.getMessages().getWaitingMusicOff(); - this.getHotbar().a(7, runnable, new ItemBuilder(Material.JUKEBOX).setDisplayName(text).build()); + String text = this.musicEnabled ? this.game.getMessages().getWaitingMusicOn() : this.game.getMessages().getWaitingMusicOff(); + this.getHotbar().setSlot(7, runnable, new ItemBuilder(Material.JUKEBOX).setDisplayName(text).build()); } - public void r() { - this.b(this.getLoses() + 1); - this.b(true); - this.a(this.game.getMap().getSpectator()); - this.game.getGamers().a(this.game.getMessages().getPlayerEliminated(), this); + public void eliminate() { + this.setLoses(this.getLoses() + 1); + this.setSpectator(true); + this.teleport(this.game.getMap().getSpectator()); + this.game.getGamers().broadcast(this.game.getMessages().getPlayerEliminated(), this); } - public void s() { + public void activatePowerUpBlock() { Block block = this.game.getBlockHologram().block(); block.setType(Material.AIR); - this.game.getViewers().b(this.game.getBlockHologram().hologram()); + this.game.getViewers().unregister(this.game.getBlockHologram().hologram()); this.game.setBlockHologram((ro.fr33styler.arcade.game.blockparty.floor.hologram.BlockPartyBlockHologram)null); - switch (Randoms.a().nextInt(7)) { + switch (Randoms.current().nextInt(7)) { case 0: - this.a(block); + this.triggerBombPowerUp(block); break; case 1: - this.t(); + this.giveNightVisionPowerUp(); break; case 2: - this.u(); + this.giveJumpBoostPowerUp(); break; case 3: - this.v(); + this.giveEnderPearlPowerUp(); break; case 4: - this.w(); + this.applyBlindnessCurse(); break; case 5: - this.x(); + this.applyJumpCurse(); break; case 6: - this.y(); + this.applyRandomTeleportCurse(); } } - private void a(Block block) { - BlockFloodFill.a(4, block.getRelative(0, -1, 0), block2 -> { - if (this.game.getMap().getFloorZone().a(block2) && Randoms.a().nextFloat() <= 0.9F) { + private void triggerBombPowerUp(Block block) { + BlockFloodFill.forEachInRadius(4, block.getRelative(0, -1, 0), block2 -> { + if (this.game.getMap().getFloorZone().contains(block2) && Randoms.current().nextFloat() <= 0.9F) { VersionAdapters.get().setBlockPartyBlock( this.game.getEngine().getPlatform(), block2, @@ -119,108 +119,108 @@ public class BlockPartyGamer extends BaseGamer { } } - private void t() { + private void giveNightVisionPowerUp() { this.player.addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.NIGHT_VISION, 210, 0, false, false, false)); - this.a(this.game.getMessages().getPowerUpNightVision()); - this.z(); + this.sendMessage(this.game.getMessages().getPowerUpNightVision()); + this.notifyPowerUpAccepted(); } - private void u() { + private void giveJumpBoostPowerUp() { this.player.getInventory().addItem(new ItemStack[]{new ItemBuilder(Material.FEATHER).setDisplayName(this.game.getMessages().getPowerUpJumpBoost()).build()}); - this.z(); + this.notifyPowerUpAccepted(); } - private void v() { + private void giveEnderPearlPowerUp() { this.player.getInventory().addItem(new ItemStack[]{new ItemBuilder(Material.ENDER_PEARL).setDisplayName(this.game.getMessages().getPowerUpTeleport()).build()}); - this.z(); + this.notifyPowerUpAccepted(); } - private void w() { + private void applyBlindnessCurse() { this.player.addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.BLINDNESS, 210, 0, false, false, false)); - this.a(this.game.getMessages().getPowerUpBlindness()); - this.z(); + this.sendMessage(this.game.getMessages().getPowerUpBlindness()); + this.notifyPowerUpAccepted(); } - private void x() { + private void applyJumpCurse() { this.player.addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.JUMP, 210, 250, false, false, false)); - this.a(this.game.getMessages().getPowerUpJumpCurse()); - this.z(); + this.sendMessage(this.game.getMessages().getPowerUpJumpCurse()); + this.notifyPowerUpAccepted(); } - private void y() { + private void applyRandomTeleportCurse() { Cuboid cuboid = this.game.getMap().getFloorZone(); - int index = Randoms.a().nextInt(cuboid.c().getBlockX() - cuboid.b().getBlockX() + 1); - int index2 = Randoms.a().nextInt(cuboid.c().getBlockZ() - cuboid.b().getBlockZ() + 1); - this.player.teleport(Locations.a(cuboid.b()).add(index, 1.0, index2)); - this.a(this.game.getMessages().getPowerUpTeleportCurse()); - this.z(); + int index = Randoms.current().nextInt(cuboid.getMax().getBlockX() - cuboid.getMin().getBlockX() + 1); + int index2 = Randoms.current().nextInt(cuboid.getMax().getBlockZ() - cuboid.getMin().getBlockZ() + 1); + this.player.teleport(Locations.copy(cuboid.getMin()).add(index, 1.0, index2)); + this.sendMessage(this.game.getMessages().getPowerUpTeleportCurse()); + this.notifyPowerUpAccepted(); } - private void z() { + private void notifyPowerUpAccepted() { for (BlockPartyGamer blockPartyGamer : this.game.getGamers()) { blockPartyGamer.playSound(ArcadeSound.PLAYER_LEVELUP, 1.0F, 1.0F); blockPartyGamer.sendMessage(this.game.getMessages().getPowerUpAccepted(), this); } } - private void A() { + private void saveStatistics() { BlockPartyStatistics blockPartyStatistics = this.game.getManager().getData(this.getUUID()); - if (blockPartyStatistics.a()) { - blockPartyStatistics.a(blockPartyStatistics.getWins() + this.getWins()); + if (blockPartyStatistics.isLoaded()) { + blockPartyStatistics.setWins(blockPartyStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - blockPartyStatistics.d(blockPartyStatistics.getCurrentWinStreak() + 1); + blockPartyStatistics.setCurrentWinStreak(blockPartyStatistics.getCurrentWinStreak() + 1); if (blockPartyStatistics.getWinStreak() < blockPartyStatistics.getCurrentWinStreak()) { - blockPartyStatistics.c(blockPartyStatistics.getCurrentWinStreak()); + blockPartyStatistics.setWinStreak(blockPartyStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - blockPartyStatistics.d(0); + blockPartyStatistics.setCurrentWinStreak(0); } - blockPartyStatistics.b(blockPartyStatistics.getLoses() + this.getLoses()); - blockPartyStatistics.e(blockPartyStatistics.d() + this.b); - this.b(blockPartyStatistics.getMap()); - this.game.getManager().getStorage().e().b(blockPartyStatistics); - this.game.getManager().getStorage().e().a(this); + blockPartyStatistics.setLoses(blockPartyStatistics.getLoses() + this.getLoses()); + blockPartyStatistics.setPoints(blockPartyStatistics.getPoints() + this.points); + this.saveProperties(blockPartyStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(blockPartyStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @Override public String getVariable(String text) { if (text.equals("power_ups")) { - return String.valueOf(this.c); + return String.valueOf(this.powerUpsUsed); } else { - return text.equals("points") ? String.valueOf(this.b) : super.getVariable(text); + return text.equals("points") ? String.valueOf(this.points) : super.getVariable(text); } } @Override - public void a(Map map) { - super.a(map); - this.d = Boolean.parseBoolean((String)map.get("music")); - this.q(); + public void loadProperties(Map map) { + super.loadProperties(map); + this.musicEnabled = Boolean.parseBoolean((String)map.get("music")); + this.updateMusicToggleItem(); } @Override - public void b(Map map) { - super.b(map); - map.put("music", String.valueOf(this.d)); + public void saveProperties(Map map) { + super.saveProperties(map); + map.put("music", String.valueOf(this.musicEnabled)); } @Override public void leave() { - this.A(); - this.game.getGamers().b(this); + this.saveStatistics(); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getEnding()) { for (Npc npc : this.game.getPodiumNpcs()) { npc.removeFromTabList(this.player); npc.setVisible(this.player, false); } } else if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - if (this.game.getGamers().a() == 1) { + if (this.game.getGamers().getAliveCount() == 1) { this.game.finishGame(); } else { if (this.game.getMusic() != null) { - this.game.getMusic().b(this.player); + this.game.getMusic().removePlayer(this.player); } this.game.getCollisionTeam().removeEntry(this.player.getName()); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySession.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySession.java index c59ec91..23182f2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySession.java @@ -25,17 +25,17 @@ public class BlockPartySession extends BaseSession { @Override public Result canPlay(UUID uuid, Collection collection) { return this.game.getFloorPatterns().size() < 5 - ? new Result(false, ChatColor.RED + "You need at least 5 floors! You must add images of " + this.game.getMap().getFloorZone().d() + "x" + this.game.getMap().getFloorZone().f()) + ? new Result(false, ChatColor.RED + "You need at least 5 floors! You must add images of " + this.game.getMap().getFloorZone().getSizeX() + "x" + this.game.getMap().getFloorZone().getSizeZ()) : super.canPlay(uuid, collection); } @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { BlockPartyGamer blockPartyGamer = new BlockPartyGamer(this.game, defaultUser); - this.game.getGamers().a(blockPartyGamer); - blockPartyGamer.a(this.game.getMessages().getStart()); - blockPartyGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(blockPartyGamer); + blockPartyGamer.sendMessages(this.game.getMessages().getStart()); + blockPartyGamer.teleport(this.game.getMap().getLobby()); return blockPartyGamer; }); } @@ -49,7 +49,7 @@ public class BlockPartySession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof BlockPartyGamer var2) { BlockPartyGame blockPartyGame = var2.getGame(); - if (blockPartyGame.getPhase() != blockPartyGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (blockPartyGame.getPhase() != blockPartyGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, blockPartyGame.getMessages().getJoinAlreadyInGame()); } } @@ -59,18 +59,18 @@ public class BlockPartySession extends BaseSession { @Override public void addSpectator(User user) { - BlockPartyGamer blockPartyGamer = this.a(user, defaultUser -> { + BlockPartyGamer blockPartyGamer = this.joinGamer(user, defaultUser -> { BlockPartyGamer blockPartyGamer2 = new BlockPartyGamer(this.game, defaultUser); - this.game.getGamers().a(blockPartyGamer2); - blockPartyGamer2.a(this.game.getMap().getSpectator()); - blockPartyGamer2.b(true); - blockPartyGamer2.getSpectatorOptions().e(true); + this.game.getGamers().add(blockPartyGamer2); + blockPartyGamer2.teleport(this.game.getMap().getSpectator()); + blockPartyGamer2.setSpectator(true); + blockPartyGamer2.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(blockPartyGamer2.getName()); this.game.getBossBar().addPlayer(blockPartyGamer2.toPlayer()); return blockPartyGamer2; }); - if (blockPartyGamer != null && this.game.getMusic() != null && blockPartyGamer.o()) { - this.game.getMusic().a(blockPartyGamer.toPlayer()); + if (blockPartyGamer != null && this.game.getMusic() != null && blockPartyGamer.isMusicEnabled()) { + this.game.getMusic().addPlayer(blockPartyGamer.toPlayer()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySessions.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySessions.java index 1ac98b3..190d7a8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/session/BlockPartySessions.java @@ -22,18 +22,18 @@ public class BlockPartySessions extends BaseSessions this.registerGame(new BlockPartyGame(this.manager, blockPartyMap))); - this.manager.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(blockPartyMap -> this.registerGame(new BlockPartyGame(this.manager, blockPartyMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected BlockPartyMap h(String text) { + protected BlockPartyMap createMap(String text) { BlockPartyMap blockPartyMap = new BlockPartyMap(); blockPartyMap.setId(text); return blockPartyMap; } - protected BlockPartyGame a(BlockPartyMap blockPartyMap) { + protected BlockPartyGame createGame(BlockPartyMap blockPartyMap) { return new BlockPartyGame(this.manager, blockPartyMap); } @@ -41,23 +41,23 @@ public class BlockPartySessions extends BaseSessions { + this.blockPartySetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (this.blockPartySetup.getMap().getFloorZone().d() == cuboid.d() && this.blockPartySetup.getMap().getFloorZone().f() == cuboid.f()) { - for (int index = 0; index < cuboid.e(); index++) { - Block block3 = block.getWorld().getBlockAt(block.getX(), cuboid.b().getBlockY() + index, block.getZ()); - Block block4 = block2.getWorld().getBlockAt(block2.getX(), cuboid.b().getBlockY() + index, block2.getZ()); - BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.a(new Cuboid(block3, block4)); + if (this.blockPartySetup.getMap().getFloorZone().getSizeX() == cuboid.getSizeX() && this.blockPartySetup.getMap().getFloorZone().getSizeZ() == cuboid.getSizeZ()) { + for (int index = 0; index < cuboid.getSizeY(); index++) { + Block block3 = block.getWorld().getBlockAt(block.getX(), cuboid.getMin().getBlockY() + index, block.getZ()); + Block block4 = block2.getWorld().getBlockAt(block2.getX(), cuboid.getMin().getBlockY() + index, block2.getZ()); + BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.fromCuboid(new Cuboid(block3, block4)); if (blockPartyFloorPattern == null) { defaultUser.sendMessage("§cFloor at " + index + " couldn't be added! Make sure the floor is made of colored Terracotta!"); } else { this.blockPartySetup.getMap().getFloors().add(blockPartyFloorPattern); } } - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); defaultUser.sendMessage("§eFloors added. §8(§b" + this.blockPartySetup.getMap().getFloors().size() + "§8)"); } else { defaultUser.sendMessage("§cThe length and width of the floor must be the same as the floor zone!"); @@ -68,10 +68,10 @@ public class BlockPartyAddFloorStep implements ClickSetupStep, RepeatableSetupSt defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd floors").build()); - this.blockPartySetup.getHotbar().a(2, () -> { + this.blockPartySetup.getHotbar().setSlot(2, () -> { this.blockPartySetup.getMap().getFloors().clear(); defaultUser.sendMessage("§eFloors have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset floors").build()); - this.blockPartySetup.getHotbar().a(3, () -> this.blockPartySetup.a(new BlockPartySetEndFloorStep(this.blockPartySetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); + this.blockPartySetup.getHotbar().setSlot(3, () -> this.blockPartySetup.advanceStep(new BlockPartySetEndFloorStep(this.blockPartySetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartyAddPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartyAddPlayerSpawnStep.java index 399ec71..f331e45 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartyAddPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartyAddPlayerSpawnStep.java @@ -17,7 +17,7 @@ public class BlockPartyAddPlayerSpawnStep implements ClickSetupStep, RepeatableS this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -25,32 +25,32 @@ public class BlockPartyAddPlayerSpawnStep implements ClickSetupStep, RepeatableS defaultUser.sendMessage("§e yellow dye to continue."); } - public void b() { + public void onUndo() { this.blockPartySetup.getMap().getSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.blockPartySetup.getMap().getPlayZone().a(location)) { + if (this.blockPartySetup.getMap().getPlayZone().contains(location)) { this.blockPartySetup.getMap().getSpawns().add(location); player.sendMessage("§eSpawn location added. §8(§b" + this.blockPartySetup.getMap().getSpawns().size() + "§8)"); if (this.blockPartySetup.getMap().getSpawns().size() == 1) { - this.e(); + this.addNextStepButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - this.blockPartySetup.getHotbar().a(2, null, null); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + this.blockPartySetup.getHotbar().setSlot(2, null, null); this.blockPartySetup.getMap().getSpawns().clear(); player.sendMessage("§eSpawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset spawns").build()); } - private void e() { - this.blockPartySetup.getHotbar().a(2, () -> this.blockPartySetup.a(new BlockPartySetFloorZoneStep(this.blockPartySetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); + private void addNextStepButton() { + this.blockPartySetup.getHotbar().setSlot(2, () -> this.blockPartySetup.advanceStep(new BlockPartySetFloorZoneStep(this.blockPartySetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetArenaNameStep.java index e0b41fe..768cb45 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetArenaNameStep.java @@ -10,12 +10,12 @@ public class BlockPartySetArenaNameStep implements ChatSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { this.blockPartySetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { + public void onChatInput(String text) { this.blockPartySetup.getMap().setName(text); - this.blockPartySetup.a(new BlockPartySetLobbySpawnStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetLobbySpawnStep(this.blockPartySetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndFloorStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndFloorStep.java index 9fbacc2..aca385a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndFloorStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndFloorStep.java @@ -18,38 +18,38 @@ public class BlockPartySetEndFloorStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the end floor."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.blockPartySetup.getUser(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block == null || block2 == null || block.getWorld() != block2.getWorld()) { defaultUser.sendMessage("§cMust make a selection!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe height must be 1"); } else { Cuboid cuboid = new Cuboid(block, block2); - if (this.blockPartySetup.getMap().getFloorZone().d() == cuboid.d() && this.blockPartySetup.getMap().getFloorZone().f() == cuboid.f()) { - BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.a(cuboid); + if (this.blockPartySetup.getMap().getFloorZone().getSizeX() == cuboid.getSizeX() && this.blockPartySetup.getMap().getFloorZone().getSizeZ() == cuboid.getSizeZ()) { + BlockPartyFloorPattern blockPartyFloorPattern = BlockPartyFloorPattern.fromCuboid(cuboid); if (blockPartyFloorPattern == null) { defaultUser.sendMessage("§cFloor couldn't be added! Make sure the floor is made of colored Terracotta!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); this.blockPartySetup.getMap().setEndFloor(blockPartyFloorPattern); - this.blockPartySetup.a(new BlockPartySetEndingSpawnStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetEndingSpawnStep(this.blockPartySetup)); } } else { defaultUser.sendMessage("§cThe length and width of the floor must be the same as the floor zone!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndingSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndingSpawnStep.java index 6441321..66a78e7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndingSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetEndingSpawnStep.java @@ -16,18 +16,18 @@ public class BlockPartySetEndingSpawnStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to at the end of the game."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); this.blockPartySetup.getMap().setTopLobby(location); - this.blockPartySetup.a(new BlockPartySetFirstPodiumStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetFirstPodiumStep(this.blockPartySetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFirstPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFirstPodiumStep.java index 6cce6b5..0509847 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFirstPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFirstPodiumStep.java @@ -16,18 +16,18 @@ public class BlockPartySetFirstPodiumStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top first player spawns at."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); this.blockPartySetup.getMap().setTopFirst(location); - this.blockPartySetup.a(new BlockPartySetSecondPodiumStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetSecondPodiumStep(this.blockPartySetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top first").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFloorZoneStep.java index e29a08d..5321a0e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetFloorZoneStep.java @@ -17,34 +17,34 @@ public class BlockPartySetFloorZoneStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.blockPartySetup.getUser(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block == null || block2 == null || block.getWorld() != block2.getWorld()) { defaultUser.sendMessage("§cMust make a selection!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe height must be 1"); } else { Cuboid cuboid = new Cuboid(block, block2); - if (this.blockPartySetup.getMap().getPlayZone().a(cuboid)) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + if (this.blockPartySetup.getMap().getPlayZone().contains(cuboid)) { + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); this.blockPartySetup.getMap().setFloorZone(cuboid); - this.blockPartySetup.a(new BlockPartyAddFloorStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartyAddFloorStep(this.blockPartySetup)); } else { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbyRemovalRegionStep.java index c7b485b..3674471 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class BlockPartySetLobbyRemovalRegionStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class BlockPartySetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.blockPartySetup.getUser(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { this.blockPartySetup.getMap().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.blockPartySetup.a(new BlockPartySetPlayZoneStep(this.blockPartySetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.blockPartySetup.advanceStep(new BlockPartySetPlayZoneStep(this.blockPartySetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.blockPartySetup.getHotbar().a(2, () -> { + this.blockPartySetup.getHotbar().setSlot(2, () -> { this.blockPartySetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.blockPartySetup.a(new BlockPartySetPlayZoneStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetPlayZoneStep(this.blockPartySetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbySpawnStep.java index a927a68..c96ece5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class BlockPartySetLobbySpawnStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { this.blockPartySetup.getMap().setLobby(player.getLocation()); - this.blockPartySetup.a(new BlockPartySetLobbyRemovalRegionStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetLobbyRemovalRegionStep(this.blockPartySetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetPlayZoneStep.java index ced611d..04ba7ab 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetPlayZoneStep.java @@ -17,29 +17,29 @@ public class BlockPartySetPlayZoneStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.blockPartySetup.getUser(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.blockPartySetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.blockPartySetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); this.blockPartySetup.getMap().setPlayZone(new Cuboid(block, block2)); - this.blockPartySetup.a(new BlockPartySetSpectatorSpawnStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetSpectatorSpawnStep(this.blockPartySetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSecondPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSecondPodiumStep.java index 8c1b29c..2a90469 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSecondPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSecondPodiumStep.java @@ -16,18 +16,18 @@ public class BlockPartySetSecondPodiumStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top second player spawns at."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); this.blockPartySetup.getMap().setTopSecond(location); - this.blockPartySetup.a(new BlockPartySetThirdPodiumStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartySetThirdPodiumStep(this.blockPartySetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top second").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSpectatorSpawnStep.java index 90dc105..f924528 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class BlockPartySetSpectatorSpawnStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.blockPartySetup.getMap().getPlayZone().a(location)) { + if (this.blockPartySetup.getMap().getPlayZone().contains(location)) { this.blockPartySetup.getMap().setSpectator(location); - this.blockPartySetup.a(new BlockPartyAddPlayerSpawnStep(this.blockPartySetup)); + this.blockPartySetup.advanceStep(new BlockPartyAddPlayerSpawnStep(this.blockPartySetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetThirdPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetThirdPodiumStep.java index 4bb927f..0d8dd40 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetThirdPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/setup/step/BlockPartySetThirdPodiumStep.java @@ -17,18 +17,18 @@ public class BlockPartySetThirdPodiumStep implements ClickSetupStep { this.blockPartySetup = blockPartySetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.blockPartySetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top third player spawns at."); } - public void a() { + public void configureHotbar() { Player player = this.blockPartySetup.getUser().toPlayer(); - this.blockPartySetup.getHotbar().a(0, () -> { + this.blockPartySetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); this.blockPartySetup.getMap().setTopThird(location); - this.blockPartySetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + this.blockPartySetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top third").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/BlockPartyStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/BlockPartyStatistics.java index 76bc9a6..99f36d8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/BlockPartyStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/BlockPartyStatistics.java @@ -6,27 +6,27 @@ import ro.fr33styler.arcade.game.blockparty.BlockPartyManager; import java.util.UUID; public class BlockPartyStatistics extends BaseGameStatistics { - private int b; + private int points; public BlockPartyStatistics(BlockPartyManager blockPartyManager, UUID uuid, String text) { super(blockPartyManager, uuid, text); } - public int d() { - return this.b; + public int getPoints() { + return this.points; } - public void e(int index) { - this.b = index; + public void setPoints(int index) { + this.points = index; } @Override - public String a(String text) { - return text.equals("stats_points") ? String.valueOf(this.b) : super.a(text); + public String resolvePlaceholder(String text) { + return text.equals("stats_points") ? String.valueOf(this.points) : super.resolvePlaceholder(text); } @Override public String getVariable(String text) { - return text.equals("points") ? String.valueOf(this.b) : super.getVariable(text); + return text.equals("points") ? String.valueOf(this.points) : super.getVariable(text); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/storage/BlockPartyStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/storage/BlockPartyStatisticsRepository.java index 5ae0b04..c5a2cbf 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/storage/BlockPartyStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/statistics/storage/BlockPartyStatisticsRepository.java @@ -14,105 +14,105 @@ public class BlockPartyStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a("CREATE TABLE IF NOT EXISTS " + this.b + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); } - public void a(BlockPartyStatistics blockPartyStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(BlockPartyStatistics blockPartyStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, blockPartyStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(blockPartyStatistics, var3); + this.readStatistics(blockPartyStatistics, var3); } - blockPartyStatistics.a(true); + blockPartyStatistics.setLoaded(true); } }); } - private void a(BlockPartyStatistics blockPartyStatistics, ResultSet resultSet) throws java.sql.SQLException { - blockPartyStatistics.b(resultSet.getString("options")); - blockPartyStatistics.a(resultSet.getInt("wins")); - blockPartyStatistics.c(resultSet.getInt("win_streak")); - blockPartyStatistics.d(resultSet.getInt("current_win_streak")); - blockPartyStatistics.b(resultSet.getInt("loses")); - blockPartyStatistics.e(resultSet.getInt("points")); + private void readStatistics(BlockPartyStatistics blockPartyStatistics, ResultSet resultSet) throws java.sql.SQLException { + blockPartyStatistics.deserializeProperties(resultSet.getString("options")); + blockPartyStatistics.setWins(resultSet.getInt("wins")); + blockPartyStatistics.setWinStreak(resultSet.getInt("win_streak")); + blockPartyStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + blockPartyStatistics.setLoses(resultSet.getInt("loses")); + blockPartyStatistics.setPoints(resultSet.getInt("points")); } - public void b(BlockPartyStatistics blockPartyStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(BlockPartyStatistics blockPartyStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, blockPartyStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(blockPartyStatistics); + this.updateStatistics(blockPartyStatistics); } else { - this.c(blockPartyStatistics); + this.insertStatistics(blockPartyStatistics); } } }); } - private void c(BlockPartyStatistics blockPartyStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(BlockPartyStatistics blockPartyStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, blockPartyStatistics.getUUID().toString()); - preparedStatement.setString(2, blockPartyStatistics.c()); + preparedStatement.setString(2, blockPartyStatistics.serializeProperties()); preparedStatement.setInt(3, blockPartyStatistics.getWins()); preparedStatement.setInt(4, blockPartyStatistics.getWinStreak()); preparedStatement.setInt(5, blockPartyStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, blockPartyStatistics.getLoses()); - preparedStatement.setInt(7, blockPartyStatistics.d()); + preparedStatement.setInt(7, blockPartyStatistics.getPoints()); preparedStatement.executeUpdate(); }); } - private void d(BlockPartyStatistics blockPartyStatistics) { - this.a() - .a( + private void updateStatistics(BlockPartyStatistics blockPartyStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, points = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, blockPartyStatistics.c()); + preparedStatement.setString(1, blockPartyStatistics.serializeProperties()); preparedStatement.setInt(2, blockPartyStatistics.getWins()); preparedStatement.setInt(3, blockPartyStatistics.getWinStreak()); preparedStatement.setInt(4, blockPartyStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, blockPartyStatistics.getLoses()); - preparedStatement.setInt(6, blockPartyStatistics.d()); + preparedStatement.setInt(6, blockPartyStatistics.getPoints()); preparedStatement.setString(7, blockPartyStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(BlockPartyGamer blockPartyGamer) { - this.a(this.b + "_weekly", blockPartyGamer); - this.a(this.b + "_monthly", blockPartyGamer); + public void savePeriodicStatistics(BlockPartyGamer blockPartyGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", blockPartyGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", blockPartyGamer); } - private void a(String text, BlockPartyGamer blockPartyGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, BlockPartyGamer blockPartyGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, blockPartyGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, blockPartyGamer); + this.updatePeriodicStatistics(text, blockPartyGamer); } else { - this.c(text, blockPartyGamer); + this.insertPeriodicStatistics(text, blockPartyGamer); } } }); } - private void b(String text, BlockPartyGamer blockPartyGamer) { + private void updatePeriodicStatistics(String text, BlockPartyGamer blockPartyGamer) { String text2 = "current_win_streak"; if (blockPartyGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -120,9 +120,9 @@ public class BlockPartyStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -132,76 +132,76 @@ public class BlockPartyStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, points = points + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, blockPartyGamer.getWins()); preparedStatement.setInt(2, blockPartyGamer.getLoses()); - preparedStatement.setInt(3, blockPartyGamer.m()); + preparedStatement.setInt(3, blockPartyGamer.getPoints()); preparedStatement.setString(4, blockPartyGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, BlockPartyGamer blockPartyGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, BlockPartyGamer blockPartyGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, blockPartyGamer.getUUID().toString()); preparedStatement.setInt(2, blockPartyGamer.getWins()); preparedStatement.setInt(3, blockPartyGamer.getWins()); preparedStatement.setInt(4, blockPartyGamer.getWins()); preparedStatement.setInt(5, blockPartyGamer.getLoses()); - preparedStatement.setInt(6, blockPartyGamer.m()); + preparedStatement.setInt(6, blockPartyGamer.getPoints()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);" ); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, points INT);"); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -211,22 +211,22 @@ public class BlockPartyStatisticsRepository extends GameStatisticsRepository { int index = var4.getInt("wins"); int index2 = var4.getInt("loses"); int index3 = var4.getInt("points"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -240,14 +240,14 @@ public class BlockPartyStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/storage/BlockPartyStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/storage/BlockPartyStorage.java index 3fa3701..6077fc4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/blockparty/storage/BlockPartyStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/blockparty/storage/BlockPartyStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.blockparty.statistics.storage.BlockPartyStatist public class BlockPartyStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final BlockPartyStatisticsRepository blockPartyStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public BlockPartyStorage(BlockPartyManager blockPartyManager) { super(blockPartyManager); this.storage = new GameMapStorage(blockPartyManager.getConfigManager(), this.file, BlockPartyMap::new); - this.storage2 = new NpcStorage(blockPartyManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(blockPartyManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(blockPartyManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(blockPartyManager.getConfigManager(), this.file); this.blockPartyStatisticsRepository = new BlockPartyStatisticsRepository(blockPartyManager.getEngine()); - this.storage4 = new LeaderboardStorage(blockPartyManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(blockPartyManager.getConfigManager(), this.file, BlockPartyMap::new); + this.leaderboardStorage = new LeaderboardStorage(blockPartyManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(blockPartyManager.getConfigManager(), this.file, BlockPartyMap::new); } @Override @@ -34,26 +34,26 @@ public class BlockPartyStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public BlockPartyStatisticsRepository e() { + public BlockPartyStatisticsRepository getStatisticsRepository() { return this.blockPartyStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersGame.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersGame.java index 8018552..d2782e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersGame.java @@ -28,40 +28,40 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class BombLobbersGame extends AbstractGame implements GameEventHandler { - private int c; + private int timeLeft; private final BombLobbersTeam team; - private final BombLobbersTeam team3; + private final BombLobbersTeam blueTeam; private BombLobbersGamer[] gamers; - private final BombLobbersMap g; + private final BombLobbersMap map; private final BombLobbersManager manager; - private final Map i = new HashMap<>(); + private final Map thrownTntEntities = new HashMap<>(); private final Lifecycle lifecycle = new BombLobbersLifecycle(this); private final Set set = EnumSet.allOf(GameAction.class); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); public BombLobbersGame(BombLobbersManager manager2, BombLobbersMap bombLobbersMap) { - this.g = bombLobbersMap; + this.map = bombLobbersMap; this.manager = manager2; this.setPhase(this.lifecycle.getWaiting()); this.team = new BombLobbersTeam(this, BombLobbersTeamColor.RED); - this.team3 = new BombLobbersTeam(this, BombLobbersTeamColor.BLUE); + this.blueTeam = new BombLobbersTeam(this, BombLobbersTeamColor.BLUE); this.set.remove(GameAction.DAMAGE); } public BombLobbersMap getMap() { - return this.g; + return this.map; } public BombLobbersTeam getTeam() { return this.team; } - public BombLobbersTeam getTeam3() { - return this.team3; + public BombLobbersTeam getBlueTeam() { + return this.blueTeam; } - public Map r() { - return this.i; + public Map getThrownTntEntities() { + return this.thrownTntEntities; } public Lifecycle getPhaseLifecycle() { @@ -72,17 +72,17 @@ public class BombLobbersGame extends AbstractGame implements GameEventHandler { return this.manager.getMessages(); } - private BombLobbersConfiguration y() { - BombLobbersConfiguration bombLobbersConfiguration = (BombLobbersConfiguration)this.getManager().H().get(this.getMap().getId()); + private BombLobbersConfiguration getActiveConfiguration() { + BombLobbersConfiguration bombLobbersConfiguration = (BombLobbersConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); return bombLobbersConfiguration == null ? this.getManager().getConfiguration() : bombLobbersConfiguration; } public BombLobbersSettings getSettings() { - return this.y().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public BombLobbersRewards u() { - return this.y().getRewards(); + public BombLobbersRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public BombLobbersManager getManager() { @@ -97,56 +97,56 @@ public class BombLobbersGame extends AbstractGame implements GameEventHandler { this.gamers = gamers3; } - public int w() { - return this.c; + public int getTimeLeft() { + return this.timeLeft; } - public void a(int index) { - this.c = index; + public void setTimeLeft(int index) { + this.timeLeft = index; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { return switch (text) { - case "time_left" -> Strings.a(this.c); - case "red_alive" -> String.valueOf(this.team.f()); - case "blue_alive" -> String.valueOf(this.team3.f()); + case "time_left" -> Strings.formatDuration(this.timeLeft); + case "red_alive" -> String.valueOf(this.team.getAliveCount()); + case "blue_alive" -> String.valueOf(this.blueTeam.getAliveCount()); default -> super.getVariable(text); }; } - public void x() { - if (this.team.f() == 0) { - this.a(this.team3); - } else if (this.team3.f() == 0) { - this.a(this.team); + public void checkWinCondition() { + if (this.team.getAliveCount() == 0) { + this.finishGame(this.blueTeam); + } else if (this.blueTeam.getAliveCount() == 0) { + this.finishGame(this.team); } } - public void a(BombLobbersTeam bombLobbersTeam) { - Arrays.sort(this.gamers, Comparator.comparingInt(BombLobbersGamer::m).reversed()); - Context context = Contexts.a(this.manager, this.gamers); + public void finishGame(BombLobbersTeam bombLobbersTeam) { + Arrays.sort(this.gamers, Comparator.comparingInt(BombLobbersGamer::getKills).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (BombLobbersGamer bombLobbersGamer : this.gamers2) { + for (BombLobbersGamer bombLobbersGamer : this.gamerSet) { bombLobbersGamer.sendMessages(this.getMessages().getEndingTop(), context); - bombLobbersGamer.a(this.getMessages().getSidebarPlaying(), bombLobbersGamer); - if (!bombLobbersGamer.getSpectatorOptions().g()) { + bombLobbersGamer.updateSidebar(this.getMessages().getSidebarPlaying(), bombLobbersGamer); + if (!bombLobbersGamer.getSpectatorOptions().isExternal()) { if (bombLobbersTeam != null && bombLobbersTeam == bombLobbersGamer.getTeam()) { - bombLobbersGamer.a(1); + bombLobbersGamer.setWins(1); bombLobbersGamer.sendTitle(this.getMessages().getTitleWon(), "", 0, 80, 0); - if (this.u().isEnabled()) { - bombLobbersGamer.a(this.u().getWinners(), text -> text.replace("%team%", bombLobbersGamer.getTeam().c())); + if (this.getRewards().isEnabled()) { + bombLobbersGamer.setRewardCommands(this.getRewards().getWinners(), text -> text.replace("%team%", bombLobbersGamer.getTeam().getDisplayName())); } } else { - bombLobbersGamer.b(1); + bombLobbersGamer.setLoses(1); bombLobbersGamer.sendTitle(this.getMessages().getTitleLost(), "", 0, 80, 0); - if (this.u().isEnabled()) { - bombLobbersGamer.a(this.u().getLosers(), text2 -> text2.replace("%team%", bombLobbersGamer.getTeam().c())); + if (this.getRewards().isEnabled()) { + bombLobbersGamer.setRewardCommands(this.getRewards().getLosers(), text2 -> text2.replace("%team%", bombLobbersGamer.getTeam().getDisplayName())); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersManager.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersManager.java index ba2a510..728f690 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/BombLobbersManager.java @@ -33,12 +33,12 @@ public class BombLobbersManager extends AbstractGameManager { private final Command command; private final BombLobbersStorage storage; private final BombLobbersMessages messages = new BombLobbersMessages(); - private final Map h = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final BombLobbersConfiguration configuration = new BombLobbersConfiguration(); private final BombLobbersListener listener = new BombLobbersListener(this); - private final Map k = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final BombLobbersSessions sessions = new BombLobbersSessions(this); - private final Map> m = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "kills", this.messages::getStatisticKills ); @@ -86,21 +86,21 @@ public class BombLobbersManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { BombLobbersStatistics bombLobbersStatistics = new BombLobbersStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(bombLobbersStatistics); - this.h.put(player.getUniqueId(), bombLobbersStatistics); + this.storage.getStatisticsRepository().loadStatistics(bombLobbersStatistics); + this.playerStatistics.put(player.getUniqueId(), bombLobbersStatistics); } public BombLobbersStatistics getData(UUID uuid) { - return this.h.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.h.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map H() { - return this.k; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -117,7 +117,7 @@ public class BombLobbersManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.m; + return this.leaderboardSources; } @Override @@ -125,16 +125,16 @@ public class BombLobbersManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "bomb_lobbers"); } - private void I() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); BombLobbersConfiguration bombLobbersConfiguration = new BombLobbersConfiguration(); - bombLobbersConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.k.put("id_1", this.configuration); - Files.a(file, file2 -> { + bombLobbersConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { BombLobbersConfiguration bombLobbersConfiguration2 = new BombLobbersConfiguration(); - bombLobbersConfiguration2.a(this.getConfigManager(), file2); - this.k.put(file2.getName(), bombLobbersConfiguration2); + bombLobbersConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), bombLobbersConfiguration2); } }); } @@ -142,16 +142,16 @@ public class BombLobbersManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.I(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { this.bombLobbersTntFactory = VersionAdapters.get().createBombLobbersTntFactorySelector().select(); - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/command/BombLobbersCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/command/BombLobbersCreateCommand.java index f3bf58b..7c0c069 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/command/BombLobbersCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/command/BombLobbersCreateCommand.java @@ -23,7 +23,7 @@ public class BombLobbersCreateCommand implements CommandExecutor { new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); @@ -42,7 +42,7 @@ public class BombLobbersCreateCommand implements CommandExecutor { public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.manager.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); @@ -50,12 +50,12 @@ public class BombLobbersCreateCommand implements CommandExecutor { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); BombLobbersMap bombLobbersMap = new BombLobbersMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -70,7 +70,7 @@ public class BombLobbersCreateCommand implements CommandExecutor { bombLobbersMap.setId(text2); bombLobbersMap.setMaximumPlayers(index3); - defaultUser.a(new BombLobbersSetup(defaultUser, bombLobbersMap, this.manager, setupTarget)); + defaultUser.setArenaSetup(new BombLobbersSetup(defaultUser, bombLobbersMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/BombLobbersConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/BombLobbersConfiguration.java index 23b6039..b73d143 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/BombLobbersConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/BombLobbersConfiguration.java @@ -9,7 +9,7 @@ public class BombLobbersConfiguration { private final BombLobbersRewards rewards = new BombLobbersRewards(); private final BombLobbersSettings settings = new BombLobbersSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/message/BombLobbersMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/message/BombLobbersMessages.java index dd73a9c..961f15d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/message/BombLobbersMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/config/message/BombLobbersMessages.java @@ -11,33 +11,33 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class BombLobbersMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Bomb Lobbers"); + private String displayName = Strings.colorize("Bomb Lobbers"); @Setting("title-won") - private String titleWon = Strings.a("&aYOU WON!"); + private String titleWon = Strings.colorize("&aYOU WON!"); @Setting("title-lost") - private String titleLost = Strings.a("&cYOU LOST!"); + private String titleLost = Strings.colorize("&cYOU LOST!"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-kills") - private String statisticKills = Strings.a("Kills"); + private String statisticKills = Strings.colorize("Kills"); @Setting("team-red") - private String teamRed = Strings.a("Red"); + private String teamRed = Strings.colorize("Red"); @Setting("team-blue") - private String teamBlue = Strings.a("Blue"); + private String teamBlue = Strings.colorize("Blue"); @Setting("team-spectator") - private String teamSpectator = Strings.a("Spectator"); + private String teamSpectator = Strings.colorize("Spectator"); @Setting("player-killed") - private Text playerKilled = TextParser.a("&a%player% &ewas killed by %killer%!"); + private Text playerKilled = TextParser.parse("&a%player% &ewas killed by %killer%!"); @Setting("player-killed-by-border") - private Text playerKilledByBorder = TextParser.a("%player% &ewas killed by the border!"); + private Text playerKilledByBorder = TextParser.parse("%player% &ewas killed by the border!"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lBomb Lobbers", @@ -49,7 +49,7 @@ public class BombLobbersMessages extends BaseGameMessages { } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lBomb Lobbers", @@ -62,7 +62,7 @@ public class BombLobbersMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -79,9 +79,9 @@ public class BombLobbersMessages extends BaseGameMessages { ); public BombLobbersMessages() { - this.chatInGame = TextParser.a("%team_color%[%team%] &7%player%&f: %message%"); - this.spectatorTargetLore = new ArrayList<>(TextParser.a(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); - this.statisticsView = TextParser.a( + this.chatInGame = TextParser.parse("%team_color%[%team%] &7%player%&f: %message%"); + this.spectatorTargetLore = new ArrayList<>(TextParser.parseAll(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); + this.statisticsView = TextParser.parseAll( new String[]{" ", " &l%display_name% Statistics", " ", " Wins&a: %wins%", " Loses&a: %loses%", " Played&a: %played%", " Kills&a: %kills%", " "} ); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/lifecycle/BombLobbersLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/lifecycle/BombLobbersLifecycle.java index 4ba4fe4..5f9c18b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/lifecycle/BombLobbersLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/lifecycle/BombLobbersLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class BombLobbersLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public BombLobbersLifecycle(BombLobbersGame bombLobbersGame) { this.phase = new WaitingPhase(bombLobbersGame); - this.phase2 = new BombLobbersPlayingPhase(bombLobbersGame); - this.phase3 = new EndingPhase(bombLobbersGame); - this.phase4 = new ResettingPhase(bombLobbersGame); + this.playingPhase = new BombLobbersPlayingPhase(bombLobbersGame); + this.endingPhase = new EndingPhase(bombLobbersGame); + this.resettingPhase = new ResettingPhase(bombLobbersGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class BombLobbersLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/listener/BombLobbersListener.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/listener/BombLobbersListener.java index bf9a5d6..a4ddbc7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/listener/BombLobbersListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/listener/BombLobbersListener.java @@ -36,17 +36,17 @@ public class BombLobbersListener extends GameListener { } @EventHandler - public void a(EntityDamageEvent event) { - if (this.a(event.getEntity(), BombLobbersGamer.class) != null && event.getCause() != DamageCause.CUSTOM) { + public void onEntityDamage(EntityDamageEvent event) { + if (this.getActiveGamer(event.getEntity(), BombLobbersGamer.class) != null && event.getCause() != DamageCause.CUSTOM) { event.setCancelled(true); } } @EventHandler - public void a(PlayerToggleFlightEvent event) { + public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - BombLobbersGamer bombLobbersGamer = this.a(player, BombLobbersGamer.class); - if (bombLobbersGamer != null && !bombLobbersGamer.f()) { + BombLobbersGamer bombLobbersGamer = this.getActiveGamer(player, BombLobbersGamer.class); + if (bombLobbersGamer != null && !bombLobbersGamer.isSpectator()) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); @@ -55,7 +55,7 @@ public class BombLobbersListener extends GameListener { BombLobbersGame bombLobbersGame = bombLobbersGamer.getGame(); item.setAmount(item.getAmount() - 1); player.getInventory().setItem(0, item.getAmount() == 0 ? null : item); - bombLobbersGamer.d(bombLobbersGame.getSettings().getTntReplenishCooldown()); + bombLobbersGamer.setTntCooldownTicks(bombLobbersGame.getSettings().getTntReplenishCooldown()); VersionAdapters.get().spawnParticle(player, ArcadeParticle.EXPLOSION_LARGE, player.getLocation(), 5); VersionAdapters.get().playSound(player, ArcadeSound.GENERIC_EXPLODE, 1.0F, 1.0F); player.setVelocity(player.getLocation().getDirection().multiply(bombLobbersGame.getSettings().getDoubleJumpDistance()).setY(bombLobbersGame.getSettings().getDoubleJumpHeight())); @@ -64,10 +64,10 @@ public class BombLobbersListener extends GameListener { } @EventHandler - public void a(ExplosionPrimeEvent event) { + public void onExplosionPrime(ExplosionPrimeEvent event) { if (event.getEntityType() == EntityType.PRIMED_TNT) { TNTPrimed tNTPrimed = (TNTPrimed)event.getEntity(); - BombLobbersGamer bombLobbersGamer = this.a(tNTPrimed.getSource(), BombLobbersGamer.class); + BombLobbersGamer bombLobbersGamer = this.getActiveGamer(tNTPrimed.getSource(), BombLobbersGamer.class); if (bombLobbersGamer == null) { return; } @@ -77,10 +77,10 @@ public class BombLobbersListener extends GameListener { } @EventHandler - public void a(EntityExplodeEvent event) { + public void onEntityExplode(EntityExplodeEvent event) { if (event.getEntityType() == EntityType.PRIMED_TNT) { TNTPrimed tNTPrimed = (TNTPrimed)event.getEntity(); - BombLobbersGamer bombLobbersGamer = this.a(tNTPrimed.getSource(), BombLobbersGamer.class); + BombLobbersGamer bombLobbersGamer = this.getActiveGamer(tNTPrimed.getSource(), BombLobbersGamer.class); if (bombLobbersGamer == null) { return; } @@ -88,25 +88,25 @@ public class BombLobbersListener extends GameListener { BombLobbersGame bombLobbersGame = bombLobbersGamer.getGame(); if (bombLobbersGame.getPhase() != bombLobbersGame.getPhaseLifecycle().getPlaying()) { event.setCancelled(true); - } else if (bombLobbersGame.r().remove(tNTPrimed.getUniqueId()) != null) { - if (bombLobbersGamer.getTeam().getSettings().getPlayZone().a(event.getLocation())) { + } else if (bombLobbersGame.getThrownTntEntities().remove(tNTPrimed.getUniqueId()) != null) { + if (bombLobbersGamer.getTeam().getSettings().getPlayZone().contains(event.getLocation())) { event.setCancelled(true); } else { for (BombLobbersGamer bombLobbersGamer2 : bombLobbersGame.getGamers()) { - if (bombLobbersGamer2.getTeam() != bombLobbersGamer.getTeam() && !bombLobbersGamer2.g()) { + if (bombLobbersGamer2.getTeam() != bombLobbersGamer.getTeam() && !bombLobbersGamer2.isActiveSpectator()) { Player player = bombLobbersGamer2.toPlayer(); if (tNTPrimed.getWorld() == player.getWorld()) { double doubleVal = tNTPrimed.getLocation().distanceSquared(player.getLocation()); if (!(doubleVal > 16.0)) { if (bombLobbersGamer2.toPlayer().getHealth() <= 16.0 - doubleVal) { player.damage(0.0); - bombLobbersGamer2.b(true); + bombLobbersGamer2.setSpectator(true); bombLobbersGame.getSpectatorTeam().addEntry(bombLobbersGamer2.getName()); - bombLobbersGamer2.a(bombLobbersGame.getMap().getSpectator()); - bombLobbersGamer.c(bombLobbersGamer.m() + 1); + bombLobbersGamer2.teleport(bombLobbersGame.getMap().getSpectator()); + bombLobbersGamer.setKills(bombLobbersGamer.getKills() + 1); bombLobbersGamer.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - Context context = Contexts.a(bombLobbersGamer2, text -> text.equals("killer") ? bombLobbersGamer.getName() : null); - bombLobbersGame.getGamers().a(bombLobbersGame.getMessages().getPlayerKilled(), context); + Context context = Contexts.withVariables(bombLobbersGamer2, text -> text.equals("killer") ? bombLobbersGamer.getName() : null); + bombLobbersGame.getGamers().broadcast(bombLobbersGame.getMessages().getPlayerKilled(), context); } else { bombLobbersGamer2.toPlayer().damage(16.0 - doubleVal); } @@ -117,58 +117,58 @@ public class BombLobbersListener extends GameListener { event.blockList().forEach(block -> { if (!block.isEmpty()) { - BlockPhysics.a(block, var1xx -> { + BlockPhysics.forEachDependent(block, var1xx -> { bombLobbersGame.getRollbackQueue().add(var1xx.getState()); var1xx.setType(Material.AIR); }); } }); event.blockList().clear(); - bombLobbersGame.x(); + bombLobbersGame.checkWinCondition(); } } } } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); - if (location != null && !Locations.a(location, event.getFrom())) { + if (location != null && !Locations.isSameBlock(location, event.getFrom())) { Player player = event.getPlayer(); - BombLobbersGamer bombLobbersGamer = this.a(player, BombLobbersGamer.class); + BombLobbersGamer bombLobbersGamer = this.getActiveGamer(player, BombLobbersGamer.class); if (bombLobbersGamer == null) { return; } BombLobbersGame bombLobbersGame = bombLobbersGamer.getGame(); - if (bombLobbersGamer.f()) { - if (!bombLobbersGame.getMap().getPlayZone().a(location)) { + if (bombLobbersGamer.isSpectator()) { + if (!bombLobbersGame.getMap().getPlayZone().contains(location)) { event.setTo(bombLobbersGame.getMap().getSpectator()); player.setFlying(true); } - } else if (bombLobbersGamer.getTeam().getSettings().getPlayZone().a(location)) { + } else if (bombLobbersGamer.getTeam().getSettings().getPlayZone().contains(location)) { if (player.getInventory().getItem(0) != null && location.getBlock().getRelative(BlockFace.DOWN).isEmpty()) { player.setAllowFlight(true); } } else { - bombLobbersGamer.b(true); + bombLobbersGamer.setSpectator(true); bombLobbersGame.getSpectatorTeam().addEntry(bombLobbersGamer.getName()); event.setTo(bombLobbersGame.getMap().getSpectator()); - bombLobbersGame.getGamers().a(bombLobbersGame.getMessages().getPlayerKilledByBorder(), bombLobbersGamer); - bombLobbersGame.x(); + bombLobbersGame.getGamers().broadcast(bombLobbersGame.getMessages().getPlayerKilledByBorder(), bombLobbersGamer); + bombLobbersGame.checkWinCondition(); } } } @EventHandler - public void a(PlayerInteractEvent event) { - if (!EngineUtils.b(event.getAction())) { + public void onPlayerInteract(PlayerInteractEvent event) { + if (!EngineUtils.isRightClick(event.getAction())) { return; } Player player = event.getPlayer(); - BombLobbersGamer bombLobbersGamer = this.a(player, BombLobbersGamer.class); - if (bombLobbersGamer == null || bombLobbersGamer.f()) { + BombLobbersGamer bombLobbersGamer = this.getActiveGamer(player, BombLobbersGamer.class); + if (bombLobbersGamer == null || bombLobbersGamer.isSpectator()) { return; } @@ -182,11 +182,11 @@ public class BombLobbersListener extends GameListener { if (item != null && item.getAmount() > 0) { item.setAmount(item.getAmount() - 1); player.getInventory().setItem(0, item.getAmount() == 0 ? null : item); - bombLobbersGamer.d(bombLobbersGame.getSettings().getTntReplenishCooldown()); + bombLobbersGamer.setTntCooldownTicks(bombLobbersGame.getSettings().getTntReplenishCooldown()); Vector vector = player.getEyeLocation().getDirection().multiply(bombLobbersGame.getSettings().getTntLaunchSpeed()); TNTPrimed tNTPrimed = bombLobbersGame.getManager().getTntFactory().spawnTnt(player, bombLobbersGamer.getTeam().getTeamColor().getColor(), vector); tNTPrimed.setFuseTicks(60); - bombLobbersGame.r().put(tNTPrimed.getUniqueId(), tNTPrimed); + bombLobbersGame.getThrownTntEntities().put(tNTPrimed.getUniqueId(), tNTPrimed); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/phase/BombLobbersPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/phase/BombLobbersPlayingPhase.java index 6bf2678..dfdc6d1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/phase/BombLobbersPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/phase/BombLobbersPlayingPhase.java @@ -23,25 +23,25 @@ public class BombLobbersPlayingPhase implements Phase { } public void start() { - this.game.a(this.game.getSettings().getTimeDuration()); - this.game.setGamers((BombLobbersGamer[])this.game.getGamers().a(new BombLobbersGamer[this.game.getGamers().size()])); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getEngine().getPlugin(), chunk)); - this.a(); - this.game.getTeam().h(); - this.game.getTeam3().h(); + this.game.setTimeLeft(this.game.getSettings().getTimeDuration()); + this.game.setGamers((BombLobbersGamer[])this.game.getGamers().toArray(new BombLobbersGamer[this.game.getGamers().size()])); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getEngine().getPlugin(), chunk)); + this.assignTeams(); + this.game.getTeam().preparePlayers(); + this.game.getBlueTeam().preparePlayers(); } - private void a() { - List list = this.game.getGamers().d(); + private void assignTeams() { + List list = this.game.getGamers().toList(); int index = list.size() / 2; int index2 = list.size() % 2; - BombLobbersTeam[] bombLobbersTeams = new BombLobbersTeam[]{this.game.getTeam(), this.game.getTeam3()}; - Randoms.b(bombLobbersTeams); - this.a(bombLobbersTeams, list, index, index2); + BombLobbersTeam[] bombLobbersTeams = new BombLobbersTeam[]{this.game.getTeam(), this.game.getBlueTeam()}; + Randoms.shuffle(bombLobbersTeams); + this.assignParties(bombLobbersTeams, list, index, index2); Collections.shuffle(list); for (BombLobbersTeam bombLobbersTeam : bombLobbersTeams) { - int index3 = bombLobbersTeam.a() < index2 ? index + 1 : index; + int index3 = bombLobbersTeam.getIndex() < index2 ? index + 1 : index; while (!list.isEmpty() && bombLobbersTeam.getList().size() < index3) { bombLobbersTeam.getList().add((BombLobbersGamer)list.remove(list.size() - 1)); @@ -49,11 +49,11 @@ public class BombLobbersPlayingPhase implements Phase { } } - private void a(BombLobbersTeam[] bombLobbersTeams, List list, int index, int index2) { + private void assignParties(BombLobbersTeam[] bombLobbersTeams, List list, int index, int index2) { HashMap> map = new HashMap<>(); for (BombLobbersGamer bombLobbersGamer : list) { - Party party = bombLobbersGamer.d(); + Party party = bombLobbersGamer.getParty(); if (party != null && party.size() > 1 && list.size() > party.size()) { map.computeIfAbsent(party.getLeader(), uuid -> new ArrayList<>()).add(bombLobbersGamer); } @@ -61,11 +61,11 @@ public class BombLobbersPlayingPhase implements Phase { for (List list2 : map.values()) { for (BombLobbersTeam bombLobbersTeam : bombLobbersTeams) { - int index3 = bombLobbersTeam.a() < index2 ? index + 1 : index; + int index3 = bombLobbersTeam.getIndex() < index2 ? index + 1 : index; if (index3 - bombLobbersTeam.getList().size() >= list2.size()) { bombLobbersTeam.getList().addAll(list2); list.removeAll(list2); - Randoms.b(bombLobbersTeams); + Randoms.shuffle(bombLobbersTeams); break; } } @@ -73,12 +73,12 @@ public class BombLobbersPlayingPhase implements Phase { } public void stop() { - this.game.getTeam().i(); - this.game.getTeam3().i(); - this.game.r().values().forEach(Entity::remove); - this.game.r().clear(); + this.game.getTeam().clear(); + this.game.getBlueTeam().clear(); + this.game.getThrownTntEntities().values().forEach(Entity::remove); + this.game.getThrownTntEntities().clear(); this.game.setGamers((ro.fr33styler.arcade.game.bomblobbers.player.BombLobbersGamer[])null); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getEngine().getPlugin(), chunk)); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getEngine().getPlugin(), chunk)); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -92,17 +92,17 @@ public class BombLobbersPlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.game.w() <= 0) { - this.game.a((ro.fr33styler.arcade.game.bomblobbers.team.BombLobbersTeam)null); + if (this.game.getTimeLeft() <= 0) { + this.game.finishGame((ro.fr33styler.arcade.game.bomblobbers.team.BombLobbersTeam)null); return; } - this.game.getGamers().a(this.game.getMessages().getSidebarPlaying()); - this.game.a(this.game.w() - 1); + this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarPlaying()); + this.game.setTimeLeft(this.game.getTimeLeft() - 1); } for (BombLobbersGamer bombLobbersGamer : this.game.getGamers()) { - bombLobbersGamer.q(); + bombLobbersGamer.tickCooldown(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/player/BombLobbersGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/player/BombLobbersGamer.java index 37e04ac..9b2883e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/player/BombLobbersGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/player/BombLobbersGamer.java @@ -14,9 +14,9 @@ import org.bukkit.inventory.ItemStack; import ro.fr33styler.arcade.platform.compat.ArcadeSound; public class BombLobbersGamer extends BaseGamer { - private int b; + private int kills; private BombLobbersTeam team; - private int d; + private int tntCooldownTicks; private final BombLobbersGame game; public BombLobbersGamer(BombLobbersGame game2, DefaultUser defaultUser) { @@ -28,16 +28,16 @@ public class BombLobbersGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getKills() { + return this.kills; } - public void c(int index) { - this.b = index; + public void setKills(int index) { + this.kills = index; } - public void d(int index) { - this.d = index; + public void setTntCooldownTicks(int index) { + this.tntCooldownTicks = index; } public BombLobbersTeam getTeam() { @@ -48,7 +48,7 @@ public class BombLobbersGamer extends BaseGamer { this.team = team2; } - public void o() { + public void replenishTnt() { ItemStack item = this.player.getInventory().getItem(0); if (item == null) { item = new ItemStack(Material.TNT); @@ -57,7 +57,7 @@ public class BombLobbersGamer extends BaseGamer { } if (item.getAmount() < this.game.getSettings().getTntMaxAmount()) { - this.d = this.game.getSettings().getTntReplenishCooldown(); + this.tntCooldownTicks = this.game.getSettings().getTntReplenishCooldown(); } this.playSound(ArcadeSound.ITEM_PICKUP, 1.0F, 1.0F); @@ -65,50 +65,50 @@ public class BombLobbersGamer extends BaseGamer { this.player.setExp(0.0F); } - public void q() { - if (this.d > 0) { - if (this.d % 2 == 0) { - if (this.f()) { + public void tickCooldown() { + if (this.tntCooldownTicks > 0) { + if (this.tntCooldownTicks % 2 == 0) { + if (this.isSpectator()) { this.player.setExp(0.0F); - this.d = 0; - } else if (this.d > 0) { - this.player.setExp(1.0F - (float)this.d / this.game.getSettings().getTntReplenishCooldown()); + this.tntCooldownTicks = 0; + } else if (this.tntCooldownTicks > 0) { + this.player.setExp(1.0F - (float)this.tntCooldownTicks / this.game.getSettings().getTntReplenishCooldown()); } } - this.d--; - if (this.d == 0) { - this.o(); + this.tntCooldownTicks--; + if (this.tntCooldownTicks == 0) { + this.replenishTnt(); } } } - private void r() { + private void saveStatistics() { BombLobbersStatistics bombLobbersStatistics = this.game.getManager().getData(this.getUUID()); - if (bombLobbersStatistics.a()) { - bombLobbersStatistics.a(bombLobbersStatistics.getWins() + this.getWins()); + if (bombLobbersStatistics.isLoaded()) { + bombLobbersStatistics.setWins(bombLobbersStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - bombLobbersStatistics.d(bombLobbersStatistics.getCurrentWinStreak() + 1); + bombLobbersStatistics.setCurrentWinStreak(bombLobbersStatistics.getCurrentWinStreak() + 1); if (bombLobbersStatistics.getWinStreak() < bombLobbersStatistics.getCurrentWinStreak()) { - bombLobbersStatistics.c(bombLobbersStatistics.getCurrentWinStreak()); + bombLobbersStatistics.setWinStreak(bombLobbersStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - bombLobbersStatistics.d(0); + bombLobbersStatistics.setCurrentWinStreak(0); } - bombLobbersStatistics.b(bombLobbersStatistics.getLoses() + this.getLoses()); - bombLobbersStatistics.e(bombLobbersStatistics.d() + this.b); - this.b(bombLobbersStatistics.getMap()); - this.game.getManager().getStorage().e().b(bombLobbersStatistics); - this.game.getManager().getStorage().e().a(this); + bombLobbersStatistics.setLoses(bombLobbersStatistics.getLoses() + this.getLoses()); + bombLobbersStatistics.setKills(bombLobbersStatistics.getKills() + this.kills); + this.saveProperties(bombLobbersStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(bombLobbersStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @Override public String getVariable(String text) { return switch (text) { - case "kills" -> String.valueOf(this.b); - case "team" -> this.team == null ? this.game.getMessages().getTeamSpectator() : this.team.getTeamColor().a(this.game.getMessages()); + case "kills" -> String.valueOf(this.kills); + case "team" -> this.team == null ? this.game.getMessages().getTeamSpectator() : this.team.getTeamColor().getDisplayName(this.game.getMessages()); case "team_color" -> (this.team == null ? ChatColor.GOLD : this.team.getTeamColor().getChatColor()).toString(); default -> super.getVariable(text); }; @@ -116,10 +116,10 @@ public class BombLobbersGamer extends BaseGamer { @Override public void leave() { - this.r(); - this.game.getGamers().b(this); + this.saveStatistics(); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - Iterator iterator = this.game.r().values().iterator(); + Iterator iterator = this.game.getThrownTntEntities().values().iterator(); while (iterator.hasNext()) { TNTPrimed tNTPrimed = (TNTPrimed)iterator.next(); @@ -132,7 +132,7 @@ public class BombLobbersGamer extends BaseGamer { if (this.team != null) { this.team.getList().remove(this); this.team.getScoreboardTeam().removeEntry(this.getName()); - this.game.x(); + this.game.checkWinCondition(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSession.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSession.java index d2bda7e..5ea9c28 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSession.java @@ -22,11 +22,11 @@ public class BombLobbersSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { BombLobbersGamer bombLobbersGamer = new BombLobbersGamer(this.game, defaultUser); - this.game.getGamers().a(bombLobbersGamer); - bombLobbersGamer.a(this.game.getMessages().getStart()); - bombLobbersGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(bombLobbersGamer); + bombLobbersGamer.sendMessages(this.game.getMessages().getStart()); + bombLobbersGamer.teleport(this.game.getMap().getLobby()); return bombLobbersGamer; }); } @@ -40,7 +40,7 @@ public class BombLobbersSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof BombLobbersGamer var2) { BombLobbersGame bombLobbersGame = var2.getGame(); - if (bombLobbersGame.getPhase() != bombLobbersGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (bombLobbersGame.getPhase() != bombLobbersGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, bombLobbersGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class BombLobbersSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { BombLobbersGamer bombLobbersGamer = new BombLobbersGamer(this.game, defaultUser); - this.game.getGamers().a(bombLobbersGamer); - bombLobbersGamer.a(this.game.getMap().getSpectator()); - bombLobbersGamer.b(true); - bombLobbersGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(bombLobbersGamer); + bombLobbersGamer.teleport(this.game.getMap().getSpectator()); + bombLobbersGamer.setSpectator(true); + bombLobbersGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(bombLobbersGamer.getName()); return bombLobbersGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSessions.java index 1b07bcc..44cdd4a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/session/BombLobbersSessions.java @@ -9,46 +9,46 @@ import ro.fr33styler.arcade.game.bomblobbers.map.BombLobbersMap; import org.bukkit.World; public class BombLobbersSessions extends BaseSessions { - private final BombLobbersManager a; + private final BombLobbersManager manager; public BombLobbersSessions(BombLobbersManager bombLobbersManager) { super(bombLobbersManager); - this.a = bombLobbersManager; + this.manager = bombLobbersManager; } public BombLobbersManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(bombLobbersMap -> this.registerGame(new BombLobbersGame(this.a, bombLobbersMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(bombLobbersMap -> this.registerGame(new BombLobbersGame(this.manager, bombLobbersMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected BombLobbersMap h(String text) { + protected BombLobbersMap createMap(String text) { BombLobbersMap bombLobbersMap = new BombLobbersMap(); bombLobbersMap.setId(text); return bombLobbersMap; } - protected BombLobbersGame a(BombLobbersMap bombLobbersMap) { - return new BombLobbersGame(this.a, bombLobbersMap); + protected BombLobbersGame createGame(BombLobbersMap bombLobbersMap) { + return new BombLobbersGame(this.manager, bombLobbersMap); } public BombLobbersSession createSession(BombLobbersGame bombLobbersGame) { return bombLobbersGame == null ? null : new BombLobbersSession(bombLobbersGame); } - protected void a(BombLobbersMap bombLobbersMap, World world, BombLobbersMap bombLobbersMap2) { - super.a(bombLobbersMap, world, bombLobbersMap2); - bombLobbersMap2.setSpectator(Locations.a(world, bombLobbersMap.getSpectator())); - bombLobbersMap2.setPlayZone(bombLobbersMap.getPlayZone().a(world)); - bombLobbersMap2.getRedTeam().setPlayZone(bombLobbersMap.getRedTeam().getPlayZone().a(world)); + protected void copyMap(BombLobbersMap bombLobbersMap, World world, BombLobbersMap bombLobbersMap2) { + super.copyMap(bombLobbersMap, world, bombLobbersMap2); + bombLobbersMap2.setSpectator(Locations.withWorld(world, bombLobbersMap.getSpectator())); + bombLobbersMap2.setPlayZone(bombLobbersMap.getPlayZone().withWorld(world)); + bombLobbersMap2.getRedTeam().setPlayZone(bombLobbersMap.getRedTeam().getPlayZone().withWorld(world)); bombLobbersMap2.getRedTeam().getSpawns().clear(); - bombLobbersMap2.getRedTeam().getSpawns().addAll(Locations.a(world, bombLobbersMap.getRedTeam().getSpawns())); - bombLobbersMap2.getBlueTeam().setPlayZone(bombLobbersMap.getBlueTeam().getPlayZone().a(world)); + bombLobbersMap2.getRedTeam().getSpawns().addAll(Locations.withWorld(world, bombLobbersMap.getRedTeam().getSpawns())); + bombLobbersMap2.getBlueTeam().setPlayZone(bombLobbersMap.getBlueTeam().getPlayZone().withWorld(world)); bombLobbersMap2.getBlueTeam().getSpawns().clear(); - bombLobbersMap2.getBlueTeam().getSpawns().addAll(Locations.a(world, bombLobbersMap.getBlueTeam().getSpawns())); + bombLobbersMap2.getBlueTeam().getSpawns().addAll(Locations.withWorld(world, bombLobbersMap.getBlueTeam().getSpawns())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/BombLobbersSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/BombLobbersSetup.java index 3db0499..c90f0bf 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/BombLobbersSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/BombLobbersSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class BombLobbersSetup extends ArenaSetup { private final BombLobbersMap map; - private final BombLobbersManager d; + private final BombLobbersManager manager; private final SetupTarget setupTarget; public BombLobbersSetup(DefaultUser defaultUser, BombLobbersMap map2, BombLobbersManager bombLobbersManager, SetupTarget setupTarget2) { super(defaultUser, bombLobbersManager.getName()); - this.d = bombLobbersManager; + this.manager = bombLobbersManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new BombLobbersSetArenaNameStep(this); } - public BombLobbersMap getMap16() { + public BombLobbersMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class BombLobbersSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new BombLobbersGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new BombLobbersGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddBlueTeamSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddBlueTeamSpawnStep.java index 425f30e..682c236 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddBlueTeamSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddBlueTeamSpawnStep.java @@ -18,7 +18,7 @@ public class BombLobbersAddBlueTeamSpawnStep implements ClickSetupStep, Repeatab this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the blue"); defaultUser.sendMessage("§e team players spawn at. If you made a mistake"); @@ -26,31 +26,31 @@ public class BombLobbersAddBlueTeamSpawnStep implements ClickSetupStep, Repeatab defaultUser.sendMessage("§e click the yellow dye to continue."); } - public void b() { - this.bombLobbersSetup.getMap16().getBlueTeam().getSpawns().clear(); + public void onUndo() { + this.bombLobbersSetup.getMap().getBlueTeam().getSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.bombLobbersSetup.getUser().toPlayer(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.bombLobbersSetup.getMap16().getBlueTeam().getPlayZone().a(location)) { - this.bombLobbersSetup.getMap16().getBlueTeam().getSpawns().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.bombLobbersSetup.getMap16().getBlueTeam().getSpawns().size() + "§8)"); - if (this.bombLobbersSetup.getMap16().getBlueTeam().getSpawns().size() == 1) { - this.e(); + if (this.bombLobbersSetup.getMap().getBlueTeam().getPlayZone().contains(location)) { + this.bombLobbersSetup.getMap().getBlueTeam().getSpawns().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.bombLobbersSetup.getMap().getBlueTeam().getSpawns().size() + "§8)"); + if (this.bombLobbersSetup.getMap().getBlueTeam().getSpawns().size() == 1) { + this.addFinishButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - this.b(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + this.onUndo(); player.sendMessage("§eBlue team spawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset blue team spawns").build()); } - private void e() { - this.bombLobbersSetup.getHotbar().a(2, () -> this.bombLobbersSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish setup").build()); + private void addFinishButton() { + this.bombLobbersSetup.getHotbar().setSlot(2, () -> this.bombLobbersSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish setup").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddRedTeamSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddRedTeamSpawnStep.java index 7c902da..aff6c66 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddRedTeamSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersAddRedTeamSpawnStep.java @@ -17,7 +17,7 @@ public class BombLobbersAddRedTeamSpawnStep implements ClickSetupStep, Repeatabl this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the red"); defaultUser.sendMessage("§e team players spawn at. If you made a mistake"); @@ -25,31 +25,31 @@ public class BombLobbersAddRedTeamSpawnStep implements ClickSetupStep, Repeatabl defaultUser.sendMessage("§e click the yellow dye to continue."); } - public void b() { - this.bombLobbersSetup.getMap16().getRedTeam().getSpawns().clear(); + public void onUndo() { + this.bombLobbersSetup.getMap().getRedTeam().getSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.bombLobbersSetup.getUser().toPlayer(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.bombLobbersSetup.getMap16().getRedTeam().getPlayZone().a(location)) { - this.bombLobbersSetup.getMap16().getRedTeam().getSpawns().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.bombLobbersSetup.getMap16().getRedTeam().getSpawns().size() + "§8)"); - if (this.bombLobbersSetup.getMap16().getRedTeam().getSpawns().size() == 1) { - this.e(); + if (this.bombLobbersSetup.getMap().getRedTeam().getPlayZone().contains(location)) { + this.bombLobbersSetup.getMap().getRedTeam().getSpawns().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.bombLobbersSetup.getMap().getRedTeam().getSpawns().size() + "§8)"); + if (this.bombLobbersSetup.getMap().getRedTeam().getSpawns().size() == 1) { + this.addNextStepButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - this.b(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + this.onUndo(); player.sendMessage("§eRed team spawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset red team spawns").build()); } - private void e() { - this.bombLobbersSetup.getHotbar().a(2, () -> this.bombLobbersSetup.a(new BombLobbersSetBlueTeamZoneStep(this.bombLobbersSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lNext Step").build()); + private void addNextStepButton() { + this.bombLobbersSetup.getHotbar().setSlot(2, () -> this.bombLobbersSetup.advanceStep(new BombLobbersSetBlueTeamZoneStep(this.bombLobbersSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lNext Step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetArenaNameStep.java index 58a1b5d..4f02f26 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetArenaNameStep.java @@ -10,12 +10,12 @@ public class BombLobbersSetArenaNameStep implements ChatSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { this.bombLobbersSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.bombLobbersSetup.getMap16().setName(text); - this.bombLobbersSetup.a(new BombLobbersSetLobbySpawnStep(this.bombLobbersSetup)); + public void onChatInput(String text) { + this.bombLobbersSetup.getMap().setName(text); + this.bombLobbersSetup.advanceStep(new BombLobbersSetLobbySpawnStep(this.bombLobbersSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetBlueTeamZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetBlueTeamZoneStep.java index 9e4c6c5..2bd8522 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetBlueTeamZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetBlueTeamZoneStep.java @@ -17,34 +17,34 @@ public class BombLobbersSetBlueTeamZoneStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the blue team play zone."); defaultUser.sendMessage("§e If you can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (this.bombLobbersSetup.getMap16().getPlayZone().a(cuboid)) { - if (this.bombLobbersSetup.getMap16().getRedTeam().getPlayZone().b(cuboid)) { + if (this.bombLobbersSetup.getMap().getPlayZone().contains(cuboid)) { + if (this.bombLobbersSetup.getMap().getRedTeam().getPlayZone().overlaps(cuboid)) { defaultUser.sendMessage("§cThe selection is overlapping the red team Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.bombLobbersSetup.getMap16().getBlueTeam().setPlayZone(cuboid); - this.bombLobbersSetup.a(new BombLobbersAddBlueTeamSpawnStep(this.bombLobbersSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.bombLobbersSetup.getMap().getBlueTeam().setPlayZone(cuboid); + this.bombLobbersSetup.advanceStep(new BombLobbersAddBlueTeamSpawnStep(this.bombLobbersSetup)); } } else { defaultUser.sendMessage("§cMust be inside the Play Zone!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbyRemovalRegionStep.java index 3252b74..43ef25b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class BombLobbersSetLobbyRemovalRegionStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class BombLobbersSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.bombLobbersSetup.getMap16().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.bombLobbersSetup.a(new BombLobbersSetPlayZoneStep(this.bombLobbersSetup)); + this.bombLobbersSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.bombLobbersSetup.advanceStep(new BombLobbersSetPlayZoneStep(this.bombLobbersSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.bombLobbersSetup.getHotbar().a(2, () -> { - this.bombLobbersSetup.getMap16().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.bombLobbersSetup.a(new BombLobbersSetPlayZoneStep(this.bombLobbersSetup)); + this.bombLobbersSetup.getHotbar().setSlot(2, () -> { + this.bombLobbersSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.bombLobbersSetup.advanceStep(new BombLobbersSetPlayZoneStep(this.bombLobbersSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbySpawnStep.java index fb82571..b0382d2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class BombLobbersSetLobbySpawnStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.bombLobbersSetup.getUser().toPlayer(); - this.bombLobbersSetup.getHotbar().a(0, () -> { - this.bombLobbersSetup.getMap16().setLobby(player.getLocation()); - this.bombLobbersSetup.a(new BombLobbersSetLobbyRemovalRegionStep(this.bombLobbersSetup)); + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { + this.bombLobbersSetup.getMap().setLobby(player.getLocation()); + this.bombLobbersSetup.advanceStep(new BombLobbersSetLobbyRemovalRegionStep(this.bombLobbersSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetPlayZoneStep.java index c5d2e0b..5cf0b9b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class BombLobbersSetPlayZoneStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.bombLobbersSetup.getMap16().setPlayZone(new Cuboid(block, block2)); - this.bombLobbersSetup.a(new BombLobbersSetSpectatorSpawnStep(this.bombLobbersSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.bombLobbersSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.bombLobbersSetup.advanceStep(new BombLobbersSetSpectatorSpawnStep(this.bombLobbersSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetRedTeamZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetRedTeamZoneStep.java index 38c5153..6f3424b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetRedTeamZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetRedTeamZoneStep.java @@ -17,31 +17,31 @@ public class BombLobbersSetRedTeamZoneStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the red team play zone."); defaultUser.sendMessage("§e If you can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.bombLobbersSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.bombLobbersSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (this.bombLobbersSetup.getMap16().getPlayZone().a(cuboid)) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.bombLobbersSetup.getMap16().getRedTeam().setPlayZone(cuboid); - this.bombLobbersSetup.a(new BombLobbersAddRedTeamSpawnStep(this.bombLobbersSetup)); + if (this.bombLobbersSetup.getMap().getPlayZone().contains(cuboid)) { + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.bombLobbersSetup.getMap().getRedTeam().setPlayZone(cuboid); + this.bombLobbersSetup.advanceStep(new BombLobbersAddRedTeamSpawnStep(this.bombLobbersSetup)); } else { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetSpectatorSpawnStep.java index 935ec2f..d22f1c8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/setup/step/BombLobbersSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class BombLobbersSetSpectatorSpawnStep implements ClickSetupStep { this.bombLobbersSetup = bombLobbersSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.bombLobbersSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.bombLobbersSetup.getUser().toPlayer(); - this.bombLobbersSetup.getHotbar().a(0, () -> { + this.bombLobbersSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.bombLobbersSetup.getMap16().getPlayZone().a(location)) { - this.bombLobbersSetup.getMap16().setSpectator(location); - this.bombLobbersSetup.a(new BombLobbersSetRedTeamZoneStep(this.bombLobbersSetup)); + if (this.bombLobbersSetup.getMap().getPlayZone().contains(location)) { + this.bombLobbersSetup.getMap().setSpectator(location); + this.bombLobbersSetup.advanceStep(new BombLobbersSetRedTeamZoneStep(this.bombLobbersSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/BombLobbersStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/BombLobbersStatistics.java index 65f2761..17e3df0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/BombLobbersStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/BombLobbersStatistics.java @@ -9,21 +9,21 @@ import ro.fr33styler.arcade.game.bomblobbers.team.BombLobbersTeam; import java.util.UUID; public class BombLobbersStatistics extends BaseGameStatistics { - private int b; + private int kills; public BombLobbersStatistics(BombLobbersManager bombLobbersManager, UUID uuid, String text) { super(bombLobbersManager, uuid, text); } - public int d() { - return this.b; + public int getKills() { + return this.kills; } - public void e(int index) { - this.b = index; + public void setKills(int index) { + this.kills = index; } - private BombLobbersTeam e() { + private BombLobbersTeam getCurrentTeam() { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(this.getUUID()); if (defaultUser == null) { return null; @@ -33,23 +33,23 @@ public class BombLobbersStatistics extends BaseGameStatistics { } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { return switch (text) { case "team" -> { - BombLobbersTeam bombLobbersTeam = this.e(); - yield bombLobbersTeam == null ? "" : bombLobbersTeam.c(); + BombLobbersTeam bombLobbersTeam = this.getCurrentTeam(); + yield bombLobbersTeam == null ? "" : bombLobbersTeam.getDisplayName(); } case "team_color" -> { - BombLobbersTeam bombLobbersTeam2 = this.e(); + BombLobbersTeam bombLobbersTeam2 = this.getCurrentTeam(); yield bombLobbersTeam2 == null ? "" : bombLobbersTeam2.getTeamColor().toString(); } - case "stats_kills" -> String.valueOf(this.b); - default -> super.a(text); + case "stats_kills" -> String.valueOf(this.kills); + default -> super.resolvePlaceholder(text); }; } @Override public String getVariable(String text) { - return text.equals("kills") ? String.valueOf(this.b) : super.getVariable(text); + return text.equals("kills") ? String.valueOf(this.kills) : super.getVariable(text); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/storage/BombLobbersStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/storage/BombLobbersStatisticsRepository.java index 185b044..057d02e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/storage/BombLobbersStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/statistics/storage/BombLobbersStatisticsRepository.java @@ -14,105 +14,105 @@ public class BombLobbersStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a("CREATE TABLE IF NOT EXISTS " + this.b + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); } - public void a(BombLobbersStatistics bombLobbersStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(BombLobbersStatistics bombLobbersStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, bombLobbersStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(bombLobbersStatistics, var3); + this.readStatistics(bombLobbersStatistics, var3); } - bombLobbersStatistics.a(true); + bombLobbersStatistics.setLoaded(true); } }); } - private void a(BombLobbersStatistics bombLobbersStatistics, ResultSet resultSet) throws java.sql.SQLException { - bombLobbersStatistics.b(resultSet.getString("options")); - bombLobbersStatistics.a(resultSet.getInt("wins")); - bombLobbersStatistics.c(resultSet.getInt("win_streak")); - bombLobbersStatistics.d(resultSet.getInt("current_win_streak")); - bombLobbersStatistics.b(resultSet.getInt("loses")); - bombLobbersStatistics.e(resultSet.getInt("kills")); + private void readStatistics(BombLobbersStatistics bombLobbersStatistics, ResultSet resultSet) throws java.sql.SQLException { + bombLobbersStatistics.deserializeProperties(resultSet.getString("options")); + bombLobbersStatistics.setWins(resultSet.getInt("wins")); + bombLobbersStatistics.setWinStreak(resultSet.getInt("win_streak")); + bombLobbersStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + bombLobbersStatistics.setLoses(resultSet.getInt("loses")); + bombLobbersStatistics.setKills(resultSet.getInt("kills")); } - public void b(BombLobbersStatistics bombLobbersStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(BombLobbersStatistics bombLobbersStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, bombLobbersStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(bombLobbersStatistics); + this.updateStatistics(bombLobbersStatistics); } else { - this.c(bombLobbersStatistics); + this.insertStatistics(bombLobbersStatistics); } } }); } - private void c(BombLobbersStatistics bombLobbersStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(BombLobbersStatistics bombLobbersStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, bombLobbersStatistics.getUUID().toString()); - preparedStatement.setString(2, bombLobbersStatistics.c()); + preparedStatement.setString(2, bombLobbersStatistics.serializeProperties()); preparedStatement.setInt(3, bombLobbersStatistics.getWins()); preparedStatement.setInt(4, bombLobbersStatistics.getWinStreak()); preparedStatement.setInt(5, bombLobbersStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, bombLobbersStatistics.getLoses()); - preparedStatement.setInt(7, bombLobbersStatistics.d()); + preparedStatement.setInt(7, bombLobbersStatistics.getKills()); preparedStatement.executeUpdate(); }); } - private void d(BombLobbersStatistics bombLobbersStatistics) { - this.a() - .a( + private void updateStatistics(BombLobbersStatistics bombLobbersStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, kills = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, bombLobbersStatistics.c()); + preparedStatement.setString(1, bombLobbersStatistics.serializeProperties()); preparedStatement.setInt(2, bombLobbersStatistics.getWins()); preparedStatement.setInt(3, bombLobbersStatistics.getWinStreak()); preparedStatement.setInt(4, bombLobbersStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, bombLobbersStatistics.getLoses()); - preparedStatement.setInt(6, bombLobbersStatistics.d()); + preparedStatement.setInt(6, bombLobbersStatistics.getKills()); preparedStatement.setString(7, bombLobbersStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(BombLobbersGamer bombLobbersGamer) { - this.a(this.b + "_weekly", bombLobbersGamer); - this.a(this.b + "_monthly", bombLobbersGamer); + public void savePeriodicStatistics(BombLobbersGamer bombLobbersGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", bombLobbersGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", bombLobbersGamer); } - private void a(String text, BombLobbersGamer bombLobbersGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, BombLobbersGamer bombLobbersGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, bombLobbersGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, bombLobbersGamer); + this.updatePeriodicStatistics(text, bombLobbersGamer); } else { - this.c(text, bombLobbersGamer); + this.insertPeriodicStatistics(text, bombLobbersGamer); } } }); } - private void b(String text, BombLobbersGamer bombLobbersGamer) { + private void updatePeriodicStatistics(String text, BombLobbersGamer bombLobbersGamer) { String text2 = "current_win_streak"; if (bombLobbersGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -120,9 +120,9 @@ public class BombLobbersStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -132,76 +132,76 @@ public class BombLobbersStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, kills = kills + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, bombLobbersGamer.getWins()); preparedStatement.setInt(2, bombLobbersGamer.getLoses()); - preparedStatement.setInt(3, bombLobbersGamer.m()); + preparedStatement.setInt(3, bombLobbersGamer.getKills()); preparedStatement.setString(4, bombLobbersGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, BombLobbersGamer bombLobbersGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, BombLobbersGamer bombLobbersGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, bombLobbersGamer.getUUID().toString()); preparedStatement.setInt(2, bombLobbersGamer.getWins()); preparedStatement.setInt(3, bombLobbersGamer.getWins()); preparedStatement.setInt(4, bombLobbersGamer.getWins()); preparedStatement.setInt(5, bombLobbersGamer.getLoses()); - preparedStatement.setInt(6, bombLobbersGamer.m()); + preparedStatement.setInt(6, bombLobbersGamer.getKills()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);" ); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -211,22 +211,22 @@ public class BombLobbersStatisticsRepository extends GameStatisticsRepository { int index = var4.getInt("wins"); int index2 = var4.getInt("loses"); int index3 = var4.getInt("kills"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -240,14 +240,14 @@ public class BombLobbersStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/storage/BombLobbersStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/storage/BombLobbersStorage.java index abc795c..cb740f8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/storage/BombLobbersStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/storage/BombLobbersStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.bomblobbers.statistics.storage.BombLobbersStati public class BombLobbersStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final BombLobbersStatisticsRepository bombLobbersStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public BombLobbersStorage(BombLobbersManager bombLobbersManager) { super(bombLobbersManager); this.storage = new GameMapStorage(bombLobbersManager.getConfigManager(), this.file, BombLobbersMap::new); - this.storage2 = new NpcStorage(bombLobbersManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(bombLobbersManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(bombLobbersManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(bombLobbersManager.getConfigManager(), this.file); this.bombLobbersStatisticsRepository = new BombLobbersStatisticsRepository(bombLobbersManager.getEngine()); - this.storage4 = new LeaderboardStorage(bombLobbersManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(bombLobbersManager.getConfigManager(), this.file, BombLobbersMap::new); + this.leaderboardStorage = new LeaderboardStorage(bombLobbersManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(bombLobbersManager.getConfigManager(), this.file, BombLobbersMap::new); } @Override @@ -34,26 +34,26 @@ public class BombLobbersStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public BombLobbersStatisticsRepository e() { + public BombLobbersStatisticsRepository getStatisticsRepository() { return this.bombLobbersStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeam.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeam.java index 3981164..3b16727 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeam.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeam.java @@ -24,13 +24,13 @@ public class BombLobbersTeam { public BombLobbersTeam(BombLobbersGame game2, BombLobbersTeamColor teamColor2) { this.game = game2; this.teamColor = teamColor2; - this.scoreboardTeam = game2.getScoreboard().createTeam(teamColor2.a(game2.getMessages())); + this.scoreboardTeam = game2.getScoreboard().createTeam(teamColor2.getDisplayName(game2.getMessages())); this.scoreboardTeam.setColor(teamColor2.getChatColor()); this.scoreboardTeam.setCollisionRule(TeamRule.FOR_OTHER_TEAMS); - this.settings = teamColor2.a(game2.getMap()); + this.settings = teamColor2.getTeamSettings(game2.getMap()); } - public int a() { + public int getIndex() { return this.game.getTeam() == this ? 0 : 1; } @@ -38,8 +38,8 @@ public class BombLobbersTeam { return this.teamColor; } - public String c() { - return this.teamColor.a(this.game.getMessages()); + public String getDisplayName() { + return this.teamColor.getDisplayName(this.game.getMessages()); } public BombLobbersTeamSettings getSettings() { @@ -50,11 +50,11 @@ public class BombLobbersTeam { return this.scoreboardTeam; } - public int f() { + public int getAliveCount() { int index = 0; for (BombLobbersGamer bombLobbersGamer : this.list) { - if (!bombLobbersGamer.f()) { + if (!bombLobbersGamer.isSpectator()) { index++; } } @@ -66,25 +66,25 @@ public class BombLobbersTeam { return this.list; } - public void h() { + public void preparePlayers() { int index = 0; for (BombLobbersGamer bombLobbersGamer : this.list) { bombLobbersGamer.setTeam(this); bombLobbersGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); this.scoreboardTeam.addEntry(bombLobbersGamer.getName()); - bombLobbersGamer.a((Location)this.settings.getSpawns().get(index++ % this.settings.getSpawns().size())); - bombLobbersGamer.o(); + bombLobbersGamer.teleport((Location)this.settings.getSpawns().get(index++ % this.settings.getSpawns().size())); + bombLobbersGamer.replenishTnt(); Player player = bombLobbersGamer.toPlayer(); player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setLeatherColor(this.teamColor.getColor()).build()); player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherColor(this.teamColor.getColor()).build()); - player.getInventory().setItem(8, new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherColor(this.teamColor.getColor()).setDisplayName(this.teamColor.getChatColor() + this.teamColor.a(this.game.getMessages())).build()); + player.getInventory().setItem(8, new ItemBuilder(Material.LEATHER_CHESTPLATE).setLeatherColor(this.teamColor.getColor()).setDisplayName(this.teamColor.getChatColor() + this.teamColor.getDisplayName(this.game.getMessages())).build()); bombLobbersGamer.playSound(ArcadeSound.NOTE_PLING, 2.0F, 2.0F); index++; } } - public void i() { + public void clear() { this.scoreboardTeam.clearEntries(); this.list.clear(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeamColor.java b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeamColor.java index 0662e47..4bbacaa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeamColor.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/bomblobbers/team/BombLobbersTeamColor.java @@ -13,18 +13,18 @@ public enum BombLobbersTeamColor { private final ChatColor chatColor; private final Color color; - private static final BombLobbersTeamColor[] e = {RED, BLUE}; + private static final BombLobbersTeamColor[] VALUES = {RED, BLUE}; BombLobbersTeamColor(ChatColor chatColor2, Color color2) { this.chatColor = chatColor2; this.color = color2; } - public String a(BombLobbersMessages bombLobbersMessages) { + public String getDisplayName(BombLobbersMessages bombLobbersMessages) { return this == RED ? bombLobbersMessages.getTeamRed() : bombLobbersMessages.getTeamBlue(); } - public BombLobbersTeamSettings a(BombLobbersMap bombLobbersMap) { + public BombLobbersTeamSettings getTeamSettings(BombLobbersMap bombLobbersMap) { return this == RED ? bombLobbersMap.getRedTeam() : bombLobbersMap.getBlueTeam(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsGame.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsGame.java index 6a4cc3b..6d07216 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsGame.java @@ -38,30 +38,30 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class MiniWallsGame extends AbstractGame implements GameEventHandler { - private int c; + private int stageTimer; private MiniWallsGamer[] gamers; - private final MiniWallsMap e; - private double f; - private int g; + private final MiniWallsMap map; + private double decayProgress; + private int fallingBlockCooldown; private MiniWallsStage miniWallsStage = MiniWallsStage.WALLS_FALL; private final MiniWallsManager manager; private final BlockDistanceIndex blockDistanceIndex; private final ViewerManager viewers = new DefaultViewerManager(); - private final Set l = new HashSet<>(); - private final Map m = new HashMap<>(); + private final Set trackedEntities = new HashSet<>(); + private final Map disconnectedPlayers = new HashMap<>(); private final MiniWallsTeamContext[] teamContexts = new MiniWallsTeamContext[4]; private final Lifecycle lifecycle = new MiniWallsLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); - private final Map q = new LinkedHashMap<>(); - private final Set r = EnumSet.of(GameAction.HUNGER, GameAction.ENTITY_INTERACT); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); + private final Map placedWoolBlocks = new LinkedHashMap<>(); + private final Set blockedActions = EnumSet.of(GameAction.HUNGER, GameAction.ENTITY_INTERACT); public MiniWallsGame(MiniWallsManager manager2, MiniWallsMap miniWallsMap) { - this.e = miniWallsMap; + this.map = miniWallsMap; this.manager = manager2; MiniWallsTeamColor[] miniWallsTeamColors = MiniWallsTeamColor.values(); for (int index = 0; index < 4; index++) { - this.teamContexts[index] = new MiniWallsTeamContext(this, miniWallsMap.a(miniWallsTeamColors[index])); + this.teamContexts[index] = new MiniWallsTeamContext(this, miniWallsMap.getTeamSettings(miniWallsTeamColors[index])); } this.blockDistanceIndex = new BlockDistanceIndex(miniWallsMap.getSpectator()); @@ -72,32 +72,32 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { return this.viewers; } - public double p() { - return this.f; + public double getDecayProgress() { + return this.decayProgress; } - public void a(double doubleVal) { - this.f = doubleVal; + public void setDecayProgress(double doubleVal) { + this.decayProgress = doubleVal; } - public int q() { - return this.g; + public int getFallingBlockCooldown() { + return this.fallingBlockCooldown; } - public void a(int index) { - this.g = index; + public void setFallingBlockCooldown(int index) { + this.fallingBlockCooldown = index; } public BlockDistanceIndex getBlockDistanceIndex() { return this.blockDistanceIndex; } - public Map s() { - return this.q; + public Map getPlacedWoolBlocks() { + return this.placedWoolBlocks; } public MiniWallsMap getMap() { - return this.e; + return this.map; } public MiniWallsStage getMiniWallsStage() { @@ -116,44 +116,44 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { return this.manager.getMessages(); } - private MiniWallsConfiguration F() { - MiniWallsConfiguration miniWallsConfiguration = (MiniWallsConfiguration)this.getManager().H().get(this.getMap().getId()); + private MiniWallsConfiguration getActiveConfiguration() { + MiniWallsConfiguration miniWallsConfiguration = (MiniWallsConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); return miniWallsConfiguration == null ? this.getManager().getConfiguration() : miniWallsConfiguration; } public MiniWallsSettings getSettings() { - return this.F().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public MiniWallsRewards x() { - return this.F().getRewards(); + public MiniWallsRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public MiniWallsManager getManager() { return this.manager; } - public Set z() { - return this.l; + public Set getTrackedEntities() { + return this.trackedEntities; } - public Map A() { - return this.m; + public Map getDisconnectedPlayers() { + return this.disconnectedPlayers; } public Set getBlockedActions() { - return this.r; + return this.blockedActions; } - public int B() { - return this.c; + public int getStageTimer() { + return this.stageTimer; } - public void b(int index) { - this.c = index; + public void setStageTimer(int index) { + this.stageTimer = index; } - public MiniWallsGamer[] getGamers4() { + public MiniWallsGamer[] getStandings() { return this.gamers; } @@ -167,18 +167,18 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { switch (text) { case "duration": - return String.valueOf(this.c); + return String.valueOf(this.stageTimer); case "duration_formatted": - return Strings.a(this.c); + return Strings.formatDuration(this.stageTimer); case "stage": - return String.valueOf(this.miniWallsStage.a(this.getMessages())); + return String.valueOf(this.miniWallsStage.getDisplayName(this.getMessages())); default: for (MiniWallsTeamContext miniWallsTeamContext : this.teamContexts) { if (text.equals(miniWallsTeamContext.getTeamSettings().getColor().name().toLowerCase(Locale.ROOT) + "_alive")) { @@ -205,9 +205,9 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { return super.getCondition(text); } - public boolean a(Block block, int index, boolean flag) { - for (Cuboid cuboid : this.e.getWalls()) { - if (flag ? cuboid.b(block, index) : cuboid.a(block, index)) { + public boolean isWallBlock(Block block, int index, boolean flag) { + for (Cuboid cuboid : this.map.getWalls()) { + if (flag ? cuboid.containsXZ(block, index) : cuboid.contains(block, index)) { return true; } } @@ -215,7 +215,7 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { return false; } - public void E() { + public void checkWinCondition() { int index = 0; MiniWallsTeamContext miniWallsTeamContext = null; @@ -227,36 +227,36 @@ public class MiniWallsGame extends AbstractGame implements GameEventHandler { } if (index <= 1) { - this.a(miniWallsTeamContext); + this.finishGame(miniWallsTeamContext); } } - public void a(MiniWallsTeamContext miniWallsTeamContext) { - Arrays.sort(this.gamers, Comparator.comparingInt(MiniWallsGamer::s).reversed()); - Context context = Contexts.a(this.manager, this.gamers); + public void finishGame(MiniWallsTeamContext miniWallsTeamContext) { + Arrays.sort(this.gamers, Comparator.comparingInt(MiniWallsGamer::getKills).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (MiniWallsTeam miniWallsTeam : this.m.values()) { + for (MiniWallsTeam miniWallsTeam : this.disconnectedPlayers.values()) { if (miniWallsTeam.getTeamContext() == miniWallsTeamContext) { - miniWallsTeam.a(1); + miniWallsTeam.setWins(1); } else { - miniWallsTeam.b(1); + miniWallsTeam.setLoses(1); } } - for (MiniWallsGamer miniWallsGamer : this.gamers2) { + for (MiniWallsGamer miniWallsGamer : this.gamerSet) { miniWallsGamer.sendMessages(this.getMessages().getEndingTop(), context); - miniWallsGamer.a(this.getMessages().getSidebarPlaying(), miniWallsGamer); - if (!miniWallsGamer.getSpectatorOptions().g()) { + miniWallsGamer.updateSidebar(this.getMessages().getSidebarPlaying(), miniWallsGamer); + if (!miniWallsGamer.getSpectatorOptions().isExternal()) { if (miniWallsGamer.getTeamContext() == miniWallsTeamContext) { - miniWallsGamer.a(1); + miniWallsGamer.setWins(1); miniWallsGamer.sendActionBar(this.getMessages().getEndWin()); } else { - miniWallsGamer.b(1); + miniWallsGamer.setLoses(1); miniWallsGamer.sendActionBar(this.getMessages().getEndLose()); } - if (this.x().isEnabled()) { - miniWallsGamer.a(miniWallsGamer.getTeamContext() == miniWallsTeamContext ? this.x().getWinner() : this.x().getLosers(), text -> text.replace("%team%", miniWallsGamer.getTeamContext().getDisplayName())); + if (this.getRewards().isEnabled()) { + miniWallsGamer.setRewardCommands(miniWallsGamer.getTeamContext() == miniWallsTeamContext ? this.getRewards().getWinner() : this.getRewards().getLosers(), text -> text.replace("%team%", miniWallsGamer.getTeamContext().getDisplayName())); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsManager.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsManager.java index 8d516eb..878b799 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/MiniWallsManager.java @@ -40,12 +40,12 @@ public class MiniWallsManager extends AbstractGameManager { private final Command command; private final MiniWallsStorage storage; private final MiniWallsMessages messages = new MiniWallsMessages(); - private final Map h = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final MiniWallsConfiguration configuration = new MiniWallsConfiguration(); private final MiniWallsListener listener = new MiniWallsListener(this); - private final Map k = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final MiniWallsSessions sessions = new MiniWallsSessions(this); - private final Map> m = Map.ofEntries( + private final Map> leaderboardSources = Map.ofEntries( Map.entry("wins", this.messages::getStatisticWins), Map.entry("win_streak", this.messages::getStatisticWinStreak), Map.entry("current_win_streak", this.messages::getStatisticCurrentWinStreak), @@ -103,33 +103,33 @@ public class MiniWallsManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { MiniWallsStatistics miniWallsStatistics = new MiniWallsStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(miniWallsStatistics); - this.h.put(player.getUniqueId(), miniWallsStatistics); + this.storage.getStatisticsRepository().loadStatistics(miniWallsStatistics); + this.playerStatistics.put(player.getUniqueId(), miniWallsStatistics); } public MiniWallsStatistics getData(UUID uuid) { - return this.h.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.h.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map H() { - return this.k; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } - public void a(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + public void recordFinalStatistics(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { MiniWallsStatistics miniWallsStatistics = this.getData(uuid); - if (miniWallsStatistics != null && miniWallsStatistics.a()) { - miniWallsStatistics.a(miniWallsTeamMember); - this.storage.e().b(miniWallsStatistics); + if (miniWallsStatistics != null && miniWallsStatistics.isLoaded()) { + miniWallsStatistics.recordMatchStats(miniWallsTeamMember); + this.storage.getStatisticsRepository().saveStatistics(miniWallsStatistics); } else { - this.storage.e().a(uuid, miniWallsTeamMember); + this.storage.getStatisticsRepository().savePeriodicStatistics(uuid, miniWallsTeamMember); } - this.storage.e().b(uuid, miniWallsTeamMember); + this.storage.getStatisticsRepository().savePeriodicMatchStats(uuid, miniWallsTeamMember); } @Override @@ -143,15 +143,15 @@ public class MiniWallsManager extends AbstractGameManager { @Override protected void initDefaultProperties() { super.initDefaultProperties(); - this.defaultProperties.put("kit", MiniWallsKits.kit.a()); + this.defaultProperties.put("kit", MiniWallsKits.kit.getId()); } @Override protected void populateMenu(GameMenuPage gameMenuPage, Context context) { super.populateMenu(gameMenuPage, context); - gameMenuPage.page().a(35, defaultUser -> { + gameMenuPage.page().setSlot(35, defaultUser -> { defaultUser.toPlayer().closeInventory(); - this.getSessions().a(defaultUser); + this.getSessions().rejoin(defaultUser); }, new ItemBuilder(Material.ENDER_PEARL).setDisplayName(this.getMessages().getJoinGuiRejoinName()).setLore(this.getMessages().getJoinGuiRejoinLore()).build()); } @@ -162,7 +162,7 @@ public class MiniWallsManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.m; + return this.leaderboardSources; } @Override @@ -170,16 +170,16 @@ public class MiniWallsManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "mini_walls"); } - private void I() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); MiniWallsConfiguration miniWallsConfiguration = new MiniWallsConfiguration(); - miniWallsConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.k.put("id_1", this.configuration); - Files.a(file, file2 -> { + miniWallsConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { MiniWallsConfiguration miniWallsConfiguration2 = new MiniWallsConfiguration(); - miniWallsConfiguration2.a(this.getConfigManager(), file2); - this.k.put(file2.getName(), miniWallsConfiguration2); + miniWallsConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), miniWallsConfiguration2); } }); } @@ -187,14 +187,14 @@ public class MiniWallsManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.I(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { this.miniWallsEntityFactory = VersionAdapters.get().createMiniWallsEntityFactorySelector().select(); - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/command/MiniWallsCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/command/MiniWallsCreateCommand.java index 587820d..66ebe9a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/command/MiniWallsCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/command/MiniWallsCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class MiniWallsCreateCommand implements CommandExecutor { - private final MiniWallsManager a; + private final MiniWallsManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public MiniWallsCreateCommand(MiniWallsManager miniWallsManager) { - this.a = miniWallsManager; + this.manager = miniWallsManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class MiniWallsCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); MiniWallsMap miniWallsMap = new MiniWallsMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -68,14 +68,14 @@ public class MiniWallsCreateCommand implements CommandExecutor { return; } - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } miniWallsMap.setId(text2); miniWallsMap.setMaximumPlayers(index3); - defaultUser.a(new MiniWallsSetup(defaultUser, miniWallsMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new MiniWallsSetup(defaultUser, miniWallsMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/MiniWallsConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/MiniWallsConfiguration.java index 9691b91..b4301de 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/MiniWallsConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/MiniWallsConfiguration.java @@ -9,7 +9,7 @@ public class MiniWallsConfiguration { private final MiniWallsRewards rewards = new MiniWallsRewards(); private final MiniWallsSettings settings = new MiniWallsSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/message/MiniWallsMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/message/MiniWallsMessages.java index 5587b03..bf96e74 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/message/MiniWallsMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/config/message/MiniWallsMessages.java @@ -13,153 +13,153 @@ public class MiniWallsMessages extends BaseGameMessages { @Setting("display-name") private String displayName = "MiniWalls"; @Setting("color-blue") - private String colorBlue = Strings.a("Blue"); + private String colorBlue = Strings.colorize("Blue"); @Setting("color-green") - private String colorGreen = Strings.a("Green"); + private String colorGreen = Strings.colorize("Green"); @Setting("color-red") - private String colorRed = Strings.a("Red"); + private String colorRed = Strings.colorize("Red"); @Setting("color-yellow") - private String colorYellow = Strings.a("Yellow"); + private String colorYellow = Strings.colorize("Yellow"); @Setting("color-spectator") - private String colorSpectator = Strings.a("Spectator"); + private String colorSpectator = Strings.colorize("Spectator"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-kills") - private String statisticKills = Strings.a("Kills"); + private String statisticKills = Strings.colorize("Kills"); @Setting("statistic-kills-final") - private String statisticKillsFinal = Strings.a("Final Kills"); + private String statisticKillsFinal = Strings.colorize("Final Kills"); @Setting("statistic-deaths") - private String statisticDeaths = Strings.a("Deaths"); + private String statisticDeaths = Strings.colorize("Deaths"); @Setting("statistic-arrows-hit") - private String statisticArrowsHit = Strings.a("Arrows Hit"); + private String statisticArrowsHit = Strings.colorize("Arrows Hit"); @Setting("statistic-arrows-shot") - private String statisticArrowsShot = Strings.a("Arrows Shot"); + private String statisticArrowsShot = Strings.colorize("Arrows Shot"); @Setting("statistic-wither-kills") - private String statisticWitherKills = Strings.a("Wither Kills"); + private String statisticWitherKills = Strings.colorize("Wither Kills"); @Setting("statistic-wither-damage") - private String statisticWitherDamage = Strings.a("Wither Damage"); + private String statisticWitherDamage = Strings.colorize("Wither Damage"); @Setting("walls-fall") - private Text wallsFall = TextParser.a("&7The Walls fall in %duration%"); + private Text wallsFall = TextParser.parse("&7The Walls fall in %duration%"); @Setting("walls-fallen") - private String wallsFallen = Strings.a("&eThe Walls have fallen!"); + private String wallsFallen = Strings.colorize("&eThe Walls have fallen!"); @Setting("stage-walls-fall") - private String stageWallsFall = Strings.a("Walls Fall"); + private String stageWallsFall = Strings.colorize("Walls Fall"); @Setting("stage-midgame") - private String stageMidgame = Strings.a("Deathmatch"); + private String stageMidgame = Strings.colorize("Deathmatch"); @Setting("stage-deathmatch") - private String stageDeathmatch = Strings.a("Time Left"); + private String stageDeathmatch = Strings.colorize("Time Left"); @Setting("gui-kit-format") - private Text guiKitFormat = TextParser.a("&a&l%kit% Kit &7(Right Click)"); + private Text guiKitFormat = TextParser.parse("&a&l%kit% Kit &7(Right Click)"); @Setting("gui-kit-selected") - private Text guiKitSelected = TextParser.a("&eYou selected the &a%kit% Kit&e!"); + private Text guiKitSelected = TextParser.parse("&eYou selected the &a%kit% Kit&e!"); @Setting("gui-kit-already") - private String guiKitAlready = Strings.a("&aYou already have that kit selected!"); + private String guiKitAlready = Strings.colorize("&aYou already have that kit selected!"); @Setting("gui-team-format") - private Text guiTeamFormat = TextParser.a("%color%&l%team% Team &7(Right Click)"); + private Text guiTeamFormat = TextParser.parse("%color%&l%team% Team &7(Right Click)"); @Setting("gui-team-already") - private String guiTeamAlready = Strings.a("&aYou already joined that team!"); + private String guiTeamAlready = Strings.colorize("&aYou already joined that team!"); @Setting("gui-team-selected") - private Text guiTeamSelected = TextParser.a("&eYou have joined the %color%%team%&e team!"); + private Text guiTeamSelected = TextParser.parse("&eYou have joined the %color%%team%&e team!"); @Setting("kit-soldier") - private String kitSoldier = Strings.a("Soldier"); + private String kitSoldier = Strings.colorize("Soldier"); @Setting("kit-archer") - private String kitArcher = Strings.a("Archer"); + private String kitArcher = Strings.colorize("Archer"); @Setting("kit-builder") - private String kitBuilder = Strings.a("Builder"); + private String kitBuilder = Strings.colorize("Builder"); @Setting("deathmatch-start-title") - private String deathmatchStartTitle = Strings.a("&cDeathmatch"); + private String deathmatchStartTitle = Strings.colorize("&cDeathmatch"); @Setting("deathmatch-start-subtitle") - private String deathmatchStartSubtitle = Strings.a("&7Watch your step!"); + private String deathmatchStartSubtitle = Strings.colorize("&7Watch your step!"); @Setting("respawn-title") - private String respawnTitle = Strings.a("&c&lYOU DIED!"); + private String respawnTitle = Strings.colorize("&c&lYOU DIED!"); @Setting("respawn-subtitle") - private Text respawnSubtitle = TextParser.a("&7Respawning in %respawn%"); + private Text respawnSubtitle = TextParser.parse("&7Respawning in %respawn%"); @Setting("block-break-wall") - private String blockBreakWall = Strings.a("&cDo not break the wall!"); + private String blockBreakWall = Strings.colorize("&cDo not break the wall!"); @Setting("block-break-generic") - private String blockBreakGeneric = Strings.a("&cYou cannot break blocks there."); + private String blockBreakGeneric = Strings.colorize("&cYou cannot break blocks there."); @Setting("block-break-mini-wither") - private String blockBreakMiniWither = Strings.a("&cYou cannot break blocks that close to the Mini Wither!"); + private String blockBreakMiniWither = Strings.colorize("&cYou cannot break blocks that close to the Mini Wither!"); @Setting("block-place-wall") - private String blockPlaceWall = Strings.a("&cYou cannot build that close to the wall."); + private String blockPlaceWall = Strings.colorize("&cYou cannot build that close to the wall."); @Setting("block-place-generic") - private String blockPlaceGeneric = Strings.a("&cYou cannot place blocks there."); + private String blockPlaceGeneric = Strings.colorize("&cYou cannot place blocks there."); @Setting("block-place-mini-wither") - private String blockPlaceMiniWither = Strings.a("&cYou cannot place that close to the Mini Wither!"); + private String blockPlaceMiniWither = Strings.colorize("&cYou cannot place that close to the Mini Wither!"); @Setting("player-killed-by-you") - private Text playerKilledByYou = TextParser.a("&7You killed %damaged_color%%damaged%!"); + private Text playerKilledByYou = TextParser.parse("&7You killed %damaged_color%%damaged%!"); @Setting("player-killed-by-player") - private Text playerKilledByPlayer = TextParser.a("%color%%player% &7was killed by %damager_color%%damager%"); + private Text playerKilledByPlayer = TextParser.parse("%color%%player% &7was killed by %damager_color%%damager%"); @Setting("player-killed-you") - private Text playerKilledYou = TextParser.a("&7You were killed by %damager_color%%damager%!"); + private Text playerKilledYou = TextParser.parse("&7You were killed by %damager_color%%damager%!"); @Setting("player-shot-by-you") - private Text playerShotByYou = TextParser.a("&7You shot %damager_color%%damager%"); + private Text playerShotByYou = TextParser.parse("&7You shot %damager_color%%damager%"); @Setting("player-shot-by-you-hp") - private Text playerShotByYouHp = TextParser.a("&7%player% is on &c%health% &7HP!"); + private Text playerShotByYouHp = TextParser.parse("&7%player% is on &c%health% &7HP!"); @Setting("player-shot-by-player") - private Text playerShotByPlayer = TextParser.a("%color%%player% &7was shot by %damager_color%%damager%"); + private Text playerShotByPlayer = TextParser.parse("%color%%player% &7was shot by %damager_color%%damager%"); @Setting("player-shot-you") - private Text playerShotYou = TextParser.a("&7You were shot by %damager_color%%damager%&7!"); + private Text playerShotYou = TextParser.parse("&7You were shot by %damager_color%%damager%&7!"); @Setting("player-void-by-you") - private Text playerVoidByYou = TextParser.a("&7You knocked %color%%player%&7 into the void!"); + private Text playerVoidByYou = TextParser.parse("&7You knocked %color%%player%&7 into the void!"); @Setting("player-void-by-player") - private Text playerVoidByPlayer = TextParser.a("%color%%player% &7was knocked into the void by %damager_color%%damager%"); + private Text playerVoidByPlayer = TextParser.parse("%color%%player% &7was knocked into the void by %damager_color%%damager%"); @Setting("player-void-you") - private Text playerVoidYou = TextParser.a("&7You were knocked into the void by %damager_color%%damager%&7!"); + private Text playerVoidYou = TextParser.parse("&7You were knocked into the void by %damager_color%%damager%&7!"); @Setting("player-fell-you") - private String playerFellYou = Strings.a("&7You fell to your death."); + private String playerFellYou = Strings.colorize("&7You fell to your death."); @Setting("player-fell") - private Text playerFell = TextParser.a("%color%%player% &7fell to their death."); + private Text playerFell = TextParser.parse("%color%%player% &7fell to their death."); @Setting("player-died") - private Text playerDied = TextParser.a("%color%%player% &7died."); + private Text playerDied = TextParser.parse("%color%%player% &7died."); @Setting("player-died-you") - private String playerDiedYou = Strings.a("&7You died."); + private String playerDiedYou = Strings.colorize("&7You died."); @Setting("end-draw") - private String endDraw = Strings.a("&eDRAW!"); + private String endDraw = Strings.colorize("&eDRAW!"); @Setting("end-win") - private String endWin = Strings.a("&aYou Win!"); + private String endWin = Strings.colorize("&aYou Win!"); @Setting("end-lose") - private String endLose = Strings.a("&cYou Lose!"); + private String endLose = Strings.colorize("&cYou Lose!"); @Setting("wither-died") - private Text witherDied = TextParser.a("%color%%team% Mini Wither died!"); + private Text witherDied = TextParser.parse("%color%%team% Mini Wither died!"); @Setting("wither-low-hp") - private String witherLowHp = Strings.a("&cYour wither is at low HP!"); + private String witherLowHp = Strings.colorize("&cYour wither is at low HP!"); @Setting("wither-died-title") - private String witherDiedTitle = Strings.a("&c&lYour Mini Wither died!"); + private String witherDiedTitle = Strings.colorize("&c&lYour Mini Wither died!"); @Setting("wither-died-subtitle") - private String witherDiedSubtitle = Strings.a("&7You can no longer respawn!"); + private String witherDiedSubtitle = Strings.colorize("&7You can no longer respawn!"); @Setting("wither-killed-by-you") - private Text witherKilledByYou = TextParser.a("&7You killed the %color%%team% Mini Wither&7!"); + private Text witherKilledByYou = TextParser.parse("&7You killed the %color%%team% Mini Wither&7!"); @Setting("wither-killed-by-player") - private Text witherKilledByPlayer = TextParser.a("%damager_color%%damager% &7killed the %color%%team% Mini Wither&7!"); + private Text witherKilledByPlayer = TextParser.parse("%damager_color%%damager% &7killed the %color%%team% Mini Wither&7!"); @Setting("wither-killed-you") - private Text witherKilledYou = TextParser.a("&7You were killed by the %color%%team% Mini Wither&7"); + private Text witherKilledYou = TextParser.parse("&7You were killed by the %color%%team% Mini Wither&7"); @Setting("wither-killed-you-with-help") - private Text witherKilledYouWithHelp = TextParser.a("&7You were killed by the %damager_color%%damager% &7with help from the %color%%team% Mini Wither&7!"); + private Text witherKilledYouWithHelp = TextParser.parse("&7You were killed by the %damager_color%%damager% &7with help from the %color%%team% Mini Wither&7!"); @Setting("wither-killed-player") - private Text witherKilledPlayer = TextParser.a("%player_color%%player% was killed by the %color%%team% Mini Wither&7!"); + private Text witherKilledPlayer = TextParser.parse("%player_color%%player% was killed by the %color%%team% Mini Wither&7!"); @Setting("wither-killed-player-with-help") - private Text witherKilledPlayerWithHelp = TextParser.a("%player_color%%player% &7was killed by %damager_color%%damager% &7with help from the %color%%team% Mini Wither&7!"); + private Text witherKilledPlayerWithHelp = TextParser.parse("%player_color%%player% &7was killed by %damager_color%%damager% &7with help from the %color%%team% Mini Wither&7!"); @Setting("wither-damage-by-arrow") - private String witherDamageByArrow = Strings.a("&cYou cannot damage Mini Withers with arrows!"); + private String witherDamageByArrow = Strings.colorize("&cYou cannot damage Mini Withers with arrows!"); @Setting("wither-actionbar-dead") - private Text witherActionbarDead = TextParser.a("%color%YOUR WITHER IS DEAD!"); + private Text witherActionbarDead = TextParser.parse("%color%YOUR WITHER IS DEAD!"); @Setting("wither-actionbar-alive") - private Text witherActionbarAlive = TextParser.a("%color%YOUR WITHER&7: "); + private Text witherActionbarAlive = TextParser.parse("%color%YOUR WITHER&7: "); @Setting("team-health") - private String teamHealth = Strings.a("&c ❤"); + private String teamHealth = Strings.colorize("&c ❤"); @Setting("team-start") - private Text teamStart = TextParser.a("%color%You are %team%"); + private Text teamStart = TextParser.parse("%color%You are %team%"); @Setting("team-wither-name") - private Text teamWitherName = TextParser.a("%color%%team% Mini Wither"); + private Text teamWitherName = TextParser.parse("%color%%team% Mini Wither"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lMiniWalls", @@ -171,7 +171,7 @@ public class MiniWallsMessages extends BaseGameMessages { } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lMiniWalls", @@ -184,7 +184,7 @@ public class MiniWallsMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year% ", " ", @@ -204,7 +204,7 @@ public class MiniWallsMessages extends BaseGameMessages { } ); @Setting("kit-soldier-lore") - private List kitSoldierLore = Strings.a( + private List kitSoldierLore = Strings.colorizeLines( new String[]{ "&7Stone Sword", "&7Stone Pickaxe", @@ -220,7 +220,7 @@ public class MiniWallsMessages extends BaseGameMessages { } ); @Setting("kit-archer-lore") - private List kitArcherLore = Strings.a( + private List kitArcherLore = Strings.colorizeLines( new String[]{ "&7Wood Sword", "&7Stone Pickaxe", @@ -236,7 +236,7 @@ public class MiniWallsMessages extends BaseGameMessages { } ); @Setting("kit-builder-lore") - private List kitBuilderLore = Strings.a( + private List kitBuilderLore = Strings.colorizeLines( new String[]{ "&7Wood Sword", "&7Iron Pickaxe", @@ -253,9 +253,9 @@ public class MiniWallsMessages extends BaseGameMessages { ); public MiniWallsMessages() { - this.chatInGame = TextParser.a("%color%[%team%%color%] &7%player%&f: %message%"); - this.spectatorTargetLore = new ArrayList<>(TextParser.a(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); - this.statisticsView = TextParser.a( + this.chatInGame = TextParser.parse("%color%[%team%%color%] &7%player%&f: %message%"); + this.spectatorTargetLore = new ArrayList<>(TextParser.parseAll(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); + this.statisticsView = TextParser.parseAll( new String[]{ " ", " &l%display_name% Statistics", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsArcherKit.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsArcherKit.java index 2347b1b..b0e80a8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsArcherKit.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsArcherKit.java @@ -15,32 +15,32 @@ import ro.fr33styler.arcade.platform.compat.ArcadeMaterial; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MiniWallsArcherKit implements MiniWallsKit { - public String a() { + public String getId() { return "ARCHER"; } - public int b() { + public int getMaxArrows() { return 4; } - public int d() { + public int getKillHealAmount() { return 3; } - public int c() { + public int getArrowRegenSeconds() { return 4; } - public String a(MiniWallsMessages miniWallsMessages) { + public String getDisplayName(MiniWallsMessages miniWallsMessages) { return miniWallsMessages.getKitArcher(); } - public ItemBuilder b(MiniWallsMessages miniWallsMessages) { - Context context = Contexts.a((VariableProvider) text -> text.equals("kit") ? this.a(miniWallsMessages) : null); - return new ItemBuilder(Material.BOW).setDisplayName(miniWallsMessages.getGuiKitFormat().a(context)).setLore(miniWallsMessages.getKitArcherLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); + public ItemBuilder createMenuItemBuilder(MiniWallsMessages miniWallsMessages) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("kit") ? this.getDisplayName(miniWallsMessages) : null); + return new ItemBuilder(Material.BOW).setDisplayName(miniWallsMessages.getGuiKitFormat().render(context)).setLore(miniWallsMessages.getKitArcherLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); } - public void a(MiniWallsGamer miniWallsGamer, boolean flag) { + public void equip(MiniWallsGamer miniWallsGamer, boolean flag) { Player player = miniWallsGamer.toPlayer(); player.getInventory().addItem(new ItemStack[]{new ItemBuilder(ArcadeMaterial.WOODEN_SWORD).setUnbreakable(true).build()}); player.getInventory() diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsBuilderKit.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsBuilderKit.java index 6d9a77d..d02c5fb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsBuilderKit.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsBuilderKit.java @@ -15,32 +15,32 @@ import ro.fr33styler.arcade.platform.compat.ArcadeMaterial; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MiniWallsBuilderKit implements MiniWallsKit { - public String a() { + public String getId() { return "BUILDER"; } - public int b() { + public int getMaxArrows() { return 2; } - public int d() { + public int getKillHealAmount() { return 4; } - public int c() { + public int getArrowRegenSeconds() { return 8; } - public String a(MiniWallsMessages miniWallsMessages) { + public String getDisplayName(MiniWallsMessages miniWallsMessages) { return miniWallsMessages.getKitBuilder(); } - public ItemBuilder b(MiniWallsMessages miniWallsMessages) { - Context context = Contexts.a((VariableProvider) text -> text.equals("kit") ? this.a(miniWallsMessages) : null); - return new ItemBuilder(Material.IRON_PICKAXE).setDisplayName(miniWallsMessages.getGuiKitFormat().a(context)).setLore(miniWallsMessages.getKitBuilderLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); + public ItemBuilder createMenuItemBuilder(MiniWallsMessages miniWallsMessages) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("kit") ? this.getDisplayName(miniWallsMessages) : null); + return new ItemBuilder(Material.IRON_PICKAXE).setDisplayName(miniWallsMessages.getGuiKitFormat().render(context)).setLore(miniWallsMessages.getKitBuilderLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); } - public void a(MiniWallsGamer miniWallsGamer, boolean flag) { + public void equip(MiniWallsGamer miniWallsGamer, boolean flag) { Player player = miniWallsGamer.toPlayer(); player.getInventory().addItem(new ItemStack[]{new ItemBuilder(ArcadeMaterial.WOODEN_SWORD).setUnbreakable(true).build()}); player.getInventory().addItem(new ItemStack[]{new ItemBuilder(Material.BOW).addEnchant(VersionAdapters.get().getPowerEnchantment(), 1).setUnbreakable(true).build()}); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKit.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKit.java index 56047b6..99c05f2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKit.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKit.java @@ -9,22 +9,22 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; public interface MiniWallsKit { - String a(); + String getId(); - int b(); + int getMaxArrows(); - int c(); + int getArrowRegenSeconds(); - int d(); + int getKillHealAmount(); - String a(MiniWallsMessages var1); + String getDisplayName(MiniWallsMessages var1); - void a(MiniWallsGamer var1, boolean var2); + void equip(MiniWallsGamer var1, boolean var2); - ItemBuilder b(MiniWallsMessages var1); + ItemBuilder createMenuItemBuilder(MiniWallsMessages var1); - default ItemStack a(MiniWallsMessages miniWallsMessages, MiniWallsKit miniWallsKit) { - ItemBuilder itemBuilder = this.b(miniWallsMessages); + default ItemStack createMenuItem(MiniWallsMessages miniWallsMessages, MiniWallsKit miniWallsKit) { + ItemBuilder itemBuilder = this.createMenuItemBuilder(miniWallsMessages); if (this == miniWallsKit) { itemBuilder.addEnchant(Enchantment.ARROW_INFINITE, 1).addFlags(new ItemFlag[]{ItemFlag.HIDE_ENCHANTS}); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKits.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKits.java index 5d7f2dc..5ab723b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKits.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsKits.java @@ -2,17 +2,17 @@ package ro.fr33styler.arcade.game.miniwalls.kit; public class MiniWallsKits { public static final MiniWallsKit kit = new MiniWallsSoldierKit(); - public static final MiniWallsKit kit4 = new MiniWallsArcherKit(); - public static final MiniWallsKit kit2 = new MiniWallsBuilderKit(); - private static final MiniWallsKit[] kits = new MiniWallsKit[]{kit, kit4, kit2}; + public static final MiniWallsKit ARCHER = new MiniWallsArcherKit(); + public static final MiniWallsKit BUILDER = new MiniWallsBuilderKit(); + private static final MiniWallsKit[] kits = new MiniWallsKit[]{kit, ARCHER, BUILDER}; public static MiniWallsKit[] getKits() { return kits; } - public static MiniWallsKit a(String text) { + public static MiniWallsKit byId(String text) { for (MiniWallsKit miniWallsKit : kits) { - if (miniWallsKit.a().equals(text)) { + if (miniWallsKit.getId().equals(text)) { return miniWallsKit; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsSoldierKit.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsSoldierKit.java index 5f2a5e5..d15ff88 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsSoldierKit.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/kit/MiniWallsSoldierKit.java @@ -15,32 +15,32 @@ import ro.fr33styler.arcade.platform.compat.ArcadeMaterial; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MiniWallsSoldierKit implements MiniWallsKit { - public String a() { + public String getId() { return "SOLDIER"; } - public int b() { + public int getMaxArrows() { return 2; } - public int d() { + public int getKillHealAmount() { return 3; } - public int c() { + public int getArrowRegenSeconds() { return 8; } - public String a(MiniWallsMessages miniWallsMessages) { + public String getDisplayName(MiniWallsMessages miniWallsMessages) { return miniWallsMessages.getKitSoldier(); } - public ItemBuilder b(MiniWallsMessages miniWallsMessages) { - Context context = Contexts.a((VariableProvider) text -> text.equals("kit") ? this.a(miniWallsMessages) : null); - return new ItemBuilder(Material.STONE_SWORD).setDisplayName(miniWallsMessages.getGuiKitFormat().a(context)).setLore(miniWallsMessages.getKitSoldierLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); + public ItemBuilder createMenuItemBuilder(MiniWallsMessages miniWallsMessages) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("kit") ? this.getDisplayName(miniWallsMessages) : null); + return new ItemBuilder(Material.STONE_SWORD).setDisplayName(miniWallsMessages.getGuiKitFormat().render(context)).setLore(miniWallsMessages.getKitSoldierLore()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}); } - public void a(MiniWallsGamer miniWallsGamer, boolean flag) { + public void equip(MiniWallsGamer miniWallsGamer, boolean flag) { Player player = miniWallsGamer.toPlayer(); player.getInventory().addItem(new ItemStack[]{new ItemBuilder(Material.STONE_SWORD).setUnbreakable(true).build()}); player.getInventory().addItem(new ItemStack[]{new ItemBuilder(Material.BOW).addEnchant(VersionAdapters.get().getPowerEnchantment(), 1).setUnbreakable(true).build()}); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/lifecycle/MiniWallsLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/lifecycle/MiniWallsLifecycle.java index 152b604..6c7682a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/lifecycle/MiniWallsLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/lifecycle/MiniWallsLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class MiniWallsLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public MiniWallsLifecycle(MiniWallsGame miniWallsGame) { this.phase = new MiniWallsWaitingPhase(miniWallsGame); - this.phase2 = new MiniWallsPlayingPhase(miniWallsGame); - this.phase3 = new EndingPhase(miniWallsGame); - this.phase4 = new ResettingPhase(miniWallsGame); + this.playingPhase = new MiniWallsPlayingPhase(miniWallsGame); + this.endingPhase = new EndingPhase(miniWallsGame); + this.resettingPhase = new ResettingPhase(miniWallsGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class MiniWallsLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/listener/MiniWallsListener.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/listener/MiniWallsListener.java index ab145fd..90864eb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/listener/MiniWallsListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/listener/MiniWallsListener.java @@ -55,20 +55,20 @@ import ro.fr33styler.arcade.platform.compat.ColoredBlockType; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MiniWallsListener extends GameListener { - private final MiniWallsManager manager2; + private final MiniWallsManager miniWallsManager; public MiniWallsListener(MiniWallsManager manager22) { super(manager22); - this.manager2 = manager22; + this.miniWallsManager = manager22; VersionAdapters.get().registerItemPickupListener(manager22.getEngine().getPlugin(), this::onItemPickup); } @EventHandler - public void a(ItemSpawnEvent event) { + public void onItemSpawn(ItemSpawnEvent event) { Item item = event.getEntity(); - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { - if (miniWallsGame.getMap().getPlayZone().a(event.getLocation())) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { + if (miniWallsGame.getMap().getPlayZone().contains(event.getLocation())) { Material material = item.getItemStack().getType(); if (!miniWallsGame.getSettings().isDropAllItems() && (!material.isBlock() || miniWallsGame.getSettings().getItemDropBlacklist().contains(material))) { event.setCancelled(true); @@ -76,16 +76,16 @@ public class MiniWallsListener extends GameListener { } item.setItemStack(VersionAdapters.get().createColoredItemStack(ColoredBlockType.WOOL, ArcadeColor.WHITE, 1)); - miniWallsGame.z().add(item); + miniWallsGame.getTrackedEntities().add(item); break; } } } @EventHandler - public void a(EntityDeathEvent event) { - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { - if (miniWallsGame.z().remove(event.getEntity())) { + public void onEntityDeath(EntityDeathEvent event) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { + if (miniWallsGame.getTrackedEntities().remove(event.getEntity())) { event.getDrops().clear(); event.setDroppedExp(0); } @@ -93,10 +93,10 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(InventoryClickEvent event) { + public void onInventoryClick(InventoryClickEvent event) { if (event.getWhoClicked().getInventory() != event.getClickedInventory()) { - MiniWallsGamer miniWallsGamer = this.a(event.getWhoClicked(), MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(event.getWhoClicked(), MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { if (event.getSlot() == 8 || event.getSlotType() == SlotType.ARMOR) { event.setCancelled(true); } @@ -105,15 +105,15 @@ public class MiniWallsListener extends GameListener { } private boolean onItemPickup(Player player, Item item) { - MiniWallsGamer miniWallsGamer = this.a(player, MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(player, MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { ItemStack item2 = item.getItemStack(); - if (Materials.a(item2.getType())) { + if (Materials.isWool(item2.getType())) { ItemStack teamWool = miniWallsGamer.getTeamContext().getTeamSettings().getColor().createWoolItemStack(item2.getAmount()); - this.manager2.getEngine().getPlatform().sendCollectItemAnimation(player, item); - VersionAdapters.get().playSound(item.getWorld(), item.getLocation(), ArcadeSound.ITEM_PICKUP, 1.0F, Randoms.a().nextFloat(1.5F, 2.0F)); + this.miniWallsManager.getEngine().getPlatform().sendCollectItemAnimation(player, item); + VersionAdapters.get().playSound(item.getWorld(), item.getLocation(), ArcadeSound.ITEM_PICKUP, 1.0F, Randoms.current().nextFloat(1.5F, 2.0F)); if (player.getInventory().addItem(new ItemStack[]{teamWool}).isEmpty()) { - miniWallsGamer.getGame().z().remove(item); + miniWallsGamer.getGame().getTrackedEntities().remove(item); item.remove(); } } @@ -123,9 +123,9 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(PlayerDropItemEvent event) { - MiniWallsGamer miniWallsGamer = this.a(event.getPlayer(), MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { + public void onPlayerDropItem(PlayerDropItemEvent event) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(event.getPlayer(), MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { ItemStack item = event.getItemDrop().getItemStack(); if (!VersionAdapters.get().isColoredItemStack(item, ColoredBlockType.WOOL, miniWallsGamer.getTeamContext().getTeamSettings().getColor().toArcadeColor())) { event.setCancelled(true); @@ -134,9 +134,9 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(EntityDamageEvent event) { + public void onEntityDamage(EntityDamageEvent event) { if (event.getEntityType() == EntityType.WITHER && event.getCause() != DamageCause.ENTITY_ATTACK) { - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { for (MiniWallsTeamContext miniWallsTeamContext : miniWallsGame.getTeamContexts()) { if (event.getEntity() == miniWallsTeamContext.getWither()) { event.setCancelled(true); @@ -145,8 +145,8 @@ public class MiniWallsListener extends GameListener { } } } else { - MiniWallsGamer miniWallsGamer = this.a(event.getEntity(), MiniWallsGamer.class); - if (miniWallsGamer == null || miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(event.getEntity(), MiniWallsGamer.class); + if (miniWallsGamer == null || miniWallsGamer.isSpectator()) { return; } @@ -156,25 +156,25 @@ public class MiniWallsListener extends GameListener { if (player.getHealth() <= event.getFinalDamage()) { for (MiniWallsGamer miniWallsGamer2 : miniWallsGame2.getGamers()) { if (miniWallsGamer == miniWallsGamer2) { - miniWallsGamer2.sendMessage(this.manager2.getMessages().getPlayerFellYou()); + miniWallsGamer2.sendMessage(this.miniWallsManager.getMessages().getPlayerFellYou()); } else { - miniWallsGamer2.sendMessage(this.manager2.getMessages().getPlayerFell(), miniWallsGamer); + miniWallsGamer2.sendMessage(this.miniWallsManager.getMessages().getPlayerFell(), miniWallsGamer); } } - miniWallsGamer.C(); + miniWallsGamer.handleDeath(); event.setCancelled(true); } } else if (player.getHealth() <= event.getFinalDamage()) { for (MiniWallsGamer miniWallsGamer3 : miniWallsGame2.getGamers()) { if (miniWallsGamer == miniWallsGamer3) { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerDiedYou()); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerDiedYou()); } else { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerDied(), miniWallsGamer); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerDied(), miniWallsGamer); } } - miniWallsGamer.C(); + miniWallsGamer.handleDeath(); event.setCancelled(true); } } @@ -187,16 +187,16 @@ public class MiniWallsListener extends GameListener { } if (event.getDamager() instanceof Projectile var2 && var2.getShooter() instanceof Player var3) { - MiniWallsGamer miniWallsGamer = this.a(var3, MiniWallsGamer.class); - if (miniWallsGamer == null || miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(var3, MiniWallsGamer.class); + if (miniWallsGamer == null || miniWallsGamer.isSpectator()) { return; } MiniWallsGame miniWallsGame = miniWallsGamer.getGame(); - if (miniWallsGame.z().remove(var2)) { + if (miniWallsGame.getTrackedEntities().remove(var2)) { if (event.getEntity().getType() == EntityType.WITHER) { miniWallsGamer.playSound(ArcadeSound.VILLAGER_NO, 1.0F, 1.0F); - miniWallsGamer.sendMessage(this.manager2.getMessages().getWitherDamageByArrow()); + miniWallsGamer.sendMessage(this.miniWallsManager.getMessages().getWitherDamageByArrow()); event.setCancelled(true); } @@ -206,26 +206,26 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(ProjectileHitEvent event) { + public void onProjectileHit(ProjectileHitEvent event) { Projectile projectile = event.getEntity(); if (projectile.getShooter() instanceof Player var3) { - MiniWallsGamer miniWallsGamer = this.a(var3, MiniWallsGamer.class); - if (miniWallsGamer == null || miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(var3, MiniWallsGamer.class); + if (miniWallsGamer == null || miniWallsGamer.isSpectator()) { return; } MiniWallsGame miniWallsGame = miniWallsGamer.getGame(); - if (miniWallsGame.z().remove(projectile)) { + if (miniWallsGame.getTrackedEntities().remove(projectile)) { Entity hitEntity = VersionAdapters.get().getProjectileHitEntity(event); Block hitBlock = VersionAdapters.get().getProjectileHitBlock(event); if (hitEntity != null && hitEntity.getType() == EntityType.WITHER) { miniWallsGamer.playSound(ArcadeSound.VILLAGER_NO, 1.0F, 1.0F); - miniWallsGamer.sendMessage(this.manager2.getMessages().getWitherDamageByArrow()); - } else if (hitBlock != null && Materials.a(hitBlock.getType())) { + miniWallsGamer.sendMessage(this.miniWallsManager.getMessages().getWitherDamageByArrow()); + } else if (hitBlock != null && Materials.isWool(hitBlock.getType())) { Location location = hitBlock.getLocation(); - BlockFloodFill.a(2, location.getBlock(), block -> { - if (Materials.a(block.getType())) { - if (miniWallsGame.getMiniWallsStage() != MiniWallsStage.WALLS_FALL || !miniWallsGame.a(block, 2, true)) { + BlockFloodFill.forEachInRadius(2, location.getBlock(), block -> { + if (Materials.isWool(block.getType())) { + if (miniWallsGame.getMiniWallsStage() != MiniWallsStage.WALLS_FALL || !miniWallsGame.isWallBlock(block, 2, true)) { if (miniWallsGame.getMiniWallsStage() != MiniWallsStage.DEATH_MATCH) { Location location2 = block.getLocation(); @@ -255,21 +255,21 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void b(BlockBreakEvent event) { + public void onArenaBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); - MiniWallsGamer miniWallsGamer = this.a(player, MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(player, MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { Block block = event.getBlock(); MiniWallsGame miniWallsGame = miniWallsGamer.getGame(); - if (miniWallsGame.getMap().getPlayZone().a(block)) { - if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.WALLS_FALL && miniWallsGame.a(block, 2, true)) { - player.sendMessage(this.manager2.getMessages().getBlockBreakWall()); + if (miniWallsGame.getMap().getPlayZone().contains(block)) { + if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.WALLS_FALL && miniWallsGame.isWallBlock(block, 2, true)) { + player.sendMessage(this.miniWallsManager.getMessages().getBlockBreakWall()); event.setCancelled(true); return; } if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH) { - miniWallsGame.s().remove(block); + miniWallsGame.getPlacedWoolBlocks().remove(block); } else { for (MiniWallsTeamContext miniWallsTeamContext : miniWallsGame.getTeamContexts()) { Location location = miniWallsTeamContext.getTeamSettings().getSpawn(); @@ -288,30 +288,30 @@ public class MiniWallsListener extends GameListener { } } - BlockPhysics.a(block, block2 -> { + BlockPhysics.forEachDependent(block, block2 -> { miniWallsGame.getRollbackQueue().add(block2.getState()); if (block2 != block) { block.setType(Material.AIR); } - miniWallsGame.getBlockDistanceIndex().b(block2); + miniWallsGame.getBlockDistanceIndex().remove(block2); }); } else { event.setCancelled(true); - player.sendMessage(this.manager2.getMessages().getBlockBreakGeneric()); + player.sendMessage(this.miniWallsManager.getMessages().getBlockBreakGeneric()); } } } @EventHandler - public void a(BlockPlaceEvent event) { + public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); - MiniWallsGamer miniWallsGamer = this.a(player, MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(player, MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { Block block = event.getBlock(); MiniWallsGame miniWallsGame = miniWallsGamer.getGame(); - if (miniWallsGame.getMap().getPlayZone().a(block)) { - if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.WALLS_FALL && miniWallsGame.a(block, 2, true)) { + if (miniWallsGame.getMap().getPlayZone().contains(block)) { + if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.WALLS_FALL && miniWallsGame.isWallBlock(block, 2, true)) { player.sendMessage(miniWallsGame.getMessages().getBlockPlaceWall()); event.setCancelled(true); return; @@ -321,34 +321,34 @@ public class MiniWallsListener extends GameListener { for (MiniWallsTeamContext miniWallsTeamContext : miniWallsGame.getTeamContexts()) { if (miniWallsTeamContext.isWitherAlive() && miniWallsTeamContext.getWither().getLocation().distanceSquared(block.getLocation()) <= miniWallsGame.getSettings().getMiniWitherProtection()) { event.setCancelled(true); - player.sendMessage(this.manager2.getMessages().getBlockPlaceMiniWither()); + player.sendMessage(this.miniWallsManager.getMessages().getBlockPlaceMiniWither()); return; } } } - if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH && miniWallsGame.getBlockDistanceIndex().c(event.getBlockPlaced())) { - miniWallsGame.s().put(event.getBlockPlaced(), 3); + if (miniWallsGame.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH && miniWallsGame.getBlockDistanceIndex().isBeyondFarthest(event.getBlockPlaced())) { + miniWallsGame.getPlacedWoolBlocks().put(event.getBlockPlaced(), 3); } else { - miniWallsGame.getBlockDistanceIndex().a(event.getBlockPlaced()); + miniWallsGame.getBlockDistanceIndex().add(event.getBlockPlaced()); } miniWallsGame.getRollbackQueue().add(event.getBlockReplacedState()); } else { event.setCancelled(true); - player.sendMessage(this.manager2.getMessages().getBlockPlaceGeneric()); + player.sendMessage(this.miniWallsManager.getMessages().getBlockPlaceGeneric()); } } } @EventHandler - public void a(BlockFromToEvent event) { + public void onBlockFromTo(BlockFromToEvent event) { if (event.getBlock().isLiquid()) { - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { - if (miniWallsGame.getMap().getPlayZone().a(event.getBlock())) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { + if (miniWallsGame.getMap().getPlayZone().contains(event.getBlock())) { Block block = event.getToBlock(); - if (miniWallsGame.getMap().getPlayZone().a(block) && !miniWallsGame.getBlockDistanceIndex().c(block)) { - miniWallsGame.getBlockDistanceIndex().a(block); + if (miniWallsGame.getMap().getPlayZone().contains(block) && !miniWallsGame.getBlockDistanceIndex().isBeyondFarthest(block)) { + miniWallsGame.getBlockDistanceIndex().add(block); miniWallsGame.getRollbackQueue().add(block.getState()); } else { event.setCancelled(true); @@ -360,13 +360,13 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(ExplosionPrimeEvent event) { + public void onExplosionPrime(ExplosionPrimeEvent event) { if (event.getEntityType() == EntityType.WITHER_SKULL) { WitherSkull witherSkull = (WitherSkull)event.getEntity(); if (witherSkull.getShooter() instanceof Wither var3) { event.setCancelled(true); - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { for (MiniWallsTeamContext miniWallsTeamContext : miniWallsGame.getTeamContexts()) { if (miniWallsTeamContext.getWither() == var3) { Location location = witherSkull.getLocation(); @@ -375,7 +375,7 @@ public class MiniWallsListener extends GameListener { for (MiniWallsGamer miniWallsGamer : miniWallsGame.getGamers()) { Player player = miniWallsGamer.toPlayer(); VersionAdapters.get().spawnParticle(player, ArcadeParticle.EXPLOSION_LARGE, location, 1, 0.2, 0.2, 0.2, 0.0); - if (!miniWallsGamer.f() && miniWallsGamer.getTeamContext() != miniWallsTeamContext) { + if (!miniWallsGamer.isSpectator() && miniWallsGamer.getTeamContext() != miniWallsTeamContext) { double doubleVal = player.getLocation().distanceSquared(location); if (doubleVal <= 10.0) { Vector vector = player.getLocation().subtract(location).toVector().normalize(); @@ -386,21 +386,21 @@ public class MiniWallsListener extends GameListener { if (player.getHealth() > 3.5) { player.damage(3.5); } else { - MiniWallsGamer miniWallsGamer2 = miniWallsGamer.z(); + MiniWallsGamer miniWallsGamer2 = miniWallsGamer.getLastDamager(); if (miniWallsGamer2 == null) { for (MiniWallsGamer miniWallsGamer3 : miniWallsGame.getGamers()) { if (miniWallsGamer == miniWallsGamer3) { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getWitherKilledYou(), miniWallsTeamContext); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getWitherKilledYou(), miniWallsTeamContext); } else { - Context context = Contexts.a( + Context context = Contexts.withVariables( miniWallsGamer, text -> text.equals("player_color") ? miniWallsGamer.getTeamContext().getTeamSettings().getColor().getChatColor().toString() : miniWallsTeamContext.getVariable(text) ); - miniWallsGamer3.sendMessage(this.manager2.getMessages().getWitherKilledPlayer(), context); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getWitherKilledPlayer(), context); } } } else { for (MiniWallsGamer miniWallsGamer4 : miniWallsGame.getGamers()) { - Context context2 = Contexts.a(miniWallsTeamContext, text2 -> { + Context context2 = Contexts.withVariables(miniWallsTeamContext, text2 -> { return switch (text2) { case "player" -> miniWallsGamer.getName(); case "player_color" -> miniWallsGamer.getTeamContext().getTeamSettings().getColor().getChatColor().toString(); @@ -410,14 +410,14 @@ public class MiniWallsListener extends GameListener { }; }); if (miniWallsGamer == miniWallsGamer4) { - miniWallsGamer4.sendMessage(this.manager2.getMessages().getWitherKilledYouWithHelp(), context2); + miniWallsGamer4.sendMessage(this.miniWallsManager.getMessages().getWitherKilledYouWithHelp(), context2); } else { - miniWallsGamer4.sendMessage(this.manager2.getMessages().getWitherKilledPlayerWithHelp(), context2); + miniWallsGamer4.sendMessage(this.miniWallsManager.getMessages().getWitherKilledPlayerWithHelp(), context2); } } } - miniWallsGamer.C(); + miniWallsGamer.handleDeath(); } } } @@ -432,36 +432,36 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(EntityShootBowEvent event) { - MiniWallsGamer miniWallsGamer = this.a(event.getEntity(), MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f()) { - miniWallsGamer.j(miniWallsGamer.getKit2().c() * 20); - event.setProjectile(this.manager2.getMiniWallsEntityFactory().spawnArrow(miniWallsGamer.toPlayer(), miniWallsGamer.getTeamContext().getTeamSettings().getColor().getColor(), event.getProjectile().getVelocity(), entity -> { + public void onEntityShootBow(EntityShootBowEvent event) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(event.getEntity(), MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator()) { + miniWallsGamer.setArrowCooldownTicks(miniWallsGamer.getSelectedKit().getArrowRegenSeconds() * 20); + event.setProjectile(this.miniWallsManager.getMiniWallsEntityFactory().spawnArrow(miniWallsGamer.toPlayer(), miniWallsGamer.getTeamContext().getTeamSettings().getColor().getColor(), event.getProjectile().getVelocity(), entity -> { MiniWallsGamer miniWallsGamer2 = (MiniWallsGamer)miniWallsGamer.getGame().getGamers().a(entity); - return miniWallsGamer2 != null && !miniWallsGamer2.f() && miniWallsGamer2.getTeamContext() != miniWallsGamer.getTeamContext(); + return miniWallsGamer2 != null && !miniWallsGamer2.isSpectator() && miniWallsGamer2.getTeamContext() != miniWallsGamer.getTeamContext(); })); - miniWallsGamer.getGame().z().add(event.getProjectile()); - miniWallsGamer.g(miniWallsGamer.u() + 1); + miniWallsGamer.getGame().getTrackedEntities().add(event.getProjectile()); + miniWallsGamer.setArrowsShot(miniWallsGamer.getArrowsShot() + 1); } } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getFrom(); Location location2 = event.getTo(); Player player = event.getPlayer(); - MiniWallsGamer miniWallsGamer = this.a(player, MiniWallsGamer.class); - if (miniWallsGamer != null && location2 != null && !Locations.a(location, location2)) { + MiniWallsGamer miniWallsGamer = this.getActiveGamer(player, MiniWallsGamer.class); + if (miniWallsGamer != null && location2 != null && !Locations.isSameBlock(location, location2)) { MiniWallsGame miniWallsGame = miniWallsGamer.getGame(); - if (!miniWallsGame.getMap().getPlayZone().a(location2)) { - if (miniWallsGamer.f()) { + if (!miniWallsGame.getMap().getPlayZone().contains(location2)) { + if (miniWallsGamer.isSpectator()) { player.setFlying(true); event.setTo(miniWallsGame.getMap().getSpectator()); } else if (miniWallsGame.getPhase() == miniWallsGame.getPhaseLifecycle().getPlaying()) { - if (location2.getBlockY() < miniWallsGame.getMap().getPlayZone().b().getBlockY()) { + if (location2.getBlockY() < miniWallsGame.getMap().getPlayZone().getMin().getBlockY()) { event.setTo(miniWallsGamer.getTeamContext().getTeamSettings().getSpawn()); - MiniWallsGamer miniWallsGamer2 = miniWallsGamer.z(); - Context context = Contexts.a(miniWallsGamer, text -> { + MiniWallsGamer miniWallsGamer2 = miniWallsGamer.getLastDamager(); + Context context = Contexts.withVariables(miniWallsGamer, text -> { if (text.equals("damager")) { return miniWallsGamer2.getName(); } else { @@ -472,21 +472,21 @@ public class MiniWallsListener extends GameListener { for (MiniWallsGamer miniWallsGamer3 : miniWallsGame.getGamers()) { if (miniWallsGamer2 == null) { if (miniWallsGamer == miniWallsGamer3) { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerFellYou()); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerFellYou()); } else { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerFell(), miniWallsGamer); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerFell(), miniWallsGamer); } } else if (miniWallsGamer == miniWallsGamer3) { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerVoidYou(), context); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerVoidYou(), context); } else if (miniWallsGamer3 == miniWallsGamer2) { miniWallsGamer3.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerVoidByYou().a(context).concat(" §a+" + miniWallsGamer3.getKit2().d() + "§c❤")); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerVoidByYou().render(context).concat(" §a+" + miniWallsGamer3.getSelectedKit().getKillHealAmount() + "§c❤")); } else { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getPlayerVoidByPlayer(), context); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getPlayerVoidByPlayer(), context); } } - miniWallsGamer.C(); + miniWallsGamer.handleDeath(); } else { event.setTo(event.getFrom()); } @@ -496,66 +496,66 @@ public class MiniWallsListener extends GameListener { } @EventHandler - public void a(EntityDamageByEntityEvent event) { + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getEntityType() == EntityType.WITHER) { Wither wither = (Wither)event.getEntity(); - for (MiniWallsGame miniWallsGame : this.manager2.getSessions().d().values()) { + for (MiniWallsGame miniWallsGame : this.miniWallsManager.getSessions().getGames().values()) { for (MiniWallsTeamContext miniWallsTeamContext : miniWallsGame.getTeamContexts()) { if (wither == miniWallsTeamContext.getWither()) { - MiniWallsGamer miniWallsGamer = this.a(event.getDamager(), MiniWallsGamer.class); - if (miniWallsGamer != null && !miniWallsGamer.f() && miniWallsGamer.getTeamContext() != miniWallsTeamContext) { - ItemStack mainHand = VersionAdapters.get().getMainHandItem(this.manager2.getEngine().getPlatform(), miniWallsGamer.toPlayer()); + MiniWallsGamer miniWallsGamer = this.getActiveGamer(event.getDamager(), MiniWallsGamer.class); + if (miniWallsGamer != null && !miniWallsGamer.isSpectator() && miniWallsGamer.getTeamContext() != miniWallsTeamContext) { + ItemStack mainHand = VersionAdapters.get().getMainHandItem(this.miniWallsManager.getEngine().getPlatform(), miniWallsGamer.toPlayer()); if (mainHand == null || mainHand.getType() == Material.AIR) { event.setDamage(Math.min(event.getDamage(), 1.0)); } - miniWallsGamer.h((int)(miniWallsGamer.v() + event.getDamage())); + miniWallsGamer.setWitherDamage((int)(miniWallsGamer.getWitherDamage() + event.getDamage())); if (wither.getHealth() > 30.0 && wither.getHealth() - event.getDamage() <= 30.0) { - miniWallsTeamContext.getMembers().forEach(miniWallsGamer2 -> miniWallsGamer2.sendActionBar(this.manager2.getMessages().getWitherLowHp())); + miniWallsTeamContext.getMembers().forEach(miniWallsGamer2 -> miniWallsGamer2.sendActionBar(this.miniWallsManager.getMessages().getWitherLowHp())); } if (wither.getHealth() <= event.getDamage()) { wither.remove(); - miniWallsGame.getViewers().b(miniWallsTeamContext.getHologram()); + miniWallsGame.getViewers().unregister(miniWallsTeamContext.getHologram()); miniWallsTeamContext.setHologram((ro.fr33styler.arcade.engine.display.hologram.Hologram)null); event.setCancelled(true); - miniWallsGame.A().entrySet().removeIf(entry -> { + miniWallsGame.getDisconnectedPlayers().entrySet().removeIf(entry -> { MiniWallsTeam miniWallsTeam = (MiniWallsTeam)entry.getValue(); boolean flag = miniWallsTeam.getTeamContext() == miniWallsTeamContext; if (flag) { - miniWallsTeam.b(1); - this.manager2.getSessions().e().remove(entry.getKey()); - miniWallsGame.getManager().a((UUID)entry.getKey(), miniWallsTeam); + miniWallsTeam.setLoses(1); + this.miniWallsManager.getSessions().getRejoinGames().remove(entry.getKey()); + miniWallsGame.getManager().recordFinalStatistics((UUID)entry.getKey(), miniWallsTeam); } return flag; }); - miniWallsGamer.i(miniWallsGamer.w() + 1); + miniWallsGamer.setWithersKilled(miniWallsGamer.getWithersKilled() + 1); for (MiniWallsGamer miniWallsGamer3 : miniWallsGame.getGamers()) { miniWallsGamer3.playSound(ArcadeSound.WITHER_DEATH, 1.0F, 1.0F); if (miniWallsGamer3.getTeamContext() == miniWallsTeamContext) { - miniWallsGamer3.sendTitle(this.manager2.getMessages().getWitherDiedTitle(), this.manager2.getMessages().getWitherDiedSubtitle(), 20, 45, 20); + miniWallsGamer3.sendTitle(this.miniWallsManager.getMessages().getWitherDiedTitle(), this.miniWallsManager.getMessages().getWitherDiedSubtitle(), 20, 45, 20); } else { - miniWallsGamer3.sendTitle(this.manager2.getMessages().getWitherDied(), TextRenderer.text, miniWallsTeamContext, 20, 45, 20); + miniWallsGamer3.sendTitle(this.miniWallsManager.getMessages().getWitherDied(), TextRenderer.text, miniWallsTeamContext, 20, 45, 20); } if (miniWallsGamer3 == miniWallsGamer) { - miniWallsGamer3.sendMessage(this.manager2.getMessages().getWitherKilledByYou(), miniWallsTeamContext); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getWitherKilledByYou(), miniWallsTeamContext); } else { - Context context = Contexts.a(miniWallsTeamContext, text -> { + Context context = Contexts.withVariables(miniWallsTeamContext, text -> { if (text.equals("damager")) { return miniWallsGamer.getName(); } else { return text.equals("damager_color") ? miniWallsGamer.getTeamContext().getTeamSettings().getColor().getChatColor().toString() : null; } }); - miniWallsGamer3.sendMessage(this.manager2.getMessages().getWitherKilledByPlayer(), context); + miniWallsGamer3.sendMessage(this.miniWallsManager.getMessages().getWitherKilledByPlayer(), context); } } - miniWallsGame.E(); + miniWallsGame.checkWinCondition(); } } else { event.setCancelled(true); @@ -566,8 +566,8 @@ public class MiniWallsListener extends GameListener { } } } else { - MiniWallsGamer miniWallsGamer4 = this.a(event.getEntity(), MiniWallsGamer.class); - if (miniWallsGamer4 == null || miniWallsGamer4.f()) { + MiniWallsGamer miniWallsGamer4 = this.getActiveGamer(event.getEntity(), MiniWallsGamer.class); + if (miniWallsGamer4 == null || miniWallsGamer4.isSpectator()) { return; } @@ -575,21 +575,21 @@ public class MiniWallsListener extends GameListener { Player player = miniWallsGamer4.toPlayer(); double doubleVal = player.getHealth() - event.getFinalDamage(); if (event.getDamager() instanceof Projectile var7 && var7.getShooter() instanceof Player var8) { - MiniWallsGamer miniWallsGamer5 = this.a(var8, MiniWallsGamer.class); - if (miniWallsGamer5 == null || miniWallsGamer5.f() || miniWallsGamer4.getTeamContext() == miniWallsGamer5.getTeamContext()) { + MiniWallsGamer miniWallsGamer5 = this.getActiveGamer(var8, MiniWallsGamer.class); + if (miniWallsGamer5 == null || miniWallsGamer5.isSpectator() || miniWallsGamer4.getTeamContext() == miniWallsGamer5.getTeamContext()) { event.setCancelled(true); return; } - miniWallsGamer4.a(miniWallsGamer5); - miniWallsGamer5.g(miniWallsGamer5.u() + 1); + miniWallsGamer4.setLastDamager(miniWallsGamer5); + miniWallsGamer5.setArrowsShot(miniWallsGamer5.getArrowsShot() + 1); if (!(doubleVal <= 0.0)) { - Context context2 = Contexts.a(miniWallsGamer4, text2 -> text2.equals("health") ? Strings.a(doubleVal, 2) : null); - miniWallsGamer5.sendMessage(this.manager2.getMessages().getPlayerShotByYouHp(), context2); + Context context2 = Contexts.withVariables(miniWallsGamer4, text2 -> text2.equals("health") ? Strings.formatFixedDecimal(doubleVal, 2) : null); + miniWallsGamer5.sendMessage(this.miniWallsManager.getMessages().getPlayerShotByYouHp(), context2); return; } - Context context3 = Contexts.a(miniWallsGamer4, text3 -> { + Context context3 = Contexts.withVariables(miniWallsGamer4, text3 -> { return switch (text3) { case "damager" -> miniWallsGamer5.getName(); case "damager_color" -> miniWallsGamer5.getTeamContext().getTeamSettings().getColor().getChatColor().toString(); @@ -601,29 +601,29 @@ public class MiniWallsListener extends GameListener { for (MiniWallsGamer miniWallsGamer6 : miniWallsGame2.getGamers()) { if (miniWallsGamer6 == miniWallsGamer4) { - miniWallsGamer6.sendMessage(this.manager2.getMessages().getPlayerShotYou(), context3); + miniWallsGamer6.sendMessage(this.miniWallsManager.getMessages().getPlayerShotYou(), context3); } else if (miniWallsGamer6 == miniWallsGamer5) { - miniWallsGamer6.sendMessage(this.manager2.getMessages().getPlayerShotByYou().a(context3).concat(" §a+" + miniWallsGamer6.getKit2().d() + "§c❤")); + miniWallsGamer6.sendMessage(this.miniWallsManager.getMessages().getPlayerShotByYou().render(context3).concat(" §a+" + miniWallsGamer6.getSelectedKit().getKillHealAmount() + "§c❤")); } else { - miniWallsGamer6.sendMessage(this.manager2.getMessages().getPlayerShotByPlayer().a(context3)); + miniWallsGamer6.sendMessage(this.miniWallsManager.getMessages().getPlayerShotByPlayer().render(context3)); } } - miniWallsGamer4.C(); - } else if (event.getDamager().getType() == EntityType.PLAYER && !miniWallsGamer4.f()) { - MiniWallsGamer miniWallsGamer7 = this.a(event.getDamager(), MiniWallsGamer.class); - if (miniWallsGamer7 == null || miniWallsGamer7.f()) { + miniWallsGamer4.handleDeath(); + } else if (event.getDamager().getType() == EntityType.PLAYER && !miniWallsGamer4.isSpectator()) { + MiniWallsGamer miniWallsGamer7 = this.getActiveGamer(event.getDamager(), MiniWallsGamer.class); + if (miniWallsGamer7 == null || miniWallsGamer7.isSpectator()) { return; } if (miniWallsGamer4.getTeamContext() != miniWallsGamer7.getTeamContext()) { - miniWallsGamer4.a(miniWallsGamer7); + miniWallsGamer4.setLastDamager(miniWallsGamer7); if (!(doubleVal <= 0.0)) { return; } miniWallsGamer7.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - Context context4 = Contexts.a(miniWallsGamer4, text4 -> { + Context context4 = Contexts.withVariables(miniWallsGamer4, text4 -> { return switch (text4) { case "damager" -> miniWallsGamer7.getName(); case "damager_color" -> miniWallsGamer7.getTeamContext().getTeamSettings().getColor().getChatColor().toString(); @@ -635,15 +635,15 @@ public class MiniWallsListener extends GameListener { for (MiniWallsGamer miniWallsGamer8 : miniWallsGame2.getGamers()) { if (miniWallsGamer8 == miniWallsGamer4) { - miniWallsGamer8.sendMessage(this.manager2.getMessages().getPlayerKilledYou(), context4); + miniWallsGamer8.sendMessage(this.miniWallsManager.getMessages().getPlayerKilledYou(), context4); } else if (miniWallsGamer8 == miniWallsGamer7) { - miniWallsGamer8.sendMessage(this.manager2.getMessages().getPlayerKilledByYou().a(context4).concat(" §a+" + miniWallsGamer8.getKit2().d() + "§c❤")); + miniWallsGamer8.sendMessage(this.miniWallsManager.getMessages().getPlayerKilledByYou().render(context4).concat(" §a+" + miniWallsGamer8.getSelectedKit().getKillHealAmount() + "§c❤")); } else { - miniWallsGamer8.sendMessage(this.manager2.getMessages().getPlayerKilledByPlayer(), context4); + miniWallsGamer8.sendMessage(this.miniWallsManager.getMessages().getPlayerKilledByPlayer(), context4); } } - miniWallsGamer4.C(); + miniWallsGamer4.handleDeath(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsMap.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsMap.java index 50be91b..9a0d5a5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsMap.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsMap.java @@ -51,8 +51,8 @@ public class MiniWallsMap extends BaseGameMap { return this.walls; } - public MiniWallsTeamSettings a(MiniWallsTeamColor miniWallsTeamColor) { - return switch (MiniWallsStageSwitchTable.a[miniWallsTeamColor.ordinal()]) { + public MiniWallsTeamSettings getTeamSettings(MiniWallsTeamColor miniWallsTeamColor) { + return switch (MiniWallsStageSwitchTable.STAGE_ORDINAL_MAP[miniWallsTeamColor.ordinal()]) { case 1 -> this.teamRed; case 2 -> this.teamBlue; case 3 -> this.teamGreen; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsStageSwitchTable.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsStageSwitchTable.java index db7a8db..4fd8aa7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsStageSwitchTable.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/map/MiniWallsStageSwitchTable.java @@ -3,26 +3,26 @@ package ro.fr33styler.arcade.game.miniwalls.map; import ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamColor; class MiniWallsStageSwitchTable { - static final int[] a = new int[MiniWallsTeamColor.values().length]; + static final int[] STAGE_ORDINAL_MAP = new int[MiniWallsTeamColor.values().length]; static { try { - a[MiniWallsTeamColor.RED.ordinal()] = 1; + STAGE_ORDINAL_MAP[MiniWallsTeamColor.RED.ordinal()] = 1; } catch (NoSuchFieldError var4) { } try { - a[MiniWallsTeamColor.BLUE.ordinal()] = 2; + STAGE_ORDINAL_MAP[MiniWallsTeamColor.BLUE.ordinal()] = 2; } catch (NoSuchFieldError var3) { } try { - a[MiniWallsTeamColor.GREEN.ordinal()] = 3; + STAGE_ORDINAL_MAP[MiniWallsTeamColor.GREEN.ordinal()] = 3; } catch (NoSuchFieldError var2) { } try { - a[MiniWallsTeamColor.YELLOW.ordinal()] = 4; + STAGE_ORDINAL_MAP[MiniWallsTeamColor.YELLOW.ordinal()] = 4; } catch (NoSuchFieldError var1) { } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsPlayingPhase.java index 7de4f9b..d5494dd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsPlayingPhase.java @@ -47,18 +47,18 @@ public class MiniWallsPlayingPhase implements Phase { } public void start() { - this.game.b(this.game.getSettings().getWallFall()); - this.game.setGamers((MiniWallsGamer[])this.game.getGamers().a(new MiniWallsGamer[this.game.getGamers().size()])); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); - this.b(); - this.game.getScoreboard().getOrCreateObjective().a(true); - this.game.getScoreboard().getOrCreateObjective().a(this.game.getMessages().getTeamHealth()); + this.game.setStageTimer(this.game.getSettings().getWallFall()); + this.game.setGamers((MiniWallsGamer[])this.game.getGamers().toArray(new MiniWallsGamer[this.game.getGamers().size()])); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.assignTeams(); + this.game.getScoreboard().getOrCreateObjective().setVisible(true); + this.game.getScoreboard().getOrCreateObjective().setDisplayName(this.game.getMessages().getTeamHealth()); for (MiniWallsTeamContext miniWallsTeamContext : this.game.getTeamContexts()) { if (!miniWallsTeamContext.getMembers().isEmpty()) { Wither wither = this.game.getManager().getMiniWallsEntityFactory().spawnWither(miniWallsTeamContext.getTeamSettings().getWitherSpawn(), livingEntity -> { MiniWallsGamer miniWallsGamer = (MiniWallsGamer)this.game.getGamers().a(livingEntity); - return miniWallsGamer != null && !miniWallsGamer.f() && miniWallsGamer.getTeamContext() == miniWallsTeamContext; + return miniWallsGamer != null && !miniWallsGamer.isSpectator() && miniWallsGamer.getTeamContext() == miniWallsTeamContext; }, () -> { for (MiniWallsGamer miniWallsGamer2 : miniWallsTeamContext.getMembers()) { miniWallsGamer2.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); @@ -68,18 +68,18 @@ public class MiniWallsPlayingPhase implements Phase { miniWallsTeamContext.setWither(wither); Hologram hologram = new Hologram(wither.getLocation().add(0.0, 1.8, 0.0)); miniWallsTeamContext.setHologram(hologram); - this.game.getViewers().a(hologram); + this.game.getViewers().register(hologram); } for (MiniWallsGamer miniWallsGamer3 : miniWallsTeamContext.getMembers()) { miniWallsGamer3.setTeamContext(miniWallsTeamContext); Player player = miniWallsGamer3.toPlayer(); - Players.a(this.game.getManager().getEngine().getPlatform(), player); + Players.reset(this.game.getManager().getEngine().getPlatform(), player); player.teleport(miniWallsTeamContext.getTeamSettings().getSpawn()); - miniWallsGamer3.getKit2().a(miniWallsGamer3, true); + miniWallsGamer3.getSelectedKit().equip(miniWallsGamer3, true); miniWallsTeamContext.getScoreboardTeam().addEntry(player.getName()); miniWallsGamer3.playSound(ArcadeSound.NOTE_PLING, 1.0F, 1.0F); - miniWallsGamer3.sendTitle(this.game.getMessages().getTeamStart().a(miniWallsGamer3), "", 0, 80, 0); + miniWallsGamer3.sendTitle(this.game.getMessages().getTeamStart().render(miniWallsGamer3), "", 0, 80, 0); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0)); player.getEquipment() .setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setLeatherColor(miniWallsTeamContext.getTeamSettings().getColor().getColor()).setUnbreakable(true).addFlags(new ItemFlag[]{ItemFlag.HIDE_UNBREAKABLE}).build()); @@ -91,15 +91,15 @@ public class MiniWallsPlayingPhase implements Phase { } } - this.game.getMap().getPlayZone().a(block -> { - if (!block.isEmpty() && !this.game.a(block, 0, false)) { - this.game.getBlockDistanceIndex().a(block); + this.game.getMap().getPlayZone().forEachBlock(block -> { + if (!block.isEmpty() && !this.game.isWallBlock(block, 0, false)) { + this.game.getBlockDistanceIndex().add(block); } }); } - private void b() { - List list = this.game.getGamers().d(); + private void assignTeams() { + List list = this.game.getGamers().toList(); int index = Math.max(2, (list.size() - 1) / (this.game.getMap().getMaximumPlayers() / 4) + 1); int index2 = Math.max(1, list.size() / index); int index3 = list.size() % index; @@ -107,7 +107,7 @@ public class MiniWallsPlayingPhase implements Phase { System.arraycopy(this.game.getTeamContexts(), 0, miniWallsTeamContexts, 0, index); for (MiniWallsGamer miniWallsGamer : list) { - MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer.getTeamContext3(); + MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer.getSelectedTeam(); if (miniWallsTeamContext != null) { miniWallsTeamContext.setWitherKills(miniWallsTeamContext.getWitherKills() + 1); } @@ -119,10 +119,10 @@ public class MiniWallsPlayingPhase implements Phase { miniWallsTeamContexts[index4].setWitherDamagedCount(index4); } - Randoms.b(miniWallsTeamContexts); - this.b(miniWallsTeamContexts, list, index2, index3); + Randoms.shuffle(miniWallsTeamContexts); + this.assignPartyTeams(miniWallsTeamContexts, list, index2, index3); Collections.shuffle(list); - this.a(miniWallsTeamContexts, list, index2, index3); + this.assignSelectedTeams(miniWallsTeamContexts, list, index2, index3); for (MiniWallsTeamContext miniWallsTeamContext2 : miniWallsTeamContexts) { int index5 = miniWallsTeamContext2.getWitherDamagedCount() < index3 ? index2 + 1 : index2; @@ -133,12 +133,12 @@ public class MiniWallsPlayingPhase implements Phase { } } - private void a(MiniWallsTeamContext[] miniWallsTeamContexts, List list, int index, int index2) { + private void assignSelectedTeams(MiniWallsTeamContext[] miniWallsTeamContexts, List list, int index, int index2) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { MiniWallsGamer miniWallsGamer = (MiniWallsGamer)iterator.next(); - MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer.getTeamContext3(); + MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer.getSelectedTeam(); if (miniWallsTeamContext != null) { int index3 = miniWallsTeamContext.getWitherDamagedCount() < index2 ? index + 1 : index; if (miniWallsTeamContexts.length > miniWallsTeamContext.getWitherDamagedCount() && miniWallsTeamContext.getMembers().size() < index3) { @@ -146,16 +146,16 @@ public class MiniWallsPlayingPhase implements Phase { iterator.remove(); } - miniWallsGamer.setTeamContext3((ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamContext)null); + miniWallsGamer.setSelectedTeam((ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamContext)null); } } } - private void b(MiniWallsTeamContext[] miniWallsTeamContexts, List list, int index, int index2) { + private void assignPartyTeams(MiniWallsTeamContext[] miniWallsTeamContexts, List list, int index, int index2) { HashMap> map = new HashMap<>(); for (MiniWallsGamer miniWallsGamer : list) { - Party party = miniWallsGamer.d(); + Party party = miniWallsGamer.getParty(); if (party != null && party.size() > 1) { map.computeIfAbsent(party.getLeader(), uuid -> new ArrayList<>()).add(miniWallsGamer); } @@ -166,10 +166,10 @@ public class MiniWallsPlayingPhase implements Phase { while (iterator.hasNext()) { Entry entry = (Entry)iterator.next(); MiniWallsGamer miniWallsGamer2 = (MiniWallsGamer)this.game.getGamers().a((UUID)entry.getKey()); - if (miniWallsGamer2 != null && miniWallsGamer2.getTeamContext3() != null) { - MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer2.getTeamContext3(); + if (miniWallsGamer2 != null && miniWallsGamer2.getSelectedTeam() != null) { + MiniWallsTeamContext miniWallsTeamContext = miniWallsGamer2.getSelectedTeam(); int index3 = miniWallsTeamContext.getWitherDamagedCount() < index2 ? index + 1 : index; - if (miniWallsTeamContexts.length > miniWallsTeamContext.getWitherDamagedCount() && this.a(list, (List)entry.getValue(), miniWallsTeamContext, index3)) { + if (miniWallsTeamContexts.length > miniWallsTeamContext.getWitherDamagedCount() && this.addPartyToTeam(list, (List)entry.getValue(), miniWallsTeamContext, index3)) { iterator.remove(); } } @@ -177,15 +177,15 @@ public class MiniWallsPlayingPhase implements Phase { for (Entry entry2 : map.entrySet()) { for (MiniWallsTeamContext miniWallsTeamContext2 : miniWallsTeamContexts) { - if (this.a(list, (List)entry2.getValue(), miniWallsTeamContext2, miniWallsTeamContext2.getWitherDamagedCount() < index2 ? index + 1 : index)) { - Randoms.b(miniWallsTeamContexts); + if (this.addPartyToTeam(list, (List)entry2.getValue(), miniWallsTeamContext2, miniWallsTeamContext2.getWitherDamagedCount() < index2 ? index + 1 : index)) { + Randoms.shuffle(miniWallsTeamContexts); break; } } } } - private boolean a(List list, List list2, MiniWallsTeamContext miniWallsTeamContext, int index) { + private boolean addPartyToTeam(List list, List list2, MiniWallsTeamContext miniWallsTeamContext, int index) { if (index - miniWallsTeamContext.getMembers().size() >= list2.size()) { miniWallsTeamContext.getMembers().addAll(list2); list.removeAll(list2); @@ -196,14 +196,14 @@ public class MiniWallsPlayingPhase implements Phase { } public void stop() { - this.game.getViewers().a(); - this.game.z().forEach(Entity::remove); - this.game.z().clear(); - this.game.a(0); - this.game.getBlockDistanceIndex().a(); - this.game.s().clear(); + this.game.getViewers().clear(); + this.game.getTrackedEntities().forEach(Entity::remove); + this.game.getTrackedEntities().clear(); + this.game.setFallingBlockCooldown(0); + this.game.getBlockDistanceIndex().clear(); + this.game.getPlacedWoolBlocks().clear(); this.game.setMiniWallsStage(MiniWallsStage.WALLS_FALL); - this.game.getScoreboard().getOrCreateObjective().a(false); + this.game.getScoreboard().getOrCreateObjective().setVisible(false); for (MiniWallsTeamContext miniWallsTeamContext : this.game.getTeamContexts()) { if (miniWallsTeamContext.isWitherAlive()) { @@ -221,12 +221,12 @@ public class MiniWallsPlayingPhase implements Phase { miniWallsTeamContext.setWitherKills(0); } - this.game.A().forEach((uuid, miniWallsTeam) -> { - this.game.getManager().getSessions().e().remove(uuid); - this.game.getManager().a(uuid, miniWallsTeam); + this.game.getDisconnectedPlayers().forEach((uuid, miniWallsTeam) -> { + this.game.getManager().getSessions().getRejoinGames().remove(uuid); + this.game.getManager().recordFinalStatistics(uuid, miniWallsTeam); }); - this.game.A().clear(); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.game.getDisconnectedPlayers().clear(); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -238,23 +238,23 @@ public class MiniWallsPlayingPhase implements Phase { return PhaseType.PLAYING; } - private void c() { + private void updateWitherDisplays() { for (MiniWallsTeamContext miniWallsTeamContext : this.game.getTeamContexts()) { if (miniWallsTeamContext.isWitherAlive()) { ChatColor chatColor = miniWallsTeamContext.getTeamSettings().getColor().getChatColor(); double doubleVal = Math.max(0L, Math.min(100L, Math.round(miniWallsTeamContext.getWither().getHealth()))); - String text = chatColor + Strings.a('█', chatColor.getChar(), '7', 10, doubleVal / 100.0) + " " + chatColor + doubleVal + "%"; - miniWallsTeamContext.getHologram().a(this.game.getManager().getEngine().getPlatform(), new String[]{text, this.game.getMessages().getTeamWitherName().a(miniWallsTeamContext)}); - miniWallsTeamContext.getMembers().forEach(miniWallsGamer -> miniWallsGamer.sendActionBar(this.game.getMessages().getWitherActionbarAlive().a(miniWallsGamer) + text)); + String text = chatColor + Strings.formatProgressBar('█', chatColor.getChar(), '7', 10, doubleVal / 100.0) + " " + chatColor + doubleVal + "%"; + miniWallsTeamContext.getHologram().setLines(this.game.getManager().getEngine().getPlatform(), new String[]{text, this.game.getMessages().getTeamWitherName().render(miniWallsTeamContext)}); + miniWallsTeamContext.getMembers().forEach(miniWallsGamer -> miniWallsGamer.sendActionBar(this.game.getMessages().getWitherActionbarAlive().render(miniWallsGamer) + text)); } else { - miniWallsTeamContext.getMembers().forEach(miniWallsGamer2 -> miniWallsGamer2.b(this.game.getMessages().getWitherActionbarDead())); + miniWallsTeamContext.getMembers().forEach(miniWallsGamer2 -> miniWallsGamer2.sendActionBar(this.game.getMessages().getWitherActionbarDead())); } } } - private void d() { - if (this.game.B() <= 0) { - this.game.b(15); + private void tickDeathmatch() { + if (this.game.getStageTimer() <= 0) { + this.game.setStageTimer(15); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); for (MiniWallsGamer miniWallsGamer : this.game.getGamers()) { @@ -263,20 +263,20 @@ public class MiniWallsPlayingPhase implements Phase { } } - private void e() { - if (this.game.B() > 0) { - if (this.game.B() <= 5) { + private void tickWallsFall() { + if (this.game.getStageTimer() > 0) { + if (this.game.getStageTimer() <= 5) { for (MiniWallsGamer miniWallsGamer : this.game.getGamers()) { miniWallsGamer.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F); - miniWallsGamer.sendTitle("", this.game.getMessages().getWallsFall().a(this.game), 0, 40, 0); + miniWallsGamer.sendTitle("", this.game.getMessages().getWallsFall().render(this.game), 0, 40, 0); } } } else { for (Cuboid cuboid : this.game.getMap().getWalls()) { - cuboid.a(block -> { + cuboid.forEachBlock(block -> { this.game.getRollbackQueue().add(block.getState()); block.setType(Material.AIR); - if (block.getY() == cuboid.b().getBlockY()) { + if (block.getY() == cuboid.getMin().getBlockY()) { Block block2 = block.getRelative(BlockFace.DOWN); if (block2.getType() == Material.DIRT) { block2.setType(VersionAdapters.get().resolveMaterial(ArcadeMaterial.GRASS_BLOCK)); @@ -291,13 +291,13 @@ public class MiniWallsPlayingPhase implements Phase { } this.game.setMiniWallsStage(MiniWallsStage.MID_GAME); - this.game.b(this.game.getSettings().getMidGameDuration()); + this.game.setStageTimer(this.game.getSettings().getMidGameDuration()); } } - private void f() { - if (this.game.B() > 0) { - if (this.game.B() % 2 != 0) { + private void tickMidGame() { + if (this.game.getStageTimer() > 0) { + if (this.game.getStageTimer() % 2 != 0) { return; } @@ -316,7 +316,7 @@ public class MiniWallsPlayingPhase implements Phase { if (miniWallsGamer2.getTeamContext() != miniWallsTeamContext) { Player player = miniWallsGamer2.toPlayer(); double doubleVal2 = wither.getLocation().distanceSquared(player.getLocation()); - if (!miniWallsGamer2.f() && doubleVal2 <= 115.6 && (miniWallsGamer == null || doubleVal > doubleVal2) && wither.hasLineOfSight(player)) { + if (!miniWallsGamer2.isSpectator() && doubleVal2 <= 115.6 && (miniWallsGamer == null || doubleVal > doubleVal2) && wither.hasLineOfSight(player)) { miniWallsGamer = miniWallsGamer2; doubleVal = doubleVal2; } @@ -329,27 +329,27 @@ public class MiniWallsPlayingPhase implements Phase { wither.getWorld().playSound(wither.getLocation(), VersionAdapters.get().resolveSound(ArcadeSound.WITHER_SHOOT), 1.0F, 1.0F); this.game.getManager().getMiniWallsEntityFactory().spawnWitherSkull(wither, vector.multiply(this.game.getSettings().getMiniWitherSkullSpeed()), entity -> { MiniWallsGamer miniWallsGamer3 = (MiniWallsGamer)this.game.getGamers().a(entity); - return miniWallsGamer3 != null && !miniWallsGamer3.f() && miniWallsGamer3.getTeamContext() != miniWallsTeamContext; + return miniWallsGamer3 != null && !miniWallsGamer3.isSpectator() && miniWallsGamer3.getTeamContext() != miniWallsTeamContext; }); } } } } else { - this.game.E(); + this.game.checkWinCondition(); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.a(); + this.startDeathmatch(); } } } - public void a() { - this.game.b(this.game.getSettings().getDeathMatchDuration()); + public void startDeathmatch() { + this.game.setStageTimer(this.game.getSettings().getDeathMatchDuration()); this.game.setMiniWallsStage(MiniWallsStage.DEATH_MATCH); for (MiniWallsTeamContext miniWallsTeamContext : this.game.getTeamContexts()) { if (miniWallsTeamContext.isWitherAlive()) { miniWallsTeamContext.getWither().remove(); - this.game.getViewers().b(miniWallsTeamContext.getHologram()); + this.game.getViewers().unregister(miniWallsTeamContext.getHologram()); miniWallsTeamContext.setHologram((ro.fr33styler.arcade.engine.display.hologram.Hologram)null); } @@ -361,29 +361,29 @@ public class MiniWallsPlayingPhase implements Phase { } } - this.game.A().forEach((uuid, miniWallsTeam) -> { + this.game.getDisconnectedPlayers().forEach((uuid, miniWallsTeam) -> { if (miniWallsTeam.getTeamContext().getMembers().isEmpty()) { - miniWallsTeam.b(1); + miniWallsTeam.setLoses(1); } - this.game.getManager().getSessions().e().remove(uuid); - this.game.getManager().a(uuid, miniWallsTeam); + this.game.getManager().getSessions().getRejoinGames().remove(uuid); + this.game.getManager().recordFinalStatistics(uuid, miniWallsTeam); }); - this.game.A().clear(); - this.game.E(); + this.game.getDisconnectedPlayers().clear(); + this.game.checkWinCondition(); } - private void g() { - double doubleVal = this.game.getBlockDistanceIndex().b() / (1.0 + (this.game.B() - 2) * 4.0); - this.game.a(this.game.p() + doubleVal); + private void tickBorderShrink() { + double doubleVal = this.game.getBlockDistanceIndex().size() / (1.0 + (this.game.getStageTimer() - 2) * 4.0); + this.game.setDecayProgress(this.game.getDecayProgress() + doubleVal); - while (this.game.p() >= 1.0) { - for (Block block : this.game.getBlockDistanceIndex().c()) { + while (this.game.getDecayProgress() >= 1.0) { + for (Block block : this.game.getBlockDistanceIndex().pollFarthest()) { this.game.getRollbackQueue().add(block.getState()); - if (this.game.q() > 0) { - this.game.a(this.game.q() - 1); + if (this.game.getFallingBlockCooldown() > 0) { + this.game.setFallingBlockCooldown(this.game.getFallingBlockCooldown() - 1); } else { - this.game.a(Randoms.a().nextInt(50, 60)); + this.game.setFallingBlockCooldown(Randoms.current().nextInt(50, 60)); Location location = block.getLocation(); VersionAdapters.get().spawnFallingBlock(location.add(0.5, 0.5, 0.5), block); VersionAdapters.get().playSound(location.getWorld(), location, ArcadeSound.SNOW_STEP, 1.0F, 1.0F); @@ -392,47 +392,47 @@ public class MiniWallsPlayingPhase implements Phase { block.setType(Material.AIR, false); } - this.game.a(this.game.p() - 1.0); + this.game.setDecayProgress(this.game.getDecayProgress() - 1.0); } } public void onTick(long longVal) { if (longVal % 20L == 0L) { if (this.game.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH) { - this.d(); + this.tickDeathmatch(); } else { - this.c(); + this.updateWitherDisplays(); } if (this.game.getMiniWallsStage() == MiniWallsStage.WALLS_FALL) { - this.e(); + this.tickWallsFall(); } else if (this.game.getMiniWallsStage() == MiniWallsStage.MID_GAME) { - this.f(); + this.tickMidGame(); } for (MiniWallsGamer miniWallsGamer : this.game.getGamers()) { Player player = miniWallsGamer.toPlayer(); - this.game.getViewers().b(player); - miniWallsGamer.a(this.game.getMessages().getSidebarPlaying(), miniWallsGamer); - this.game.getScoreboard().getOrCreateObjective().a(player.getName(), Math.ceil(player.getHealth())); - if (this.game.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH && !miniWallsGamer.g()) { - MiniWallsGamer miniWallsGamer2 = miniWallsGamer.A(); + this.game.getViewers().update(player); + miniWallsGamer.updateSidebar(this.game.getMessages().getSidebarPlaying(), miniWallsGamer); + this.game.getScoreboard().getOrCreateObjective().setScore(player.getName(), Math.ceil(player.getHealth())); + if (this.game.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH && !miniWallsGamer.isActiveSpectator()) { + MiniWallsGamer miniWallsGamer2 = miniWallsGamer.findNearestEnemy(); if (miniWallsGamer2 != null) { player.setCompassTarget(miniWallsGamer2.toPlayer().getLocation()); } } } - this.game.b(this.game.B() - 1); + this.game.setStageTimer(this.game.getStageTimer() - 1); } if (this.game.getMiniWallsStage() == MiniWallsStage.DEATH_MATCH) { if (longVal % 5L == 0L) { - this.g(); + this.tickBorderShrink(); } if (longVal % 20L == 0L) { - Iterator iterator = this.game.s().entrySet().iterator(); + Iterator iterator = this.game.getPlacedWoolBlocks().entrySet().iterator(); while (iterator.hasNext()) { Entry entry = (Entry)iterator.next(); @@ -447,7 +447,7 @@ public class MiniWallsPlayingPhase implements Phase { } for (MiniWallsGamer miniWallsGamer3 : this.game.getGamers()) { - miniWallsGamer3.b(longVal); + miniWallsGamer3.onPlayingTick(longVal); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsStage.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsStage.java index 829a99f..8a7095b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsStage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsStage.java @@ -7,9 +7,9 @@ public enum MiniWallsStage { MID_GAME, DEATH_MATCH; - private static final MiniWallsStage[] d = {WALLS_FALL, MID_GAME, DEATH_MATCH}; + private static final MiniWallsStage[] VALUES = {WALLS_FALL, MID_GAME, DEATH_MATCH}; - public String a(MiniWallsMessages miniWallsMessages) { + public String getDisplayName(MiniWallsMessages miniWallsMessages) { return switch (this) { case WALLS_FALL -> miniWallsMessages.getStageWallsFall(); case MID_GAME -> miniWallsMessages.getStageMidgame(); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsWaitingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsWaitingPhase.java index fd3bcc1..bd026f7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsWaitingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/phase/MiniWallsWaitingPhase.java @@ -11,10 +11,10 @@ public class MiniWallsWaitingPhase extends WaitingPhase { } @Override - public void a(BaseGamer baseGamer) { - super.a(baseGamer); + public void onJoin(BaseGamer baseGamer) { + super.onJoin(baseGamer); if (baseGamer instanceof MiniWallsGamer var2) { - var2.B(); + var2.updateTeamHotbar(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/player/MiniWallsGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/player/MiniWallsGamer.java index babaa90..25bc766 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/player/MiniWallsGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/player/MiniWallsGamer.java @@ -27,34 +27,34 @@ import ro.fr33styler.arcade.platform.compat.ArcadeSound; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MiniWallsGamer extends BaseGamer implements Context, MiniWallsTeamMember { - private int b; - private int c; - private int d; - private int e; - private int f; - private int g; - private int h; - private int i; + private int deaths; + private int kills; + private int finalKills; + private int arrowsShot; + private int witherDamage; + private int withersKilled; + private int respawnTimer; + private int arrowCooldownTicks; private MiniWallsKit kit; - private ItemStack[] k; - private ItemStack[] l; + private ItemStack[] savedInventoryContents; + private ItemStack[] savedArmorContents; private MiniWallsTeamContext teamContext; - private MiniWallsTeamContext teamContext3; + private MiniWallsTeamContext selectedTeam; private final MiniWallsGame game; - private MiniWallsKit kit2 = MiniWallsKits.kit; - private MiniWallsGamer q; + private MiniWallsKit selectedKit = MiniWallsKits.kit; + private MiniWallsGamer lastDamager; public MiniWallsGamer(MiniWallsGame game2, DefaultUser defaultUser) { super(defaultUser); this.game = game2; } - public MiniWallsKit getKit2() { - return this.kit2; + public MiniWallsKit getSelectedKit() { + return this.selectedKit; } - public void setKit2(MiniWallsKit kit22) { - this.kit2 = kit22; + public void setSelectedKit(MiniWallsKit kit22) { + this.selectedKit = kit22; } public MiniWallsKit getKit() { @@ -65,76 +65,76 @@ public class MiniWallsGamer extends BaseGamer implements Context, MiniWallsTeamM this.kit = kit3; } - public ItemStack[] n() { - return this.k; + public ItemStack[] getSavedInventoryContents() { + return this.savedInventoryContents; } - public void a(ItemStack[] items) { - this.k = items; + public void setSavedInventoryContents(ItemStack[] items) { + this.savedInventoryContents = items; } - public ItemStack[] o() { - return this.l; + public ItemStack[] getSavedArmorContents() { + return this.savedArmorContents; } - public void b(ItemStack[] items) { - this.l = items; + public void setSavedArmorContents(ItemStack[] items) { + this.savedArmorContents = items; } - public void c(int index) { - this.h = index; + public void setRespawnTimer(int index) { + this.respawnTimer = index; } public MiniWallsGame getGame() { return this.game; } - public int r() { - return this.b; + public int getDeaths() { + return this.deaths; } - public void d(int index) { - this.b = index; + public void setDeaths(int index) { + this.deaths = index; } - public int s() { - return this.c; + public int getKills() { + return this.kills; } - public void e(int index) { - this.c = index; + public void setKills(int index) { + this.kills = index; } - public int t() { - return this.d; + public int getFinalKills() { + return this.finalKills; } - public void f(int index) { - this.d = index; + public void setFinalKills(int index) { + this.finalKills = index; } - public int u() { - return this.e; + public int getArrowsShot() { + return this.arrowsShot; } - public void g(int index) { - this.e = index; + public void setArrowsShot(int index) { + this.arrowsShot = index; } - public int v() { - return this.f; + public int getWitherDamage() { + return this.witherDamage; } - public void h(int index) { - this.f = index; + public void setWitherDamage(int index) { + this.witherDamage = index; } - public int w() { - return this.g; + public int getWithersKilled() { + return this.withersKilled; } - public void i(int index) { - this.g = index; + public void setWithersKilled(int index) { + this.withersKilled = index; } public MiniWallsTeamContext getTeamContext() { @@ -145,93 +145,93 @@ public class MiniWallsGamer extends BaseGamer implements Context, MiniWallsTeamM this.teamContext = teamContext2; } - public MiniWallsTeamContext getTeamContext3() { - return this.teamContext3; + public MiniWallsTeamContext getSelectedTeam() { + return this.selectedTeam; } - public void setTeamContext3(MiniWallsTeamContext teamContext32) { - this.teamContext3 = teamContext32; + public void setSelectedTeam(MiniWallsTeamContext teamContext32) { + this.selectedTeam = teamContext32; } - public void a(MiniWallsGamer miniWallsGamer) { - this.q = miniWallsGamer; + public void setLastDamager(MiniWallsGamer miniWallsGamer) { + this.lastDamager = miniWallsGamer; } - public MiniWallsGamer z() { - return this.q; + public MiniWallsGamer getLastDamager() { + return this.lastDamager; } - public void j(int index) { - this.i = index; + public void setArrowCooldownTicks(int index) { + this.arrowCooldownTicks = index; } - private void c(boolean flag) { + private void saveStatistics(boolean flag) { MiniWallsStatistics miniWallsStatistics = this.game.getManager().getData(this.getUUID()); - this.b(miniWallsStatistics.getMap()); + this.saveProperties(miniWallsStatistics.getMap()); if (flag) { - this.game.getManager().a(this.getUUID(), this); - } else if (miniWallsStatistics.a()) { - this.game.getManager().getStorage().e().c(miniWallsStatistics); + this.game.getManager().recordFinalStatistics(this.getUUID(), this); + } else if (miniWallsStatistics.isLoaded()) { + this.game.getManager().getStorage().getStatisticsRepository().insertStatistics(miniWallsStatistics); } } @Override public String getVariable(String text) { return switch (text) { - case "respawn" -> String.valueOf(this.h); - case "kit" -> this.kit2.a(this.game.getMessages()); + case "respawn" -> String.valueOf(this.respawnTimer); + case "kit" -> this.selectedKit.getDisplayName(this.game.getMessages()); case "color" -> (this.teamContext == null ? ChatColor.GOLD : this.teamContext.getTeamSettings().getColor().getChatColor()).toString(); - case "team" -> this.teamContext == null ? this.game.getMessages().getColorSpectator() : this.teamContext.getTeamSettings().getColor().a(this.game.getMessages()); - case "deaths" -> String.valueOf(this.b); - case "kills" -> String.valueOf(this.c); - case "final_kills" -> String.valueOf(this.d); - case "arrows_shot" -> String.valueOf(this.e); + case "team" -> this.teamContext == null ? this.game.getMessages().getColorSpectator() : this.teamContext.getTeamSettings().getColor().getDisplayName(this.game.getMessages()); + case "deaths" -> String.valueOf(this.deaths); + case "kills" -> String.valueOf(this.kills); + case "final_kills" -> String.valueOf(this.finalKills); + case "arrows_shot" -> String.valueOf(this.arrowsShot); default -> super.getVariable(text); }; } @Override public void leave() { - this.game.getGamers().b(this); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.getViewers().a(this.player); - if (this.getSpectatorOptions().g()) { - this.c(false); + this.game.getViewers().hideWorld(this.player); + if (this.getSpectatorOptions().isExternal()) { + this.saveStatistics(false); } else { this.teamContext.getMembers().remove(this); this.teamContext.getScoreboardTeam().removeEntry(this.player.getName()); for (MiniWallsGamer miniWallsGamer : this.game.getGamers()) { - if (miniWallsGamer.z() == this) { - miniWallsGamer.a((MiniWallsGamer)null); + if (miniWallsGamer.getLastDamager() == this) { + miniWallsGamer.setLastDamager((MiniWallsGamer)null); } } if (this.teamContext.isWitherAlive()) { - this.kit = this.kit2; - this.k = this.player.getInventory().getContents(); - this.l = this.player.getInventory().getArmorContents(); - this.game.A().put(this.player.getUniqueId(), new MiniWallsTeam(this)); - this.game.getManager().getSessions().e().put(this.player.getUniqueId(), this.game.getMap().getId()); - this.c(false); + this.kit = this.selectedKit; + this.savedInventoryContents = this.player.getInventory().getContents(); + this.savedArmorContents = this.player.getInventory().getArmorContents(); + this.game.getDisconnectedPlayers().put(this.player.getUniqueId(), new MiniWallsTeam(this)); + this.game.getManager().getSessions().getRejoinGames().put(this.player.getUniqueId(), this.game.getMap().getId()); + this.saveStatistics(false); } else { - this.c(true); - this.game.E(); + this.saveStatistics(true); + this.game.checkWinCondition(); } } } else { - this.c(this.game.getPhase() != this.game.getPhaseLifecycle().getWaiting()); + this.saveStatistics(this.game.getPhase() != this.game.getPhaseLifecycle().getWaiting()); } super.leave(); } - public MiniWallsGamer A() { + public MiniWallsGamer findNearestEnemy() { double doubleVal = 0.0; MiniWallsGamer miniWallsGamer = null; for (MiniWallsGamer miniWallsGamer2 : this.game.getGamers()) { - if (!miniWallsGamer2.f() && miniWallsGamer2.getTeamContext() != this.teamContext) { + if (!miniWallsGamer2.isSpectator() && miniWallsGamer2.getTeamContext() != this.teamContext) { double doubleVal2 = this.player.getLocation().distanceSquared(this.player.getLocation()); if (miniWallsGamer == null || doubleVal > doubleVal2) { miniWallsGamer = miniWallsGamer2; @@ -243,126 +243,126 @@ public class MiniWallsGamer extends BaseGamer implements Context, MiniWallsTeamM return miniWallsGamer; } - private void a(MiniWallsKit kit22, int index) { - if (this.kit2 == kit22) { + private void selectKit(MiniWallsKit kit22, int index) { + if (this.selectedKit == kit22) { this.player.sendMessage(this.game.getMessages().getGuiKitAlready()); } else { - this.kit2 = kit22; - this.player.sendMessage(this.game.getMessages().getGuiKitSelected().a(this)); - this.k(index); + this.selectedKit = kit22; + this.player.sendMessage(this.game.getMessages().getGuiKitSelected().render(this)); + this.populateKitHotbar(index); } VersionAdapters.get().playSound(this.player, ArcadeSound.STONE_BUTTON_CLICK_ON, 1.0F, 1.0F); } - private void c(MiniWallsTeamContext teamContext32) { - if (this.teamContext3 == teamContext32) { + private void selectTeam(MiniWallsTeamContext teamContext32) { + if (this.selectedTeam == teamContext32) { this.player.sendMessage(this.game.getMessages().getGuiTeamAlready()); this.playSound(ArcadeSound.ENDERMAN_TELEPORT, 1.0F, 1.0F); } else { - this.teamContext3 = teamContext32; + this.selectedTeam = teamContext32; this.playSound(ArcadeSound.STONE_BUTTON_CLICK_ON, 1.0F, 1.0F); - this.player.sendMessage(this.game.getMessages().getGuiTeamSelected().a(teamContext32)); - this.B(); + this.player.sendMessage(this.game.getMessages().getGuiTeamSelected().render(teamContext32)); + this.updateTeamHotbar(); } } - public void k(int index) { + public void populateKitHotbar(int index) { int index2 = index; for (MiniWallsKit miniWallsKit : MiniWallsKits.getKits()) { - this.getHotbar().a(index2++, () -> this.a(miniWallsKit, index), miniWallsKit.a(this.game.getMessages(), this.kit2)); + this.getHotbar().setSlot(index2++, () -> this.selectKit(miniWallsKit, index), miniWallsKit.createMenuItem(this.game.getMessages(), this.selectedKit)); } } - public void B() { + public void updateTeamHotbar() { int index = 4; for (MiniWallsTeamContext miniWallsTeamContext : this.game.getTeamContexts()) { ItemBuilder itemBuilder = miniWallsTeamContext.getTeamSettings().getColor().createWoolItemBuilder(); - itemBuilder.setDisplayName(this.game.getMessages().getGuiTeamFormat().a(miniWallsTeamContext)); - if (this.teamContext3 == miniWallsTeamContext) { + itemBuilder.setDisplayName(this.game.getMessages().getGuiTeamFormat().render(miniWallsTeamContext)); + if (this.selectedTeam == miniWallsTeamContext) { itemBuilder.addEnchant(VersionAdapters.get().getInfinityEnchantment(), 1).addFlags(new ItemFlag[]{ItemFlag.HIDE_ENCHANTS}); } - this.getHotbar().a(index++, () -> this.c(miniWallsTeamContext), itemBuilder.build()); + this.getHotbar().setSlot(index++, () -> this.selectTeam(miniWallsTeamContext), itemBuilder.build()); } } - public void C() { - this.b++; + public void handleDeath() { + this.deaths++; this.player.playEffect(EntityEffect.HURT); Skeleton skeleton = (Skeleton)this.player.getWorld().spawn(this.player.getLocation(), Skeleton.class); VersionAdapters.get().copyPlayerEquipment(this.player, skeleton); - this.game.z().add(skeleton); + this.game.getTrackedEntities().add(skeleton); skeleton.damage(skeleton.getHealth()); - if (this.q != null) { - this.q.e(this.q.s() + 1); - this.q.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - if (!this.q.f()) { - this.q.player.setHealth(Math.min(20.0, this.q.player.getHealth() + this.q.getKit2().d())); + if (this.lastDamager != null) { + this.lastDamager.setKills(this.lastDamager.getKills() + 1); + this.lastDamager.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); + if (!this.lastDamager.isSpectator()) { + this.lastDamager.player.setHealth(Math.min(20.0, this.lastDamager.player.getHealth() + this.lastDamager.getSelectedKit().getKillHealAmount())); } } if (this.teamContext.isWitherAlive()) { - this.kit = this.kit2; - this.k = this.player.getInventory().getContents(); - this.l = this.player.getInventory().getArmorContents(); - this.h = Locations.b(this.player.getLocation(), this.teamContext.getTeamSettings().getSpawn()) <= this.game.getSettings().getIncreasedSpawnTimeDistance() ? 12 : 6; - this.a(true); - this.k(3); + this.kit = this.selectedKit; + this.savedInventoryContents = this.player.getInventory().getContents(); + this.savedArmorContents = this.player.getInventory().getArmorContents(); + this.respawnTimer = Locations.distanceSquared(this.player.getLocation(), this.teamContext.getTeamSettings().getSpawn()) <= this.game.getSettings().getIncreasedSpawnTimeDistance() ? 12 : 6; + this.setTemporarySpectator(true); + this.populateKitHotbar(3); } else { - this.b(true); + this.setSpectator(true); this.teamContext.getMembers().remove(this); this.player.teleport(this.game.getMap().getSpectator()); - if (this.q != null) { - this.q.f(this.q.t() + 1); + if (this.lastDamager != null) { + this.lastDamager.setFinalKills(this.lastDamager.getFinalKills() + 1); } for (MiniWallsGamer miniWallsGamer : this.game.getGamers()) { - if (miniWallsGamer.q == miniWallsGamer) { - miniWallsGamer.q = null; + if (miniWallsGamer.lastDamager == miniWallsGamer) { + miniWallsGamer.lastDamager = null; } } - this.game.E(); + this.game.checkWinCondition(); } - this.q = null; + this.lastDamager = null; } - public void b(long longVal) { - if (longVal % 20L == 0L && this.f() && this.getSpectatorOptions().f()) { - if (this.h > 0) { - this.h--; - this.sendTitle(this.game.getMessages().getRespawnTitle(), this.game.getMessages().getRespawnSubtitle().a(this), 0, 30, 0); + public void onPlayingTick(long longVal) { + if (longVal % 20L == 0L && this.isSpectator() && this.getSpectatorOptions().isTemporary()) { + if (this.respawnTimer > 0) { + this.respawnTimer--; + this.sendTitle(this.game.getMessages().getRespawnTitle(), this.game.getMessages().getRespawnSubtitle().render(this), 0, 30, 0); } else { - this.a(false); - this.getHotbar().a(); + this.setTemporarySpectator(false); + this.getHotbar().clear(); this.player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0)); - if (this.kit == this.kit2) { - this.player.getInventory().setContents(this.k); - this.player.getInventory().setItem(8, new ItemStack(Material.ARROW, this.kit2.b())); + if (this.kit == this.selectedKit) { + this.player.getInventory().setContents(this.savedInventoryContents); + this.player.getInventory().setItem(8, new ItemStack(Material.ARROW, this.selectedKit.getMaxArrows())); } else { - this.kit2.a(this, false); + this.selectedKit.equip(this, false); - for (ItemStack item : this.k) { - if (item != null && Materials.a(item.getType())) { + for (ItemStack item : this.savedInventoryContents) { + if (item != null && Materials.isWool(item.getType())) { this.player.getInventory().addItem(new ItemStack[]{item}); } } } - this.player.getInventory().setArmorContents(this.l); + this.player.getInventory().setArmorContents(this.savedArmorContents); this.player.teleport(this.teamContext.getTeamSettings().getSpawn()); } } - if (this.i > 0) { - this.i--; - if (this.f()) { + if (this.arrowCooldownTicks > 0) { + this.arrowCooldownTicks--; + if (this.isSpectator()) { this.player.setExp(0.0F); - } else if (this.i == 0) { + } else if (this.arrowCooldownTicks == 0) { ItemStack item2 = this.player.getInventory().getItem(8); if (item2 == null) { item2 = new ItemStack(Material.ARROW); @@ -370,31 +370,31 @@ public class MiniWallsGamer extends BaseGamer implements Context, MiniWallsTeamM } item2.setAmount(item2.getAmount() + 1); - if (item2.getAmount() < this.kit2.b()) { - this.i = this.kit2.c() * 20; + if (item2.getAmount() < this.selectedKit.getMaxArrows()) { + this.arrowCooldownTicks = this.selectedKit.getArrowRegenSeconds() * 20; } VersionAdapters.get().playSound(this.player, ArcadeSound.ITEM_PICKUP, 1.0F, 1.0F); this.player.getInventory().setItem(8, item2); this.player.setExp(0.0F); } else if (longVal % 2L == 0L) { - this.player.setExp(1.0F - this.i / (this.kit2.c() * 20.0F)); + this.player.setExp(1.0F - this.arrowCooldownTicks / (this.selectedKit.getArrowRegenSeconds() * 20.0F)); } } } @Override - public void a(Map map) { - super.a(map); - this.kit2 = MiniWallsKits.a((String)map.get("kit")); - if (!this.f()) { - this.k(0); + public void loadProperties(Map map) { + super.loadProperties(map); + this.selectedKit = MiniWallsKits.byId((String)map.get("kit")); + if (!this.isSpectator()) { + this.populateKitHotbar(0); } } @Override - public void b(Map map) { - super.b(map); - map.put("kit", this.kit2.a()); + public void saveProperties(Map map) { + super.saveProperties(map); + map.put("kit", this.selectedKit.getId()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSession.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSession.java index 9161783..a4e2a96 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSession.java @@ -23,11 +23,11 @@ public class MiniWallsSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { MiniWallsGamer miniWallsGamer = new MiniWallsGamer(this.game, defaultUser); - this.game.getGamers().a(miniWallsGamer); - miniWallsGamer.a(this.game.getMessages().getStart()); - miniWallsGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(miniWallsGamer); + miniWallsGamer.sendMessages(this.game.getMessages().getStart()); + miniWallsGamer.teleport(this.game.getMap().getLobby()); return miniWallsGamer; }); } @@ -41,7 +41,7 @@ public class MiniWallsSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof MiniWallsGamer var2) { MiniWallsGame miniWallsGame = var2.getGame(); - if (miniWallsGame.getPhase() != miniWallsGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (miniWallsGame.getPhase() != miniWallsGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, miniWallsGame.getMessages().getJoinAlreadyInGame()); } } @@ -51,12 +51,12 @@ public class MiniWallsSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { MiniWallsGamer miniWallsGamer = new MiniWallsGamer(this.game, defaultUser); - this.game.getGamers().a(miniWallsGamer); - miniWallsGamer.a(this.game.getMap().getSpectator()); - miniWallsGamer.b(true); - miniWallsGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(miniWallsGamer); + miniWallsGamer.teleport(this.game.getMap().getSpectator()); + miniWallsGamer.setSpectator(true); + miniWallsGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(miniWallsGamer.getName()); return miniWallsGamer; }); @@ -74,23 +74,23 @@ public class MiniWallsSession extends BaseSession { @Override public void addRejoin(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { MiniWallsGamer miniWallsGamer = new MiniWallsGamer(this.game, defaultUser); - this.game.getGamers().a(miniWallsGamer); - miniWallsGamer.a(this.game.getMap().getSpectator()); - miniWallsGamer.a(true); + this.game.getGamers().add(miniWallsGamer); + miniWallsGamer.teleport(this.game.getMap().getSpectator()); + miniWallsGamer.setTemporarySpectator(true); - for (int index = 0; index < this.game.getGamers4().length; index++) { - if (this.game.getGamers4()[index].getUUID().equals(user.getUUID())) { - this.game.getGamers4()[index] = miniWallsGamer; + for (int index = 0; index < this.game.getStandings().length; index++) { + if (this.game.getStandings()[index].getUUID().equals(user.getUUID())) { + this.game.getStandings()[index] = miniWallsGamer; break; } } - this.game.getManager().getSessions().e().remove(defaultUser.getUUID()); - ((MiniWallsTeam)this.game.A().remove(defaultUser.getUUID())).a(miniWallsGamer); - miniWallsGamer.k(3); - miniWallsGamer.c(12); + this.game.getManager().getSessions().getRejoinGames().remove(defaultUser.getUUID()); + ((MiniWallsTeam)this.game.getDisconnectedPlayers().remove(defaultUser.getUUID())).restoreTo(miniWallsGamer); + miniWallsGamer.populateKitHotbar(3); + miniWallsGamer.setRespawnTimer(12); return miniWallsGamer; }); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSessions.java index ff75622..aa96c93 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/session/MiniWallsSessions.java @@ -12,52 +12,52 @@ import ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamColor; import org.bukkit.World; public class MiniWallsSessions extends BaseSessions { - private final MiniWallsManager a; + private final MiniWallsManager manager; public MiniWallsSessions(MiniWallsManager miniWallsManager) { super(miniWallsManager); - this.a = miniWallsManager; + this.manager = miniWallsManager; } public MiniWallsManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(miniWallsMap -> this.registerGame(new MiniWallsGame(this.a, miniWallsMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(miniWallsMap -> this.registerGame(new MiniWallsGame(this.manager, miniWallsMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected MiniWallsMap h(String text) { + protected MiniWallsMap createMap(String text) { MiniWallsMap miniWallsMap = new MiniWallsMap(); miniWallsMap.setId(text); return miniWallsMap; } - protected MiniWallsGame a(MiniWallsMap miniWallsMap) { - return new MiniWallsGame(this.a, miniWallsMap); + protected MiniWallsGame createGame(MiniWallsMap miniWallsMap) { + return new MiniWallsGame(this.manager, miniWallsMap); } public MiniWallsSession createSession(MiniWallsGame miniWallsGame) { return miniWallsGame == null ? null : new MiniWallsSession(miniWallsGame); } - protected void a(MiniWallsMap miniWallsMap, World world, MiniWallsMap miniWallsMap2) { - super.a(miniWallsMap, world, miniWallsMap2); - miniWallsMap2.setPlayZone(miniWallsMap.getPlayZone().a(world)); - miniWallsMap2.setSpectator(Locations.a(world, miniWallsMap.getSpectator())); + protected void copyMap(MiniWallsMap miniWallsMap, World world, MiniWallsMap miniWallsMap2) { + super.copyMap(miniWallsMap, world, miniWallsMap2); + miniWallsMap2.setPlayZone(miniWallsMap.getPlayZone().withWorld(world)); + miniWallsMap2.setSpectator(Locations.withWorld(world, miniWallsMap.getSpectator())); miniWallsMap2.getWalls().clear(); for (Cuboid cuboid : miniWallsMap.getWalls()) { - miniWallsMap2.getWalls().add(cuboid.a(world)); + miniWallsMap2.getWalls().add(cuboid.withWorld(world)); } for (MiniWallsTeamColor miniWallsTeamColor : MiniWallsTeamColor.values()) { - MiniWallsTeamSettings miniWallsTeamSettings = miniWallsMap2.a(miniWallsTeamColor); - MiniWallsTeamSettings miniWallsTeamSettings2 = miniWallsMap.a(miniWallsTeamColor); - miniWallsTeamSettings.setSpawn(Locations.a(world, miniWallsTeamSettings2.getSpawn())); - miniWallsTeamSettings.setWitherSpawn(Locations.a(world, miniWallsTeamSettings2.getWitherSpawn())); + MiniWallsTeamSettings miniWallsTeamSettings = miniWallsMap2.getTeamSettings(miniWallsTeamColor); + MiniWallsTeamSettings miniWallsTeamSettings2 = miniWallsMap.getTeamSettings(miniWallsTeamColor); + miniWallsTeamSettings.setSpawn(Locations.withWorld(world, miniWallsTeamSettings2.getSpawn())); + miniWallsTeamSettings.setWitherSpawn(Locations.withWorld(world, miniWallsTeamSettings2.getWitherSpawn())); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/MiniWallsSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/MiniWallsSetup.java index a4128e3..15620d7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/MiniWallsSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/MiniWallsSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class MiniWallsSetup extends ArenaSetup { private final MiniWallsMap map; - private final MiniWallsManager d; + private final MiniWallsManager manager; private final SetupTarget setupTarget; public MiniWallsSetup(DefaultUser defaultUser, MiniWallsMap map2, MiniWallsManager miniWallsManager, SetupTarget setupTarget2) { super(defaultUser, miniWallsManager.getName()); - this.d = miniWallsManager; + this.manager = miniWallsManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new MiniWallsSetArenaNameStep(this); } - public MiniWallsMap getMap17() { + public MiniWallsMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class MiniWallsSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new MiniWallsGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new MiniWallsGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsAddWallStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsAddWallStep.java index fa650f3..97ca3e5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsAddWallStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsAddWallStep.java @@ -17,37 +17,37 @@ public class MiniWallsAddWallStep implements ClickSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to add a wall. If you can't"); defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.miniWallsSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.miniWallsSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.miniWallsSetup.getMap17().getWalls().add(new Cuboid(block, block2)); - defaultUser.sendMessage("§eWall added! §8(§b" + this.miniWallsSetup.getMap17().getWalls().size() + "§8)"); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.miniWallsSetup.getMap().getWalls().add(new Cuboid(block, block2)); + defaultUser.sendMessage("§eWall added! §8(§b" + this.miniWallsSetup.getMap().getWalls().size() + "§8)"); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd Wall").build()); - this.miniWallsSetup.getHotbar().a(2, () -> { - this.miniWallsSetup.getMap17().getWalls().clear(); + this.miniWallsSetup.getHotbar().setSlot(2, () -> { + this.miniWallsSetup.getMap().getWalls().clear(); defaultUser.sendMessage("§eWalls reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset Walls").build()); - this.miniWallsSetup.getHotbar().a(3, () -> this.miniWallsSetup.a(new MiniWallsSetTeamSpawnStep(0, this.miniWallsSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); + this.miniWallsSetup.getHotbar().setSlot(3, () -> this.miniWallsSetup.advanceStep(new MiniWallsSetTeamSpawnStep(0, this.miniWallsSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetArenaNameStep.java index fc4fe7e..f229d52 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetArenaNameStep.java @@ -10,12 +10,12 @@ public class MiniWallsSetArenaNameStep implements ChatSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { this.miniWallsSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.miniWallsSetup.getMap17().setName(text); - this.miniWallsSetup.a(new MiniWallsSetLobbySpawnStep(this.miniWallsSetup)); + public void onChatInput(String text) { + this.miniWallsSetup.getMap().setName(text); + this.miniWallsSetup.advanceStep(new MiniWallsSetLobbySpawnStep(this.miniWallsSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbyRemovalRegionStep.java index a2fe14b..5c457c3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class MiniWallsSetLobbyRemovalRegionStep implements ClickSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class MiniWallsSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.miniWallsSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.miniWallsSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.miniWallsSetup.getMap17().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.miniWallsSetup.a(new MiniWallsSetPlayZoneStep(this.miniWallsSetup)); + this.miniWallsSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.miniWallsSetup.advanceStep(new MiniWallsSetPlayZoneStep(this.miniWallsSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.miniWallsSetup.getHotbar().a(2, () -> { - this.miniWallsSetup.getMap17().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.miniWallsSetup.a(new MiniWallsSetPlayZoneStep(this.miniWallsSetup)); + this.miniWallsSetup.getHotbar().setSlot(2, () -> { + this.miniWallsSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.miniWallsSetup.advanceStep(new MiniWallsSetPlayZoneStep(this.miniWallsSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbySpawnStep.java index 4775fb0..09dc255 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class MiniWallsSetLobbySpawnStep implements ClickSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.miniWallsSetup.getUser().toPlayer(); - this.miniWallsSetup.getHotbar().a(0, () -> { - this.miniWallsSetup.getMap17().setLobby(player.getLocation()); - this.miniWallsSetup.a(new MiniWallsSetLobbyRemovalRegionStep(this.miniWallsSetup)); + this.miniWallsSetup.getHotbar().setSlot(0, () -> { + this.miniWallsSetup.getMap().setLobby(player.getLocation()); + this.miniWallsSetup.advanceStep(new MiniWallsSetLobbyRemovalRegionStep(this.miniWallsSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetPlayZoneStep.java index 48a5562..6643035 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class MiniWallsSetPlayZoneStep implements ClickSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.miniWallsSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.miniWallsSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.miniWallsSetup.getMap17().setPlayZone(new Cuboid(block, block2)); - this.miniWallsSetup.a(new MiniWallsSetSpectatorSpawnStep(this.miniWallsSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.miniWallsSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.miniWallsSetup.advanceStep(new MiniWallsSetSpectatorSpawnStep(this.miniWallsSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetSpectatorSpawnStep.java index b81aec7..dfd18b4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class MiniWallsSetSpectatorSpawnStep implements ClickSetupStep { this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.miniWallsSetup.getUser().toPlayer(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.miniWallsSetup.getMap17().getPlayZone().a(location)) { - this.miniWallsSetup.getMap17().setSpectator(location); - this.miniWallsSetup.a(new MiniWallsAddWallStep(this.miniWallsSetup)); + if (this.miniWallsSetup.getMap().getPlayZone().contains(location)) { + this.miniWallsSetup.getMap().setSpectator(location); + this.miniWallsSetup.advanceStep(new MiniWallsAddWallStep(this.miniWallsSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetTeamSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetTeamSpawnStep.java index 5258e00..710402e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetTeamSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetTeamSpawnStep.java @@ -11,28 +11,28 @@ import ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamColor; public class MiniWallsSetTeamSpawnStep implements ClickSetupStep { - private final int a; + private final int teamIndex; private final MiniWallsSetup miniWallsSetup; public MiniWallsSetTeamSpawnStep(int index, MiniWallsSetup miniWallsSetup2) { - this.a = index; + this.teamIndex = index; this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); - defaultUser.sendMessage("§e Click the green dye to set where the " + MiniWallsTeamColor.values()[this.a].name() + " team"); + defaultUser.sendMessage("§e Click the green dye to set where the " + MiniWallsTeamColor.values()[this.teamIndex].name() + " team"); defaultUser.sendMessage("§e players spawns at."); } - public void a() { + public void configureHotbar() { Player player = this.miniWallsSetup.getUser().toPlayer(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.miniWallsSetup.getMap17().getPlayZone().a(location)) { - this.miniWallsSetup.getMap17().a(MiniWallsTeamColor.values()[this.a]).setSpawn(location); - this.miniWallsSetup.a(new MiniWallsSetWitherSpawnStep(this.a, this.miniWallsSetup)); + if (this.miniWallsSetup.getMap().getPlayZone().contains(location)) { + this.miniWallsSetup.getMap().getTeamSettings(MiniWallsTeamColor.values()[this.teamIndex]).setSpawn(location); + this.miniWallsSetup.advanceStep(new MiniWallsSetWitherSpawnStep(this.teamIndex, this.miniWallsSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetWitherSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetWitherSpawnStep.java index 82fcdc7..98616ed 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetWitherSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/setup/step/MiniWallsSetWitherSpawnStep.java @@ -12,31 +12,31 @@ import ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamColor; public class MiniWallsSetWitherSpawnStep implements ClickSetupStep { - private final int a; + private final int teamIndex; private final MiniWallsSetup miniWallsSetup; public MiniWallsSetWitherSpawnStep(int index, MiniWallsSetup miniWallsSetup2) { - this.a = index; + this.teamIndex = index; this.miniWallsSetup = miniWallsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.miniWallsSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the wither"); - defaultUser.sendMessage("§e spawns at for team " + MiniWallsTeamColor.values()[this.a].name() + "."); + defaultUser.sendMessage("§e spawns at for team " + MiniWallsTeamColor.values()[this.teamIndex].name() + "."); } - public void a() { + public void configureHotbar() { Player player = this.miniWallsSetup.getUser().toPlayer(); - this.miniWallsSetup.getHotbar().a(0, () -> { + this.miniWallsSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.miniWallsSetup.getMap17().getPlayZone().a(location)) { - this.miniWallsSetup.getMap17().a(MiniWallsTeamColor.values()[this.a]).setWitherSpawn(location); - if (this.a == 3) { - this.miniWallsSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.miniWallsSetup.getMap().getPlayZone().contains(location)) { + this.miniWallsSetup.getMap().getTeamSettings(MiniWallsTeamColor.values()[this.teamIndex]).setWitherSpawn(location); + if (this.teamIndex == 3) { + this.miniWallsSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { - this.miniWallsSetup.a(new MiniWallsSetTeamSpawnStep(this.a + 1, this.miniWallsSetup)); + this.miniWallsSetup.advanceStep(new MiniWallsSetTeamSpawnStep(this.teamIndex + 1, this.miniWallsSetup)); } } else { player.sendMessage("§cMust be inside the Play Zone!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/MiniWallsStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/MiniWallsStatistics.java index 7506c83..4b5a9e9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/MiniWallsStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/MiniWallsStatistics.java @@ -10,66 +10,66 @@ import ro.fr33styler.arcade.game.miniwalls.team.MiniWallsTeamMember; import java.util.UUID; public class MiniWallsStatistics extends BaseGameStatistics { - private int b; - private int c; - private int d; - private int e; - private int f; - private int g; + private int deaths; + private int kills; + private int finalKills; + private int arrowsShot; + private int withersKilled; + private int witherDamage; public MiniWallsStatistics(MiniWallsManager miniWallsManager, UUID uuid, String text) { super(miniWallsManager, uuid, text); } - public int d() { - return this.b; + public int getDeaths() { + return this.deaths; } - public void e(int index) { - this.b = index; + public void setDeaths(int index) { + this.deaths = index; } - public int e() { - return this.c; + public int getKills() { + return this.kills; } - public void f(int index) { - this.c = index; + public void setKills(int index) { + this.kills = index; } - public int f() { - return this.d; + public int getFinalKills() { + return this.finalKills; } - public void g(int index) { - this.d = index; + public void setFinalKills(int index) { + this.finalKills = index; } - public int g() { - return this.e; + public int getArrowsShot() { + return this.arrowsShot; } - public void h(int index) { - this.e = index; + public void setArrowsShot(int index) { + this.arrowsShot = index; } - public int h() { - return this.f; + public int getWithersKilled() { + return this.withersKilled; } - public void i(int index) { - this.f = index; + public void setWithersKilled(int index) { + this.withersKilled = index; } - public int i() { - return this.g; + public int getWitherDamage() { + return this.witherDamage; } - public void j(int index) { - this.g = index; + public void setWitherDamage(int index) { + this.witherDamage = index; } - private MiniWallsTeamContext j() { + private MiniWallsTeamContext getCurrentTeamContext() { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(this.getUUID()); if (defaultUser == null) { return null; @@ -79,56 +79,56 @@ public class MiniWallsStatistics extends BaseGameStatistics { } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { return switch (text) { case "team" -> { - MiniWallsTeamContext miniWallsTeamContext = this.j(); + MiniWallsTeamContext miniWallsTeamContext = this.getCurrentTeamContext(); yield miniWallsTeamContext == null ? "" : miniWallsTeamContext.getDisplayName(); } case "team_color" -> { - MiniWallsTeamContext miniWallsTeamContext2 = this.j(); + MiniWallsTeamContext miniWallsTeamContext2 = this.getCurrentTeamContext(); yield miniWallsTeamContext2 == null ? "" : miniWallsTeamContext2.getChatColor().toString(); } - case "stats_kills" -> String.valueOf(this.c); - case "stats_final_kills" -> String.valueOf(this.d); - case "stats_deaths" -> String.valueOf(this.b); - case "stats_arrows_shot" -> String.valueOf(this.e); - case "stats_withers_killed" -> String.valueOf(this.f); - case "stats_withers_damage" -> String.valueOf(this.g); - default -> super.a(text); + case "stats_kills" -> String.valueOf(this.kills); + case "stats_final_kills" -> String.valueOf(this.finalKills); + case "stats_deaths" -> String.valueOf(this.deaths); + case "stats_arrows_shot" -> String.valueOf(this.arrowsShot); + case "stats_withers_killed" -> String.valueOf(this.withersKilled); + case "stats_withers_damage" -> String.valueOf(this.witherDamage); + default -> super.resolvePlaceholder(text); }; } @Override public String getVariable(String text) { return switch (text) { - case "kills" -> String.valueOf(this.c); - case "final_kills" -> String.valueOf(this.d); - case "deaths" -> String.valueOf(this.b); - case "arrows_shot" -> String.valueOf(this.e); - case "withers_killed" -> String.valueOf(this.f); - case "withers_damage" -> String.valueOf(this.g); + case "kills" -> String.valueOf(this.kills); + case "final_kills" -> String.valueOf(this.finalKills); + case "deaths" -> String.valueOf(this.deaths); + case "arrows_shot" -> String.valueOf(this.arrowsShot); + case "withers_killed" -> String.valueOf(this.withersKilled); + case "withers_damage" -> String.valueOf(this.witherDamage); default -> super.getVariable(text); }; } - public void a(MiniWallsTeamMember miniWallsTeamMember) { - this.a(this.getWins() + miniWallsTeamMember.getWins()); + public void recordMatchStats(MiniWallsTeamMember miniWallsTeamMember) { + this.setWins(this.getWins() + miniWallsTeamMember.getWins()); if (miniWallsTeamMember.getWins() > 0) { - this.d(this.getCurrentWinStreak() + 1); + this.setCurrentWinStreak(this.getCurrentWinStreak() + 1); if (this.getWinStreak() < this.getCurrentWinStreak()) { - this.c(this.getCurrentWinStreak()); + this.setWinStreak(this.getCurrentWinStreak()); } } else if (miniWallsTeamMember.getLoses() > 0) { - this.d(0); + this.setCurrentWinStreak(0); } - this.b(this.getLoses() + miniWallsTeamMember.getLoses()); - this.b = this.b + miniWallsTeamMember.r(); - this.c = this.c + miniWallsTeamMember.s(); - this.d = this.d + miniWallsTeamMember.t(); - this.e = this.e + miniWallsTeamMember.u(); - this.f = this.f + miniWallsTeamMember.w(); - this.g = this.g + miniWallsTeamMember.v(); + this.setLoses(this.getLoses() + miniWallsTeamMember.getLoses()); + this.deaths = this.deaths + miniWallsTeamMember.getDeaths(); + this.kills = this.kills + miniWallsTeamMember.getKills(); + this.finalKills = this.finalKills + miniWallsTeamMember.getFinalKills(); + this.arrowsShot = this.arrowsShot + miniWallsTeamMember.getArrowsShot(); + this.withersKilled = this.withersKilled + miniWallsTeamMember.getWithersKilled(); + this.witherDamage = this.witherDamage + miniWallsTeamMember.getWitherDamage(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/storage/MiniWallsStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/storage/MiniWallsStatisticsRepository.java index 718b272..e1fc4f4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/storage/MiniWallsStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/statistics/storage/MiniWallsStatisticsRepository.java @@ -15,139 +15,139 @@ public class MiniWallsStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a( + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); } - public void a(MiniWallsStatistics miniWallsStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(MiniWallsStatistics miniWallsStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, miniWallsStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(miniWallsStatistics, var3); + this.readStatistics(miniWallsStatistics, var3); } - miniWallsStatistics.a(true); + miniWallsStatistics.setLoaded(true); } }); } - private void a(MiniWallsStatistics miniWallsStatistics, ResultSet resultSet) throws java.sql.SQLException { - miniWallsStatistics.b(resultSet.getString("options")); - miniWallsStatistics.a(resultSet.getInt("wins")); - miniWallsStatistics.c(resultSet.getInt("win_streak")); - miniWallsStatistics.d(resultSet.getInt("current_win_streak")); - miniWallsStatistics.b(resultSet.getInt("loses")); - miniWallsStatistics.e(resultSet.getInt("deaths")); - miniWallsStatistics.f(resultSet.getInt("kills")); - miniWallsStatistics.g(resultSet.getInt("final_kills")); - miniWallsStatistics.h(resultSet.getInt("arrows_shot")); - miniWallsStatistics.i(resultSet.getInt("withers_killed")); - miniWallsStatistics.j(resultSet.getInt("withers_damage")); + private void readStatistics(MiniWallsStatistics miniWallsStatistics, ResultSet resultSet) throws java.sql.SQLException { + miniWallsStatistics.deserializeProperties(resultSet.getString("options")); + miniWallsStatistics.setWins(resultSet.getInt("wins")); + miniWallsStatistics.setWinStreak(resultSet.getInt("win_streak")); + miniWallsStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + miniWallsStatistics.setLoses(resultSet.getInt("loses")); + miniWallsStatistics.setDeaths(resultSet.getInt("deaths")); + miniWallsStatistics.setKills(resultSet.getInt("kills")); + miniWallsStatistics.setFinalKills(resultSet.getInt("final_kills")); + miniWallsStatistics.setArrowsShot(resultSet.getInt("arrows_shot")); + miniWallsStatistics.setWithersKilled(resultSet.getInt("withers_killed")); + miniWallsStatistics.setWitherDamage(resultSet.getInt("withers_damage")); } - public void b(MiniWallsStatistics miniWallsStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(MiniWallsStatistics miniWallsStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, miniWallsStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.c(miniWallsStatistics); + this.insertStatistics(miniWallsStatistics); } else { - this.d(miniWallsStatistics); + this.updateStatistics(miniWallsStatistics); } } }); } - private void d(MiniWallsStatistics miniWallsStatistics) { - this.a() - .a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void updateStatistics(MiniWallsStatistics miniWallsStatistics) { + this.getDatabase() + .executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, miniWallsStatistics.getUUID().toString()); - preparedStatement.setString(2, miniWallsStatistics.c()); + preparedStatement.setString(2, miniWallsStatistics.serializeProperties()); preparedStatement.setInt(3, miniWallsStatistics.getWins()); preparedStatement.setInt(4, miniWallsStatistics.getWinStreak()); preparedStatement.setInt(5, miniWallsStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, miniWallsStatistics.getLoses()); - preparedStatement.setInt(7, miniWallsStatistics.d()); - preparedStatement.setInt(8, miniWallsStatistics.e()); - preparedStatement.setInt(9, miniWallsStatistics.f()); - preparedStatement.setInt(10, miniWallsStatistics.g()); - preparedStatement.setInt(11, miniWallsStatistics.h()); - preparedStatement.setInt(12, miniWallsStatistics.i()); + preparedStatement.setInt(7, miniWallsStatistics.getDeaths()); + preparedStatement.setInt(8, miniWallsStatistics.getKills()); + preparedStatement.setInt(9, miniWallsStatistics.getFinalKills()); + preparedStatement.setInt(10, miniWallsStatistics.getArrowsShot()); + preparedStatement.setInt(11, miniWallsStatistics.getWithersKilled()); + preparedStatement.setInt(12, miniWallsStatistics.getWitherDamage()); preparedStatement.executeUpdate(); }); } - public void c(MiniWallsStatistics miniWallsStatistics) { - this.a() - .a( + public void insertStatistics(MiniWallsStatistics miniWallsStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, deaths = ?, kills = ?, final_kills = ?, arrows_shot = ?, withers_killed = ?, withers_damage = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, miniWallsStatistics.c()); + preparedStatement.setString(1, miniWallsStatistics.serializeProperties()); preparedStatement.setInt(2, miniWallsStatistics.getWins()); preparedStatement.setInt(3, miniWallsStatistics.getWinStreak()); preparedStatement.setInt(4, miniWallsStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, miniWallsStatistics.getLoses()); - preparedStatement.setInt(6, miniWallsStatistics.d()); - preparedStatement.setInt(7, miniWallsStatistics.e()); - preparedStatement.setInt(8, miniWallsStatistics.f()); - preparedStatement.setInt(9, miniWallsStatistics.g()); - preparedStatement.setInt(10, miniWallsStatistics.h()); - preparedStatement.setInt(11, miniWallsStatistics.i()); + preparedStatement.setInt(6, miniWallsStatistics.getDeaths()); + preparedStatement.setInt(7, miniWallsStatistics.getKills()); + preparedStatement.setInt(8, miniWallsStatistics.getFinalKills()); + preparedStatement.setInt(9, miniWallsStatistics.getArrowsShot()); + preparedStatement.setInt(10, miniWallsStatistics.getWithersKilled()); + preparedStatement.setInt(11, miniWallsStatistics.getWitherDamage()); preparedStatement.setString(12, miniWallsStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { - this.b(this.b, uuid, miniWallsTeamMember); + public void savePeriodicStatistics(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + this.updatePeriodicStatistics(this.tableName, uuid, miniWallsTeamMember); } - public void b(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { - this.a(this.b + "_weekly", uuid, miniWallsTeamMember); - this.a(this.b + "_monthly", uuid, miniWallsTeamMember); + public void savePeriodicMatchStats(UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", uuid, miniWallsTeamMember); + this.upsertPeriodicStatistics(this.tableName + "_monthly", uuid, miniWallsTeamMember); } - private void a(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); try (ResultSet var5 = preparedStatement.executeQuery()) { if (var5.next()) { - this.b(text, uuid, miniWallsTeamMember); + this.updatePeriodicStatistics(text, uuid, miniWallsTeamMember); } else { - this.c(text, uuid, miniWallsTeamMember); + this.insertPeriodicStatistics(text, uuid, miniWallsTeamMember); } } }); } - private void b(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + private void updatePeriodicStatistics(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { String text2 = "current_win_streak"; if (miniWallsTeamMember.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -155,9 +155,9 @@ public class MiniWallsStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -167,94 +167,94 @@ public class MiniWallsStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, deaths = deaths + ?, kills = kills + ?, final_kills = final_kills + ?, arrows_shot = arrows_shot + ?, withers_killed = withers_killed + ?, withers_damage = withers_damage + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, miniWallsTeamMember.getWins()); preparedStatement.setInt(2, miniWallsTeamMember.getLoses()); - preparedStatement.setInt(3, miniWallsTeamMember.r()); - preparedStatement.setInt(4, miniWallsTeamMember.s()); - preparedStatement.setInt(5, miniWallsTeamMember.t()); - preparedStatement.setInt(6, miniWallsTeamMember.u()); - preparedStatement.setInt(7, miniWallsTeamMember.w()); - preparedStatement.setInt(8, miniWallsTeamMember.v()); + preparedStatement.setInt(3, miniWallsTeamMember.getDeaths()); + preparedStatement.setInt(4, miniWallsTeamMember.getKills()); + preparedStatement.setInt(5, miniWallsTeamMember.getFinalKills()); + preparedStatement.setInt(6, miniWallsTeamMember.getArrowsShot()); + preparedStatement.setInt(7, miniWallsTeamMember.getWithersKilled()); + preparedStatement.setInt(8, miniWallsTeamMember.getWitherDamage()); preparedStatement.setString(9, uuid.toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, UUID uuid, MiniWallsTeamMember miniWallsTeamMember) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); preparedStatement.setInt(2, miniWallsTeamMember.getWins()); preparedStatement.setInt(3, miniWallsTeamMember.getWins()); preparedStatement.setInt(4, miniWallsTeamMember.getWins()); preparedStatement.setInt(5, miniWallsTeamMember.getLoses()); - preparedStatement.setInt(6, miniWallsTeamMember.r()); - preparedStatement.setInt(7, miniWallsTeamMember.s()); - preparedStatement.setInt(8, miniWallsTeamMember.t()); - preparedStatement.setInt(9, miniWallsTeamMember.u()); - preparedStatement.setInt(10, miniWallsTeamMember.w()); - preparedStatement.setInt(11, miniWallsTeamMember.v()); + preparedStatement.setInt(6, miniWallsTeamMember.getDeaths()); + preparedStatement.setInt(7, miniWallsTeamMember.getKills()); + preparedStatement.setInt(8, miniWallsTeamMember.getFinalKills()); + preparedStatement.setInt(9, miniWallsTeamMember.getArrowsShot()); + preparedStatement.setInt(10, miniWallsTeamMember.getWithersKilled()); + preparedStatement.setInt(11, miniWallsTeamMember.getWitherDamage()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, deaths INT, kills INT, final_kills INT, arrows_shot INT, withers_killed INT, withers_damage INT);" ); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -269,22 +269,22 @@ public class MiniWallsStatisticsRepository extends GameStatisticsRepository { int index6 = var4.getInt("arrows_shot"); int index7 = var4.getInt("withers_killed"); int index8 = var4.getInt("withers_damage"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -303,14 +303,14 @@ public class MiniWallsStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/storage/MiniWallsStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/storage/MiniWallsStorage.java index ab8a577..c5f8598 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/storage/MiniWallsStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/storage/MiniWallsStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.miniwalls.statistics.storage.MiniWallsStatistic public class MiniWallsStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final MiniWallsStatisticsRepository miniWallsStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public MiniWallsStorage(MiniWallsManager miniWallsManager) { super(miniWallsManager); this.storage = new GameMapStorage(miniWallsManager.getConfigManager(), this.file, MiniWallsMap::new); - this.storage2 = new NpcStorage(miniWallsManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(miniWallsManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(miniWallsManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(miniWallsManager.getConfigManager(), this.file); this.miniWallsStatisticsRepository = new MiniWallsStatisticsRepository(miniWallsManager.getEngine()); - this.storage4 = new LeaderboardStorage(miniWallsManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(miniWallsManager.getConfigManager(), this.file, MiniWallsMap::new); + this.leaderboardStorage = new LeaderboardStorage(miniWallsManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(miniWallsManager.getConfigManager(), this.file, MiniWallsMap::new); } @Override @@ -34,26 +34,26 @@ public class MiniWallsStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public MiniWallsStatisticsRepository e() { + public MiniWallsStatisticsRepository getStatisticsRepository() { return this.miniWallsStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeam.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeam.java index 49f2cd7..7e506e4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeam.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeam.java @@ -7,33 +7,33 @@ import org.bukkit.inventory.ItemStack; public class MiniWallsTeam implements MiniWallsTeamMember { private final MiniWallsTeamContext teamContext; - private int b; - private int c; - private final int d; - private final int e; - private final int f; - private final int g; - private final int h; - private final int i; + private int wins; + private int loses; + private final int deaths; + private final int kills; + private final int finalKills; + private final int arrowsShot; + private final int witherDamage; + private final int withersKilled; private final MiniWallsKit kit; - private final MiniWallsKit kit2; - private final ItemStack[] l; - private final ItemStack[] m; + private final MiniWallsKit selectedKit; + private final ItemStack[] savedInventoryContents; + private final ItemStack[] savedArmorContents; public MiniWallsTeam(MiniWallsGamer miniWallsGamer) { this.teamContext = miniWallsGamer.getTeamContext(); - this.kit = miniWallsGamer.getKit2(); - this.kit2 = miniWallsGamer.getKit(); - this.l = miniWallsGamer.n(); - this.m = miniWallsGamer.o(); - this.b = miniWallsGamer.getWins(); - this.c = miniWallsGamer.getLoses(); - this.d = miniWallsGamer.r(); - this.e = miniWallsGamer.s(); - this.f = miniWallsGamer.t(); - this.g = miniWallsGamer.u(); - this.h = miniWallsGamer.v(); - this.i = miniWallsGamer.w(); + this.kit = miniWallsGamer.getSelectedKit(); + this.selectedKit = miniWallsGamer.getKit(); + this.savedInventoryContents = miniWallsGamer.getSavedInventoryContents(); + this.savedArmorContents = miniWallsGamer.getSavedArmorContents(); + this.wins = miniWallsGamer.getWins(); + this.loses = miniWallsGamer.getLoses(); + this.deaths = miniWallsGamer.getDeaths(); + this.kills = miniWallsGamer.getKills(); + this.finalKills = miniWallsGamer.getFinalKills(); + this.arrowsShot = miniWallsGamer.getArrowsShot(); + this.witherDamage = miniWallsGamer.getWitherDamage(); + this.withersKilled = miniWallsGamer.getWithersKilled(); } public MiniWallsTeamContext getTeamContext() { @@ -41,60 +41,60 @@ public class MiniWallsTeam implements MiniWallsTeamMember { } public int getWins() { - return this.b; + return this.wins; } - public void a(int index) { - this.b = index; + public void setWins(int index) { + this.wins = index; } public int getLoses() { - return this.c; + return this.loses; } - public void b(int index) { - this.c = index; + public void setLoses(int index) { + this.loses = index; } - public int r() { - return this.d; + public int getDeaths() { + return this.deaths; } - public int s() { - return this.e; + public int getKills() { + return this.kills; } - public int t() { - return this.f; + public int getFinalKills() { + return this.finalKills; } - public int u() { - return this.g; + public int getArrowsShot() { + return this.arrowsShot; } - public int v() { - return this.h; + public int getWitherDamage() { + return this.witherDamage; } - public int w() { - return this.i; + public int getWithersKilled() { + return this.withersKilled; } - public void a(MiniWallsGamer miniWallsGamer) { + public void restoreTo(MiniWallsGamer miniWallsGamer) { miniWallsGamer.setTeamContext(this.teamContext); this.teamContext.getMembers().add(miniWallsGamer); this.teamContext.getScoreboardTeam().addEntry(miniWallsGamer.getName()); - miniWallsGamer.a(this.b); - miniWallsGamer.b(this.c); - miniWallsGamer.d(this.d); - miniWallsGamer.e(this.e); - miniWallsGamer.f(this.f); - miniWallsGamer.g(this.g); - miniWallsGamer.h(this.h); - miniWallsGamer.i(this.i); - miniWallsGamer.setKit2(this.kit); - miniWallsGamer.setKit(this.kit2); - miniWallsGamer.a(this.l); - miniWallsGamer.b(this.m); + miniWallsGamer.setWins(this.wins); + miniWallsGamer.setLoses(this.loses); + miniWallsGamer.setDeaths(this.deaths); + miniWallsGamer.setKills(this.kills); + miniWallsGamer.setFinalKills(this.finalKills); + miniWallsGamer.setArrowsShot(this.arrowsShot); + miniWallsGamer.setWitherDamage(this.witherDamage); + miniWallsGamer.setWithersKilled(this.withersKilled); + miniWallsGamer.setSelectedKit(this.kit); + miniWallsGamer.setKit(this.selectedKit); + miniWallsGamer.setSavedInventoryContents(this.savedInventoryContents); + miniWallsGamer.setSavedArmorContents(this.savedArmorContents); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamColor.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamColor.java index 8b138cf..6d8c4d7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamColor.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamColor.java @@ -20,14 +20,14 @@ public enum MiniWallsTeamColor { private final ArcadeColor arcadeColor; private final ChatColor chatColor; private final Color color; - private final Function h; - private static final MiniWallsTeamColor[] i = values(); + private final Function displayNameResolver; + private static final MiniWallsTeamColor[] VALUES = values(); MiniWallsTeamColor(ArcadeColor arcadeColor2, ChatColor chatColor2, Color color2, Function function) { this.arcadeColor = arcadeColor2; this.chatColor = chatColor2; this.color = color2; - this.h = function; + this.displayNameResolver = function; } public ArcadeColor toArcadeColor() { @@ -50,7 +50,7 @@ public enum MiniWallsTeamColor { return this.chatColor; } - public String a(MiniWallsMessages miniWallsMessages) { - return this.h.apply(miniWallsMessages); + public String getDisplayName(MiniWallsMessages miniWallsMessages) { + return this.displayNameResolver.apply(miniWallsMessages); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamContext.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamContext.java index 0080260..091b3ec 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamContext.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamContext.java @@ -61,7 +61,7 @@ public class MiniWallsTeamContext implements Context { } public String getDisplayName() { - return this.teamSettings.getColor().a(this.game.getMessages()); + return this.teamSettings.getColor().getDisplayName(this.game.getMessages()); } public String getFormattedName() { @@ -104,7 +104,7 @@ public class MiniWallsTeamContext implements Context { int index = 0; for (MiniWallsGamer miniWallsGamer : this.members) { - if (!miniWallsGamer.g()) { + if (!miniWallsGamer.isActiveSpectator()) { index++; } } @@ -116,7 +116,7 @@ public class MiniWallsTeamContext implements Context { if (text.equals("color")) { return this.teamSettings.getColor().getChatColor().toString(); } else if (text.equals("team")) { - return this.teamSettings.getColor().a(this.game.getMessages()); + return this.teamSettings.getColor().getDisplayName(this.game.getMessages()); } else { return this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying() && !this.wither.isDead() && text.equals("health") ? String.valueOf((int)this.wither.getHealth()) diff --git a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamMember.java b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamMember.java index 5f0bd92..7ad2176 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamMember.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/miniwalls/team/MiniWallsTeamMember.java @@ -3,17 +3,17 @@ package ro.fr33styler.arcade.game.miniwalls.team; public interface MiniWallsTeamMember { int getWins(); - int r(); + int getDeaths(); int getLoses(); - int s(); + int getKills(); - int t(); + int getFinalKills(); - int u(); + int getArrowsShot(); - int v(); + int getWitherDamage(); - int w(); + int getWithersKilled(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesGame.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesGame.java index 4bab544..4764b69 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesGame.java @@ -179,16 +179,16 @@ public class PartyGamesGame extends AbstractGame implements GameEventHandler { if (this.roundStarting) { this.roundStarting = false; this.roundEnding = true; - this.getCurrentRound().g(); + this.getCurrentRound().startRound(); } if (this.roundEnding) { - this.getCurrentRound().h(); + this.getCurrentRound().finishRound(); } if (this.roundRunning) { this.roundRunning = false; - this.getCurrentRound().i(); + this.getCurrentRound().cleanupRound(); } } @@ -201,7 +201,7 @@ public class PartyGamesGame extends AbstractGame implements GameEventHandler { } } - return this.currentRound != null && text.equals("party_game") ? this.currentRound.a() : super.getVariable(text); + return this.currentRound != null && text.equals("party_game") ? this.currentRound.getRoundName() : super.getVariable(text); } @Override @@ -222,39 +222,39 @@ public class PartyGamesGame extends AbstractGame implements GameEventHandler { public void celebrateAt(Location location) { VersionAdapters.get().playSound(location.getWorld(), location, ArcadeSound.OCELOT_HURT, 1.0F, 1.0F); - Fireworks.a(this.getEngine().getPlatform(), location); + Fireworks.detonateRandom(this.getEngine().getPlatform(), location); } public void finishGame() { - this.standings.sort(Comparator.comparingInt(PartyGamesGamer::m).reversed()); + this.standings.sort(Comparator.comparingInt(PartyGamesGamer::getStars).reversed()); this.currentRound = null; for (PartyGamesTeam partyGamesTeam : this.playerTeams.values()) { - if (partyGamesTeam.a().equals(this.standings.get(0).getUUID())) { - partyGamesTeam.a(1); + if (partyGamesTeam.getUUID().equals(this.standings.get(0).getUUID())) { + partyGamesTeam.setWins(1); } else { - partyGamesTeam.b(1); + partyGamesTeam.setLoses(1); } } for (PartyGamesGamer partyGamesGamer : this.gamers) { partyGamesGamer.sendMessages(this.getMessages().getEndingTop(), this); - partyGamesGamer.a(this.getMessages().getSidebarPlaying(), partyGamesGamer); - if (!partyGamesGamer.getSpectatorOptions().g()) { + partyGamesGamer.updateSidebar(this.getMessages().getSidebarPlaying(), partyGamesGamer); + if (!partyGamesGamer.getSpectatorOptions().isExternal()) { if (this.getRewards().isEnabled()) { if (!this.standings.isEmpty() && partyGamesGamer == this.standings.get(0)) { - partyGamesGamer.b(this.getRewards().getFirst()); + partyGamesGamer.setRewardCommands(this.getRewards().getFirst()); } else if (this.standings.size() > 1 && partyGamesGamer == this.standings.get(1)) { - partyGamesGamer.b(this.getRewards().getSecond()); + partyGamesGamer.setRewardCommands(this.getRewards().getSecond()); } else if (this.standings.size() > 2 && partyGamesGamer == this.standings.get(2)) { - partyGamesGamer.b(this.getRewards().getThird()); + partyGamesGamer.setRewardCommands(this.getRewards().getThird()); } } if (!this.standings.isEmpty() && partyGamesGamer == this.standings.get(0)) { - partyGamesGamer.a(1); + partyGamesGamer.setWins(1); } else { - partyGamesGamer.b(1); + partyGamesGamer.setLoses(1); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesManager.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesManager.java index 9a31050..cc0b642 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/PartyGamesManager.java @@ -93,7 +93,7 @@ public class PartyGamesManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { PartyGamesStatistics partyGamesStatistics = new PartyGamesStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(partyGamesStatistics); + this.storage.getStatisticsRepository().loadStatistics(partyGamesStatistics); this.playerStats.put(player.getUniqueId(), partyGamesStatistics); } @@ -112,14 +112,14 @@ public class PartyGamesManager extends AbstractGameManager { public void updateTeamStats(UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { PartyGamesStatistics partyGamesStatistics = this.getData(uuid); - if (partyGamesStatistics != null && partyGamesStatistics.a()) { - partyGamesStatistics.a(partyGamesTeamMember); - this.storage.e().b(partyGamesStatistics); + if (partyGamesStatistics != null && partyGamesStatistics.isLoaded()) { + partyGamesStatistics.recordMatchStats(partyGamesTeamMember); + this.storage.getStatisticsRepository().saveStatistics(partyGamesStatistics); } else { - this.storage.e().a(uuid, partyGamesTeamMember); + this.storage.getStatisticsRepository().saveAllTimeMatchStats(uuid, partyGamesTeamMember); } - this.storage.e().b(uuid, partyGamesTeamMember); + this.storage.getStatisticsRepository().savePeriodicMatchStats(uuid, partyGamesTeamMember); } @Override @@ -136,9 +136,9 @@ public class PartyGamesManager extends AbstractGameManager { @Override protected void populateMenu(GameMenuPage gameMenuPage, Context context) { super.populateMenu(gameMenuPage, context); - gameMenuPage.page().a(35, defaultUser -> { + gameMenuPage.page().setSlot(35, defaultUser -> { defaultUser.toPlayer().closeInventory(); - this.getSessions().a(defaultUser); + this.getSessions().rejoin(defaultUser); }, new ItemBuilder(Material.ENDER_PEARL).setDisplayName(this.getMessages().getJoinGuiRejoinName()).setLore(this.getMessages().getJoinGuiRejoinLore()).build()); } @@ -160,12 +160,12 @@ public class PartyGamesManager extends AbstractGameManager { private void loadArenaConfigs() { File file = new File(this.getDataFolder(), "tweaks/per game/"); PartyGamesConfiguration partyGamesConfiguration = new PartyGamesConfiguration(); - partyGamesConfiguration.a(this.getConfigManager(), new File(file, "id_1")); + partyGamesConfiguration.load(this.getConfigManager(), new File(file, "id_1")); this.configurations.put("id_1", this.defaultConfiguration); - Files.a(file, file2 -> { + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { PartyGamesConfiguration partyGamesConfiguration2 = new PartyGamesConfiguration(); - partyGamesConfiguration2.a(this.getConfigManager(), file2); + partyGamesConfiguration2.load(this.getConfigManager(), file2); this.configurations.put(file2.getName(), partyGamesConfiguration2); } }); @@ -174,14 +174,14 @@ public class PartyGamesManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.defaultConfiguration.a(this.getEngine().getConfigManager(), this.getDataFolder()); + this.defaultConfiguration.load(this.getEngine().getConfigManager(), this.getDataFolder()); this.loadArenaConfigs(); } @Override public void start() { this.fallingBlockFactory = VersionAdapters.get().createPartyGamesFallingBlockFactorySelector().select(); - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/PartyGamesCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/PartyGamesCreateCommand.java index 8d401af..67c5af9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/PartyGamesCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/PartyGamesCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class PartyGamesCreateCommand implements CommandExecutor { - private final PartyGamesManager a; + private final PartyGamesManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public PartyGamesCreateCommand(PartyGamesManager partyGamesManager) { - this.a = partyGamesManager; + this.manager = partyGamesManager; } public boolean isPlayerOnly() { @@ -40,25 +40,25 @@ public class PartyGamesCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().a((Entity)sender); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a((Entity)sender); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); PartyGamesMap partyGamesMap = new PartyGamesMap(); if (index3 > 16) { defaultUser.sendMessage("§cThe maximum must be less than 16!"); @@ -71,14 +71,14 @@ public class PartyGamesCreateCommand implements CommandExecutor { } partyGamesMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } partyGamesMap.setId(text2); partyGamesMap.setMaximumPlayers(index3); - defaultUser.a(new PartyGamesSetup(defaultUser, partyGamesMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new PartyGamesSetup(defaultUser, partyGamesMap, this.manager, setupTarget)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/AddPartyRoundCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/AddPartyRoundCommand.java index 16e14b1..dd6d039 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/AddPartyRoundCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/AddPartyRoundCommand.java @@ -17,16 +17,16 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class AddPartyRoundCommand implements CommandExecutor { - private final PartyGamesManager a; + private final PartyGamesManager manager; private final ArgumentSet arguments; public AddPartyRoundCommand(PartyGamesManager partyGamesManager) { - this.a = partyGamesManager; + this.manager = partyGamesManager; this.arguments = new DefaultArgumentSet( new Argument[]{ - new CollectionArgument("id", null, partyGamesManager.getSessions().d().keySet()), - new ArrayArgument("party_game", null, PartyRoundType.b()), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("id", null, partyGamesManager.getSessions().getGames().keySet()), + new ArrayArgument("party_game", null, PartyRoundType.getIds()), + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); } @@ -40,35 +40,35 @@ public class AddPartyRoundCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - PartyRoundType partyRoundType = PartyRoundType.a(texts[index + 1]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 2]); - if (setupTarget == SetupTarget.MAP && !this.a.getSessions().a(text2)) { + PartyRoundType partyRoundType = PartyRoundType.byId(texts[index + 1]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 2]); + if (setupTarget == SetupTarget.MAP && !this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cNo game found under this id!"); - } else if (setupTarget == SetupTarget.TEMPLATE && !this.a.getSessions().d(text2)) { + } else if (setupTarget == SetupTarget.TEMPLATE && !this.manager.getSessions().hasTemplate(text2)) { sender.sendMessage("§cNo template found under this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().a((Entity)sender); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a((Entity)sender); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { PartyGamesMap partyGamesMap = setupTarget == SetupTarget.MAP - ? ((PartyGamesGame)this.a.getSessions().b(text2)).getMap() - : (PartyGamesMap)this.a.getSessions().e(text2).getMap(); + ? ((PartyGamesGame)this.manager.getSessions().getGame(text2)).getMap() + : (PartyGamesMap)this.manager.getSessions().getTemplate(text2).getMap(); if (partyRoundType == null) { sender.sendMessage("§cInvalid party game!"); - } else if (partyRoundType.a(partyGamesMap) != null) { + } else if (partyRoundType.getRoundMap(partyGamesMap) != null) { sender.sendMessage("§cParty game already set!"); } else { - defaultUser.a(partyRoundType.a(defaultUser, this.a, partyGamesMap, setupTarget)); + defaultUser.setArenaSetup(partyRoundType.createSetup(defaultUser, this.manager, partyGamesMap, setupTarget)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/RemovePartyRoundCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/RemovePartyRoundCommand.java index 4b94887..88e5163 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/RemovePartyRoundCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/RemovePartyRoundCommand.java @@ -14,13 +14,13 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class RemovePartyRoundCommand implements CommandExecutor { - private final PartyGamesManager a; + private final PartyGamesManager manager; private final ArgumentSet arguments; public RemovePartyRoundCommand(PartyGamesManager partyGamesManager) { - this.a = partyGamesManager; + this.manager = partyGamesManager; this.arguments = new DefaultArgumentSet( - new Argument[]{new CollectionArgument("id", null, partyGamesManager.getSessions().d().keySet()), new ArrayArgument("party_game", null, PartyRoundType.b())} + new Argument[]{new CollectionArgument("id", null, partyGamesManager.getSessions().getGames().keySet()), new ArrayArgument("party_game", null, PartyRoundType.getIds())} ); } @@ -33,22 +33,22 @@ public class RemovePartyRoundCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - if (!this.a.getSessions().a(text2)) { + if (!this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cNo game found under this id!"); } else { - PartyGamesGame partyGamesGame = (PartyGamesGame)this.a.getSessions().d().get(text2); - PartyRoundType partyRoundType = PartyRoundType.a(texts[index + 1]); + PartyGamesGame partyGamesGame = (PartyGamesGame)this.manager.getSessions().getGames().get(text2); + PartyRoundType partyRoundType = PartyRoundType.byId(texts[index + 1]); if (partyRoundType != null) { for (PartyRound partyRound : partyGamesGame.getRoundQueue()) { - if (partyRound.b().getPartyRoundType() == partyRoundType) { + if (partyRound.getRoundMap().getPartyRoundType() == partyRoundType) { partyGamesGame.getRoundQueue().remove(partyRound); - partyGamesGame.getMap().a(partyRoundType); - partyGamesGame.getManager().getStorage().getStorage().a(partyGamesGame.getMap()); + partyGamesGame.getMap().clearRoundMap(partyRoundType); + partyGamesGame.getManager().getStorage().getStorage().save(partyGamesGame.getMap()); sender.sendMessage("§aParty game has been removed!"); return; } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/SkipPartyRoundCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/SkipPartyRoundCommand.java index 3e81116..9b621c8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/SkipPartyRoundCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/command/round/SkipPartyRoundCommand.java @@ -11,12 +11,12 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class SkipPartyRoundCommand implements CommandExecutor { - private final PartyGamesManager a; + private final PartyGamesManager manager; private final ArgumentSet arguments; public SkipPartyRoundCommand(PartyGamesManager partyGamesManager) { - this.a = partyGamesManager; - this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, partyGamesManager.getSessions().d().keySet())}); + this.manager = partyGamesManager; + this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, partyGamesManager.getSessions().getGames().keySet())}); } public ArgumentSet getArguments() { @@ -24,15 +24,15 @@ public class SkipPartyRoundCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; - if (!this.a.getSessions().a(text2)) { + if (!this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cNo game found under this id!"); } else { - PartyGamesGame partyGamesGame = (PartyGamesGame)this.a.getSessions().d().get(text2); + PartyGamesGame partyGamesGame = (PartyGamesGame)this.manager.getSessions().getGames().get(text2); if (partyGamesGame.getPhase() == partyGamesGame.getPhaseLifecycle().getPlaying()) { partyGamesGame.clearStandings(); } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/PartyGamesConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/PartyGamesConfiguration.java index 5cff9d8..fa9a6bd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/PartyGamesConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/PartyGamesConfiguration.java @@ -9,7 +9,7 @@ public class PartyGamesConfiguration { private final PartyGamesRewards rewards = new PartyGamesRewards(); private final PartyGamesSettings settings = new PartyGamesSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/message/PartyGamesMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/message/PartyGamesMessages.java index 5ce1702..27a6a0e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/message/PartyGamesMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/config/message/PartyGamesMessages.java @@ -11,111 +11,111 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class PartyGamesMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Party Games"); + private String displayName = Strings.colorize("Party Games"); @Setting("color-black") - private String colorBlack = Strings.a("Black"); + private String colorBlack = Strings.colorize("Black"); @Setting("color-blue") - private String colorBlue = Strings.a("Blue"); + private String colorBlue = Strings.colorize("Blue"); @Setting("color-brown") - private String colorBrown = Strings.a("Brown"); + private String colorBrown = Strings.colorize("Brown"); @Setting("color-cyan") - private String colorCyan = Strings.a("Cyan"); + private String colorCyan = Strings.colorize("Cyan"); @Setting("color-gray") - private String colorGray = Strings.a("Gray"); + private String colorGray = Strings.colorize("Gray"); @Setting("color-green") - private String colorGreen = Strings.a("Green"); + private String colorGreen = Strings.colorize("Green"); @Setting("color-light-blue") - private String colorLightBlue = Strings.a("Light Blue"); + private String colorLightBlue = Strings.colorize("Light Blue"); @Setting("color-light-gray") - private String colorLightGray = Strings.a("Light Gray"); + private String colorLightGray = Strings.colorize("Light Gray"); @Setting("color-lime") - private String colorLime = Strings.a("Lime"); + private String colorLime = Strings.colorize("Lime"); @Setting("color-magenta") - private String colorMagenta = Strings.a("Magenta"); + private String colorMagenta = Strings.colorize("Magenta"); @Setting("color-orange") - private String colorOrange = Strings.a("Orange"); + private String colorOrange = Strings.colorize("Orange"); @Setting("color-pink") - private String colorPink = Strings.a("Pink"); + private String colorPink = Strings.colorize("Pink"); @Setting("color-purple") - private String colorPurple = Strings.a("Purple"); + private String colorPurple = Strings.colorize("Purple"); @Setting("color-red") - private String colorRed = Strings.a("Red"); + private String colorRed = Strings.colorize("Red"); @Setting("color-white") - private String colorWhite = Strings.a("White"); + private String colorWhite = Strings.colorize("White"); @Setting("color-yellow") - private String colorYellow = Strings.a("Yellow"); + private String colorYellow = Strings.colorize("Yellow"); @Setting("color-spectator") - private String colorSpectator = Strings.a("Spectator"); + private String colorSpectator = Strings.colorize("Spectator"); @Setting("animal-slaughter-name") - private String animalSlaughterName = Strings.a("Animal Slaughter"); + private String animalSlaughterName = Strings.colorize("Animal Slaughter"); @Setting("avalanche-name") - private String avalancheName = Strings.a("Avalanche"); + private String avalancheName = Strings.colorize("Avalanche"); @Setting("frozen-floor-name") - private String frozenFloorName = Strings.a("Frozen Floor"); + private String frozenFloorName = Strings.colorize("Frozen Floor"); @Setting("hoe-hoe-hoe-name") - private String hoeHoeHoeName = Strings.a("Hoe Hoe Hoe"); + private String hoeHoeHoeName = Strings.colorize("Hoe Hoe Hoe"); @Setting("minecart-racing-name") - private String minecartRacingName = Strings.a("Minecart Racing"); + private String minecartRacingName = Strings.colorize("Minecart Racing"); @Setting("jungle-jump-name") - private String jungleJumpName = Strings.a("Jungle Jump"); + private String jungleJumpName = Strings.colorize("Jungle Jump"); @Setting("the-floor-is-lava-name") - private String theFloorIsLavaName = Strings.a("The Floor Is Lava"); + private String theFloorIsLavaName = Strings.colorize("The Floor Is Lava"); @Setting("pig-fishing-name") - private String pigFishingName = Strings.a("Pig Fishing"); + private String pigFishingName = Strings.colorize("Pig Fishing"); @Setting("punch-the-bats-name") - private String punchTheBatsName = Strings.a("Punch The Bats"); + private String punchTheBatsName = Strings.colorize("Punch The Bats"); @Setting("trampolino-name") - private String trampolinoName = Strings.a("Trampolino"); + private String trampolinoName = Strings.colorize("Trampolino"); @Setting("volcano-name") - private String volcanoName = Strings.a("Volcano"); + private String volcanoName = Strings.colorize("Volcano"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("boss-bar-time-left") - private Text bossBarTimeLeft = TextParser.a("&6&lTime Left: &c&l%countdown%"); + private Text bossBarTimeLeft = TextParser.parse("&6&lTime Left: &c&l%countdown%"); @Setting("party-game-boss-bar-start") - private Text partyGameBossBarStart = TextParser.a("&e&l%party_game% starts in &c&l%countdown% &e&lseconds!"); + private Text partyGameBossBarStart = TextParser.parse("&e&l%party_game% starts in &c&l%countdown% &e&lseconds!"); @Setting("avalanche-boss-bar-cover") - private Text avalancheBossBarCover = TextParser.a("&lTake Cover!!"); + private Text avalancheBossBarCover = TextParser.parse("&lTake Cover!!"); @Setting("avalanche-boss-bar-next") - private Text avalancheBossBarNext = TextParser.a("&6&lNext Avalanche: &c&l%countdown%"); + private Text avalancheBossBarNext = TextParser.parse("&6&lNext Avalanche: &c&l%countdown%"); @Setting("avalanche-can-hit") - private String avalancheCanHit = Strings.a("&aYou can hit other players now!"); + private String avalancheCanHit = Strings.colorize("&aYou can hit other players now!"); @Setting("avalanche-starts-in") - private Text avalancheStartsIn = TextParser.a("&eWave &c%wave%&e will begin in &c%countdown%&e seconds with &c%safe_points%&e safe points! Find Cover!"); + private Text avalancheStartsIn = TextParser.parse("&eWave &c%wave%&e will begin in &c%countdown%&e seconds with &c%safe_points%&e safe points! Find Cover!"); @Setting("hoe-hoe-hoe-item") - private Text hoeHoeHoeItem = TextParser.a("%color% %color_name% Wool"); + private Text hoeHoeHoeItem = TextParser.parse("%color% %color_name% Wool"); @Setting("hoe-hoe-hoe-your-color") - private Text hoeHoeHoeYourColor = TextParser.a("%color%You are %color_name%"); + private Text hoeHoeHoeYourColor = TextParser.parse("%color%You are %color_name%"); @Setting("hoe-hoe-hoe-your-only") - private Text hoeHoeHoeYourOnly = TextParser.a("&cYou can only hoe next to %color%%color_name% &ccolor!"); + private Text hoeHoeHoeYourOnly = TextParser.parse("&cYou can only hoe next to %color%%color_name% &ccolor!"); @Setting("hoe-hoe-hoe-time-left") - private Text hoeHoeHoeTimeLeft = TextParser.a("&6&lHoe Time Left: &c&l%countdown%"); + private Text hoeHoeHoeTimeLeft = TextParser.parse("&6&lHoe Time Left: &c&l%countdown%"); @Setting("parkour-finished") - private Text parkourFinished = TextParser.a("&7%player% &ehas finished the parkour!"); + private Text parkourFinished = TextParser.parse("&7%player% &ehas finished the parkour!"); @Setting("parkour-checkpoint") - private String parkourCheckpoint = Strings.a("&a&lCheckpoint!"); + private String parkourCheckpoint = Strings.colorize("&a&lCheckpoint!"); @Setting("punch-the-bats-bat") - private String punchTheBatsBat = Strings.a("&aPunch Me!"); + private String punchTheBatsBat = Strings.colorize("&aPunch Me!"); @Setting("punch-the-bats-bonus-bat") - private String punchTheBatsBonusBat = Strings.a("&6Bonus!"); + private String punchTheBatsBonusBat = Strings.colorize("&6Bonus!"); @Setting("punch-the-bats-killed") - private String punchTheBatsKilled = Strings.a("&cOuch!"); + private String punchTheBatsKilled = Strings.colorize("&cOuch!"); @Setting("punch-the-bats-time-left") - private Text punchTheBatsTimeLeft = TextParser.a("&6&lPunch Time Left: &c&l%countdown%"); + private Text punchTheBatsTimeLeft = TextParser.parse("&6&lPunch Time Left: &c&l%countdown%"); @Setting("pig-fishing-super-bacon") - private String pigFishingSuperBacon = Strings.a("&cSuper Bacon"); + private String pigFishingSuperBacon = Strings.colorize("&cSuper Bacon"); @Setting("animal-slaughter-time-left") - private Text animalSlaughterTimeLeft = TextParser.a("&6&lSlay them all: &c&l%countdown%"); + private Text animalSlaughterTimeLeft = TextParser.parse("&6&lSlay them all: &c&l%countdown%"); @Setting("minecart-racing-speed") - private Text minecartRacingSpeed = TextParser.a("&b&lCurrent Speed: &6&l%speed% Blocks/s"); + private Text minecartRacingSpeed = TextParser.parse("&b&lCurrent Speed: &6&l%speed% Blocks/s"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lParty Games", @@ -127,7 +127,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("avalanche-start") - private List avalancheStart = TextParser.a( + private List avalancheStart = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -141,19 +141,19 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("hoe-hoe-hoe-start") - private List hoeHoeHoeStart = TextParser.a( + private List hoeHoeHoeStart = TextParser.parseAll( new String[]{"&a%line%", " ", " &f&lHoe Hoe Hoe", " ", " &e&lGoal: Claim as much land as possible with your hoe!", " ", "&a%line%"} ); @Setting("jungle-jump-start") - private List jungleJumpStart = TextParser.a( + private List jungleJumpStart = TextParser.parseAll( new String[]{"&a%line%", " ", " &f&lJungle Jump", " ", " &e&lBeat the parkour by keeping a good rhythm!", " ", "&a%line%"} ); @Setting("the-floor-is-lava-start") - private List theFloorIsLavaStart = TextParser.a( + private List theFloorIsLavaStart = TextParser.parseAll( new String[]{"&a%line%", " ", " &f&lThe Floor Is Lava", " ", " &e&lBeat the parkour by keeping a good rhythm!", " ", "&a%line%"} ); @Setting("punch-the-bats-start") - private List punchTheBatsStart = TextParser.a( + private List punchTheBatsStart = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -167,21 +167,21 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("pig-fishing-start") - private List pigFishingStart = TextParser.a( + private List pigFishingStart = TextParser.parseAll( new String[]{"&a%line%", " ", " &f&lPig Fishing", " ", " &e&lGoal: Use your fishing pole to get pigs in your", " &e<rap!", " ", "&a%line%"} ); @Setting("trampolino-start") - private List trampolinoStart = TextParser.a( + private List trampolinoStart = TextParser.parseAll( new String[]{ "&a%line%", " ", " &f&lTrampolino", " ", " &e&lGoal: Catch as many coins as you can!", " ", " &e&lFirst to 40 coins wins!", " ", "&a%line%" } ); @Setting("animal-slaughter-start") - private List animalSlaughterStart = TextParser.a(new String[]{"&a%line%", " ", " &f&lAnimal Slaughter", " ", " &e&lGoal: Kill animals!", " ", "&a%line%"}); + private List animalSlaughterStart = TextParser.parseAll(new String[]{"&a%line%", " ", " &f&lAnimal Slaughter", " ", " &e&lGoal: Kill animals!", " ", "&a%line%"}); @Setting("volcano-start") - private List volcanoStart = TextParser.a(new String[]{"&a%line%", " ", " &f&lVolcano", " ", " &e&lGoal: Don't take a bath in lava!", " ", "&a%line%"}); + private List volcanoStart = TextParser.parseAll(new String[]{"&a%line%", " ", " &f&lVolcano", " ", " &e&lGoal: Don't take a bath in lava!", " ", "&a%line%"}); @Setting("frozen-floor-start") - private List frozenFloorStart = TextParser.a( + private List frozenFloorStart = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -194,7 +194,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("minecart-racing-start") - private List minecartRacingStart = TextParser.a( + private List minecartRacingStart = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -208,7 +208,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("avalanche-sidebar") - private List avalancheSidebar = TextParser.a( + private List avalancheSidebar = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -226,7 +226,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("volcano-sidebar") - private List volcanoSidebar = TextParser.a( + private List volcanoSidebar = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -244,7 +244,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("frozen-floor-sidebar") - private List frozenFloorSidebar = TextParser.a( + private List frozenFloorSidebar = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -262,7 +262,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("party-game-sidebar") - private List partyGameSidebar = TextParser.a( + private List partyGameSidebar = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -282,7 +282,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("round-top") - private List roundTop = TextParser.a( + private List roundTop = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -298,7 +298,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &f&lParty Games", @@ -311,7 +311,7 @@ public class PartyGamesMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -332,7 +332,7 @@ public class PartyGamesMessages extends BaseGameMessages { ); public PartyGamesMessages() { - this.spectatorTargetLore = new ArrayList<>(TextParser.a(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); + this.spectatorTargetLore = new ArrayList<>(TextParser.parseAll(new String[]{"&7Health: &f%health%%", "&7Left-click to spectate"})); } @Override diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/lifecycle/PartyGamesLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/lifecycle/PartyGamesLifecycle.java index 3df5e3f..400d01e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/lifecycle/PartyGamesLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/lifecycle/PartyGamesLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class PartyGamesLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public PartyGamesLifecycle(PartyGamesGame partyGamesGame) { this.phase = new WaitingPhase(partyGamesGame); - this.phase2 = new PartyGamesPlayingPhase(partyGamesGame); - this.phase3 = new PartyGamesEndingPhase(partyGamesGame); - this.phase4 = new ResettingPhase(partyGamesGame); + this.playingPhase = new PartyGamesPlayingPhase(partyGamesGame); + this.endingPhase = new PartyGamesEndingPhase(partyGamesGame); + this.resettingPhase = new ResettingPhase(partyGamesGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class PartyGamesLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/listener/PartyGamesListener.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/listener/PartyGamesListener.java index 86c0773..f38b850 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/listener/PartyGamesListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/listener/PartyGamesListener.java @@ -60,45 +60,45 @@ import ro.fr33styler.arcade.platform.compat.ColoredBlockType; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class PartyGamesListener extends GameListener { - private final PartyGamesManager manager2; - private static final BlockFace[] b = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}; + private final PartyGamesManager partyGamesManager; + private static final BlockFace[] HORIZONTAL_FACES = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}; public PartyGamesListener(PartyGamesManager manager22) { super(manager22); - this.manager2 = manager22; + this.partyGamesManager = manager22; } @EventHandler - public void a(PlayerMoveEvent event) { + public void onSpectatorOrBoundaryMove(PlayerMoveEvent event) { Location location = event.getFrom(); Location location2 = event.getTo(); Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && location2 != null && !Locations.a(location, location2)) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && location2 != null && !Locations.isSameBlock(location, location2)) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGamer.f()) { + if (partyGamesGamer.isSpectator()) { PartyRound partyRound = partyGamesGame.getCurrentRound(); if (partyRound == null) { - if (Locations.b(partyGamesGame.getMap().getTopLobby(), location2) >= 3600.0) { + if (Locations.distanceSquared(partyGamesGame.getMap().getTopLobby(), location2) >= 3600.0) { player.setFlying(true); event.setTo(partyGamesGame.getMap().getTopLobby()); } - } else if (!partyRound.b().getPlayZone().a(location2)) { + } else if (!partyRound.getRoundMap().getPlayZone().contains(location2)) { player.setFlying(true); - event.setTo(partyRound.b().getSpectator()); + event.setTo(partyRound.getRoundMap().getSpectator()); } } else if (partyGamesGame.isRoundStarting() && partyGamesGame.isGameEnding()) { event.setTo(location); - } else if (partyGamesGame.isRoundEnding() && !partyGamesGame.getCurrentRound().b().getPlayZone().a(location2)) { + } else if (partyGamesGame.isRoundEnding() && !partyGamesGame.getCurrentRound().getRoundMap().getPlayZone().contains(location2)) { event.setTo(location); } } } @EventHandler - public void a(EntityDeathEvent event) { - for (PartyGamesGame partyGamesGame : this.manager2.getSessions().d().values()) { - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof AnimalSlaughterRound var4 && var4.getMap18().remove(event.getEntity().getUniqueId()) != null) { + public void onAnimalSlaughterEntityDeath(EntityDeathEvent event) { + for (PartyGamesGame partyGamesGame : this.partyGamesManager.getSessions().getGames().values()) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof AnimalSlaughterRound var4 && var4.getSpawnedAnimals().remove(event.getEntity().getUniqueId()) != null) { event.getDrops().clear(); event.setDroppedExp(0); break; @@ -107,28 +107,28 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(EntityDamageByEntityEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getDamager(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + public void onAnimalSlaughterDamage(EntityDamageByEntityEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getDamager(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof AnimalSlaughterRound var4) { Player player = partyGamesGamer.toPlayer(); if (player.getInventory().getHeldItemSlot() == 0) { - LivingEntity livingEntity = (LivingEntity)var4.getMap18().get(event.getEntity().getUniqueId()); + LivingEntity livingEntity = (LivingEntity)var4.getSpawnedAnimals().get(event.getEntity().getUniqueId()); if (livingEntity != null && livingEntity.getCustomName() != null && livingEntity.getNoDamageTicks() == 0) { event.setDamage(1.0); if (livingEntity.getCustomName().equals("§c-50%")) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() / 2); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() / 2); event.setDamage(3.0); } if (livingEntity.getHealth() <= event.getDamage()) { if (livingEntity.getCustomName().equals("§a+1")) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 1); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 1); } else if (livingEntity.getCustomName().equals("§a+3")) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 3); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 3); } else if (livingEntity.getCustomName().equals("§a+5")) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 5); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 5); } partyGamesGamer.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); @@ -145,9 +145,9 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(EntityDamageEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getEntity(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + public void onAvalancheDamage(EntityDamageEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getEntity(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof AvalancheRound) { event.setDamage(0.0); @@ -156,9 +156,9 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void b(EntityDamageEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getEntity(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f() && event.getCause() != DamageCause.PROJECTILE) { + public void onFrozenFloorDamage(EntityDamageEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getEntity(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator() && event.getCause() != DamageCause.PROJECTILE) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof FrozenFloorRound) { event.setCancelled(true); @@ -167,16 +167,16 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(PlayerInteractEvent event) { + public void onFrozenFloorInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof FrozenFloorRound) { FrozenFloorGamer frozenFloorGamer = (FrozenFloorGamer)partyGamesGamer.getGamer(); - if (System.currentTimeMillis() - frozenFloorGamer.d() >= 150L) { - frozenFloorGamer.b(frozenFloorGamer.b() + 1); - frozenFloorGamer.a(System.currentTimeMillis()); + if (System.currentTimeMillis() - frozenFloorGamer.getLastShotTimestamp() >= 150L) { + frozenFloorGamer.setShots(frozenFloorGamer.getShots() + 1); + frozenFloorGamer.setLastShotTimestamp(System.currentTimeMillis()); } else { event.setCancelled(true); } @@ -191,12 +191,12 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void b(EntityDamageByEntityEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getEntity(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f() && event.getCause() == DamageCause.PROJECTILE) { + public void onFrozenFloorSnowballHit(EntityDamageByEntityEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getEntity(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator() && event.getCause() == DamageCause.PROJECTILE) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof FrozenFloorRound && ((Snowball)event.getDamager()).getShooter() instanceof Player var4) { - PartyGamesGamer partyGamesGamer2 = this.a(var4, PartyGamesGamer.class); + PartyGamesGamer partyGamesGamer2 = this.getActiveGamer(var4, PartyGamesGamer.class); if (partyGamesGamer2 == null) { event.setCancelled(true); } else { @@ -210,47 +210,47 @@ public class PartyGamesListener extends GameListener { } @EventHandler(priority = EventPriority.LOWEST) - public void b(PlayerMoveEvent event) { + public void onFrozenFloorMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f() && location != null) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator() && location != null) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof FrozenFloorRound var6 && !Locations.a(event.getFrom(), location) && !var6.b().getPlayZone().a(location)) { - event.setTo(var6.b().getSpectator()); - partyGamesGamer.a(true); + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof FrozenFloorRound var6 && !Locations.isSameBlock(event.getFrom(), location) && !var6.getRoundMap().getPlayZone().contains(location)) { + event.setTo(var6.getRoundMap().getSpectator()); + partyGamesGamer.setTemporarySpectator(true); FrozenFloorGamer frozenFloorGamer = (FrozenFloorGamer)partyGamesGamer.getGamer(); - if (frozenFloorGamer.getGamer3() != null) { - frozenFloorGamer.getGamer3().playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); + if (frozenFloorGamer.getLastAttacker() != null) { + frozenFloorGamer.getLastAttacker().playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); } for (PartyGamesGamer partyGamesGamer2 : partyGamesGame.getGamers()) { - if (!partyGamesGamer2.f()) { - partyGamesGamer2.getGamer().a(partyGamesGamer2.getGamer().a() + 1); + if (!partyGamesGamer2.isSpectator()) { + partyGamesGamer2.getGamer().setScore(partyGamesGamer2.getGamer().getScore() + 1); } } - if (partyGamesGame.getGamers().a() <= 1) { - var6.h(); + if (partyGamesGame.getGamers().getAliveCount() <= 1) { + var6.finishRound(); } } } } @EventHandler - public void b(PlayerInteractEvent event) { + public void onHoeHoeHoeInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f() && event.getAction() == Action.RIGHT_CLICK_BLOCK) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator() && event.getAction() == Action.RIGHT_CLICK_BLOCK) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); Block block = event.getClickedBlock(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof HoeHoeHoeRound var6 && block != null && player.getInventory().getHeldItemSlot() == 0) { HoeHoeHoeGamer hoeHoeHoeGamer = (HoeHoeHoeGamer)partyGamesGamer.getGamer(); - if (var6.b().getFloorZone().a(block) && !Materials.a(block.getType())) { - if (partyGamesGamer.getGamer().a() > 0) { + if (var6.getRoundMap().getFloorZone().contains(block) && !Materials.isWool(block.getType())) { + if (partyGamesGamer.getGamer().getScore() > 0) { boolean flag = true; - for (BlockFace blockFace : b) { + for (BlockFace blockFace : HORIZONTAL_FACES) { Block block2 = block.getRelative(blockFace); if (VersionAdapters.get().readColoredBlock(block2, ColoredBlockType.WOOL) == hoeHoeHoeGamer.getTeamColor().toArcadeColor()) { flag = false; @@ -259,12 +259,12 @@ public class PartyGamesListener extends GameListener { } if (flag) { - partyGamesGamer.a(partyGamesGame.getMessages().getHoeHoeHoeYourOnly()); + partyGamesGamer.sendMessage(partyGamesGame.getMessages().getHoeHoeHoeYourOnly()); return; } } - hoeHoeHoeGamer.a(hoeHoeHoeGamer.a() + 1); + hoeHoeHoeGamer.setScore(hoeHoeHoeGamer.getScore() + 1); partyGamesGame.getRollbackQueue().add(block.getState()); VersionAdapters.get().setColoredBlock(partyGamesGame.getEngine().getPlatform(), block, ColoredBlockType.WOOL, hoeHoeHoeGamer.getTeamColor().toArcadeColor()); Location location = block.getLocation().add(0.5, 0.9, 0.5); @@ -276,9 +276,9 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(VehicleDestroyEvent event) { - for (PartyGamesGame partyGamesGame : this.manager2.getSessions().d().values()) { - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var4 && var4.getSet9().contains(event.getVehicle())) { + public void onMinecartDestroy(VehicleDestroyEvent event) { + for (PartyGamesGame partyGamesGame : this.partyGamesManager.getSessions().getGames().values()) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var4 && var4.getMinecarts().contains(event.getVehicle())) { event.setCancelled(true); break; } @@ -286,9 +286,9 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(VehicleExitEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getExited(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + public void onMinecartExit(VehicleExitEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getExited(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound) { event.setCancelled(true); @@ -297,27 +297,27 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(ProjectileHitEvent event) { + public void onMinecartArrowHit(ProjectileHitEvent event) { if (event.getEntityType() == EntityType.ARROW) { Projectile projectile = event.getEntity(); if (projectile.getShooter() instanceof Player var3) { Block block = VersionAdapters.get().getProjectileHitBlock(event); - PartyGamesGamer partyGamesGamer = this.a(var3, PartyGamesGamer.class); - if (partyGamesGamer == null || partyGamesGamer.f() || block == null) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(var3, PartyGamesGamer.class); + if (partyGamesGamer == null || partyGamesGamer.isSpectator() || block == null) { return; } PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var7 && var7.b().getBreakZone().a(block)) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var7 && var7.getRoundMap().getBreakZone().contains(block)) { projectile.remove(); - if (Materials.a(block.getType())) { + if (Materials.isWool(block.getType())) { ArcadeColor blockColor = VersionAdapters.get().readColoredBlock(block, ColoredBlockType.WOOL); for (PartyGamesGamer partyGamesGamer2 : partyGamesGame.getGamers()) { - if (!partyGamesGamer2.f()) { + if (!partyGamesGamer2.isSpectator()) { MinecartRacingGamer minecartRacingGamer = (MinecartRacingGamer)partyGamesGamer2.getGamer(); if (minecartRacingGamer.getMinecartRacingLane().getColor().toArcadeColor() == blockColor) { partyGamesGamer2.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - minecartRacingGamer.a(minecartRacingGamer.d() + partyGamesGame.getSettings().getMinecartRacingSpeed()); + minecartRacingGamer.setSpeed(minecartRacingGamer.getSpeed() + partyGamesGame.getSettings().getMinecartRacingSpeed()); break; } } @@ -333,28 +333,28 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(VehicleMoveEvent event) { + public void onMinecartMove(VehicleMoveEvent event) { Location location = event.getTo(); Vehicle vehicle = event.getVehicle(); Entity passenger = VersionAdapters.get().getSingleVehiclePassenger(vehicle); - if (!Locations.a(event.getFrom(), location) && passenger instanceof Player) { - PartyGamesGamer partyGamesGamer = this.a(passenger, PartyGamesGamer.class); - if (partyGamesGamer == null || partyGamesGamer.f()) { + if (!Locations.isSameBlock(event.getFrom(), location) && passenger instanceof Player) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(passenger, PartyGamesGamer.class); + if (partyGamesGamer == null || partyGamesGamer.isSpectator()) { return; } PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var6 && var6.b().getFinishZone().a(location)) { - var6.h(); + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof MinecartRacingRound var6 && var6.getRoundMap().getFinishZone().contains(location)) { + var6.finishRound(); } } } - private int a(PartyGamesGame partyGamesGame) { + private int countFinishedPlayers(PartyGamesGame partyGamesGame) { int index = 0; for (PartyGamesGamer partyGamesGamer : partyGamesGame.getGamers()) { - if (partyGamesGamer.f() && partyGamesGamer.getSpectatorOptions().f()) { + if (partyGamesGamer.isSpectator() && partyGamesGamer.getSpectatorOptions().isTemporary()) { index++; } } @@ -363,35 +363,35 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void c(PlayerMoveEvent event) { + public void onParkourMove(PlayerMoveEvent event) { Location location = event.getTo(); - if (location != null && !Locations.a(event.getFrom(), location)) { + if (location != null && !Locations.isSameBlock(event.getFrom(), location)) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer == null || partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer == null || partyGamesGamer.isSpectator()) { return; } PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof ParkourRound var6) { ParkourGamer parkourGamer = (ParkourGamer)partyGamesGamer.getGamer(); - double doubleVal = Locations.b(var6.b().getSpawn(), var6.b().getFinishZone().b()); - parkourGamer.a((int)(Locations.b(player.getLocation(), var6.b().getSpawn()) / doubleVal * 100.0)); - if (var6.b().getPlayZone().a(location) && !location.getBlock().isLiquid()) { - if (var6.b().getCheckpointZone().a(location)) { - if (parkourGamer.getLocation() == var6.b().getSpawn()) { + double doubleVal = Locations.distanceSquared(var6.getRoundMap().getSpawn(), var6.getRoundMap().getFinishZone().getMin()); + parkourGamer.setScore((int)(Locations.distanceSquared(player.getLocation(), var6.getRoundMap().getSpawn()) / doubleVal * 100.0)); + if (var6.getRoundMap().getPlayZone().contains(location) && !location.getBlock().isLiquid()) { + if (var6.getRoundMap().getCheckpointZone().contains(location)) { + if (parkourGamer.getLocation() == var6.getRoundMap().getSpawn()) { partyGamesGamer.playSound(ArcadeSound.UI_BUTTON_CLICK, 1.0F, 1.0F); parkourGamer.setLocation(player.getLocation()); partyGamesGamer.sendMessage(partyGamesGame.getMessages().getParkourCheckpoint()); } - } else if (var6.b().getFinishZone().a(location)) { - partyGamesGamer.a(true); + } else if (var6.getRoundMap().getFinishZone().contains(location)) { + partyGamesGamer.setTemporarySpectator(true); partyGamesGamer.sendTitle("", "", 0, 0, 0); - parkourGamer.a(100); - parkourGamer.b(parkourGamer.b() + 1); - int index = this.a(partyGamesGame); + parkourGamer.setScore(100); + parkourGamer.setFinishRank(parkourGamer.getFinishRank() + 1); + int index = this.countFinishedPlayers(partyGamesGame); if (index == partyGamesGame.getStandings().size()) { - var6.h(); + var6.finishRound(); } else if (partyGamesGame.getRoundTicks() > 10 && partyGamesGame.getGamers().size() > 3 && index == 3) { partyGamesGame.setRoundTicks(10); } @@ -401,8 +401,8 @@ public class PartyGamesListener extends GameListener { for (PartyGamesGamer partyGamesGamer2 : partyGamesGame.getGamers()) { partyGamesGamer2.sendMessage(partyGamesGame.getMessages().getParkourFinished(), partyGamesGamer); - if (!partyGamesGamer2.f()) { - PlayerVisibility.a(javaPlugin, partyGamesGamer2.toPlayer(), partyGamesGame.getGamers(), partyGamesGame.getGamers()); + if (!partyGamesGamer2.isSpectator()) { + PlayerVisibility.syncVisibility(javaPlugin, partyGamesGamer2.toPlayer(), partyGamesGame.getGamers(), partyGamesGame.getGamers()); } } } @@ -415,9 +415,9 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void c(EntityDamageEvent event) { - for (PartyGamesGame partyGamesGame : this.manager2.getSessions().d().values()) { - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PigFishingRound var4 && var4.getSet10().contains(event.getEntity())) { + public void onPigFishingDamage(EntityDamageEvent event) { + for (PartyGamesGame partyGamesGame : this.partyGamesManager.getSessions().getGames().values()) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PigFishingRound var4 && var4.getPigs().contains(event.getEntity())) { event.setDamage(0.0); break; } @@ -430,27 +430,27 @@ public class PartyGamesListener extends GameListener { return; } - PartyGamesGamer partyGamesGamer = this.a(event.getDamager(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getDamager(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PigFishingRound var4 && !var4.getSet10().contains(event.getEntity())) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PigFishingRound var4 && !var4.getPigs().contains(event.getEntity())) { event.setCancelled(true); } } } @EventHandler - public void d(PlayerMoveEvent event) { + public void onPigFishingMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PigFishingRound) { Location location = event.getTo(); - if (location != null && !Locations.a(event.getFrom(), location)) { + if (location != null && !Locations.isSameBlock(event.getFrom(), location)) { PigFishingGamer pigFishingGamer = (PigFishingGamer)partyGamesGamer.getGamer(); - if (!pigFishingGamer.getPigFishingLane().getSafeZone().a(location)) { - partyGamesGamer.a(pigFishingGamer.getPigFishingLane().getSpawn()); + if (!pigFishingGamer.getPigFishingLane().getSafeZone().contains(location)) { + partyGamesGamer.teleport(pigFishingGamer.getPigFishingLane().getSpawn()); } } } @@ -458,10 +458,10 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void a(PlayerToggleFlightEvent event) { + public void onPunchTheBatsDoubleJump(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PunchTheBatsRound) { event.setCancelled(true); @@ -474,10 +474,10 @@ public class PartyGamesListener extends GameListener { } @EventHandler(priority = EventPriority.LOWEST) - public void e(PlayerMoveEvent event) { + public void onPunchTheBatsMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f() && event.getTo() != null) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator() && event.getTo() != null) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PunchTheBatsRound) { Block block = event.getFrom().getBlock().getRelative(BlockFace.DOWN); @@ -490,30 +490,30 @@ public class PartyGamesListener extends GameListener { } @EventHandler - public void c(EntityDamageByEntityEvent event) { - PartyGamesGamer partyGamesGamer = this.a(event.getDamager(), PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + public void onPunchTheBatsHit(EntityDamageByEntityEvent event) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(event.getDamager(), PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof PunchTheBatsRound var4) { Entity entity = event.getEntity(); - if (var4.getSet11().remove(entity)) { + if (var4.getBats().remove(entity)) { event.setDamage(20.0); if (partyGamesGame.getMessages().getPunchTheBatsBat().equals(entity.getCustomName())) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 1); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 1); } else if (partyGamesGame.getMessages().getPunchTheBatsBonusBat().equals(entity.getCustomName())) { - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 5); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 5); } entity.setCustomName(partyGamesGame.getMessages().getPunchTheBatsKilled()); - if (var4.getSet11().size() <= 40) { - var4.m(); + if (var4.getBats().size() <= 40) { + var4.spawnBats(); } } } } } - private void a(Entity marker, PartyGamesGamer partyGamesGamer, TrampolinoRound trampolinoRound) { + private void handleTrampolinoMarkerCollect(Entity marker, PartyGamesGamer partyGamesGamer, TrampolinoRound trampolinoRound) { Player player = partyGamesGamer.toPlayer(); String text = VersionAdapters.get().getTrampolinoMarkerLabel(marker); if (text != null) { @@ -522,84 +522,84 @@ public class PartyGamesListener extends GameListener { player.setVelocity(new Vector(0, 3, 0)); break; case "§a+1": - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 1); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 1); break; case "§a+3": - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 3); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 3); break; case "§c+10": - partyGamesGamer.getGamer().a(partyGamesGamer.getGamer().a() + 10); + partyGamesGamer.getGamer().setScore(partyGamesGamer.getGamer().getScore() + 10); } VersionAdapters.get().removeTrampolinoMarker(marker); partyGamesGamer.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - if (partyGamesGamer.getGamer().a() >= partyGamesGamer.getGame().getSettings().getTrampolinoScoreToWin()) { - trampolinoRound.h(); + if (partyGamesGamer.getGamer().getScore() >= partyGamesGamer.getGame().getSettings().getTrampolinoScoreToWin()) { + trampolinoRound.finishRound(); } else { - trampolinoRound.a(text); + trampolinoRound.spawnMarker(text); } } } @EventHandler(priority = EventPriority.LOWEST) - public void f(PlayerMoveEvent event) { + public void onTrampolinoMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { Location location = event.getTo(); PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof TrampolinoRound var6 && location != null && !Locations.a(event.getFrom(), location)) { - if (var6.b().getPlayZone().a(location)) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof TrampolinoRound var6 && location != null && !Locations.isSameBlock(event.getFrom(), location)) { + if (var6.getRoundMap().getPlayZone().contains(location)) { Block block = location.getBlock(); Block block2 = block.getRelative(BlockFace.UP); - Entity marker = var6.getMap29().remove(block); + Entity marker = var6.getMarkers().remove(block); if (marker != null) { - this.a(marker, partyGamesGamer, var6); + this.handleTrampolinoMarkerCollect(marker, partyGamesGamer, var6); } else { - Entity marker2 = var6.getMap29().remove(block2); + Entity marker2 = var6.getMarkers().remove(block2); if (marker2 != null) { - this.a(marker2, partyGamesGamer, var6); + this.handleTrampolinoMarkerCollect(marker2, partyGamesGamer, var6); } } Block block3 = location.getBlock().getRelative(BlockFace.DOWN); - if (var6.b().getFloorZone().a(block3)) { + if (var6.getRoundMap().getFloorZone().contains(block3)) { Vector vector = player.getEyeLocation().getDirection(); vector.setY(1.27); player.setVelocity(vector); } } else { - event.setTo(var6.b().getSpawn()); + event.setTo(var6.getRoundMap().getSpawn()); } } } } @EventHandler(priority = EventPriority.LOWEST) - public void g(PlayerMoveEvent event) { + public void onVolcanoMove(PlayerMoveEvent event) { Player player = event.getPlayer(); - PartyGamesGamer partyGamesGamer = this.a(player, PartyGamesGamer.class); - if (partyGamesGamer != null && !partyGamesGamer.f()) { + PartyGamesGamer partyGamesGamer = this.getActiveGamer(player, PartyGamesGamer.class); + if (partyGamesGamer != null && !partyGamesGamer.isSpectator()) { Location location = event.getTo(); PartyGamesGame partyGamesGame = partyGamesGamer.getGame(); - if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof VolcanoRound var6 && location != null && !Locations.a(event.getFrom(), location)) { - if (var6.b().getPlayZone().a(location)) { + if (partyGamesGame.isRoundEnding() && partyGamesGame.getCurrentRound() instanceof VolcanoRound var6 && location != null && !Locations.isSameBlock(event.getFrom(), location)) { + if (var6.getRoundMap().getPlayZone().contains(location)) { Block block = location.getBlock().getRelative(BlockFace.DOWN); - if (var6.b().getFloorZone().a(block) && var6.getList17().remove(block)) { - var6.getMap31().put(block, 13); + if (var6.getRoundMap().getFloorZone().contains(block) && var6.getIntactFloorBlocks().remove(block)) { + var6.getFallingFloorBlocks().put(block, 13); } } else { - event.setTo(var6.b().getSpectator()); - partyGamesGamer.a(true); + event.setTo(var6.getRoundMap().getSpectator()); + partyGamesGamer.setTemporarySpectator(true); for (PartyGamesGamer partyGamesGamer2 : partyGamesGame.getGamers()) { - if (!partyGamesGamer2.f()) { - partyGamesGamer2.getGamer().a(partyGamesGamer2.getGamer().a() + 1); + if (!partyGamesGamer2.isSpectator()) { + partyGamesGamer2.getGamer().setScore(partyGamesGamer2.getGamer().getScore() + 1); } } - if (partyGamesGame.getGamers().a() <= 1) { - var6.h(); + if (partyGamesGame.getGamers().getAliveCount() <= 1) { + var6.finishRound(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesMap.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesMap.java index 456feea..aacb335 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesMap.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesMap.java @@ -174,8 +174,8 @@ public class PartyGamesMap extends BaseGameMap { this.partyGamesVolcano = partyGamesVolcano2; } - public void a(PartyRoundType partyRoundType) { - switch (PartyGamesRoundSwitchTable.a[partyRoundType.ordinal()]) { + public void clearRoundMap(PartyRoundType partyRoundType) { + switch (PartyGamesRoundSwitchTable.ROUND_ORDINAL_MAP[partyRoundType.ordinal()]) { case 1: this.partyGamesAnimalSlaughter = null; break; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesRoundSwitchTable.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesRoundSwitchTable.java index 01d2ba2..a39ca00 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesRoundSwitchTable.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/map/PartyGamesRoundSwitchTable.java @@ -3,61 +3,61 @@ package ro.fr33styler.arcade.game.partygames.map; import ro.fr33styler.arcade.game.partygames.round.registry.PartyRoundType; class PartyGamesRoundSwitchTable { - static final int[] a = new int[PartyRoundType.values().length]; + static final int[] ROUND_ORDINAL_MAP = new int[PartyRoundType.values().length]; static { try { - a[PartyRoundType.ANIMAL_SLAUGHTER.ordinal()] = 1; + ROUND_ORDINAL_MAP[PartyRoundType.ANIMAL_SLAUGHTER.ordinal()] = 1; } catch (NoSuchFieldError var11) { } try { - a[PartyRoundType.AVALANCHE.ordinal()] = 2; + ROUND_ORDINAL_MAP[PartyRoundType.AVALANCHE.ordinal()] = 2; } catch (NoSuchFieldError var10) { } try { - a[PartyRoundType.FROZEN_FLOOR.ordinal()] = 3; + ROUND_ORDINAL_MAP[PartyRoundType.FROZEN_FLOOR.ordinal()] = 3; } catch (NoSuchFieldError var9) { } try { - a[PartyRoundType.HOEHOEHOE.ordinal()] = 4; + ROUND_ORDINAL_MAP[PartyRoundType.HOEHOEHOE.ordinal()] = 4; } catch (NoSuchFieldError var8) { } try { - a[PartyRoundType.MINECART_RACING.ordinal()] = 5; + ROUND_ORDINAL_MAP[PartyRoundType.MINECART_RACING.ordinal()] = 5; } catch (NoSuchFieldError var7) { } try { - a[PartyRoundType.JUNGLE_JUMP.ordinal()] = 6; + ROUND_ORDINAL_MAP[PartyRoundType.JUNGLE_JUMP.ordinal()] = 6; } catch (NoSuchFieldError var6) { } try { - a[PartyRoundType.THE_FLOOR_IS_LAVA.ordinal()] = 7; + ROUND_ORDINAL_MAP[PartyRoundType.THE_FLOOR_IS_LAVA.ordinal()] = 7; } catch (NoSuchFieldError var5) { } try { - a[PartyRoundType.PIG_FISHING.ordinal()] = 8; + ROUND_ORDINAL_MAP[PartyRoundType.PIG_FISHING.ordinal()] = 8; } catch (NoSuchFieldError var4) { } try { - a[PartyRoundType.PUNCH_THE_BATS.ordinal()] = 9; + ROUND_ORDINAL_MAP[PartyRoundType.PUNCH_THE_BATS.ordinal()] = 9; } catch (NoSuchFieldError var3) { } try { - a[PartyRoundType.TRAMPOLINO.ordinal()] = 10; + ROUND_ORDINAL_MAP[PartyRoundType.TRAMPOLINO.ordinal()] = 10; } catch (NoSuchFieldError var2) { } try { - a[PartyRoundType.VOLCANO.ordinal()] = 11; + ROUND_ORDINAL_MAP[PartyRoundType.VOLCANO.ordinal()] = 11; } catch (NoSuchFieldError var1) { } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesEndingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesEndingPhase.java index 797155d..96f5e76 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesEndingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesEndingPhase.java @@ -10,37 +10,37 @@ import ro.fr33styler.arcade.platform.api.npc.Npc; import org.bukkit.Location; public class PartyGamesEndingPhase extends EndingPhase { - private int b; + private int tabRemovalTicks; private Location location; - private final PartyGamesGame game2; + private final PartyGamesGame partyGamesGame; public PartyGamesEndingPhase(PartyGamesGame game22) { super(game22); - this.game2 = game22; + this.partyGamesGame = game22; } @Override public void start() { super.start(); - this.game2.setPodiumNpcs(new Npc[Math.min(3, this.game2.getStandings().size())]); - ServerPlatform serverPlatform = this.game2.getManager().getEngine().getPlatform(); - if (!this.game2.getStandings().isEmpty()) { - this.game2.getPodiumNpcs()[0] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopFirst(), ((PartyGamesGamer)this.game2.getStandings().get(0)).toPlayer()); - this.location = Locations.a(this.game2.getMap().getTopFirst()).add(0.0, 1.75, 0.0); + this.partyGamesGame.setPodiumNpcs(new Npc[Math.min(3, this.partyGamesGame.getStandings().size())]); + ServerPlatform serverPlatform = this.partyGamesGame.getManager().getEngine().getPlatform(); + if (!this.partyGamesGame.getStandings().isEmpty()) { + this.partyGamesGame.getPodiumNpcs()[0] = serverPlatform.getNpcFactory().createPlayerNpc(this.partyGamesGame.getMap().getTopFirst(), ((PartyGamesGamer)this.partyGamesGame.getStandings().get(0)).toPlayer()); + this.location = Locations.copy(this.partyGamesGame.getMap().getTopFirst()).add(0.0, 1.75, 0.0); } - if (this.game2.getStandings().size() > 1) { - this.game2.getPodiumNpcs()[1] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopSecond(), ((PartyGamesGamer)this.game2.getStandings().get(1)).toPlayer()); + if (this.partyGamesGame.getStandings().size() > 1) { + this.partyGamesGame.getPodiumNpcs()[1] = serverPlatform.getNpcFactory().createPlayerNpc(this.partyGamesGame.getMap().getTopSecond(), ((PartyGamesGamer)this.partyGamesGame.getStandings().get(1)).toPlayer()); } - if (this.game2.getStandings().size() > 2) { - this.game2.getPodiumNpcs()[2] = serverPlatform.getNpcFactory().createPlayerNpc(this.game2.getMap().getTopThird(), ((PartyGamesGamer)this.game2.getStandings().get(2)).toPlayer()); + if (this.partyGamesGame.getStandings().size() > 2) { + this.partyGamesGame.getPodiumNpcs()[2] = serverPlatform.getNpcFactory().createPlayerNpc(this.partyGamesGame.getMap().getTopThird(), ((PartyGamesGamer)this.partyGamesGame.getStandings().get(2)).toPlayer()); } - for (PartyGamesGamer partyGamesGamer : this.game2.getGamers()) { - partyGamesGamer.a(this.game2.getMap().getTopLobby()); + for (PartyGamesGamer partyGamesGamer : this.partyGamesGame.getGamers()) { + partyGamesGamer.teleport(this.partyGamesGame.getMap().getTopLobby()); - for (Npc npc : this.game2.getPodiumNpcs()) { + for (Npc npc : this.partyGamesGame.getPodiumNpcs()) { npc.setVisible(partyGamesGamer.toPlayer(), true); } } @@ -49,19 +49,19 @@ public class PartyGamesEndingPhase extends EndingPhase { @Override public void stop() { super.stop(); - this.game2.setPodiumNpcs((ro.fr33styler.arcade.platform.api.npc.Npc[])null); - this.game2.getStandings().clear(); - this.b = 0; + this.partyGamesGame.setPodiumNpcs((ro.fr33styler.arcade.platform.api.npc.Npc[])null); + this.partyGamesGame.getStandings().clear(); + this.tabRemovalTicks = 0; this.location = null; } @Override - protected void a() { + protected void spawnFireworks() { } - protected void b() { - for (PartyGamesGamer partyGamesGamer : this.game2.getGamers()) { - for (Npc npc : this.game2.getPodiumNpcs()) { + protected void removePodiumFromTabList() { + for (PartyGamesGamer partyGamesGamer : this.partyGamesGame.getGamers()) { + for (Npc npc : this.partyGamesGame.getPodiumNpcs()) { npc.removeFromTabList(partyGamesGamer.toPlayer()); } } @@ -70,9 +70,9 @@ public class PartyGamesEndingPhase extends EndingPhase { @Override public void onTick(long longVal) { if (longVal % 20L == 0L) { - this.game2.celebrateAt(this.location); - if (this.b++ == 3) { - this.b(); + this.partyGamesGame.celebrateAt(this.location); + if (this.tabRemovalTicks++ == 3) { + this.removePodiumFromTabList(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesPlayingPhase.java index 4a6e2b0..ab8a49b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/phase/PartyGamesPlayingPhase.java @@ -16,7 +16,7 @@ public class PartyGamesPlayingPhase implements Phase { } public void start() { - this.game.getStandings().addAll(this.game.getGamers().c()); + this.game.getStandings().addAll(this.game.getGamers().values()); this.game.setRoundIndex(0); Collections.shuffle(this.game.getRoundQueue()); this.game.setCurrentRound((PartyRound)this.game.getRoundQueue().get(0)); @@ -27,7 +27,7 @@ public class PartyGamesPlayingPhase implements Phase { this.game.setRoundTicks(5); this.game.setRoundStarting(true); - this.game.getCurrentRound().f(); + this.game.getCurrentRound().prepareRound(); } public void stop() { @@ -35,7 +35,7 @@ public class PartyGamesPlayingPhase implements Phase { this.game.setCurrentRound((ro.fr33styler.arcade.game.partygames.round.base.PartyRound)null); this.game.getBossBar().removeAll(); this.game.getPlayerTeams().forEach((uuid, partyGamesTeam) -> { - this.game.getManager().getSessions().e().remove(uuid); + this.game.getManager().getSessions().getRejoinGames().remove(uuid); this.game.getManager().updateTeamStats(uuid, partyGamesTeam); }); this.game.getPlayerTeams().clear(); @@ -58,9 +58,9 @@ public class PartyGamesPlayingPhase implements Phase { case "first" -> !this.game.getStandings().isEmpty() ? ((PartyGamesGamer)this.game.getStandings().get(0)).getName() : null; case "second" -> this.game.getStandings().size() > 1 ? ((PartyGamesGamer)this.game.getStandings().get(1)).getName() : null; case "third" -> this.game.getStandings().size() > 2 ? ((PartyGamesGamer)this.game.getStandings().get(2)).getName() : null; - case "first_stars" -> !this.game.getStandings().isEmpty() ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(0)).m()) : null; - case "second_stars" -> this.game.getStandings().size() > 1 ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(1)).m()) : null; - case "third_stars" -> this.game.getStandings().size() > 2 ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(2)).m()) : null; + case "first_stars" -> !this.game.getStandings().isEmpty() ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(0)).getStars()) : null; + case "second_stars" -> this.game.getStandings().size() > 1 ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(1)).getStars()) : null; + case "third_stars" -> this.game.getStandings().size() > 2 ? String.valueOf(((PartyGamesGamer)this.game.getStandings().get(2)).getStars()) : null; default -> null; }; } @@ -79,21 +79,21 @@ public class PartyGamesPlayingPhase implements Phase { if (this.game.isRoundStarting()) { if (this.game.getRoundTicks() > 0) { this.game.setRoundTicks(this.game.getRoundTicks() - 1); - this.game.getBossBar().setTitle(this.game.getMessages().getPartyGameBossBarStart().a(this.game)); + this.game.getBossBar().setTitle(this.game.getMessages().getPartyGameBossBarStart().render(this.game)); } else { this.game.setRoundStarting(false); this.game.setRoundEnding(true); - this.game.getCurrentRound().g(); + this.game.getCurrentRound().startRound(); } } else if (this.game.isRoundRunning()) { if (this.game.getRoundTicks() > 0) { this.game.setRoundTicks(this.game.getRoundTicks() - 1); - if (!this.game.getCurrentRound().getList2().isEmpty()) { - this.game.celebrateAt(((PartyGamesGamer)this.game.getCurrentRound().getList2().get(0)).toPlayer().getEyeLocation()); + if (!this.game.getCurrentRound().getRoundStandings().isEmpty()) { + this.game.celebrateAt(((PartyGamesGamer)this.game.getCurrentRound().getRoundStandings().get(0)).toPlayer().getEyeLocation()); } } else { this.game.setRoundRunning(false); - this.game.getCurrentRound().i(); + this.game.getCurrentRound().cleanupRound(); } } else if (!this.game.isRoundEnding()) { int index = this.game.getRoundIndex() + 1; @@ -102,7 +102,7 @@ public class PartyGamesPlayingPhase implements Phase { this.game.setCurrentRound((PartyRound)this.game.getRoundQueue().get(index)); this.game.setRoundTicks(5); this.game.setRoundStarting(true); - this.game.getCurrentRound().f(); + this.game.getCurrentRound().prepareRound(); } else { this.game.finishGame(); } @@ -110,7 +110,7 @@ public class PartyGamesPlayingPhase implements Phase { } if (this.game.isRoundEnding()) { - this.game.getCurrentRound().a(longVal); + this.game.getCurrentRound().onTick(longVal); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/player/PartyGamesGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/player/PartyGamesGamer.java index 46f1ff2..e109235 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/player/PartyGamesGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/player/PartyGamesGamer.java @@ -13,7 +13,7 @@ import java.util.List; import ro.fr33styler.arcade.api.engine.text.Context; public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { - private int b; + private int stars; private PartyRoundGamer gamer; private final PartyGamesGame game; @@ -26,16 +26,16 @@ public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { return this.game; } - public int m() { - return this.b; + public int getStars() { + return this.stars; } - public void c(int index) { - this.b = index; + public void setStars(int index) { + this.stars = index; } - public int n() { - return this.gamer.a(); + public int getRoundScore() { + return this.gamer.getScore(); } public PartyRoundGamer getGamer() { @@ -56,9 +56,9 @@ public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { } if (text.equals("stars")) { - return String.valueOf(this.b); + return String.valueOf(this.stars); } else { - return text.equals("score") ? String.valueOf(this.getGamer().a()) : super.getVariable(text); + return text.equals("score") ? String.valueOf(this.getGamer().getScore()) : super.getVariable(text); } } @@ -68,7 +68,7 @@ public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { return super.getCondition(text); } - List list = !this.game.isRoundStarting() && !this.game.isRoundEnding() ? this.game.getStandings() : this.game.getCurrentRound().getList2(); + List list = !this.game.isRoundStarting() && !this.game.isRoundEnding() ? this.game.getStandings() : this.game.getCurrentRound().getRoundStandings(); for (int index = 0; index < Math.min(list.size(), 3); index++) { if (list.get(index) == this) { @@ -79,19 +79,19 @@ public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { return false; } - private void c(boolean flag) { + private void saveStatistics(boolean flag) { PartyGamesStatistics partyGamesStatistics = this.game.getManager().getData(this.getUUID()); - this.b(partyGamesStatistics.getMap()); + this.saveProperties(partyGamesStatistics.getMap()); if (flag) { this.game.getManager().updateTeamStats(this.getUUID(), this); - } else if (partyGamesStatistics.a()) { - this.game.getManager().getStorage().e().b(partyGamesStatistics); + } else if (partyGamesStatistics.isLoaded()) { + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(partyGamesStatistics); } } @Override public void leave() { - this.game.getGamers().b(this); + this.game.getGamers().remove(this); this.game.getStandings().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getEnding()) { for (Npc npc : this.game.getPodiumNpcs()) { @@ -101,17 +101,17 @@ public class PartyGamesGamer extends BaseGamer implements PartyGamesTeamMember { } if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.getCurrentRound().getList2().remove(this); - if (!this.g()) { - this.getGamer().a(this); + this.game.getCurrentRound().getRoundStandings().remove(this); + if (!this.isActiveSpectator()) { + this.getGamer().awardSurvivalPoints(this); this.game.getPlayerTeams().put(this.player.getUniqueId(), new PartyGamesTeam(this)); - this.game.getManager().getSessions().e().put(this.player.getUniqueId(), this.game.getMap().getId()); + this.game.getManager().getSessions().getRejoinGames().put(this.player.getUniqueId(), this.game.getMap().getId()); } - this.c(false); + this.saveStatistics(false); this.game.getBossBar().removePlayer(this.player); } else { - this.c(true); + this.saveStatistics(true); } super.leave(); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/round/AnimalSlaughterRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/round/AnimalSlaughterRound.java index a3c9993..8027236 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/round/AnimalSlaughterRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/round/AnimalSlaughterRound.java @@ -21,112 +21,112 @@ import ro.fr33styler.arcade.platform.compat.ArcadeMaterial; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class AnimalSlaughterRound extends PartyRound { - private int d; + private int remainingSeconds; private final Map map = new HashMap<>(); public AnimalSlaughterRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } - public Map getMap18() { + public Map getSpawnedAnimals() { return this.map; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getAnimalSlaughterName(); } - public AnimalSlaughterMap b() { + public AnimalSlaughterMap getRoundMap() { return this.game.getMap().getPartyGamesAnimalSlaughter(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PartyRoundGamer(); } @Override - public void f() { - this.d = this.game.getSettings().getAnimalSlaughterPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getAnimalSlaughterPlayTime(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getAnimalSlaughterStart(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.getBossBar().setVisible(true); this.game.getBlockedActions().remove(GameAction.ATTACK); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { partyGamesGamer.toPlayer().getInventory().setItem(0, new ItemBuilder(ArcadeMaterial.WOODEN_SWORD).setUnbreakable(true).build()); } } } @Override - public void h() { + public void finishRound() { this.game.getBlockedActions().add(GameAction.ATTACK); this.map.values().forEach(Entity::remove); this.map.clear(); this.game.getBossBar().setVisible(false); - super.h(); + super.finishRound(); } @Override public String getVariable(String text) { - return this.game.isRoundEnding() && text.equals("countdown") ? String.valueOf(this.d) : super.getVariable(text); + return this.game.isRoundEnding() && text.equals("countdown") ? String.valueOf(this.remainingSeconds) : super.getVariable(text); } - private void a(EntityType entityType, String text, int index) { - int index2 = Randoms.a().nextInt(-13, 13); - int index3 = Randoms.a().nextInt(-13, 13); - Location location = Locations.a(this.b().getSpawn()).add(index2, 0.0, index3); + private void spawnAnimal(EntityType entityType, String text, int index) { + int index2 = Randoms.current().nextInt(-13, 13); + int index3 = Randoms.current().nextInt(-13, 13); + Location location = Locations.copy(this.getRoundMap().getSpawn()).add(index2, 0.0, index3); LivingEntity livingEntity = (LivingEntity)location.getWorld().spawnEntity(location, entityType); VersionAdapters.get().setMovementSpeed(this.game.getEngine().getPlatform(), livingEntity, 0.3); - livingEntity.setCustomName(Randoms.a().nextFloat() < 0.1 ? "§c-50%" : text); + livingEntity.setCustomName(Randoms.current().nextFloat() < 0.1 ? "§c-50%" : text); livingEntity.setHealth(index); this.map.put(livingEntity.getUniqueId(), livingEntity); } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.d <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.d--; - if (this.d % 2 == 0 && this.map.size() <= 50) { + this.remainingSeconds--; + if (this.remainingSeconds % 2 == 0 && this.map.size() <= 50) { for (int index = 0; index < 4; index++) { - this.a(EntityType.CHICKEN, "§a+1", 1); + this.spawnAnimal(EntityType.CHICKEN, "§a+1", 1); } for (int index2 = 0; index2 < 2; index2++) { - this.a(EntityType.PIG, "§a+3", 2); + this.spawnAnimal(EntityType.PIG, "§a+3", 2); } - this.a(EntityType.COW, "§a+5", 3); + this.spawnAnimal(EntityType.COW, "§a+5", 3); } - this.j(); - this.game.getBossBar().setTitle(this.game.getMessages().getAnimalSlaughterTimeLeft().a(this)); + this.sortStandings(); + this.game.getBossBar().setTitle(this.game.getMessages().getAnimalSlaughterTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/AnimalSlaughterSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/AnimalSlaughterSetup.java index ac83d32..f4488a8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/AnimalSlaughterSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/AnimalSlaughterSetup.java @@ -16,18 +16,18 @@ public class AnimalSlaughterSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Animal Slaughter"); } - public AnimalSlaughterMap i() { + public AnimalSlaughterMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new AnimalSlaughterSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesAnimalSlaughter(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesAnimalSlaughter(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/step/AnimalSlaughterSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/step/AnimalSlaughterSetPlayerSpawnStep.java index 3811ff2..ae26308 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/step/AnimalSlaughterSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/animalslaughter/setup/step/AnimalSlaughterSetPlayerSpawnStep.java @@ -17,19 +17,19 @@ public class AnimalSlaughterSetPlayerSpawnStep implements ClickSetupStep { this.animalSlaughterSetup = animalSlaughterSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.animalSlaughterSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.animalSlaughterSetup.getUser().toPlayer(); - this.animalSlaughterSetup.getHotbar().a(0, () -> { + this.animalSlaughterSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.animalSlaughterSetup.i().getPlayZone().a(location)) { - this.animalSlaughterSetup.i().setSpawn(location); - this.animalSlaughterSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.animalSlaughterSetup.getRoundMap().getPlayZone().contains(location)) { + this.animalSlaughterSetup.getRoundMap().setSpawn(location); + this.animalSlaughterSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/round/AvalancheRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/round/AvalancheRound.java index cd0f9bc..3fa81a3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/round/AvalancheRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/round/AvalancheRound.java @@ -29,9 +29,9 @@ import ro.fr33styler.arcade.platform.compat.ArcadeSound; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class AvalancheRound extends PartyRound { - private int d; - private int e = 1; - private int f; + private int waveCooldownTicks; + private int wave = 1; + private int countdownSeconds; private final Set set = new HashSet<>(); private final List list = new ArrayList<>(); @@ -40,106 +40,106 @@ public class AvalancheRound extends PartyRound { } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getAvalancheName(); } - public AvalancheMap b() { + public AvalancheMap getRoundMap() { return this.game.getMap().getPartyGamesAvalanche(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PartyRoundGamer(); } @Override - protected List e() { + protected List getSidebarLines() { return this.game.getMessages().getAvalancheSidebar(); } @Override - public void f() { - this.f = 8; + public void prepareRound() { + this.countdownSeconds = 8; for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getAvalancheStart(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.getBossBar().setVisible(true); - if (this.game.getGamers().a() <= 1) { - this.h(); + if (this.game.getGamers().getAliveCount() <= 1) { + this.finishRound(); } } @Override - public void h() { + public void finishRound() { this.list.forEach(Entity::remove); this.list.clear(); this.set.forEach(block -> block.setType(Material.AIR)); this.set.clear(); this.game.getBossBar().setVisible(false); - if (this.e > 10) { + if (this.wave > 10) { this.game.getBlockedActions().add(GameAction.DAMAGE); this.game.getBlockedActions().add(GameAction.ATTACK); } - super.h(); + super.finishRound(); } @Override - public void i() { - this.e = 1; - this.d = 0; - super.i(); + public void cleanupRound() { + this.wave = 1; + this.waveCooldownTicks = 0; + super.cleanupRound(); } @Override public String getVariable(String text) { return switch (text) { - case "wave" -> String.valueOf(this.e); - case "countdown" -> this.game.isRoundEnding() ? String.valueOf(this.f) : null; + case "wave" -> String.valueOf(this.wave); + case "countdown" -> this.game.isRoundEnding() ? String.valueOf(this.countdownSeconds) : null; case "safe_points" -> String.valueOf(this.set.size()); default -> super.getVariable(text); }; } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.d == 0) { - if (this.f == 8) { - this.f = 3; + if (this.waveCooldownTicks == 0) { + if (this.countdownSeconds == 8) { + this.countdownSeconds = 3; int index = 1; - if (this.e < 7) { + if (this.wave < 7) { index = 4; - this.f = 9 - this.e; - } else if (this.e < 9) { - index = 10 - this.e; + this.countdownSeconds = 9 - this.wave; + } else if (this.wave < 9) { + index = 10 - this.wave; } this.set.forEach(block -> block.setType(Material.AIR)); this.set.clear(); while (this.set.size() < index) { - Block block2 = this.b().getFloorZone().b().getBlock(); - Block block3 = this.b().getFloorZone().c().getBlock(); - int index2 = Randoms.a().nextInt(block2.getX(), block3.getX()); - int index3 = Randoms.a().nextInt(block2.getZ(), block3.getZ()); - Block block4 = this.b().getFloorZone().a().getBlockAt(index2, block3.getY() + 4, index3); + Block block2 = this.getRoundMap().getFloorZone().getMin().getBlock(); + Block block3 = this.getRoundMap().getFloorZone().getMax().getBlock(); + int index2 = Randoms.current().nextInt(block2.getX(), block3.getX()); + int index3 = Randoms.current().nextInt(block2.getZ(), block3.getZ()); + Block block4 = this.getRoundMap().getFloorZone().getWorld().getBlockAt(index2, block3.getY() + 4, index3); if (this.set.add(block4)) { block4.setType(VersionAdapters.get().resolveMaterial(ArcadeMaterial.OAK_SLAB)); block4.getWorld().playEffect(block4.getLocation(), Effect.STEP_SOUND, block4.getType()); @@ -148,61 +148,61 @@ public class AvalancheRound extends PartyRound { for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { partyGamesGamer.sendMessage(this.game.getMessages().getAvalancheStartsIn(), this); - if (this.e == 10) { + if (this.wave == 10) { partyGamesGamer.sendMessage(this.game.getMessages().getAvalancheCanHit()); } } - if (this.e == 10) { + if (this.wave == 10) { this.game.getBlockedActions().remove(GameAction.DAMAGE); this.game.getBlockedActions().remove(GameAction.ATTACK); } } - if (this.f > 0) { - if (this.f < 4) { + if (this.countdownSeconds > 0) { + if (this.countdownSeconds < 4) { this.game.getGamers().forEach(partyGamesGamer2 -> partyGamesGamer2.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F)); } - this.game.getBossBar().setTitle(this.game.getMessages().getAvalancheBossBarNext().a(this)); - this.f--; + this.game.getBossBar().setTitle(this.game.getMessages().getAvalancheBossBarNext().render(this)); + this.countdownSeconds--; } else { - this.d = 1; - this.f = 1; - this.b().getFloorZone().a(block5 -> { - Location location = block5.getLocation().add(0.5, 20 + Randoms.a().nextInt(0, 5), 0.5); + this.waveCooldownTicks = 1; + this.countdownSeconds = 1; + this.getRoundMap().getFloorZone().forEachBlock(block5 -> { + Location location = block5.getLocation().add(0.5, 20 + Randoms.current().nextInt(0, 5), 0.5); if (location.getBlock().isEmpty()) { this.list.add((Snowball)block5.getWorld().spawn(location, Snowball.class)); } }); } - } else if (this.d == 1) { - if (this.f > 0) { - this.f--; + } else if (this.waveCooldownTicks == 1) { + if (this.countdownSeconds > 0) { + this.countdownSeconds--; } else { - this.e++; - this.d = 0; + this.wave++; + this.waveCooldownTicks = 0; this.list.clear(); - this.f = 8; + this.countdownSeconds = 8; for (PartyGamesGamer partyGamesGamer3 : this.game.getGamers()) { Player player = partyGamesGamer3.toPlayer(); Block block6 = player.getLocation().getBlock(); - if (!partyGamesGamer3.f()) { - int index4 = this.b().getFloorZone().c().getBlockY() + 4; + if (!partyGamesGamer3.isSpectator()) { + int index4 = this.getRoundMap().getFloorZone().getMax().getBlockY() + 4; if (!this.set.contains(player.getWorld().getBlockAt(block6.getX(), index4, block6.getZ()))) { - partyGamesGamer3.a(true); - player.teleport(this.b().getSpectator()); + partyGamesGamer3.setTemporarySpectator(true); + player.teleport(this.getRoundMap().getSpectator()); player.playEffect(EntityEffect.HURT); for (PartyGamesGamer partyGamesGamer4 : this.game.getGamers()) { - if (!partyGamesGamer4.f()) { - partyGamesGamer4.getGamer().a(partyGamesGamer4.getGamer().a() + 1); + if (!partyGamesGamer4.isSpectator()) { + partyGamesGamer4.getGamer().setScore(partyGamesGamer4.getGamer().getScore() + 1); } } - if (this.game.getGamers().a() <= 1) { - this.h(); + if (this.game.getGamers().getAliveCount() <= 1) { + this.finishRound(); return; } } @@ -212,11 +212,11 @@ public class AvalancheRound extends PartyRound { } } - if (this.d == 1 && longVal % 5L == 0L) { - Context context = Contexts.a((ConditionProvider) text -> text.equals("COVER") ? longVal % 10L == 0L : null); - this.game.getBossBar().setTitle(this.game.getMessages().getAvalancheBossBarCover().a(context)); + if (this.waveCooldownTicks == 1 && longVal % 5L == 0L) { + Context context = Contexts.ofConditions((ConditionProvider) text -> text.equals("COVER") ? longVal % 10L == 0L : null); + this.game.getBossBar().setTitle(this.game.getMessages().getAvalancheBossBarCover().render(context)); } - super.a(longVal); + super.onTick(longVal); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/AvalancheSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/AvalancheSetup.java index 567d71a..8495234 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/AvalancheSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/AvalancheSetup.java @@ -16,18 +16,18 @@ public class AvalancheSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Avalanche"); } - public AvalancheMap i() { + public AvalancheMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new AvalancheSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesAvalanche(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesAvalanche(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetFloorZoneStep.java index 497ee70..c5f4aed 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetFloorZoneStep.java @@ -18,35 +18,35 @@ public class AvalancheSetFloorZoneStep implements ClickSetupStep { this.avalancheSetup = avalancheSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.avalancheSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.avalancheSetup.getUser(); - this.avalancheSetup.getHotbar().a(0, () -> { + this.avalancheSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.avalancheSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.avalancheSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.avalancheSetup.i().getPlayZone().a(cuboid)) { + if (!this.avalancheSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe floor must be 1 block thick!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.avalancheSetup.i().setFloorZone(cuboid); - this.avalancheSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.avalancheSetup.getRoundMap().setFloorZone(cuboid); + this.avalancheSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetPlayerSpawnStep.java index d6d698d..1bf8217 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/avalanche/setup/step/AvalancheSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class AvalancheSetPlayerSpawnStep implements ClickSetupStep { this.avalancheSetup = avalancheSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.avalancheSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.avalancheSetup.getUser().toPlayer(); - this.avalancheSetup.getHotbar().a(0, () -> { + this.avalancheSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.avalancheSetup.i().getPlayZone().a(location)) { - this.avalancheSetup.i().setSpawn(location); - this.avalancheSetup.a(new AvalancheSetFloorZoneStep(this.avalancheSetup)); + if (this.avalancheSetup.getRoundMap().getPlayZone().contains(location)) { + this.avalancheSetup.getRoundMap().setSpawn(location); + this.avalancheSetup.advanceStep(new AvalancheSetFloorZoneStep(this.avalancheSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRound.java index 1d05024..c378947 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRound.java @@ -12,117 +12,117 @@ import ro.fr33styler.arcade.api.engine.text.Context; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public abstract class PartyRound implements Context { - protected int a; - protected List list2; + protected int elapsedSeconds; + protected List roundStandings; protected final PartyGamesGame game; protected PartyRound(PartyGamesGame game2) { this.game = game2; } - public abstract String a(); + public abstract String getRoundName(); - public abstract PartyRoundMap b(); + public abstract PartyRoundMap getRoundMap(); - public abstract PartyRoundGamer c(); + public abstract PartyRoundGamer createRoundGamer(); - public List getList2() { - return this.list2; + public List getRoundStandings() { + return this.roundStandings; } - protected List e() { + protected List getSidebarLines() { return this.game.getMessages().getPartyGameSidebar(); } - public void f() { - this.list2 = new ArrayList<>(this.game.getStandings()); - this.b().getPlayZone().b(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); - this.game.getBossBar().setTitle(this.game.getMessages().getPartyGameBossBarStart().a(this.game)); + public void prepareRound() { + this.roundStandings = new ArrayList<>(this.game.getStandings()); + this.getRoundMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.game.getBossBar().setTitle(this.game.getMessages().getPartyGameBossBarStart().render(this.game)); this.game.getBossBar().setVisible(true); - this.game.getGamers().a(this.e()); + this.game.getGamers().updateSidebars(this.getSidebarLines()); } - public void g() { + public void startRound() { this.game.getBossBar().setVisible(false); } - public void h() { - this.j(); - if (!this.list2.isEmpty()) { - PartyGamesGamer partyGamesGamer = this.list2.get(0); - partyGamesGamer.c(partyGamesGamer.m() + 3); + public void finishRound() { + this.sortStandings(); + if (!this.roundStandings.isEmpty()) { + PartyGamesGamer partyGamesGamer = this.roundStandings.get(0); + partyGamesGamer.setStars(partyGamesGamer.getStars() + 3); } - if (this.list2.size() > 1) { - PartyGamesGamer partyGamesGamer2 = this.list2.get(1); - partyGamesGamer2.c(partyGamesGamer2.m() + 2); + if (this.roundStandings.size() > 1) { + PartyGamesGamer partyGamesGamer2 = this.roundStandings.get(1); + partyGamesGamer2.setStars(partyGamesGamer2.getStars() + 2); } - if (this.list2.size() > 2) { - PartyGamesGamer partyGamesGamer3 = this.list2.get(2); - partyGamesGamer3.c(partyGamesGamer3.m() + 1); + if (this.roundStandings.size() > 2) { + PartyGamesGamer partyGamesGamer3 = this.roundStandings.get(2); + partyGamesGamer3.setStars(partyGamesGamer3.getStars() + 1); } for (PartyGamesGamer partyGamesGamer4 : this.game.getGamers()) { - partyGamesGamer4.a(this.game.getMessages().getRoundTop()); + partyGamesGamer4.sendMessages(this.game.getMessages().getRoundTop()); } - this.game.getStandings().sort(Comparator.comparingInt(PartyGamesGamer::m).reversed()); + this.game.getStandings().sort(Comparator.comparingInt(PartyGamesGamer::getStars).reversed()); this.game.setRoundTicks(3); this.game.setRoundEnding(false); this.game.setRoundRunning(true); - this.game.getGamers().a(this.game.getMessages().getSidebarPlaying()); + this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarPlaying()); } - public void i() { - this.list2 = null; - this.a = 0; + public void cleanupRound() { + this.roundStandings = null; + this.elapsedSeconds = 0; for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - if (partyGamesGamer.getSpectatorOptions().f()) { - partyGamesGamer.a(false); + if (partyGamesGamer.isSpectator()) { + if (partyGamesGamer.getSpectatorOptions().isTemporary()) { + partyGamesGamer.setTemporarySpectator(false); } } else { - Players.a(partyGamesGamer); - partyGamesGamer.getGamer().a(partyGamesGamer); + Players.reset(partyGamesGamer); + partyGamesGamer.getGamer().awardSurvivalPoints(partyGamesGamer); } } - this.b().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.getRoundMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); } - protected void j() { - this.list2.sort(Comparator.comparingInt(PartyGamesGamer::n).reversed()); + protected void sortStandings() { + this.roundStandings.sort(Comparator.comparingInt(PartyGamesGamer::getRoundScore).reversed()); } public String getVariable(String text) { return switch (text) { - case "left" -> String.valueOf(this.game.getGamers().a()); - case "elapsed" -> String.valueOf(this.a); - case "first" -> !this.list2.isEmpty() ? this.list2.get(0).getName() : null; - case "second" -> this.list2.size() > 1 ? this.list2.get(1).getName() : null; - case "third" -> this.list2.size() > 2 ? this.list2.get(2).getName() : null; - case "first_score" -> !this.list2.isEmpty() ? String.valueOf(this.list2.get(0).getGamer().a()) : null; - case "second_score" -> this.list2.size() > 1 ? String.valueOf(this.list2.get(1).getGamer().a()) : null; - case "third_score" -> this.list2.size() > 2 ? String.valueOf(this.list2.get(2).getGamer().a()) : null; + case "left" -> String.valueOf(this.game.getGamers().getAliveCount()); + case "elapsed" -> String.valueOf(this.elapsedSeconds); + case "first" -> !this.roundStandings.isEmpty() ? this.roundStandings.get(0).getName() : null; + case "second" -> this.roundStandings.size() > 1 ? this.roundStandings.get(1).getName() : null; + case "third" -> this.roundStandings.size() > 2 ? this.roundStandings.get(2).getName() : null; + case "first_score" -> !this.roundStandings.isEmpty() ? String.valueOf(this.roundStandings.get(0).getGamer().getScore()) : null; + case "second_score" -> this.roundStandings.size() > 1 ? String.valueOf(this.roundStandings.get(1).getGamer().getScore()) : null; + case "third_score" -> this.roundStandings.size() > 2 ? String.valueOf(this.roundStandings.get(2).getGamer().getScore()) : null; default -> null; }; } public Boolean getCondition(String text) { return switch (text) { - case "FIRST" -> !this.list2.isEmpty(); - case "SECOND" -> this.list2.size() > 1; - case "THIRD" -> this.list2.size() > 2; + case "FIRST" -> !this.roundStandings.isEmpty(); + case "SECOND" -> this.roundStandings.size() > 1; + case "THIRD" -> this.roundStandings.size() > 2; default -> null; }; } - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - this.a++; - this.game.getGamers().a(this.e()); + this.elapsedSeconds++; + this.game.getGamers().updateSidebars(this.getSidebarLines()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundGamer.java index 16b03f0..d4dbcc9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundGamer.java @@ -3,21 +3,21 @@ package ro.fr33styler.arcade.game.partygames.round.base; import ro.fr33styler.arcade.game.partygames.player.PartyGamesGamer; public class PartyRoundGamer { - private int a; + private int score; - public int a() { - return this.a; + public int getScore() { + return this.score; } - public void a(int index) { - this.a = index; + public void setScore(int index) { + this.score = index; } - public void a(PartyGamesGamer partyGamesGamer) { - if (!partyGamesGamer.f()) { + public void awardSurvivalPoints(PartyGamesGamer partyGamesGamer) { + if (!partyGamesGamer.isSpectator()) { for (PartyGamesGamer partyGamesGamer2 : partyGamesGamer.getGame().getGamers()) { - if (partyGamesGamer != partyGamesGamer2 && !partyGamesGamer2.f()) { - partyGamesGamer2.getGamer().a(partyGamesGamer2.getGamer().a() + 1); + if (partyGamesGamer != partyGamesGamer2 && !partyGamesGamer2.isSpectator()) { + partyGamesGamer2.getGamer().setScore(partyGamesGamer2.getGamer().getScore() + 1); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundSetup.java index c7e83b7..ee80b52 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/base/PartyRoundSetup.java @@ -11,41 +11,41 @@ import ro.fr33styler.arcade.game.partygames.map.PartyGamesMap; import ro.fr33styler.arcade.game.partygames.setup.step.PartyGamesSetPlayZoneStep; public abstract class PartyRoundSetup extends ArenaSetup { - protected final PartyGamesMap map2; - private final PartyGamesManager d; + protected final PartyGamesMap partyGamesMap; + private final PartyGamesManager manager; private final SetupTarget setupTarget; public PartyRoundSetup(DefaultUser defaultUser, PartyGamesManager partyGamesManager, PartyGamesMap map22, SetupTarget setupTarget2, String text) { super(defaultUser, text); - this.d = partyGamesManager; - this.map2 = map22; + this.manager = partyGamesManager; + this.partyGamesMap = map22; this.setupTarget = setupTarget2; this.setupStep = new PartyGamesSetPlayZoneStep(this); } - public PartyGamesMap getMap2() { - return this.map2; + public PartyGamesMap getPartyGamesMap() { + return this.partyGamesMap; } - public abstract PartyRoundMap i(); + public abstract PartyRoundMap getRoundMap(); - public abstract SetupStep j(); + public abstract SetupStep createInitialStep(); @Override - public void f() { + public void finish() { if (this.setupTarget == SetupTarget.TEMPLATE) { - GameTemplate gameTemplate = this.d.getSessions().e(this.map2.getId()); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(this.partyGamesMap.getId()); if (gameTemplate != null) { - this.d.getStorage().getStorage5().a(gameTemplate); + this.manager.getStorage().getTemplateStorage().save(gameTemplate); } } else { - this.d.getStorage().getStorage().a(this.map2); - PartyGamesGame partyGamesGame = (PartyGamesGame)this.d.getSessions().b(this.map2.getId()); + this.manager.getStorage().getStorage().save(this.partyGamesMap); + PartyGamesGame partyGamesGame = (PartyGamesGame)this.manager.getSessions().getGame(this.partyGamesMap.getId()); if (partyGamesGame != null) { - partyGamesGame.getRoundQueue().add(this.i().getPartyRoundType().a(partyGamesGame)); + partyGamesGame.getRoundQueue().add(this.getRoundMap().getPartyRoundType().createRound(partyGamesGame)); } } - super.f(); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/player/FrozenFloorGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/player/FrozenFloorGamer.java index 47a8478..85e3201 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/player/FrozenFloorGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/player/FrozenFloorGamer.java @@ -6,19 +6,19 @@ import ro.fr33styler.arcade.game.partygames.round.base.PartyRoundGamer; import ro.fr33styler.arcade.api.engine.text.Context; public class FrozenFloorGamer extends PartyRoundGamer implements Context { - private int a; + private int shots; private PartyGamesGamer gamer; - private long c = System.currentTimeMillis(); + private long lastShotTimestamp = System.currentTimeMillis(); - public int b() { - return this.a; + public int getShots() { + return this.shots; } - public void b(int index) { - this.a = index; + public void setShots(int index) { + this.shots = index; } - public PartyGamesGamer getGamer3() { + public PartyGamesGamer getLastAttacker() { return this.gamer; } @@ -26,15 +26,15 @@ public class FrozenFloorGamer extends PartyRoundGamer implements Context { this.gamer = gamer2; } - public long d() { - return this.c; + public long getLastShotTimestamp() { + return this.lastShotTimestamp; } - public void a(long longVal) { - this.c = longVal; + public void setLastShotTimestamp(long longVal) { + this.lastShotTimestamp = longVal; } public String getVariable(String text) { - return text.equals("shots") ? String.valueOf(this.a) : null; + return text.equals("shots") ? String.valueOf(this.shots) : null; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/round/FrozenFloorRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/round/FrozenFloorRound.java index 2c29006..73e8814 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/round/FrozenFloorRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/round/FrozenFloorRound.java @@ -20,7 +20,7 @@ import ro.fr33styler.arcade.platform.compat.ArcadeMaterial; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class FrozenFloorRound extends PartyRound { - private int d; + private int remainingSeconds; private BlockDistanceIndex blockDistanceIndex; public FrozenFloorRound(PartyGamesGame partyGamesGame) { @@ -28,61 +28,61 @@ public class FrozenFloorRound extends PartyRound { } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getFrozenFloorName(); } - public FrozenFloorMap b() { + public FrozenFloorMap getRoundMap() { return this.game.getMap().getPartyGamesFrozenFloor(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new FrozenFloorGamer(); } @Override - protected List e() { + protected List getSidebarLines() { return this.game.getMessages().getFrozenFloorSidebar(); } @Override - public void f() { - this.d = this.game.getSettings().getFrozenFloorPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getFrozenFloorPlayTime(); this.game.setGameEnding(true); int index = 0; for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { partyGamesGamer.toPlayer().setWalkSpeed(0.0F); - partyGamesGamer.a((Location)this.b().getSpawns().get(index++ % this.b().getSpawns().size())); + partyGamesGamer.teleport((Location)this.getRoundMap().getSpawns().get(index++ % this.getRoundMap().getSpawns().size())); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getFrozenFloorStart(), this.game); } - this.blockDistanceIndex = new BlockDistanceIndex(this.b().getSpectator()); - this.b().getFloorZone().a(block -> { + this.blockDistanceIndex = new BlockDistanceIndex(this.getRoundMap().getSpectator()); + this.getRoundMap().getFloorZone().forEachBlock(block -> { if (!block.isEmpty()) { - this.blockDistanceIndex.a(block); + this.blockDistanceIndex.add(block); } }); - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.setGameEnding(false); this.game.getBlockedActions().remove(GameAction.ATTACK); this.game.getBlockedActions().remove(GameAction.DAMAGE); this.game.getBlockedActions().remove(GameAction.INTERACT); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { Player player = partyGamesGamer.toPlayer(); player.setWalkSpeed(0.2F); @@ -92,39 +92,39 @@ public class FrozenFloorRound extends PartyRound { } } - if (this.game.getGamers().a() <= 1) { - this.h(); + if (this.game.getGamers().getAliveCount() <= 1) { + this.finishRound(); } } @Override - public void h() { + public void finishRound() { this.blockDistanceIndex = null; this.game.getBlockedActions().add(GameAction.ATTACK); this.game.getBlockedActions().add(GameAction.DAMAGE); this.game.getBlockedActions().add(GameAction.INTERACT); - super.h(); + super.finishRound(); } @Override public String getVariable(String text) { if (this.game.isRoundEnding() && text.equals("countdown")) { - return String.valueOf(this.d); + return String.valueOf(this.remainingSeconds); } else { - return text.equals("alive") ? String.valueOf(this.game.getGamers().a()) : super.getVariable(text); + return text.equals("alive") ? String.valueOf(this.game.getGamers().getAliveCount()) : super.getVariable(text); } } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 5L == 0L) { - int index = this.blockDistanceIndex.b() / ((this.d + 1) * 4); - if (this.d == 0) { - index = this.blockDistanceIndex.b(); + int index = this.blockDistanceIndex.size() / ((this.remainingSeconds + 1) * 4); + if (this.remainingSeconds == 0) { + index = this.blockDistanceIndex.size(); } - while (this.blockDistanceIndex.b() > 0 && index >= 1) { - for (Block block : this.blockDistanceIndex.c()) { + while (this.blockDistanceIndex.size() > 0 && index >= 1) { + for (Block block : this.blockDistanceIndex.pollFarthest()) { this.game.getRollbackQueue().add(block.getState()); block.setType(Material.AIR); } @@ -133,10 +133,10 @@ public class FrozenFloorRound extends PartyRound { } } - if (longVal % 20L == 0L && this.d > 0) { - this.d--; + if (longVal % 20L == 0L && this.remainingSeconds > 0) { + this.remainingSeconds--; } - super.a(longVal); + super.onTick(longVal); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/FrozenFloorSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/FrozenFloorSetup.java index 4d72241..666c380 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/FrozenFloorSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/FrozenFloorSetup.java @@ -16,18 +16,18 @@ public class FrozenFloorSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Frozen Floor"); } - public FrozenFloorMap i() { + public FrozenFloorMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new FrozenFloorSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesFrozenFloor(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesFrozenFloor(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetFloorZoneStep.java index 8a2770d..2fe0a98 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetFloorZoneStep.java @@ -18,33 +18,33 @@ public class FrozenFloorSetFloorZoneStep implements ClickSetupStep { this.frozenFloorSetup = frozenFloorSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.frozenFloorSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.frozenFloorSetup.getUser(); - this.frozenFloorSetup.getHotbar().a(0, () -> { + this.frozenFloorSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.frozenFloorSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.frozenFloorSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.frozenFloorSetup.i().getPlayZone().a(cuboid)) { + if (!this.frozenFloorSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.frozenFloorSetup.i().setFloorZone(cuboid); - this.frozenFloorSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.frozenFloorSetup.getRoundMap().setFloorZone(cuboid); + this.frozenFloorSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetPlayerSpawnStep.java index ab2c236..e4c4f19 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/frozenfloor/setup/step/FrozenFloorSetPlayerSpawnStep.java @@ -16,27 +16,27 @@ public class FrozenFloorSetPlayerSpawnStep implements ClickSetupStep { this.frozenFloorSetup = frozenFloorSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.frozenFloorSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.frozenFloorSetup.getUser().toPlayer(); - this.frozenFloorSetup.getHotbar().a(0, () -> { + this.frozenFloorSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.frozenFloorSetup.i().getPlayZone().a(location)) { - this.frozenFloorSetup.i().getSpawns().add(location); - player.sendMessage("§eSpawn added! §8(§b" + this.frozenFloorSetup.i().getSpawns().size() + "§8)"); + if (this.frozenFloorSetup.getRoundMap().getPlayZone().contains(location)) { + this.frozenFloorSetup.getRoundMap().getSpawns().add(location); + player.sendMessage("§eSpawn added! §8(§b" + this.frozenFloorSetup.getRoundMap().getSpawns().size() + "§8)"); } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.frozenFloorSetup.getHotbar().a(1, () -> { - this.frozenFloorSetup.i().getSpawns().clear(); + this.frozenFloorSetup.getHotbar().setSlot(1, () -> { + this.frozenFloorSetup.getRoundMap().getSpawns().clear(); player.sendMessage("§eSpawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset spawns").build()); - this.frozenFloorSetup.getHotbar().a(2, () -> this.frozenFloorSetup.a(new FrozenFloorSetFloorZoneStep(this.frozenFloorSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); + this.frozenFloorSetup.getHotbar().setSlot(2, () -> this.frozenFloorSetup.advanceStep(new FrozenFloorSetFloorZoneStep(this.frozenFloorSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/player/HoeHoeHoeGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/player/HoeHoeHoeGamer.java index b32f5c5..a47b9a3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/player/HoeHoeHoeGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/player/HoeHoeHoeGamer.java @@ -25,13 +25,13 @@ public class HoeHoeHoeGamer extends PartyRoundGamer implements Context { if (text.equals("color")) { return (this.teamColor == null ? ChatColor.GOLD : this.teamColor.getChatColor()).toString(); } else if (text.equals("color_name")) { - return this.teamColor == null ? this.messages.getColorSpectator() : this.teamColor.a(this.messages); + return this.teamColor == null ? this.messages.getColorSpectator() : this.teamColor.getDisplayName(this.messages); } else { return null; } } @Override - public void a(PartyGamesGamer partyGamesGamer) { + public void awardSurvivalPoints(PartyGamesGamer partyGamesGamer) { } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/round/HoeHoeHoeRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/round/HoeHoeHoeRound.java index 4e6b153..36b697e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/round/HoeHoeHoeRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/round/HoeHoeHoeRound.java @@ -12,92 +12,92 @@ import ro.fr33styler.arcade.game.partygames.team.PartyGamesTeamColor; import org.bukkit.Material; public class HoeHoeHoeRound extends PartyRound { - private int d; + private int remainingSeconds; public HoeHoeHoeRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getHoeHoeHoeName(); } - public HoeHoeHoeMap b() { + public HoeHoeHoeMap getRoundMap() { return this.game.getMap().getPartyGamesHoehoehoe(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new HoeHoeHoeGamer(this.game.getMessages(), null); } @Override - public void f() { - this.d = this.game.getSettings().getHoeHoeHoePlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getHoeHoeHoePlayTime(); int index = 0; PartyGamesTeamColor[] partyGamesTeamColors = PartyGamesTeamColor.values(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); - partyGamesGamer.setGamer(this.c()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); + partyGamesGamer.setGamer(this.createRoundGamer()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); partyGamesGamer.setGamer(new HoeHoeHoeGamer(this.game.getMessages(), partyGamesTeamColors[index++])); } partyGamesGamer.sendMessages(this.game.getMessages().getHoeHoeHoeStart(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.getBossBar().setVisible(true); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { - partyGamesGamer.toPlayer().getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_HOE).setDisplayName(this.game.getMessages().getHoeHoeHoeItem().a((HoeHoeHoeGamer)partyGamesGamer.getGamer())).build()); + if (!partyGamesGamer.isSpectator()) { + partyGamesGamer.toPlayer().getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_HOE).setDisplayName(this.game.getMessages().getHoeHoeHoeItem().render((HoeHoeHoeGamer)partyGamesGamer.getGamer())).build()); } } } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.game.getBossBar().setVisible(false); } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.d <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.d--; - this.j(); + this.remainingSeconds--; + this.sortStandings(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { partyGamesGamer.sendActionBar(this.game.getMessages().getHoeHoeHoeYourColor(), (HoeHoeHoeGamer)partyGamesGamer.getGamer()); } } - this.game.getBossBar().setTitle(this.game.getMessages().getHoeHoeHoeTimeLeft().a(this)); + this.game.getBossBar().setTitle(this.game.getMessages().getHoeHoeHoeTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } @Override public String getVariable(String text) { if (text.equals("countdown")) { - return this.game.isRoundEnding() ? String.valueOf(this.d) : null; + return this.game.isRoundEnding() ? String.valueOf(this.remainingSeconds) : null; } else { return super.getVariable(text); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/HoeHoeHoeSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/HoeHoeHoeSetup.java index 34d4d3c..55f553d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/HoeHoeHoeSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/HoeHoeHoeSetup.java @@ -16,18 +16,18 @@ public class HoeHoeHoeSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "HoeHoeHoe"); } - public HoeHoeHoeMap i() { + public HoeHoeHoeMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new HoeHoeHoeSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesHoehoehoe(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesHoehoehoe(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetFloorZoneStep.java index ebabdfc..49a057c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetFloorZoneStep.java @@ -18,35 +18,35 @@ public class HoeHoeHoeSetFloorZoneStep implements ClickSetupStep { this.hoeHoeHoeSetup = hoeHoeHoeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.hoeHoeHoeSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.hoeHoeHoeSetup.getUser(); - this.hoeHoeHoeSetup.getHotbar().a(0, () -> { + this.hoeHoeHoeSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.hoeHoeHoeSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.hoeHoeHoeSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.hoeHoeHoeSetup.i().getPlayZone().a(cuboid)) { + if (!this.hoeHoeHoeSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe floor must be 1 block thick!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.hoeHoeHoeSetup.i().setFloorZone(cuboid); - this.hoeHoeHoeSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.hoeHoeHoeSetup.getRoundMap().setFloorZone(cuboid); + this.hoeHoeHoeSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetPlayerSpawnStep.java index b7bb49d..81c29aa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/hoehoehoe/setup/step/HoeHoeHoeSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class HoeHoeHoeSetPlayerSpawnStep implements ClickSetupStep { this.hoeHoeHoeSetup = hoeHoeHoeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.hoeHoeHoeSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.hoeHoeHoeSetup.getUser().toPlayer(); - this.hoeHoeHoeSetup.getHotbar().a(0, () -> { + this.hoeHoeHoeSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.hoeHoeHoeSetup.i().getPlayZone().a(location)) { - this.hoeHoeHoeSetup.i().setSpawn(location); - this.hoeHoeHoeSetup.a(new HoeHoeHoeSetFloorZoneStep(this.hoeHoeHoeSetup)); + if (this.hoeHoeHoeSetup.getRoundMap().getPlayZone().contains(location)) { + this.hoeHoeHoeSetup.getRoundMap().setSpawn(location); + this.hoeHoeHoeSetup.advanceStep(new HoeHoeHoeSetFloorZoneStep(this.hoeHoeHoeSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/round/JungleJumpRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/round/JungleJumpRound.java index 445759b..e42b979 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/round/JungleJumpRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/round/JungleJumpRound.java @@ -13,16 +13,16 @@ public class JungleJumpRound extends ParkourRound { } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getJungleJumpName(); } - public JungleJumpMap b() { + public JungleJumpMap getRoundMap() { return this.game.getMap().getPartyGamesJungleJump(); } @Override - public List l() { + public List getStartMessages() { return this.game.getMessages().getJungleJumpStart(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/setup/JungleJumpSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/setup/JungleJumpSetup.java index b3bb448..2182f44 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/setup/JungleJumpSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/junglejump/setup/JungleJumpSetup.java @@ -16,18 +16,18 @@ public class JungleJumpSetup extends ParkourSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Jungle Jump"); } - public JungleJumpMap i() { + public JungleJumpMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new ParkourSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesJungleJump(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesJungleJump(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/player/MinecartRacingGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/player/MinecartRacingGamer.java index 4974c42..a6f62a6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/player/MinecartRacingGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/player/MinecartRacingGamer.java @@ -16,33 +16,33 @@ import ro.fr33styler.arcade.platform.compat.GameBossBar; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class MinecartRacingGamer extends PartyRoundGamer implements Context { - private Minecart a; + private Minecart minecart; private Vector vector; - private double c = 0.15; - private final GameBossBar d; + private double speed = 0.15; + private final GameBossBar speedBossBar; private final PartyGamesMessages messages; private final MinecartRacingLane minecartRacingLane; public MinecartRacingGamer(ServerPlatform serverPlatform, MinecartRacingLane minecartRacingLane2, PartyGamesMessages messages2) { this.minecartRacingLane = minecartRacingLane2; this.messages = messages2; - this.d = VersionAdapters.get().createBossBar(serverPlatform, messages2.getMinecartRacingSpeed().a(this), BossBarColor.WHITE); + this.speedBossBar = VersionAdapters.get().createBossBar(serverPlatform, messages2.getMinecartRacingSpeed().render(this), BossBarColor.WHITE); } public MinecartRacingLane getMinecartRacingLane() { return this.minecartRacingLane; } - public GameBossBar c() { - return this.d; + public GameBossBar getSpeedBossBar() { + return this.speedBossBar; } - public double d() { - return this.c; + public double getSpeed() { + return this.speed; } - public void a(double doubleVal) { - this.c = doubleVal; + public void setSpeed(double doubleVal) { + this.speed = doubleVal; } public Vector getVector() { @@ -53,30 +53,30 @@ public class MinecartRacingGamer extends PartyRoundGamer implements Context { this.vector = vector2; } - public Minecart f() { - return this.a; + public Minecart getMinecart() { + return this.minecart; } - public void a(Minecart minecart) { - this.a = minecart; + public void setMinecart(Minecart minecart) { + this.minecart = minecart; } @Override - public void a(PartyGamesGamer partyGamesGamer) { - this.d.removeAll(); - if (this.a != null) { + public void awardSurvivalPoints(PartyGamesGamer partyGamesGamer) { + this.speedBossBar.removeAll(); + if (this.minecart != null) { partyGamesGamer.toPlayer().eject(); - this.a.remove(); + this.minecart.remove(); } - super.a(partyGamesGamer); + super.awardSurvivalPoints(partyGamesGamer); } public String getVariable(String text) { return switch (text) { - case "speed" -> Strings.a(this.a == null ? 0.0 : this.a.getVelocity().lengthSquared() * 15.0, 2); + case "speed" -> Strings.formatFixedDecimal(this.minecart == null ? 0.0 : this.minecart.getVelocity().lengthSquared() * 15.0, 2); case "color" -> (this.minecartRacingLane == null ? ChatColor.GOLD : this.minecartRacingLane.getColor().getChatColor()).toString(); - case "color_name" -> this.minecartRacingLane == null ? this.messages.getColorSpectator() : this.minecartRacingLane.getColor().a(this.messages); + case "color_name" -> this.minecartRacingLane == null ? this.messages.getColorSpectator() : this.minecartRacingLane.getColor().getDisplayName(this.messages); default -> null; }; } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/round/MinecartRacingRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/round/MinecartRacingRound.java index 9950cec..21b0613 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/round/MinecartRacingRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/round/MinecartRacingRound.java @@ -29,56 +29,56 @@ public class MinecartRacingRound extends PartyRound { super(partyGamesGame); } - public Set getSet9() { + public Set getMinecarts() { return this.set; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getMinecartRacingName(); } - public MinecartRacingMap b() { + public MinecartRacingMap getRoundMap() { return this.game.getMap().getPartyGamesMinecartRacing(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new MinecartRacingGamer(this.game.getEngine().getPlatform(), null, this.game.getMessages()); } @Override - public void f() { + public void prepareRound() { int index = 0; this.game.setGameEnding(true); - MinecartRacingLane[] minecartRacingLanes = this.b().getColorsData().values().toArray(new MinecartRacingLane[0]); + MinecartRacingLane[] minecartRacingLanes = this.getRoundMap().getColorsData().values().toArray(new MinecartRacingLane[0]); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); - partyGamesGamer.setGamer(this.c()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); + partyGamesGamer.setGamer(this.createRoundGamer()); } else { partyGamesGamer.toPlayer().setWalkSpeed(0.0F); MinecartRacingLane minecartRacingLane = minecartRacingLanes[index]; - partyGamesGamer.a(minecartRacingLane.getSpawn()); + partyGamesGamer.teleport(minecartRacingLane.getSpawn()); partyGamesGamer.setGamer(new MinecartRacingGamer(this.game.getEngine().getPlatform(), minecartRacingLane, this.game.getMessages())); index++; } - partyGamesGamer.a(this.game.getMessages().getMinecartRacingStart()); + partyGamesGamer.sendMessages(this.game.getMessages().getMinecartRacingStart()); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.setGameEnding(false); this.game.getBlockedActions().remove(GameAction.INTERACT); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { Player player = partyGamesGamer.toPlayer(); player.setWalkSpeed(0.2F); MinecartRacingGamer minecartRacingGamer = (MinecartRacingGamer)partyGamesGamer.getGamer(); @@ -93,37 +93,37 @@ public class MinecartRacingRound extends PartyRound { Minecart minecart = (Minecart)location.getWorld().spawn(location, Minecart.class); minecart.setMaxSpeed(100.0); VersionAdapters.get().setInvulnerable(this.game.getEngine().getPlatform(), minecart, true); - minecartRacingGamer.a(minecart); + minecartRacingGamer.setMinecart(minecart); minecartRacingGamer.setVector(location.getDirection()); - this.set.add(minecartRacingGamer.f()); - VersionAdapters.get().setVehiclePassenger(minecartRacingGamer.f(), player); - minecartRacingGamer.c().addPlayer(player); + this.set.add(minecartRacingGamer.getMinecart()); + VersionAdapters.get().setVehiclePassenger(minecartRacingGamer.getMinecart(), player); + minecartRacingGamer.getSpeedBossBar().addPlayer(player); } } } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.game.getBlockedActions().add(GameAction.INTERACT); this.set.clear(); } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - this.j(); + this.sortStandings(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { MinecartRacingGamer minecartRacingGamer = (MinecartRacingGamer)partyGamesGamer.getGamer(); - minecartRacingGamer.a((int)Locations.c(partyGamesGamer.toPlayer().getLocation(), minecartRacingGamer.getMinecartRacingLane().getSpawn())); - minecartRacingGamer.f().setVelocity(minecartRacingGamer.getVector().clone().multiply(minecartRacingGamer.d())); - minecartRacingGamer.c().setTitle(this.game.getMessages().getMinecartRacingSpeed().a(minecartRacingGamer)); + minecartRacingGamer.setScore((int)Locations.distanceSquaredXZ(partyGamesGamer.toPlayer().getLocation(), minecartRacingGamer.getMinecartRacingLane().getSpawn())); + minecartRacingGamer.getMinecart().setVelocity(minecartRacingGamer.getVector().clone().multiply(minecartRacingGamer.getSpeed())); + minecartRacingGamer.getSpeedBossBar().setTitle(this.game.getMessages().getMinecartRacingSpeed().render(minecartRacingGamer)); } } } - super.a(longVal); + super.onTick(longVal); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/MinecartRacingSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/MinecartRacingSetup.java index 3dc0a3c..6b0c680 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/MinecartRacingSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/MinecartRacingSetup.java @@ -16,18 +16,18 @@ public class MinecartRacingSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Minecart Racing"); } - public MinecartRacingMap i() { + public MinecartRacingMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new MinecartRacingSetBreakZoneStep(this); } @Override - public void f() { - this.map2.setPartyGamesMinecartRacing(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesMinecartRacing(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingAddLaneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingAddLaneStep.java index 0e9fcb0..739c472 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingAddLaneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingAddLaneStep.java @@ -24,19 +24,19 @@ public class MinecartRacingAddLaneStep implements ChatSetupStep, RepeatableSetup this.minecartRacingSetup = minecartRacingSetup2; } - public void b() { + public void onUndo() { if (this.teamColor != null) { - this.minecartRacingSetup.i().getColorsData().remove(this.teamColor.name()); + this.minecartRacingSetup.getRoundMap().getColorsData().remove(this.teamColor.name()); } } - public void c() { + public void sendInstructions() { TextComponent textComponent = null; Player player = this.minecartRacingSetup.getUser().toPlayer(); ArrayList list = new ArrayList<>(); for (PartyGamesTeamColor partyGamesTeamColor : PartyGamesTeamColor.values()) { - if (!this.minecartRacingSetup.i().getColorsData().containsKey(partyGamesTeamColor.name()) || this.teamColor == partyGamesTeamColor) { + if (!this.minecartRacingSetup.getRoundMap().getColorsData().containsKey(partyGamesTeamColor.name()) || this.teamColor == partyGamesTeamColor) { TextComponent textComponent2 = new TextComponent(partyGamesTeamColor.name()); textComponent2.setColor(partyGamesTeamColor.getChatColor().asBungee()); textComponent2.setClickEvent(new ClickEvent(Action.RUN_COMMAND, "/color " + partyGamesTeamColor.name())); @@ -69,23 +69,23 @@ public class MinecartRacingAddLaneStep implements ChatSetupStep, RepeatableSetup } } - private void c(String text) { + private void selectLaneColor(String text) { PartyGamesTeamColor teamColor2 = PartyGamesTeamColor.valueOf(text); - if (this.minecartRacingSetup.i().getColorsData().containsKey(text) && this.teamColor != teamColor2) { + if (this.minecartRacingSetup.getRoundMap().getColorsData().containsKey(text) && this.teamColor != teamColor2) { this.minecartRacingSetup.getUser().sendMessage("§cThis color has been already set!"); } else { MinecartRacingLane minecartRacingLane = new MinecartRacingLane(); minecartRacingLane.setColor(this.teamColor = teamColor2); - this.minecartRacingSetup.i().getColorsData().put(teamColor2.name(), minecartRacingLane); - this.minecartRacingSetup.a(new MinecartRacingSetPlayerSpawnStep(minecartRacingLane, this.minecartRacingSetup)); + this.minecartRacingSetup.getRoundMap().getColorsData().put(teamColor2.name(), minecartRacingLane); + this.minecartRacingSetup.advanceStep(new MinecartRacingSetPlayerSpawnStep(minecartRacingLane, this.minecartRacingSetup)); } } - public boolean b(String text) { + public boolean onCommandInput(String text) { try { String[] texts = text.split(" "); if (texts.length == 2 && texts[0].equals("color")) { - this.c(texts[1]); + this.selectLaneColor(texts[1]); } return true; @@ -94,17 +94,17 @@ public class MinecartRacingAddLaneStep implements ChatSetupStep, RepeatableSetup } } - public void a(String text) { + public void onChatInput(String text) { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); try { - this.c(text); + this.selectLaneColor(text); } catch (IllegalArgumentException ex) { defaultUser.sendMessage("§cInvalid color!"); StringJoiner stringJoiner = new StringJoiner(", "); for (PartyGamesTeamColor partyGamesTeamColor : PartyGamesTeamColor.values()) { - if (!this.minecartRacingSetup.i().getColorsData().containsKey(partyGamesTeamColor.name())) { + if (!this.minecartRacingSetup.getRoundMap().getColorsData().containsKey(partyGamesTeamColor.name())) { stringJoiner.add(partyGamesTeamColor.name()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetBreakZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetBreakZoneStep.java index 5e564c9..9974002 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetBreakZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetBreakZoneStep.java @@ -17,33 +17,33 @@ public class MinecartRacingSetBreakZoneStep implements ClickSetupStep { this.minecartRacingSetup = minecartRacingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the break zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); - this.minecartRacingSetup.getHotbar().a(0, () -> { + this.minecartRacingSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.minecartRacingSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.minecartRacingSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.minecartRacingSetup.i().getPlayZone().a(cuboid)) { + if (!this.minecartRacingSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.minecartRacingSetup.i().setBreakZone(cuboid); - this.minecartRacingSetup.a(new MinecartRacingSetFinishZoneStep(this.minecartRacingSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.minecartRacingSetup.getRoundMap().setBreakZone(cuboid); + this.minecartRacingSetup.advanceStep(new MinecartRacingSetFinishZoneStep(this.minecartRacingSetup)); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetFinishZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetFinishZoneStep.java index b90fb3a..9ad6dbb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetFinishZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetFinishZoneStep.java @@ -17,33 +17,33 @@ public class MinecartRacingSetFinishZoneStep implements ClickSetupStep { this.minecartRacingSetup = minecartRacingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the finish zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); - this.minecartRacingSetup.getHotbar().a(0, () -> { + this.minecartRacingSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.minecartRacingSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.minecartRacingSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.minecartRacingSetup.i().getPlayZone().a(cuboid)) { + if (!this.minecartRacingSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.minecartRacingSetup.i().setFinishZone(cuboid); - this.minecartRacingSetup.a(new MinecartRacingAddLaneStep(this.minecartRacingSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.minecartRacingSetup.getRoundMap().setFinishZone(cuboid); + this.minecartRacingSetup.advanceStep(new MinecartRacingAddLaneStep(this.minecartRacingSetup)); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetMinecartSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetMinecartSpawnStep.java index 493d010..1e0f0b9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetMinecartSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetMinecartSpawnStep.java @@ -21,22 +21,22 @@ public class MinecartRacingSetMinecartSpawnStep implements ClickSetupStep { this.minecartRacingSetup = minecartRacingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the minecart"); defaultUser.sendMessage("§e spawns."); } - public void a() { + public void configureHotbar() { Player player = this.minecartRacingSetup.getUser().toPlayer(); - this.minecartRacingSetup.getHotbar().a(0, () -> { + this.minecartRacingSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.minecartRacingSetup.i().getPlayZone().a(location)) { + if (this.minecartRacingSetup.getRoundMap().getPlayZone().contains(location)) { this.minecartRacingLane.setMinecart(location); - if (this.minecartRacingSetup.getMap2().getMaximumPlayers() == this.minecartRacingSetup.i().getColorsData().size()) { - this.minecartRacingSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.minecartRacingSetup.getPartyGamesMap().getMaximumPlayers() == this.minecartRacingSetup.getRoundMap().getColorsData().size()) { + this.minecartRacingSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { - this.minecartRacingSetup.a(new MinecartRacingAddLaneStep(this.minecartRacingSetup)); + this.minecartRacingSetup.advanceStep(new MinecartRacingAddLaneStep(this.minecartRacingSetup)); } } else { player.sendMessage("§cMust be inside the Play Zone!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetPlayerSpawnStep.java index 43c4dd9..bf914c9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/minecartracing/setup/step/MinecartRacingSetPlayerSpawnStep.java @@ -20,19 +20,19 @@ public class MinecartRacingSetPlayerSpawnStep implements ClickSetupStep { this.minecartRacingSetup = minecartRacingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.minecartRacingSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the player"); defaultUser.sendMessage("§e is teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.minecartRacingSetup.getUser().toPlayer(); - this.minecartRacingSetup.getHotbar().a(0, () -> { + this.minecartRacingSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.minecartRacingSetup.i().getPlayZone().a(location)) { + if (this.minecartRacingSetup.getRoundMap().getPlayZone().contains(location)) { this.minecartRacingLane.setSpawn(location); - this.minecartRacingSetup.a(new MinecartRacingSetMinecartSpawnStep(this.minecartRacingLane, this.minecartRacingSetup)); + this.minecartRacingSetup.advanceStep(new MinecartRacingSetMinecartSpawnStep(this.minecartRacingLane, this.minecartRacingSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/round/PigFishingRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/round/PigFishingRound.java index 2564a9d..206c060 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/round/PigFishingRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/round/PigFishingRound.java @@ -30,59 +30,59 @@ import ro.fr33styler.arcade.platform.compat.ColoredBlockType; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class PigFishingRound extends PartyRound { - private int d; - private int e; + private int remainingSeconds; + private int openHolesTimer; private final Set set = new HashSet<>(); public PigFishingRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } - public Set getSet10() { + public Set getPigs() { return this.set; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getPigFishingName(); } - public PigFishingMap b() { + public PigFishingMap getRoundMap() { return this.game.getMap().getPartyGamesPigFishing(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PigFishingGamer(null); } @Override - public void f() { - this.d = this.game.getSettings().getPigFishingPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getPigFishingPlayTime(); this.game.setGameEnding(true); int index = 0; - PigFishingLane[] pigFishingLanes = this.b().getColorsData().values().toArray(new PigFishingLane[0]); + PigFishingLane[] pigFishingLanes = this.getRoundMap().getColorsData().values().toArray(new PigFishingLane[0]); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); - partyGamesGamer.setGamer(this.c()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); + partyGamesGamer.setGamer(this.createRoundGamer()); } else { PigFishingLane pigFishingLane = pigFishingLanes[index++]; partyGamesGamer.toPlayer().setWalkSpeed(0.0F); - partyGamesGamer.a(pigFishingLane.getSpawn()); + partyGamesGamer.teleport(pigFishingLane.getSpawn()); partyGamesGamer.setGamer(new PigFishingGamer(pigFishingLane)); } - partyGamesGamer.a(this.game.getMessages().getPigFishingStart()); + partyGamesGamer.sendMessages(this.game.getMessages().getPigFishingStart()); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.setGameEnding(false); this.game.getBlockedActions().remove(GameAction.INTERACT); if (VersionAdapters.get().isLegacyPigFishingGuard()) { @@ -98,21 +98,21 @@ public class PigFishingRound extends PartyRound { } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.game.getBlockedActions().add(GameAction.INTERACT); if (VersionAdapters.get().isLegacyPigFishingGuard()) { this.game.getBlockedActions().add(GameAction.DAMAGE); } this.game.getBossBar().setVisible(false); - this.m(); + this.closeHoles(); this.set.forEach(Entity::remove); this.set.clear(); } - private void m() { - for (PigFishingLane pigFishingLane : this.b().getColorsData().values()) { - pigFishingLane.getHoleZone().a(block -> { + private void closeHoles() { + for (PigFishingLane pigFishingLane : this.getRoundMap().getColorsData().values()) { + pigFishingLane.getHoleZone().forEachBlock(block -> { if (block.getType() == VersionAdapters.get().resolveMaterial(ArcadeMaterial.STICKY_PISTON)) { Block block2 = block.getRelative(BlockFace.DOWN); this.game.getRollbackQueue().add(block2.getState()); @@ -123,24 +123,24 @@ public class PigFishingRound extends PartyRound { } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.d <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.d--; - if (this.e > 0) { - this.e--; - if (this.e == 0) { - this.m(); + this.remainingSeconds--; + if (this.openHolesTimer > 0) { + this.openHolesTimer--; + if (this.openHolesTimer == 0) { + this.closeHoles(); } } - if (Randoms.a().nextBoolean() && this.set.size() < 15) { - Pig pig = (Pig)this.b().getPigSpawn().getWorld().spawn(this.b().getPigSpawn(), Pig.class); - if (Randoms.a().nextFloat() <= 0.05) { + if (Randoms.current().nextBoolean() && this.set.size() < 15) { + Pig pig = (Pig)this.getRoundMap().getPigSpawn().getWorld().spawn(this.getRoundMap().getPigSpawn(), Pig.class); + if (Randoms.current().nextFloat() <= 0.05) { pig.setBaby(); pig.setCustomName(this.game.getMessages().getPigFishingSuperBacon()); pig.setCustomNameVisible(true); @@ -161,16 +161,16 @@ public class PigFishingRound extends PartyRound { } for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { PigFishingGamer pigFishingGamer = (PigFishingGamer)partyGamesGamer.getGamer(); - if (pigFishingGamer.getPigFishingLane().getHoleZone().a(location)) { - pigFishingGamer.a(pigFishingGamer.a() + 1); + if (pigFishingGamer.getPigFishingLane().getHoleZone().contains(location)) { + pigFishingGamer.setScore(pigFishingGamer.getScore() + 1); partyGamesGamer.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); VersionAdapters.get().spawnParticle(location.getWorld(), ArcadeParticle.LAVA, location, 50, 2.0, 5.0, 2.0, 0.0); if (this.game.getMessages().getPigFishingSuperBacon().equals(entity.getCustomName())) { - for (PigFishingLane pigFishingLane : this.b().getColorsData().values()) { + for (PigFishingLane pigFishingLane : this.getRoundMap().getColorsData().values()) { if (pigFishingLane != pigFishingGamer.getPigFishingLane()) { - pigFishingLane.getHoleZone().a(block -> { + pigFishingLane.getHoleZone().forEachBlock(block -> { if (block.getType() == VersionAdapters.get().resolveMaterial(ArcadeMaterial.STICKY_PISTON)) { Block block2 = block.getRelative(BlockFace.DOWN); this.game.getRollbackQueue().add(block2.getState()); @@ -180,7 +180,7 @@ public class PigFishingRound extends PartyRound { } } - this.e = 11; + this.openHolesTimer = 11; } entity.remove(); @@ -191,17 +191,17 @@ public class PigFishingRound extends PartyRound { } } - this.j(); - this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().a(this)); + this.sortStandings(); + this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } @Override public String getVariable(String text) { if (text.equals("countdown")) { - return this.game.isRoundEnding() ? String.valueOf(this.d) : null; + return this.game.isRoundEnding() ? String.valueOf(this.remainingSeconds) : null; } else { return super.getVariable(text); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/PigFishingSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/PigFishingSetup.java index 8192b02..5296372 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/PigFishingSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/PigFishingSetup.java @@ -16,18 +16,18 @@ public class PigFishingSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Pig Fishing"); } - public PigFishingMap i() { + public PigFishingMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new PigFishingSetPigSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesPigFishing(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesPigFishing(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingAddLaneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingAddLaneStep.java index ea35409..dc77133 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingAddLaneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingAddLaneStep.java @@ -24,19 +24,19 @@ public class PigFishingAddLaneStep implements ChatSetupStep, RepeatableSetupStep this.pigFishingSetup = pigFishingSetup2; } - public void b() { + public void onUndo() { if (this.teamColor != null) { - this.pigFishingSetup.i().getColorsData().remove(this.teamColor.name()); + this.pigFishingSetup.getRoundMap().getColorsData().remove(this.teamColor.name()); } } - public void c() { + public void sendInstructions() { TextComponent textComponent = null; Player player = this.pigFishingSetup.getUser().toPlayer(); ArrayList list = new ArrayList<>(); for (PartyGamesTeamColor partyGamesTeamColor : PartyGamesTeamColor.values()) { - if (!this.pigFishingSetup.i().getColorsData().containsKey(partyGamesTeamColor.name()) || this.teamColor == partyGamesTeamColor) { + if (!this.pigFishingSetup.getRoundMap().getColorsData().containsKey(partyGamesTeamColor.name()) || this.teamColor == partyGamesTeamColor) { TextComponent textComponent2 = new TextComponent(partyGamesTeamColor.name()); textComponent2.setColor(partyGamesTeamColor.getChatColor().asBungee()); textComponent2.setClickEvent(new ClickEvent(Action.RUN_COMMAND, "/color " + partyGamesTeamColor.name())); @@ -69,23 +69,23 @@ public class PigFishingAddLaneStep implements ChatSetupStep, RepeatableSetupStep } } - private void c(String text) { + private void selectLaneColor(String text) { PartyGamesTeamColor teamColor2 = PartyGamesTeamColor.valueOf(text); - if (this.pigFishingSetup.i().getColorsData().containsKey(text) && this.teamColor != teamColor2) { + if (this.pigFishingSetup.getRoundMap().getColorsData().containsKey(text) && this.teamColor != teamColor2) { this.pigFishingSetup.getUser().sendMessage("§cThis color has been already set!"); } else { PigFishingLane pigFishingLane = new PigFishingLane(); pigFishingLane.setColor(this.teamColor = teamColor2); - this.pigFishingSetup.i().getColorsData().put(teamColor2.name(), pigFishingLane); - this.pigFishingSetup.a(new PigFishingSetPlayerSafeZoneStep(pigFishingLane, this.pigFishingSetup)); + this.pigFishingSetup.getRoundMap().getColorsData().put(teamColor2.name(), pigFishingLane); + this.pigFishingSetup.advanceStep(new PigFishingSetPlayerSafeZoneStep(pigFishingLane, this.pigFishingSetup)); } } - public boolean b(String text) { + public boolean onCommandInput(String text) { try { String[] texts = text.split(" "); if (texts.length == 2 && texts[0].equals("color")) { - this.c(texts[1]); + this.selectLaneColor(texts[1]); } return true; @@ -94,17 +94,17 @@ public class PigFishingAddLaneStep implements ChatSetupStep, RepeatableSetupStep } } - public void a(String text) { + public void onChatInput(String text) { DefaultUser defaultUser = this.pigFishingSetup.getUser(); try { - this.c(text); + this.selectLaneColor(text); } catch (IllegalArgumentException ex) { defaultUser.sendMessage("§cInvalid color!"); StringJoiner stringJoiner = new StringJoiner(", "); for (PartyGamesTeamColor partyGamesTeamColor : PartyGamesTeamColor.values()) { - if (!this.pigFishingSetup.i().getColorsData().containsKey(partyGamesTeamColor.name())) { + if (!this.pigFishingSetup.getRoundMap().getColorsData().containsKey(partyGamesTeamColor.name())) { stringJoiner.add(partyGamesTeamColor.name()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPigSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPigSpawnStep.java index cf344ff..ceff013 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPigSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPigSpawnStep.java @@ -16,19 +16,19 @@ public class PigFishingSetPigSpawnStep implements ClickSetupStep { this.pigFishingSetup = pigFishingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the pig"); defaultUser.sendMessage("§e spawns during the game!"); } - public void a() { + public void configureHotbar() { Player player = this.pigFishingSetup.getUser().toPlayer(); - this.pigFishingSetup.getHotbar().a(0, () -> { + this.pigFishingSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.pigFishingSetup.i().getPlayZone().a(location)) { - this.pigFishingSetup.i().setPigSpawn(location); - this.pigFishingSetup.a(new PigFishingAddLaneStep(this.pigFishingSetup)); + if (this.pigFishingSetup.getRoundMap().getPlayZone().contains(location)) { + this.pigFishingSetup.getRoundMap().setPigSpawn(location); + this.pigFishingSetup.advanceStep(new PigFishingAddLaneStep(this.pigFishingSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerHoleZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerHoleZoneStep.java index ae177b0..5bed9db 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerHoleZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerHoleZoneStep.java @@ -22,36 +22,36 @@ public class PigFishingSetPlayerHoleZoneStep implements ClickSetupStep { this.pigFishingSetup = pigFishingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the player hole zone."); defaultUser.sendMessage("§e Make sure to include the player pistons too!"); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); - this.pigFishingSetup.getHotbar().a(0, () -> { + this.pigFishingSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.pigFishingSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.pigFishingSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.pigFishingSetup.i().getPlayZone().a(cuboid)) { + if (!this.pigFishingSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); this.pigFishingLane.setHoleZone(cuboid); - if (this.pigFishingSetup.getMap2().getMaximumPlayers() == this.pigFishingSetup.i().getColorsData().size()) { - this.pigFishingSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.pigFishingSetup.getPartyGamesMap().getMaximumPlayers() == this.pigFishingSetup.getRoundMap().getColorsData().size()) { + this.pigFishingSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { - this.pigFishingSetup.a(new PigFishingAddLaneStep(this.pigFishingSetup)); + this.pigFishingSetup.advanceStep(new PigFishingAddLaneStep(this.pigFishingSetup)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSafeZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSafeZoneStep.java index f953e1a..d495195 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSafeZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSafeZoneStep.java @@ -21,33 +21,33 @@ public class PigFishingSetPlayerSafeZoneStep implements ClickSetupStep { this.pigFishingSetup = pigFishingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the player safe zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); - this.pigFishingSetup.getHotbar().a(0, () -> { + this.pigFishingSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.pigFishingSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.pigFishingSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.pigFishingSetup.i().getPlayZone().a(cuboid)) { + if (!this.pigFishingSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); this.pigFishingLane.setSafeZone(cuboid); - this.pigFishingSetup.a(new PigFishingSetPlayerSpawnStep(this.pigFishingLane, this.pigFishingSetup)); + this.pigFishingSetup.advanceStep(new PigFishingSetPlayerSpawnStep(this.pigFishingLane, this.pigFishingSetup)); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSpawnStep.java index 33e992f..83f6eea 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/pigfishing/setup/step/PigFishingSetPlayerSpawnStep.java @@ -20,19 +20,19 @@ public class PigFishingSetPlayerSpawnStep implements ClickSetupStep { this.pigFishingSetup = pigFishingSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.pigFishingSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the player"); defaultUser.sendMessage("§e is teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.pigFishingSetup.getUser().toPlayer(); - this.pigFishingSetup.getHotbar().a(0, () -> { + this.pigFishingSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.pigFishingLane.getSafeZone().a(location)) { + if (this.pigFishingLane.getSafeZone().contains(location)) { this.pigFishingLane.setSpawn(location); - this.pigFishingSetup.a(new PigFishingSetPlayerHoleZoneStep(this.pigFishingLane, this.pigFishingSetup)); + this.pigFishingSetup.advanceStep(new PigFishingSetPlayerHoleZoneStep(this.pigFishingLane, this.pigFishingSetup)); } else { player.sendMessage("§cMust be inside the Safe Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/round/PunchTheBatsRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/round/PunchTheBatsRound.java index d7106e8..78dd561 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/round/PunchTheBatsRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/round/PunchTheBatsRound.java @@ -18,60 +18,60 @@ import org.bukkit.util.Vector; public class PunchTheBatsRound extends PartyRound { private final Vector vector = new Vector(0, 0, 0); - private int e; + private int remainingSeconds; private final Set set = new HashSet<>(); public PunchTheBatsRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } - public Set getSet11() { + public Set getBats() { return this.set; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getPunchTheBatsName(); } - public PunchTheBatsMap b() { + public PunchTheBatsMap getRoundMap() { return this.game.getMap().getPartyGamesPunchTheBats(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PartyRoundGamer(); } @Override - public void f() { - this.e = this.game.getSettings().getPunchTheBatsPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getPunchTheBatsPlayTime(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getPunchTheBatsStart(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.getBossBar().setVisible(true); this.game.getBlockedActions().remove(GameAction.ATTACK); - this.m(); + this.spawnBats(); } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.game.getBossBar().setVisible(false); this.set.forEach(Entity::remove); this.set.clear(); @@ -79,37 +79,37 @@ public class PunchTheBatsRound extends PartyRound { } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.e <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.e--; - this.j(); - this.game.getBossBar().setTitle(this.game.getMessages().getPunchTheBatsTimeLeft().a(this)); + this.remainingSeconds--; + this.sortStandings(); + this.game.getBossBar().setTitle(this.game.getMessages().getPunchTheBatsTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } - public void m() { + public void spawnBats() { for (int index = 0; index < 60; index++) { - Cuboid cuboid = this.b().getBatZone(); - int index2 = cuboid.b().getBlockX(); - int index3 = cuboid.b().getBlockY(); - int index4 = cuboid.b().getBlockZ(); - int index5 = cuboid.c().getBlockX(); - int index6 = cuboid.c().getBlockY(); - int index7 = cuboid.c().getBlockZ(); - int index8 = index5 > index2 ? Randoms.a().nextInt(index2, index5) : index2; - int index9 = index6 > index3 ? Randoms.a().nextInt(index3, index6) : index3; - int index10 = index7 > index4 ? Randoms.a().nextInt(index4, index7) : index4; - Bat bat = (Bat)cuboid.a().spawn(new Location(cuboid.a(), index8, index9, index10), Bat.class); + Cuboid cuboid = this.getRoundMap().getBatZone(); + int index2 = cuboid.getMin().getBlockX(); + int index3 = cuboid.getMin().getBlockY(); + int index4 = cuboid.getMin().getBlockZ(); + int index5 = cuboid.getMax().getBlockX(); + int index6 = cuboid.getMax().getBlockY(); + int index7 = cuboid.getMax().getBlockZ(); + int index8 = index5 > index2 ? Randoms.current().nextInt(index2, index5) : index2; + int index9 = index6 > index3 ? Randoms.current().nextInt(index3, index6) : index3; + int index10 = index7 > index4 ? Randoms.current().nextInt(index4, index7) : index4; + Bat bat = (Bat)cuboid.getWorld().spawn(new Location(cuboid.getWorld(), index8, index9, index10), Bat.class); bat.setVelocity(this.vector); bat.setCustomNameVisible(true); - if (Randoms.a().nextFloat() > 0.1) { + if (Randoms.current().nextFloat() > 0.1) { bat.setCustomName(this.game.getMessages().getPunchTheBatsBat()); } else { bat.setCustomName(this.game.getMessages().getPunchTheBatsBonusBat()); @@ -121,7 +121,7 @@ public class PunchTheBatsRound extends PartyRound { @Override public String getVariable(String text) { if (text.equals("countdown")) { - return this.game.isRoundEnding() ? String.valueOf(this.e) : null; + return this.game.isRoundEnding() ? String.valueOf(this.remainingSeconds) : null; } else { return super.getVariable(text); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/PunchTheBatsSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/PunchTheBatsSetup.java index 563ccd2..db58f6e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/PunchTheBatsSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/PunchTheBatsSetup.java @@ -16,18 +16,18 @@ public class PunchTheBatsSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Punch The Bats"); } - public PunchTheBatsMap i() { + public PunchTheBatsMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new PunchTheBatsSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesPunchTheBats(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesPunchTheBats(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetBatZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetBatZoneStep.java index 68fd3ec..5dd89fa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetBatZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetBatZoneStep.java @@ -18,33 +18,33 @@ public class PunchTheBatsSetBatZoneStep implements ClickSetupStep { this.punchTheBatsSetup = punchTheBatsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.punchTheBatsSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the bat zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.punchTheBatsSetup.getUser(); - this.punchTheBatsSetup.getHotbar().a(0, () -> { + this.punchTheBatsSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.punchTheBatsSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.punchTheBatsSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.punchTheBatsSetup.i().getPlayZone().a(cuboid)) { + if (!this.punchTheBatsSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.punchTheBatsSetup.i().setBatZone(cuboid); - this.punchTheBatsSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.punchTheBatsSetup.getRoundMap().setBatZone(cuboid); + this.punchTheBatsSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetPlayerSpawnStep.java index 31cb99e..2a652ee 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/punchthebats/setup/step/PunchTheBatsSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class PunchTheBatsSetPlayerSpawnStep implements ClickSetupStep { this.punchTheBatsSetup = punchTheBatsSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.punchTheBatsSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.punchTheBatsSetup.getUser().toPlayer(); - this.punchTheBatsSetup.getHotbar().a(0, () -> { + this.punchTheBatsSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.punchTheBatsSetup.i().getPlayZone().a(location)) { - this.punchTheBatsSetup.i().setSpawn(location); - this.punchTheBatsSetup.a(new PunchTheBatsSetBatZoneStep(this.punchTheBatsSetup)); + if (this.punchTheBatsSetup.getRoundMap().getPlayZone().contains(location)) { + this.punchTheBatsSetup.getRoundMap().setSpawn(location); + this.punchTheBatsSetup.advanceStep(new PunchTheBatsSetBatZoneStep(this.punchTheBatsSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/registry/PartyRoundType.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/registry/PartyRoundType.java index 113c602..bbc1a9e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/registry/PartyRoundType.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/registry/PartyRoundType.java @@ -44,39 +44,39 @@ public enum PartyRoundType { TRAMPOLINO("Trampolino", TrampolinoSetup::new, TrampolinoRound::new, PartyGamesMap::getPartyGamesTrampolino), VOLCANO("Volcano", VolcanoSetup::new, VolcanoRound::new, PartyGamesMap::getPartyGamesVolcano); - private static final PartyRoundType[] l = values(); - private final String m; + private static final PartyRoundType[] VALUES = values(); + private final String id; private final PartyRoundSetupFactory partyRoundSetupFactory; private final PartyRoundFactory partyRoundFactory; private final PartyRoundMapAccessor partyRoundMapAccessor; - private static final PartyRoundType[] q = values(); + private static final PartyRoundType[] ENUM_VALUES = values(); PartyRoundType(String text, PartyRoundSetupFactory partyRoundSetupFactory2, PartyRoundFactory partyRoundFactory2, PartyRoundMapAccessor partyRoundMapAccessor2) { - this.m = text; + this.id = text; this.partyRoundMapAccessor = partyRoundMapAccessor2; this.partyRoundSetupFactory = partyRoundSetupFactory2; this.partyRoundFactory = partyRoundFactory2; } - public String a() { - return this.m; + public String getId() { + return this.id; } - public PartyRoundMap a(PartyGamesMap partyGamesMap) { + public PartyRoundMap getRoundMap(PartyGamesMap partyGamesMap) { return this.partyRoundMapAccessor.getMap(partyGamesMap); } - public PartyRound a(PartyGamesGame partyGamesGame) { + public PartyRound createRound(PartyGamesGame partyGamesGame) { return this.partyRoundFactory.newPartyGame(partyGamesGame); } - public PartyRoundSetup a(DefaultUser defaultUser, PartyGamesManager partyGamesManager, PartyGamesMap partyGamesMap, SetupTarget setupTarget) { + public PartyRoundSetup createSetup(DefaultUser defaultUser, PartyGamesManager partyGamesManager, PartyGamesMap partyGamesMap, SetupTarget setupTarget) { return this.partyRoundSetupFactory.newSetup(defaultUser, partyGamesManager, partyGamesMap, setupTarget); } - public static PartyRoundType a(String text) { - for (PartyRoundType partyRoundType : l) { - if (partyRoundType.a().equals(text)) { + public static PartyRoundType byId(String text) { + for (PartyRoundType partyRoundType : VALUES) { + if (partyRoundType.getId().equals(text)) { return partyRoundType; } } @@ -84,11 +84,11 @@ public enum PartyRoundType { return null; } - public static String[] b() { - String[] texts = new String[l.length]; + public static String[] getIds() { + String[] texts = new String[VALUES.length]; - for (int index = 0; index < l.length; index++) { - texts[index] = l[index].a(); + for (int index = 0; index < VALUES.length; index++) { + texts[index] = VALUES[index].getId(); } return texts; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/round/TheFloorIsLavaRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/round/TheFloorIsLavaRound.java index 1d25d10..b6819b7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/round/TheFloorIsLavaRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/round/TheFloorIsLavaRound.java @@ -13,17 +13,17 @@ public class TheFloorIsLavaRound extends ParkourRound { } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getTheFloorIsLavaName(); } @Override - public ParkourMap b() { + public ParkourMap getRoundMap() { return this.game.getMap().getPartyGamesTheFloorIsLava(); } @Override - public List l() { + public List getStartMessages() { return this.game.getMessages().getTheFloorIsLavaStart(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/setup/TheFloorIsLavaSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/setup/TheFloorIsLavaSetup.java index 5ad1a71..01cfca8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/setup/TheFloorIsLavaSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/thefloorislava/setup/TheFloorIsLavaSetup.java @@ -16,18 +16,18 @@ public class TheFloorIsLavaSetup extends ParkourSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "The Floor Is Lava"); } - public TheFloorIsLavaMap i() { + public TheFloorIsLavaMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new ParkourSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesTheFloorIsLava(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesTheFloorIsLava(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/round/TrampolinoRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/round/TrampolinoRound.java index 63d40da..5e55cb6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/round/TrampolinoRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/round/TrampolinoRound.java @@ -18,101 +18,101 @@ import ro.fr33styler.arcade.platform.compat.ArcadeColor; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class TrampolinoRound extends PartyRound { - private int d; + private int remainingSeconds; private final Map map = new HashMap<>(); public TrampolinoRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } - public Map getMap29() { + public Map getMarkers() { return this.map; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getTrampolinoName(); } - public TrampolinoMap b() { + public TrampolinoMap getRoundMap() { return this.game.getMap().getPartyGamesTrampolino(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PartyRoundGamer(); } @Override - public void f() { - this.d = this.game.getSettings().getTrampolinoPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getTrampolinoPlayTime(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getTrampolinoStart(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); - this.a("BOOSTER"); + public void startRound() { + super.startRound(); + this.spawnMarker("BOOSTER"); for (int index = 0; index < 7; index++) { - this.a("§a+1"); + this.spawnMarker("§a+1"); } for (int index2 = 0; index2 < 5; index2++) { - this.a("§a+3"); + this.spawnMarker("§a+3"); } for (int index3 = 0; index3 < 4; index3++) { - this.a("§c+10"); + this.spawnMarker("§c+10"); } this.game.getBossBar().setVisible(true); } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.map.values().forEach(marker -> VersionAdapters.get().removeTrampolinoMarker(marker)); this.map.clear(); this.game.getBossBar().setVisible(false); } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - this.j(); + this.sortStandings(); VersionAdapters.get().tickTrampolinoMarkers(this.map.values()); - if (this.d <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.d--; - this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().a(this)); + this.remainingSeconds--; + this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } - public void a(String text) { + public void spawnMarker(String text) { ArcadeColor colorOrNull = null; - Location location = this.b().getSpawn(); - int index = Randoms.a().nextInt(-15, 15); - int index2 = Randoms.a().nextInt(-15, 15); - Location location2 = Locations.a(location).add(index, 6.0, index2); + Location location = this.getRoundMap().getSpawn(); + int index = Randoms.current().nextInt(-15, 15); + int index2 = Randoms.current().nextInt(-15, 15); + Location location2 = Locations.copy(location).add(index, 6.0, index2); if ("§a+1".equals(text)) { location2.add(0.0, -3.0, 0.0); colorOrNull = ArcadeColor.LIME; @@ -136,7 +136,7 @@ public class TrampolinoRound extends PartyRound { @Override public String getVariable(String text) { if (text.equals("countdown")) { - return this.game.isRoundEnding() ? String.valueOf(this.d) : null; + return this.game.isRoundEnding() ? String.valueOf(this.remainingSeconds) : null; } else { return super.getVariable(text); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/TrampolinoSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/TrampolinoSetup.java index 81246b1..ad29309 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/TrampolinoSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/TrampolinoSetup.java @@ -16,18 +16,18 @@ public class TrampolinoSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Trampolino"); } - public TrampolinoMap i() { + public TrampolinoMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new TrampolinoSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesTrampolino(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesTrampolino(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetFloorZoneStep.java index 80cb26c..1a02584 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetFloorZoneStep.java @@ -18,35 +18,35 @@ public class TrampolinoSetFloorZoneStep implements ClickSetupStep { this.trampolinoSetup = trampolinoSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.trampolinoSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.trampolinoSetup.getUser(); - this.trampolinoSetup.getHotbar().a(0, () -> { + this.trampolinoSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.trampolinoSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.trampolinoSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.trampolinoSetup.i().getPlayZone().a(cuboid)) { + if (!this.trampolinoSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe floor must be 1 block thick!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.trampolinoSetup.i().setFloorZone(cuboid); - this.trampolinoSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.trampolinoSetup.getRoundMap().setFloorZone(cuboid); + this.trampolinoSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetPlayerSpawnStep.java index 0d2933e..9cc0ac3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/trampolino/setup/step/TrampolinoSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class TrampolinoSetPlayerSpawnStep implements ClickSetupStep { this.trampolinoSetup = trampolinoSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.trampolinoSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.trampolinoSetup.getUser().toPlayer(); - this.trampolinoSetup.getHotbar().a(0, () -> { + this.trampolinoSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.trampolinoSetup.i().getPlayZone().a(location)) { - this.trampolinoSetup.i().setSpawn(location); - this.trampolinoSetup.a(new TrampolinoSetFloorZoneStep(this.trampolinoSetup)); + if (this.trampolinoSetup.getRoundMap().getPlayZone().contains(location)) { + this.trampolinoSetup.getRoundMap().setSpawn(location); + this.trampolinoSetup.advanceStep(new TrampolinoSetFloorZoneStep(this.trampolinoSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/round/VolcanoRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/round/VolcanoRound.java index 9f11fa7..8920e68 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/round/VolcanoRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/round/VolcanoRound.java @@ -29,83 +29,83 @@ public class VolcanoRound extends PartyRound { super(partyGamesGame); } - public List getList17() { + public List getIntactFloorBlocks() { return this.list; } - public Map getMap31() { + public Map getFallingFloorBlocks() { return this.map; } @Override - public String a() { + public String getRoundName() { return this.game.getMessages().getVolcanoName(); } @Override - protected List e() { + protected List getSidebarLines() { return this.game.getMessages().getVolcanoSidebar(); } - public VolcanoMap b() { + public VolcanoMap getRoundMap() { return this.game.getMap().getPartyGamesVolcano(); } @Override - public PartyRoundGamer c() { + public PartyRoundGamer createRoundGamer() { return new PartyRoundGamer(); } @Override - public void f() { + public void prepareRound() { for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); } - partyGamesGamer.setGamer(this.c()); + partyGamesGamer.setGamer(this.createRoundGamer()); partyGamesGamer.sendMessages(this.game.getMessages().getVolcanoStart(), this.game); } - this.b().getFloorZone().a(block -> { + this.getRoundMap().getFloorZone().forEachBlock(block -> { if (!block.isEmpty()) { this.list.add(block); this.map.put(block, -1); } }); Collections.shuffle(this.list); - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { + if (!partyGamesGamer.isSpectator()) { Block block = partyGamesGamer.toPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN); - if (this.b().getFloorZone().a(block) && this.list.remove(block)) { + if (this.getRoundMap().getFloorZone().contains(block) && this.list.remove(block)) { this.map.put(block, 13); } } } - if (this.game.getGamers().a() <= 1) { - this.h(); + if (this.game.getGamers().getAliveCount() <= 1) { + this.finishRound(); } } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.list.clear(); this.map.clear(); } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 10L == 0L) { Iterator iterator = this.map.entrySet().iterator(); @@ -136,14 +136,14 @@ public class VolcanoRound extends PartyRound { } if (longVal % 20L == 0L) { - this.j(); + this.sortStandings(); for (int index2 = 0; index2 < Math.min(this.list.size(), this.game.getSettings().getVolcanoBlocksPerSecond()); index2++) { this.map.put(this.list.remove(0), 13); } } - super.a(longVal); + super.onTick(longVal); } @Override diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/VolcanoSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/VolcanoSetup.java index cc99b5d..923ee15 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/VolcanoSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/VolcanoSetup.java @@ -16,18 +16,18 @@ public class VolcanoSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, "Volcano"); } - public VolcanoMap i() { + public VolcanoMap getRoundMap() { return this.map; } @Override - public SetupStep j() { + public SetupStep createInitialStep() { return new VolcanoSetPlayerSpawnStep(this); } @Override - public void f() { - this.map2.setPartyGamesVolcano(this.map); - super.f(); + public void finish() { + this.partyGamesMap.setPartyGamesVolcano(this.map); + super.finish(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetFloorZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetFloorZoneStep.java index 7e4c9ad..d9ed1b5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetFloorZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetFloorZoneStep.java @@ -18,35 +18,35 @@ public class VolcanoSetFloorZoneStep implements ClickSetupStep { this.volcanoSetup = volcanoSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.volcanoSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the floor zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.volcanoSetup.getUser(); - this.volcanoSetup.getHotbar().a(0, () -> { + this.volcanoSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.volcanoSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.volcanoSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.volcanoSetup.i().getPlayZone().a(cuboid)) { + if (!this.volcanoSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else if (block.getY() != block2.getY()) { defaultUser.sendMessage("§cThe floor must be 1 block thick!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.volcanoSetup.i().setFloorZone(cuboid); - this.volcanoSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.volcanoSetup.getRoundMap().setFloorZone(cuboid); + this.volcanoSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetPlayerSpawnStep.java index e58bd35..7ce41d5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/round/volcano/setup/step/VolcanoSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class VolcanoSetPlayerSpawnStep implements ClickSetupStep { this.volcanoSetup = volcanoSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.volcanoSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.volcanoSetup.getUser().toPlayer(); - this.volcanoSetup.getHotbar().a(0, () -> { + this.volcanoSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.volcanoSetup.i().getPlayZone().a(location)) { - this.volcanoSetup.i().setSpawn(location); - this.volcanoSetup.a(new VolcanoSetFloorZoneStep(this.volcanoSetup)); + if (this.volcanoSetup.getRoundMap().getPlayZone().contains(location)) { + this.volcanoSetup.getRoundMap().setSpawn(location); + this.volcanoSetup.advanceStep(new VolcanoSetFloorZoneStep(this.volcanoSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSession.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSession.java index 49b1edb..12a5847 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSession.java @@ -24,11 +24,11 @@ public class PartyGamesSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { PartyGamesGamer partyGamesGamer = new PartyGamesGamer(this.game, defaultUser); - this.game.getGamers().a(partyGamesGamer); - partyGamesGamer.a(this.game.getMessages().getStart()); - partyGamesGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(partyGamesGamer); + partyGamesGamer.sendMessages(this.game.getMessages().getStart()); + partyGamesGamer.teleport(this.game.getMap().getLobby()); return partyGamesGamer; }); } @@ -47,7 +47,7 @@ public class PartyGamesSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof PartyGamesGamer var2) { PartyGamesGame partyGamesGame = var2.getGame(); - if (partyGamesGame.getPhase() != partyGamesGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (partyGamesGame.getPhase() != partyGamesGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, partyGamesGame.getMessages().getJoinAlreadyInGame()); } } @@ -57,13 +57,13 @@ public class PartyGamesSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { PartyGamesGamer partyGamesGamer = new PartyGamesGamer(this.game, defaultUser); - this.game.getGamers().a(partyGamesGamer); - partyGamesGamer.a(this.game.getCurrentRound().b().getSpectator()); - partyGamesGamer.setGamer(this.game.getCurrentRound().c()); - partyGamesGamer.b(true); - partyGamesGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(partyGamesGamer); + partyGamesGamer.teleport(this.game.getCurrentRound().getRoundMap().getSpectator()); + partyGamesGamer.setGamer(this.game.getCurrentRound().createRoundGamer()); + partyGamesGamer.setSpectator(true); + partyGamesGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(partyGamesGamer.getName()); this.game.getBossBar().addPlayer(defaultUser.toPlayer()); return partyGamesGamer; @@ -82,15 +82,15 @@ public class PartyGamesSession extends BaseSession { @Override public void addRejoin(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { PartyGamesGamer partyGamesGamer = new PartyGamesGamer(this.game, defaultUser); - this.game.getGamers().a(partyGamesGamer); - partyGamesGamer.a(this.game.getCurrentRound().b().getSpectator()); - partyGamesGamer.setGamer(this.game.getCurrentRound().c()); - partyGamesGamer.a(true); + this.game.getGamers().add(partyGamesGamer); + partyGamesGamer.teleport(this.game.getCurrentRound().getRoundMap().getSpectator()); + partyGamesGamer.setGamer(this.game.getCurrentRound().createRoundGamer()); + partyGamesGamer.setTemporarySpectator(true); this.game.getStandings().add(partyGamesGamer); - this.game.getManager().getSessions().e().remove(defaultUser.getUUID()); - ((PartyGamesTeam)this.game.getPlayerTeams().remove(defaultUser.getUUID())).a(partyGamesGamer); + this.game.getManager().getSessions().getRejoinGames().remove(defaultUser.getUUID()); + ((PartyGamesTeam)this.game.getPlayerTeams().remove(defaultUser.getUUID())).restoreTo(partyGamesGamer); this.game.getBossBar().addPlayer(user.toPlayer()); return partyGamesGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSessions.java index 39f830a..f31b296 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/session/PartyGamesSessions.java @@ -24,100 +24,100 @@ import java.util.Map.Entry; import org.bukkit.World; public class PartyGamesSessions extends BaseSessions { - private final PartyGamesManager a; + private final PartyGamesManager manager; public PartyGamesSessions(PartyGamesManager partyGamesManager) { super(partyGamesManager); - this.a = partyGamesManager; + this.manager = partyGamesManager; } public PartyGamesManager getManager() { - return this.a; + return this.manager; } - protected PartyGamesMap h(String text) { + protected PartyGamesMap createMap(String text) { PartyGamesMap partyGamesMap = new PartyGamesMap(); partyGamesMap.setId(text); return partyGamesMap; } - protected PartyGamesGame a(PartyGamesMap partyGamesMap) { - return new PartyGamesGame(this.a, partyGamesMap); + protected PartyGamesGame createGame(PartyGamesMap partyGamesMap) { + return new PartyGamesGame(this.manager, partyGamesMap); } @Override - public void a() { - this.a.getStorage().getStorage().a(partyGamesMap -> { - PartyGamesGame partyGamesGame = new PartyGamesGame(this.a, partyGamesMap); + public void load() { + this.manager.getStorage().getStorage().loadAll(partyGamesMap -> { + PartyGamesGame partyGamesGame = new PartyGamesGame(this.manager, partyGamesMap); for (PartyRoundType partyRoundType : PartyRoundType.values()) { - if (partyRoundType.a(partyGamesMap) != null) { - partyGamesGame.getRoundQueue().add(partyRoundType.a(partyGamesGame)); + if (partyRoundType.getRoundMap(partyGamesMap) != null) { + partyGamesGame.getRoundQueue().add(partyRoundType.createRound(partyGamesGame)); } } this.registerGame(partyGamesGame); }); - this.a.getStorage().getStorage5().a(this::b); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } public PartyGamesSession createSession(PartyGamesGame partyGamesGame) { return partyGamesGame == null ? null : new PartyGamesSession(partyGamesGame); } - protected void a(PartyGamesMap partyGamesMap, World world, PartyGamesMap partyGamesMap2) { - super.a(partyGamesMap, world, partyGamesMap2); - partyGamesMap2.setTopLobby(Locations.a(world, partyGamesMap.getTopLobby())); - partyGamesMap2.setTopFirst(Locations.a(world, partyGamesMap.getTopFirst())); - partyGamesMap2.setTopSecond(Locations.a(world, partyGamesMap.getTopSecond())); - partyGamesMap2.setTopThird(Locations.a(world, partyGamesMap.getTopThird())); + protected void copyMap(PartyGamesMap partyGamesMap, World world, PartyGamesMap partyGamesMap2) { + super.copyMap(partyGamesMap, world, partyGamesMap2); + partyGamesMap2.setTopLobby(Locations.withWorld(world, partyGamesMap.getTopLobby())); + partyGamesMap2.setTopFirst(Locations.withWorld(world, partyGamesMap.getTopFirst())); + partyGamesMap2.setTopSecond(Locations.withWorld(world, partyGamesMap.getTopSecond())); + partyGamesMap2.setTopThird(Locations.withWorld(world, partyGamesMap.getTopThird())); if (partyGamesMap.getPartyGamesAnimalSlaughter() != null) { AnimalSlaughterMap animalSlaughterMap = new AnimalSlaughterMap(); - animalSlaughterMap.setSpectator(Locations.a(world, partyGamesMap.getPartyGamesAnimalSlaughter().getSpectator())); - animalSlaughterMap.setPlayZone(partyGamesMap.getPartyGamesAnimalSlaughter().getPlayZone().a(world)); - animalSlaughterMap.setSpawn(Locations.a(world, partyGamesMap.getPartyGamesAnimalSlaughter().getSpawn())); + animalSlaughterMap.setSpectator(Locations.withWorld(world, partyGamesMap.getPartyGamesAnimalSlaughter().getSpectator())); + animalSlaughterMap.setPlayZone(partyGamesMap.getPartyGamesAnimalSlaughter().getPlayZone().withWorld(world)); + animalSlaughterMap.setSpawn(Locations.withWorld(world, partyGamesMap.getPartyGamesAnimalSlaughter().getSpawn())); partyGamesMap2.setPartyGamesAnimalSlaughter(animalSlaughterMap); } if (partyGamesMap.getPartyGamesAvalanche() != null) { AvalancheMap avalancheMap = new AvalancheMap(); - avalancheMap.setSpectator(Locations.a(world, partyGamesMap.getPartyGamesAvalanche().getSpectator())); - avalancheMap.setPlayZone(partyGamesMap.getPartyGamesAvalanche().getPlayZone().a(world)); - avalancheMap.setSpawn(Locations.a(world, partyGamesMap.getPartyGamesAvalanche().getSpawn())); - avalancheMap.setFloorZone(partyGamesMap.getPartyGamesAvalanche().getFloorZone().a(world)); + avalancheMap.setSpectator(Locations.withWorld(world, partyGamesMap.getPartyGamesAvalanche().getSpectator())); + avalancheMap.setPlayZone(partyGamesMap.getPartyGamesAvalanche().getPlayZone().withWorld(world)); + avalancheMap.setSpawn(Locations.withWorld(world, partyGamesMap.getPartyGamesAvalanche().getSpawn())); + avalancheMap.setFloorZone(partyGamesMap.getPartyGamesAvalanche().getFloorZone().withWorld(world)); partyGamesMap2.setPartyGamesAvalanche(avalancheMap); } if (partyGamesMap.getPartyGamesFrozenFloor() != null) { FrozenFloorMap frozenFloorMap = new FrozenFloorMap(); - frozenFloorMap.setSpectator(Locations.a(world, partyGamesMap.getPartyGamesFrozenFloor().getSpectator())); - frozenFloorMap.setPlayZone(partyGamesMap.getPartyGamesFrozenFloor().getPlayZone().a(world)); - frozenFloorMap.getSpawns().addAll(Locations.a(world, partyGamesMap.getPartyGamesFrozenFloor().getSpawns())); - frozenFloorMap.setFloorZone(partyGamesMap.getPartyGamesFrozenFloor().getFloorZone().a(world)); + frozenFloorMap.setSpectator(Locations.withWorld(world, partyGamesMap.getPartyGamesFrozenFloor().getSpectator())); + frozenFloorMap.setPlayZone(partyGamesMap.getPartyGamesFrozenFloor().getPlayZone().withWorld(world)); + frozenFloorMap.getSpawns().addAll(Locations.withWorld(world, partyGamesMap.getPartyGamesFrozenFloor().getSpawns())); + frozenFloorMap.setFloorZone(partyGamesMap.getPartyGamesFrozenFloor().getFloorZone().withWorld(world)); partyGamesMap2.setPartyGamesFrozenFloor(frozenFloorMap); } if (partyGamesMap.getPartyGamesHoehoehoe() != null) { HoeHoeHoeMap hoeHoeHoeMap = new HoeHoeHoeMap(); - hoeHoeHoeMap.setSpectator(Locations.a(world, partyGamesMap.getPartyGamesHoehoehoe().getSpectator())); - hoeHoeHoeMap.setPlayZone(partyGamesMap.getPartyGamesHoehoehoe().getPlayZone().a(world)); - hoeHoeHoeMap.setSpawn(Locations.a(world, partyGamesMap.getPartyGamesHoehoehoe().getSpawn())); - hoeHoeHoeMap.setFloorZone(partyGamesMap.getPartyGamesHoehoehoe().getFloorZone().a(world)); + hoeHoeHoeMap.setSpectator(Locations.withWorld(world, partyGamesMap.getPartyGamesHoehoehoe().getSpectator())); + hoeHoeHoeMap.setPlayZone(partyGamesMap.getPartyGamesHoehoehoe().getPlayZone().withWorld(world)); + hoeHoeHoeMap.setSpawn(Locations.withWorld(world, partyGamesMap.getPartyGamesHoehoehoe().getSpawn())); + hoeHoeHoeMap.setFloorZone(partyGamesMap.getPartyGamesHoehoehoe().getFloorZone().withWorld(world)); partyGamesMap2.setPartyGamesHoehoehoe(hoeHoeHoeMap); } if (partyGamesMap.getPartyGamesMinecartRacing() != null) { MinecartRacingMap minecartRacingMap = new MinecartRacingMap(); - minecartRacingMap.setSpectator(Locations.a(world, partyGamesMap.getPartyGamesMinecartRacing().getSpectator())); - minecartRacingMap.setPlayZone(partyGamesMap.getPartyGamesMinecartRacing().getPlayZone().a(world)); - minecartRacingMap.setBreakZone(partyGamesMap.getPartyGamesMinecartRacing().getBreakZone().a(world)); - minecartRacingMap.setFinishZone(partyGamesMap.getPartyGamesMinecartRacing().getFinishZone().a(world)); + minecartRacingMap.setSpectator(Locations.withWorld(world, partyGamesMap.getPartyGamesMinecartRacing().getSpectator())); + minecartRacingMap.setPlayZone(partyGamesMap.getPartyGamesMinecartRacing().getPlayZone().withWorld(world)); + minecartRacingMap.setBreakZone(partyGamesMap.getPartyGamesMinecartRacing().getBreakZone().withWorld(world)); + minecartRacingMap.setFinishZone(partyGamesMap.getPartyGamesMinecartRacing().getFinishZone().withWorld(world)); for (Entry entry : partyGamesMap.getPartyGamesMinecartRacing().getColorsData().entrySet()) { MinecartRacingLane minecartRacingLane = new MinecartRacingLane(); minecartRacingLane.setColor(((MinecartRacingLane)entry.getValue()).getColor()); - minecartRacingLane.setSpawn(Locations.a(world, ((MinecartRacingLane)entry.getValue()).getSpawn())); - minecartRacingLane.setMinecart(Locations.a(world, ((MinecartRacingLane)entry.getValue()).getMinecart())); + minecartRacingLane.setSpawn(Locations.withWorld(world, ((MinecartRacingLane)entry.getValue()).getSpawn())); + minecartRacingLane.setMinecart(Locations.withWorld(world, ((MinecartRacingLane)entry.getValue()).getMinecart())); minecartRacingMap.getColorsData().put((String)entry.getKey(), minecartRacingLane); } @@ -126,38 +126,38 @@ public class PartyGamesSessions extends BaseSessions this.user.sendMessage("§cThe setup has been finalized! To set up games please use /partygames add " + this.map.getId() + " ")); - this.h(); + public void finish() { + this.sendPanel((Runnable)() -> this.user.sendMessage("§cThe setup has been finalized! To set up games please use /partygames add " + this.map.getId() + " ")); + this.cleanup(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -39,11 +39,11 @@ public class PartyGamesSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new PartyGamesGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new PartyGamesGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetArenaNameStep.java index e9ba703..decd997 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetArenaNameStep.java @@ -10,12 +10,12 @@ public class PartyGamesSetArenaNameStep implements ChatSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { this.partyGamesSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.partyGamesSetup.getMap33().setName(text); - this.partyGamesSetup.a(new PartyGamesSetLobbySpawnStep(this.partyGamesSetup)); + public void onChatInput(String text) { + this.partyGamesSetup.getMap().setName(text); + this.partyGamesSetup.advanceStep(new PartyGamesSetLobbySpawnStep(this.partyGamesSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetEndingSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetEndingSpawnStep.java index 5482056..d58f7fb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetEndingSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetEndingSpawnStep.java @@ -15,17 +15,17 @@ public class PartyGamesSetEndingSpawnStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to at the end of the game."); } - public void a() { - this.partyGamesSetup.getHotbar().a(0, () -> { + public void configureHotbar() { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { Location location = this.partyGamesSetup.getUser().toPlayer().getLocation(); - this.partyGamesSetup.getMap33().setTopLobby(location); - this.partyGamesSetup.a(new PartyGamesSetFirstPodiumStep(this.partyGamesSetup)); + this.partyGamesSetup.getMap().setTopLobby(location); + this.partyGamesSetup.advanceStep(new PartyGamesSetFirstPodiumStep(this.partyGamesSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetFirstPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetFirstPodiumStep.java index e1a749c..a457931 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetFirstPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetFirstPodiumStep.java @@ -15,17 +15,17 @@ public class PartyGamesSetFirstPodiumStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top first player spawns at."); } - public void a() { - this.partyGamesSetup.getHotbar().a(0, () -> { + public void configureHotbar() { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { Location location = this.partyGamesSetup.getUser().toPlayer().getLocation(); - this.partyGamesSetup.getMap33().setTopFirst(location); - this.partyGamesSetup.a(new PartyGamesSetSecondPodiumStep(this.partyGamesSetup)); + this.partyGamesSetup.getMap().setTopFirst(location); + this.partyGamesSetup.advanceStep(new PartyGamesSetSecondPodiumStep(this.partyGamesSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top first").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbyRemovalRegionStep.java index 5f8c484..9c5a6d8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class PartyGamesSetLobbyRemovalRegionStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class PartyGamesSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); - this.partyGamesSetup.getHotbar().a(0, () -> { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.partyGamesSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.partyGamesSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.partyGamesSetup.getMap33().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.partyGamesSetup.a(new PartyGamesSetEndingSpawnStep(this.partyGamesSetup)); + this.partyGamesSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.partyGamesSetup.advanceStep(new PartyGamesSetEndingSpawnStep(this.partyGamesSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.partyGamesSetup.getHotbar().a(2, () -> { - this.partyGamesSetup.getMap33().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.partyGamesSetup.a(new PartyGamesSetEndingSpawnStep(this.partyGamesSetup)); + this.partyGamesSetup.getHotbar().setSlot(2, () -> { + this.partyGamesSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.partyGamesSetup.advanceStep(new PartyGamesSetEndingSpawnStep(this.partyGamesSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbySpawnStep.java index 147e575..86eeca5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetLobbySpawnStep.java @@ -14,16 +14,16 @@ public class PartyGamesSetLobbySpawnStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { - this.partyGamesSetup.getHotbar().a(0, () -> { - this.partyGamesSetup.getMap33().setLobby(this.partyGamesSetup.getUser().toPlayer().getLocation()); - this.partyGamesSetup.a(new PartyGamesSetLobbyRemovalRegionStep(this.partyGamesSetup)); + public void configureHotbar() { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { + this.partyGamesSetup.getMap().setLobby(this.partyGamesSetup.getUser().toPlayer().getLocation()); + this.partyGamesSetup.advanceStep(new PartyGamesSetLobbyRemovalRegionStep(this.partyGamesSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetPlayZoneStep.java index 9873779..248af06 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class PartyGamesSetPlayZoneStep implements ClickSetupStep { this.partyRoundSetup = partyRoundSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyRoundSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.partyRoundSetup.getUser(); - this.partyRoundSetup.getHotbar().a(0, () -> { + this.partyRoundSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.partyRoundSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.partyRoundSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.partyRoundSetup.i().setPlayZone(new Cuboid(block, block2)); - this.partyRoundSetup.a(new PartyGamesSetSpectatorSpawnStep(this.partyRoundSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.partyRoundSetup.getRoundMap().setPlayZone(new Cuboid(block, block2)); + this.partyRoundSetup.advanceStep(new PartyGamesSetSpectatorSpawnStep(this.partyRoundSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSecondPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSecondPodiumStep.java index ed41fc0..d009ff9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSecondPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSecondPodiumStep.java @@ -15,17 +15,17 @@ public class PartyGamesSetSecondPodiumStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top second player spawns at."); } - public void a() { - this.partyGamesSetup.getHotbar().a(0, () -> { + public void configureHotbar() { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { Location location = this.partyGamesSetup.getUser().toPlayer().getLocation(); - this.partyGamesSetup.getMap33().setTopSecond(location); - this.partyGamesSetup.a(new PartyGamesSetThirdPodiumStep(this.partyGamesSetup)); + this.partyGamesSetup.getMap().setTopSecond(location); + this.partyGamesSetup.advanceStep(new PartyGamesSetThirdPodiumStep(this.partyGamesSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top second").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSpectatorSpawnStep.java index 3685c38..a3f3a46 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class PartyGamesSetSpectatorSpawnStep implements ClickSetupStep { this.partyRoundSetup = partyRoundSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyRoundSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.partyRoundSetup.getUser().toPlayer(); - this.partyRoundSetup.getHotbar().a(0, () -> { + this.partyRoundSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.partyRoundSetup.i().getPlayZone().a(location)) { - this.partyRoundSetup.i().setSpectator(location); - this.partyRoundSetup.a(this.partyRoundSetup.j()); + if (this.partyRoundSetup.getRoundMap().getPlayZone().contains(location)) { + this.partyRoundSetup.getRoundMap().setSpectator(location); + this.partyRoundSetup.advanceStep(this.partyRoundSetup.createInitialStep()); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetThirdPodiumStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetThirdPodiumStep.java index a379de5..43535c1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetThirdPodiumStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/setup/step/PartyGamesSetThirdPodiumStep.java @@ -16,17 +16,17 @@ public class PartyGamesSetThirdPodiumStep implements ClickSetupStep { this.partyGamesSetup = partyGamesSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.partyGamesSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the npc"); defaultUser.sendMessage("§e of the top third player spawns at."); } - public void a() { - this.partyGamesSetup.getHotbar().a(0, () -> { + public void configureHotbar() { + this.partyGamesSetup.getHotbar().setSlot(0, () -> { Location location = this.partyGamesSetup.getUser().toPlayer().getLocation(); - this.partyGamesSetup.getMap33().setTopThird(location); - this.partyGamesSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + this.partyGamesSetup.getMap().setTopThird(location); + this.partyGamesSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet top third").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/player/ParkourGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/player/ParkourGamer.java index e742576..1660d39 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/player/ParkourGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/player/ParkourGamer.java @@ -6,20 +6,20 @@ import org.bukkit.Location; import ro.fr33styler.arcade.api.engine.text.Context; public class ParkourGamer extends PartyRoundGamer implements Context { - private int a; - private boolean b; + private int finishRank; + private boolean finished; private Location location; - public int b() { - return this.a; + public int getFinishRank() { + return this.finishRank; } - public void b(int index) { - this.a = index; + public void setFinishRank(int index) { + this.finishRank = index; } - public boolean c() { - return this.b; + public boolean isFinished() { + return this.finished; } public Location getLocation() { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/round/ParkourRound.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/round/ParkourRound.java index f5aaf6b..4ef725a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/round/ParkourRound.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/round/ParkourRound.java @@ -14,84 +14,84 @@ import org.bukkit.Material; import org.bukkit.plugin.java.JavaPlugin; public abstract class ParkourRound extends PartyRound { - private int d; + private int remainingSeconds; public ParkourRound(PartyGamesGame partyGamesGame) { super(partyGamesGame); } - public abstract ParkourMap b(); + public abstract ParkourMap getRoundMap(); - public abstract List l(); + public abstract List getStartMessages(); - public ParkourGamer c() { + public ParkourGamer createRoundGamer() { return new ParkourGamer(); } @Override - public void f() { - this.d = this.game.getSettings().getParkourPlayTime(); + public void prepareRound() { + this.remainingSeconds = this.game.getSettings().getParkourPlayTime(); this.game.getBlockedActions().remove(GameAction.INTERACT); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - ParkourGamer parkourGamer = this.c(); - if (partyGamesGamer.f()) { - partyGamesGamer.a(this.b().getSpectator()); + ParkourGamer parkourGamer = this.createRoundGamer(); + if (partyGamesGamer.isSpectator()) { + partyGamesGamer.teleport(this.getRoundMap().getSpectator()); } else { - partyGamesGamer.a(this.b().getSpawn()); - parkourGamer.setLocation(this.b().getSpawn()); + partyGamesGamer.teleport(this.getRoundMap().getSpawn()); + parkourGamer.setLocation(this.getRoundMap().getSpawn()); partyGamesGamer.toPlayer().setWalkSpeed(0.4F); } partyGamesGamer.setGamer(parkourGamer); - partyGamesGamer.sendMessages(this.l(), this.game); + partyGamesGamer.sendMessages(this.getStartMessages(), this.game); } - super.f(); + super.prepareRound(); } @Override - public void g() { - super.g(); + public void startRound() { + super.startRound(); this.game.getBossBar().setVisible(true); - this.b().getBarrierZone().a(block -> { + this.getRoundMap().getBarrierZone().forEachBlock(block -> { this.game.getRollbackQueue().add(block.getState()); block.setType(Material.AIR); }); JavaPlugin javaPlugin = this.game.getManager().getEngine().getPlugin(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { - PlayerVisibility.b(javaPlugin, partyGamesGamer.toPlayer(), this.game.getGamers(), this.game.getGamers()); + if (!partyGamesGamer.isSpectator()) { + PlayerVisibility.restoreVisibility(javaPlugin, partyGamesGamer.toPlayer(), this.game.getGamers(), this.game.getGamers()); } } } @Override - public void h() { - super.h(); + public void finishRound() { + super.finishRound(); this.game.getBossBar().setVisible(false); this.game.getBlockedActions().add(GameAction.INTERACT); JavaPlugin javaPlugin = this.game.getManager().getEngine().getPlugin(); for (PartyGamesGamer partyGamesGamer : this.game.getGamers()) { - if (!partyGamesGamer.f()) { - PlayerVisibility.a(javaPlugin, partyGamesGamer.toPlayer(), this.game.getGamers(), this.game.getGamers()); + if (!partyGamesGamer.isSpectator()) { + PlayerVisibility.syncVisibility(javaPlugin, partyGamesGamer.toPlayer(), this.game.getGamers(), this.game.getGamers()); } } } @Override - protected void j() { - this.list2.sort((partyGamesGamer, partyGamesGamer2) -> { + protected void sortStandings() { + this.roundStandings.sort((partyGamesGamer, partyGamesGamer2) -> { if (partyGamesGamer2.getGamer() instanceof ParkourGamer var2) { if (partyGamesGamer.getGamer() instanceof ParkourGamer var5) { - if (var5.c() && var2.c()) { - return Integer.compare(var5.b(), var2.b()); - } else if (!var5.c() && !var2.c()) { - return Integer.compare(var2.a(), var5.a()); + if (var5.isFinished() && var2.isFinished()) { + return Integer.compare(var5.getFinishRank(), var2.getFinishRank()); + } else if (!var5.isFinished() && !var2.isFinished()) { + return Integer.compare(var2.getScore(), var5.getScore()); } else { - return var5.c() ? -1 : 1; + return var5.isFinished() ? -1 : 1; } } else { return -1; @@ -103,25 +103,25 @@ public abstract class ParkourRound extends PartyRound { } @Override - public void a(long longVal) { + public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.d <= 0) { - this.h(); + if (this.remainingSeconds <= 0) { + this.finishRound(); return; } - this.d--; - this.j(); - this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().a(this)); + this.remainingSeconds--; + this.sortStandings(); + this.game.getBossBar().setTitle(this.game.getMessages().getBossBarTimeLeft().render(this)); } - super.a(longVal); + super.onTick(longVal); } @Override public String getVariable(String text) { if (text.equals("countdown")) { - return this.game.isRoundEnding() ? String.valueOf(this.d) : null; + return this.game.isRoundEnding() ? String.valueOf(this.remainingSeconds) : null; } else { return super.getVariable(text); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/ParkourSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/ParkourSetup.java index 6547179..7bccde9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/ParkourSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/ParkourSetup.java @@ -12,5 +12,5 @@ public abstract class ParkourSetup extends PartyRoundSetup { super(defaultUser, partyGamesManager, partyGamesMap, setupTarget, text); } - public abstract ParkourMap i(); + public abstract ParkourMap getRoundMap(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetBarrierZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetBarrierZoneStep.java index dcec697..a566d48 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetBarrierZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetBarrierZoneStep.java @@ -17,33 +17,33 @@ public class ParkourSetBarrierZoneStep implements ClickSetupStep { this.parkourSetup = parkourSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.parkourSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the barrier zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.parkourSetup.getUser(); - this.parkourSetup.getHotbar().a(0, () -> { + this.parkourSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.parkourSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.parkourSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.parkourSetup.i().getPlayZone().a(cuboid)) { + if (!this.parkourSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.parkourSetup.i().setBarrierZone(cuboid); - this.parkourSetup.a(new ParkourSetCheckpointZoneStep(this.parkourSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.parkourSetup.getRoundMap().setBarrierZone(cuboid); + this.parkourSetup.advanceStep(new ParkourSetCheckpointZoneStep(this.parkourSetup)); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetCheckpointZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetCheckpointZoneStep.java index 00ab700..807f17c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetCheckpointZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetCheckpointZoneStep.java @@ -17,33 +17,33 @@ public class ParkourSetCheckpointZoneStep implements ClickSetupStep { this.parkourSetup = parkourSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.parkourSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the checkpoint zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.parkourSetup.getUser(); - this.parkourSetup.getHotbar().a(0, () -> { + this.parkourSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.parkourSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.parkourSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.parkourSetup.i().getPlayZone().a(cuboid)) { + if (!this.parkourSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.parkourSetup.i().setCheckpointZone(cuboid); - this.parkourSetup.a(new ParkourSetFinishZoneStep(this.parkourSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.parkourSetup.getRoundMap().setCheckpointZone(cuboid); + this.parkourSetup.advanceStep(new ParkourSetFinishZoneStep(this.parkourSetup)); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetFinishZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetFinishZoneStep.java index 72e414c..a05ec9e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetFinishZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetFinishZoneStep.java @@ -18,33 +18,33 @@ public class ParkourSetFinishZoneStep implements ClickSetupStep { this.parkourSetup = parkourSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.parkourSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the finish zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.parkourSetup.getUser(); - this.parkourSetup.getHotbar().a(0, () -> { + this.parkourSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.parkourSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.parkourSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { Cuboid cuboid = new Cuboid(block, block2); - if (!this.parkourSetup.i().getPlayZone().a(cuboid)) { + if (!this.parkourSetup.getRoundMap().getPlayZone().contains(cuboid)) { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } else { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.parkourSetup.i().setFinishZone(cuboid); - this.parkourSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.parkourSetup.getRoundMap().setFinishZone(cuboid); + this.parkourSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } } else { defaultUser.sendMessage("§cMust make a selection!"); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetPlayerSpawnStep.java index 33d6ed6..ea8e392 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/shared/parkour/setup/step/ParkourSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class ParkourSetPlayerSpawnStep implements ClickSetupStep { this.parkourSetup = parkourSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.parkourSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e are teleported to on game start."); } - public void a() { + public void configureHotbar() { Player player = this.parkourSetup.getUser().toPlayer(); - this.parkourSetup.getHotbar().a(0, () -> { + this.parkourSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.parkourSetup.i().getPlayZone().a(location)) { - this.parkourSetup.i().setSpawn(location); - this.parkourSetup.a(new ParkourSetBarrierZoneStep(this.parkourSetup)); + if (this.parkourSetup.getRoundMap().getPlayZone().contains(location)) { + this.parkourSetup.getRoundMap().setSpawn(location); + this.parkourSetup.advanceStep(new ParkourSetBarrierZoneStep(this.parkourSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/PartyGamesStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/PartyGamesStatistics.java index f25bda7..182e995 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/PartyGamesStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/PartyGamesStatistics.java @@ -11,17 +11,17 @@ public class PartyGamesStatistics extends BaseGameStatistics { super(partyGamesManager, uuid, text); } - public void a(PartyGamesTeamMember partyGamesTeamMember) { - this.a(this.getWins() + partyGamesTeamMember.getWins()); + public void recordMatchStats(PartyGamesTeamMember partyGamesTeamMember) { + this.setWins(this.getWins() + partyGamesTeamMember.getWins()); if (partyGamesTeamMember.getWins() > 0) { - this.d(this.getCurrentWinStreak() + 1); + this.setCurrentWinStreak(this.getCurrentWinStreak() + 1); if (this.getWinStreak() < this.getCurrentWinStreak()) { - this.c(this.getCurrentWinStreak()); + this.setWinStreak(this.getCurrentWinStreak()); } } else if (partyGamesTeamMember.getLoses() > 0) { - this.d(0); + this.setCurrentWinStreak(0); } - this.b(this.getLoses() + partyGamesTeamMember.getLoses()); + this.setLoses(this.getLoses() + partyGamesTeamMember.getLoses()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/storage/PartyGamesStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/storage/PartyGamesStatisticsRepository.java index 96b322d..76bc275 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/storage/PartyGamesStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/statistics/storage/PartyGamesStatisticsRepository.java @@ -15,53 +15,53 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); } - public void a(PartyGamesStatistics partyGamesStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(PartyGamesStatistics partyGamesStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, partyGamesStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(partyGamesStatistics, var3); + this.readStatistics(partyGamesStatistics, var3); } - partyGamesStatistics.a(true); + partyGamesStatistics.setLoaded(true); } }); } - private void a(PartyGamesStatistics partyGamesStatistics, ResultSet resultSet) throws java.sql.SQLException { - partyGamesStatistics.b(resultSet.getString("options")); - partyGamesStatistics.a(resultSet.getInt("wins")); - partyGamesStatistics.c(resultSet.getInt("win_streak")); - partyGamesStatistics.d(resultSet.getInt("current_win_streak")); - partyGamesStatistics.b(resultSet.getInt("loses")); + private void readStatistics(PartyGamesStatistics partyGamesStatistics, ResultSet resultSet) throws java.sql.SQLException { + partyGamesStatistics.deserializeProperties(resultSet.getString("options")); + partyGamesStatistics.setWins(resultSet.getInt("wins")); + partyGamesStatistics.setWinStreak(resultSet.getInt("win_streak")); + partyGamesStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + partyGamesStatistics.setLoses(resultSet.getInt("loses")); } - public void b(PartyGamesStatistics partyGamesStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(PartyGamesStatistics partyGamesStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, partyGamesStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(partyGamesStatistics); + this.updateStatistics(partyGamesStatistics); } else { - this.c(partyGamesStatistics); + this.insertStatistics(partyGamesStatistics); } } }); } - private void c(PartyGamesStatistics partyGamesStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(PartyGamesStatistics partyGamesStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, partyGamesStatistics.getUUID().toString()); - preparedStatement.setString(2, partyGamesStatistics.c()); + preparedStatement.setString(2, partyGamesStatistics.serializeProperties()); preparedStatement.setInt(3, partyGamesStatistics.getWins()); preparedStatement.setInt(4, partyGamesStatistics.getWinStreak()); preparedStatement.setInt(5, partyGamesStatistics.getCurrentWinStreak()); @@ -70,16 +70,16 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { }); } - private void d(PartyGamesStatistics partyGamesStatistics) { - this.a() - .a( + private void updateStatistics(PartyGamesStatistics partyGamesStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, partyGamesStatistics.c()); + preparedStatement.setString(1, partyGamesStatistics.serializeProperties()); preparedStatement.setInt(2, partyGamesStatistics.getWins()); preparedStatement.setInt(3, partyGamesStatistics.getWinStreak()); preparedStatement.setInt(4, partyGamesStatistics.getCurrentWinStreak()); @@ -90,30 +90,30 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { ); } - public void a(UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { - this.b(this.b, uuid, partyGamesTeamMember); + public void saveAllTimeMatchStats(UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { + this.updatePeriodicStatistics(this.tableName, uuid, partyGamesTeamMember); } - public void b(UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { - this.a(this.b + "_weekly", uuid, partyGamesTeamMember); - this.a(this.b + "_monthly", uuid, partyGamesTeamMember); + public void savePeriodicMatchStats(UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", uuid, partyGamesTeamMember); + this.upsertPeriodicStatistics(this.tableName + "_monthly", uuid, partyGamesTeamMember); } - private void a(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); try (ResultSet var5 = preparedStatement.executeQuery()) { if (var5.next()) { - this.b(text, uuid, partyGamesTeamMember); + this.updatePeriodicStatistics(text, uuid, partyGamesTeamMember); } else { - this.c(text, uuid, partyGamesTeamMember); + this.insertPeriodicStatistics(text, uuid, partyGamesTeamMember); } } }); } - private void b(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { + private void updatePeriodicStatistics(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { String text2 = "current_win_streak"; if (partyGamesTeamMember.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -121,9 +121,9 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -133,7 +133,7 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, partyGamesTeamMember.getWins()); @@ -144,8 +144,8 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { ); } - private void c(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, UUID uuid, PartyGamesTeamMember partyGamesTeamMember) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, uuid.toString()); preparedStatement.setInt(2, partyGamesTeamMember.getWins()); preparedStatement.setInt(3, partyGamesTeamMember.getWins()); @@ -155,45 +155,45 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { }); } - private void e() { - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + private void createMigrationTables() { + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -202,22 +202,22 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { String text3 = var4.getString("name"); int index = var4.getInt("wins"); int index2 = var4.getInt("loses"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -230,9 +230,9 @@ public class PartyGamesStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( - "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", + this.getDatabase() + .executeSync( + "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); preparedStatement3.setInt(2, index); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/storage/PartyGamesStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/storage/PartyGamesStorage.java index 9e7bdcf..3ac0867 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/storage/PartyGamesStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/storage/PartyGamesStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.partygames.statistics.storage.PartyGamesStatist public class PartyGamesStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final PartyGamesStatisticsRepository partyGamesStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public PartyGamesStorage(PartyGamesManager partyGamesManager) { super(partyGamesManager); this.storage = new GameMapStorage(partyGamesManager.getConfigManager(), this.file, PartyGamesMap::new); - this.storage2 = new NpcStorage(partyGamesManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(partyGamesManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(partyGamesManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(partyGamesManager.getConfigManager(), this.file); this.partyGamesStatisticsRepository = new PartyGamesStatisticsRepository(partyGamesManager.getEngine()); - this.storage4 = new LeaderboardStorage(partyGamesManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(partyGamesManager.getConfigManager(), this.file, PartyGamesMap::new); + this.leaderboardStorage = new LeaderboardStorage(partyGamesManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(partyGamesManager.getConfigManager(), this.file, PartyGamesMap::new); } @Override @@ -34,26 +34,26 @@ public class PartyGamesStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public PartyGamesStatisticsRepository e() { + public PartyGamesStatisticsRepository getStatisticsRepository() { return this.partyGamesStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeam.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeam.java index 9677aa0..076beab 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeam.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeam.java @@ -5,43 +5,43 @@ import ro.fr33styler.arcade.game.partygames.player.PartyGamesGamer; import java.util.UUID; public class PartyGamesTeam implements PartyGamesTeamMember { - private final String a; - private final UUID b; - private int c; - private int d; - private final int e; + private final String playerName; + private final UUID uuid; + private int wins; + private int loses; + private final int stars; public PartyGamesTeam(PartyGamesGamer partyGamesGamer) { - this.a = partyGamesGamer.getName(); - this.b = partyGamesGamer.getUUID(); - this.c = partyGamesGamer.getWins(); - this.d = partyGamesGamer.getLoses(); - this.e = partyGamesGamer.m(); + this.playerName = partyGamesGamer.getName(); + this.uuid = partyGamesGamer.getUUID(); + this.wins = partyGamesGamer.getWins(); + this.loses = partyGamesGamer.getLoses(); + this.stars = partyGamesGamer.getStars(); } - public UUID a() { - return this.b; + public UUID getUUID() { + return this.uuid; } public int getWins() { - return this.c; + return this.wins; } - public void a(int index) { - this.c = index; + public void setWins(int index) { + this.wins = index; } public int getLoses() { - return this.d; + return this.loses; } - public void b(int index) { - this.d = index; + public void setLoses(int index) { + this.loses = index; } - public void a(PartyGamesGamer partyGamesGamer) { - partyGamesGamer.a(this.c); - partyGamesGamer.b(this.d); - partyGamesGamer.c(this.e); + public void restoreTo(PartyGamesGamer partyGamesGamer) { + partyGamesGamer.setWins(this.wins); + partyGamesGamer.setLoses(this.loses); + partyGamesGamer.setStars(this.stars); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeamColor.java b/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeamColor.java index e27e06b..a2ca2eb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeamColor.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/partygames/team/PartyGamesTeamColor.java @@ -29,13 +29,13 @@ public enum PartyGamesTeamColor { private final ArcadeColor arcadeColor; private final ChatColor chatColor; - private final Function s; - private static final PartyGamesTeamColor[] t = values(); + private final Function displayNameResolver; + private static final PartyGamesTeamColor[] VALUES = values(); PartyGamesTeamColor(ArcadeColor arcadeColor2, ChatColor chatColor2, Function function) { this.arcadeColor = arcadeColor2; this.chatColor = chatColor2; - this.s = function; + this.displayNameResolver = function; } public ArcadeColor toArcadeColor() { @@ -50,7 +50,7 @@ public enum PartyGamesTeamColor { return this.chatColor; } - public String a(PartyGamesMessages partyGamesMessages) { - return this.s.apply(partyGamesMessages); + public String getDisplayName(PartyGamesMessages partyGamesMessages) { + return this.displayNameResolver.apply(partyGamesMessages); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntGame.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntGame.java index e6355a2..bc54cc7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntGame.java @@ -33,54 +33,54 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class PropHuntGame extends AbstractGame implements GameEventHandler { - private int c; + private int timeLeft; private final PropHuntTeam team; - private final PropHuntTeam team2; + private final PropHuntTeam seekerTeam; private PropHuntGamer[] gamers; - private final PropHuntMap g; + private final PropHuntMap map; private final PropHuntManager manager; - private final Map i = new HashMap<>(); + private final Map props = new HashMap<>(); private final Lifecycle lifecycle = new PropHuntLifecycle(this); - private final Map> k = new HashMap<>(); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final Map> propInspectors = new HashMap<>(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); private final Set set = EnumSet.of(GameAction.HUNGER, GameAction.HEALTH_REGAIN, GameAction.BLOCK_BREAK, GameAction.BLOCK_PLACE, GameAction.ITEM_DROP, GameAction.ITEM_PICKUP, GameAction.CLICK); public PropHuntGame(PropHuntManager manager2, PropHuntMap propHuntMap) { - this.g = propHuntMap; + this.map = propHuntMap; this.manager = manager2; this.setPhase(this.lifecycle.getWaiting()); this.team = new PropHuntTeam(this.getMessages().getTeamHider(), this.getScoreboard()); this.team.getScoreboardTeam().setColor(ChatColor.GRAY); this.team.getScoreboardTeam().setCanSeeFriendlyInvisibles(true); - this.team2 = new PropHuntTeam(this.getMessages().getTeamSeeker(), this.getScoreboard()); - this.team2.getScoreboardTeam().setColor(ChatColor.GREEN); + this.seekerTeam = new PropHuntTeam(this.getMessages().getTeamSeeker(), this.getScoreboard()); + this.seekerTeam.getScoreboardTeam().setColor(ChatColor.GREEN); if (this.getSettings().isHideSeekerNameTag()) { - this.team2.getScoreboardTeam().setNameTagVisibility(TeamRule.FOR_OWN_TEAM); + this.seekerTeam.getScoreboardTeam().setNameTagVisibility(TeamRule.FOR_OWN_TEAM); } } - public int o() { - return this.c; + public int getTimeLeft() { + return this.timeLeft; } - public void a(int index) { - this.c = index; + public void setTimeLeft(int index) { + this.timeLeft = index; } public PropHuntMap getMap() { - return this.g; + return this.map; } - public PropHuntTeam getTeam4() { + public PropHuntTeam getHiderTeam() { return this.team; } - public PropHuntTeam getTeam2() { - return this.team2; + public PropHuntTeam getSeekerTeam() { + return this.seekerTeam; } - public Map s() { - return this.i; + public Map getProps() { + return this.props; } public Lifecycle getPhaseLifecycle() { @@ -91,17 +91,17 @@ public class PropHuntGame extends AbstractGame implements GameEventHandler { return this.manager.getMessages(); } - private PropHuntConfiguration z() { - PropHuntConfiguration propHuntConfiguration = (PropHuntConfiguration)this.getManager().H().get(this.getMap().getId()); - return propHuntConfiguration == null ? this.getManager().getConfiguration4() : propHuntConfiguration; + private PropHuntConfiguration getConfiguration() { + PropHuntConfiguration propHuntConfiguration = (PropHuntConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return propHuntConfiguration == null ? this.getManager().getConfiguration() : propHuntConfiguration; } public PropHuntSettings getSettings() { - return this.z().getSettings(); + return this.getConfiguration().getSettings(); } - public PropHuntRewards v() { - return this.z().getRewards(); + public PropHuntRewards getRewards() { + return this.getConfiguration().getRewards(); } public PropHuntManager getManager() { @@ -116,30 +116,30 @@ public class PropHuntGame extends AbstractGame implements GameEventHandler { this.gamers = gamers3; } - public Map> x() { - return this.k; + public Map> getPropInspectors() { + return this.propInspectors; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { return switch (text) { - case "time_left" -> Strings.a(this.c); + case "time_left" -> Strings.formatDuration(this.timeLeft); case "hiders_alive" -> String.valueOf(this.team.getList().size()); - case "seekers_alive" -> String.valueOf(this.team2.getList().size()); + case "seekers_alive" -> String.valueOf(this.seekerTeam.getList().size()); default -> super.getVariable(text); }; } - public PropHuntProp a(Location location) { + public PropHuntProp findPropAt(Location location) { PropHuntProp propHuntProp = null; - for (PropHuntProp propHuntProp2 : this.i.values()) { - if (Locations.b(propHuntProp2.getLocation(), location) <= 0.7) { + for (PropHuntProp propHuntProp2 : this.props.values()) { + if (Locations.distanceSquared(propHuntProp2.getLocation(), location) <= 0.7) { if (propHuntProp2.getOwner() != null) { return propHuntProp2; } @@ -153,13 +153,13 @@ public class PropHuntGame extends AbstractGame implements GameEventHandler { return propHuntProp; } - public PropHuntProp b(Location location) { + public PropHuntProp raycastProp(Location location) { PropHuntProp propHuntProp = null; Vector vector = location.getDirection().multiply(0.3); for (int index = 0; index < 10; index++) { - for (PropHuntProp propHuntProp2 : this.i.values()) { - if (Locations.b(propHuntProp2.getLocation(), location) <= 0.7) { + for (PropHuntProp propHuntProp2 : this.props.values()) { + if (Locations.distanceSquared(propHuntProp2.getLocation(), location) <= 0.7) { if (propHuntProp2.getOwner() != null) { return propHuntProp2; } @@ -176,54 +176,54 @@ public class PropHuntGame extends AbstractGame implements GameEventHandler { return propHuntProp; } - public void y() { + public void checkWinCondition() { if (this.team.getList().isEmpty()) { - for (PropHuntGamer propHuntGamer : this.gamers2) { + for (PropHuntGamer propHuntGamer : this.gamerSet) { propHuntGamer.sendTitle(this.getMessages().getTitleSeekersWon(), this.getMessages().getSubtitleSeekersWon(), 0, 80, 0); } - this.a(this.team2); - } else if (this.team2.getList().isEmpty()) { - for (PropHuntGamer propHuntGamer2 : this.gamers2) { + this.finishGame(this.seekerTeam); + } else if (this.seekerTeam.getList().isEmpty()) { + for (PropHuntGamer propHuntGamer2 : this.gamerSet) { propHuntGamer2.sendTitle(this.getMessages().getTitleHidersWon(), this.getMessages().getTitleHidersWonOnQuit(), 0, 80, 0); } - this.a(this.team); + this.finishGame(this.team); } } - public void a(PropHuntTeam propHuntTeam) { - Arrays.sort(this.gamers, Comparator.comparingInt(PropHuntGamer::n).reversed()); - Context context = Contexts.a(Contexts.a(this.manager, this.gamers), text -> { + public void finishGame(PropHuntTeam propHuntTeam) { + Arrays.sort(this.gamers, Comparator.comparingInt(PropHuntGamer::getKills).reversed()); + Context context = Contexts.withVariables(Contexts.withPodium(this.manager, this.gamers), text -> { return switch (text) { - case "winner" -> propHuntTeam.a(); + case "winner" -> propHuntTeam.getName(); case "winner_color" -> (propHuntTeam == this.team ? ChatColor.AQUA : ChatColor.RED).toString(); - case "first_kills" -> String.valueOf(this.gamers.length > 0 ? this.gamers[0].n() : 0); - case "second_kills" -> String.valueOf(this.gamers.length > 1 ? this.gamers[1].n() : 0); - case "third_kills" -> String.valueOf(this.gamers.length > 2 ? this.gamers[2].n() : 0); + case "first_kills" -> String.valueOf(this.gamers.length > 0 ? this.gamers[0].getKills() : 0); + case "second_kills" -> String.valueOf(this.gamers.length > 1 ? this.gamers[1].getKills() : 0); + case "third_kills" -> String.valueOf(this.gamers.length > 2 ? this.gamers[2].getKills() : 0); default -> null; }; }); - for (PropHuntGamer propHuntGamer : this.gamers2) { + for (PropHuntGamer propHuntGamer : this.gamerSet) { propHuntGamer.sendMessages(this.getMessages().getEndingTop(), context); - propHuntGamer.a(this.getMessages().getSidebarPlaying(), propHuntGamer); - if (!propHuntGamer.getSpectatorOptions().g()) { - if (propHuntTeam == propHuntGamer.getTeam6()) { + propHuntGamer.updateSidebar(this.getMessages().getSidebarPlaying(), propHuntGamer); + if (!propHuntGamer.getSpectatorOptions().isExternal()) { + if (propHuntTeam == propHuntGamer.getTeam()) { if (propHuntGamer.getLoses() == 0) { - propHuntGamer.a(1); + propHuntGamer.setWins(1); if (propHuntTeam == this.team) { - propHuntGamer.c(1); + propHuntGamer.setHiderWins(1); } else { - propHuntGamer.d(1); + propHuntGamer.setSeekerWins(1); } } - if (this.v().isEnabled()) { - propHuntGamer.a(this.v().getWinners(), text2 -> text2.replace("%team%", propHuntGamer.getTeam6().a())); + if (this.getRewards().isEnabled()) { + propHuntGamer.setRewardCommands(this.getRewards().getWinners(), text2 -> text2.replace("%team%", propHuntGamer.getTeam().getName())); } - } else if (this.v().isEnabled()) { - propHuntGamer.a(this.v().getLosers(), text3 -> text3.replace("%team%", propHuntGamer.getTeam6().a())); + } else if (this.getRewards().isEnabled()) { + propHuntGamer.setRewardCommands(this.getRewards().getLosers(), text3 -> text3.replace("%team%", propHuntGamer.getTeam().getName())); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntManager.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntManager.java index 210d235..308145b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/PropHuntManager.java @@ -33,12 +33,12 @@ public class PropHuntManager extends AbstractGameManager { private final Command command; private final PropHuntStorage storage; private final PropHuntMessages messages = new PropHuntMessages(); - private final Map h = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final PropHuntConfiguration configuration = new PropHuntConfiguration(); private final PropHuntListener listener = new PropHuntListener(this); - private final Map k = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final PropHuntSessions sessions = new PropHuntSessions(this); - private final Map> m = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "hider_wins", this.messages::getStatisticHiderWins, "seeker_wins", this.messages::getStatisticSeekerWins ); @@ -71,7 +71,7 @@ public class PropHuntManager extends AbstractGameManager { return this.sessions; } - public PropHuntConfiguration getConfiguration4() { + public PropHuntConfiguration getConfiguration() { return this.configuration; } @@ -86,21 +86,21 @@ public class PropHuntManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { PropHuntStatistics propHuntStatistics = new PropHuntStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(propHuntStatistics); - this.h.put(player.getUniqueId(), propHuntStatistics); + this.storage.getStatisticsRepository().loadStatistics(propHuntStatistics); + this.playerStatistics.put(player.getUniqueId(), propHuntStatistics); } public PropHuntStatistics getData(UUID uuid) { - return this.h.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.h.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map H() { - return this.k; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -117,7 +117,7 @@ public class PropHuntManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.m; + return this.leaderboardSources; } @Override @@ -125,16 +125,16 @@ public class PropHuntManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "prop_hunt"); } - private void I() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); PropHuntConfiguration propHuntConfiguration = new PropHuntConfiguration(); - propHuntConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.k.put("id_1", this.configuration); - Files.a(file, file2 -> { + propHuntConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { PropHuntConfiguration propHuntConfiguration2 = new PropHuntConfiguration(); - propHuntConfiguration2.a(this.getConfigManager(), file2); - this.k.put(file2.getName(), propHuntConfiguration2); + propHuntConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), propHuntConfiguration2); } }); } @@ -142,16 +142,16 @@ public class PropHuntManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.I(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { this.propHuntPropFactory = VersionAdapters.get().createPropHuntPropFactorySelector().select(); - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/command/PropHuntCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/command/PropHuntCreateCommand.java index 20a8625..49318ec 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/command/PropHuntCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/command/PropHuntCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class PropHuntCreateCommand implements CommandExecutor { - private final PropHuntManager a; + private final PropHuntManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public PropHuntCreateCommand(PropHuntManager propHuntManager) { - this.a = propHuntManager; + this.manager = propHuntManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class PropHuntCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); PropHuntMap propHuntMap = new PropHuntMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class PropHuntCreateCommand implements CommandExecutor { } propHuntMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } propHuntMap.setId(text2); propHuntMap.setMaximumPlayers(index3); - defaultUser.a(new PropHuntSetup(defaultUser, propHuntMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new PropHuntSetup(defaultUser, propHuntMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/PropHuntConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/PropHuntConfiguration.java index 93aaad4..4f56f56 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/PropHuntConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/PropHuntConfiguration.java @@ -9,7 +9,7 @@ public class PropHuntConfiguration { private final PropHuntRewards rewards = new PropHuntRewards(); private final PropHuntSettings settings = new PropHuntSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/message/PropHuntMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/message/PropHuntMessages.java index fd94966..e55c74a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/message/PropHuntMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/config/message/PropHuntMessages.java @@ -12,115 +12,115 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class PropHuntMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Prop Hunt"); + private String displayName = Strings.colorize("Prop Hunt"); @Setting("title-seekers-won") - private String titleSeekersWon = Strings.a("&cSeekers WIN!"); + private String titleSeekersWon = Strings.colorize("&cSeekers WIN!"); @Setting("subtitle-seekers-won") - private String subtitleSeekersWon = Strings.a("&eAll Hiders have been found!"); + private String subtitleSeekersWon = Strings.colorize("&eAll Hiders have been found!"); @Setting("title-hiders-won") - private String titleHidersWon = Strings.a("&bHiders WIN!"); + private String titleHidersWon = Strings.colorize("&bHiders WIN!"); @Setting("title-hiders-won-on-time") - private String titleHidersWonOnTime = Strings.a("&eThe Seekers ran out of time!"); + private String titleHidersWonOnTime = Strings.colorize("&eThe Seekers ran out of time!"); @Setting("title-hiders-won-on-quit") - private String titleHidersWonOnQuit = Strings.a("&eAll Seekers have left!"); + private String titleHidersWonOnQuit = Strings.colorize("&eAll Seekers have left!"); @Setting("title-seeker-start") - private String titleSeekerStart = Strings.a("&aYou are the Seeker!"); + private String titleSeekerStart = Strings.colorize("&aYou are the Seeker!"); @Setting("subtitle-seeker-start") - private Text subtitleSeekerStart = TextParser.a("&aYou will be teleported in &e%grace_period%s&a!"); + private Text subtitleSeekerStart = TextParser.parse("&aYou will be teleported in &e%grace_period%s&a!"); @Setting("subtitle-seeker-grace-period-expired") - private String subtitleSeekerGracePeriodExpired = Strings.a("&aYou can now kill the Hiders!"); + private String subtitleSeekerGracePeriodExpired = Strings.colorize("&aYou can now kill the Hiders!"); @Setting("ability-stun") - private String abilityStun = Strings.a("Stun"); + private String abilityStun = Strings.colorize("Stun"); @Setting("ability-camouflage") - private String abilityCamouflage = Strings.a("Camouflage"); + private String abilityCamouflage = Strings.colorize("Camouflage"); @Setting("ability-explode") - private String abilityExplode = Strings.a("Explode"); + private String abilityExplode = Strings.colorize("Explode"); @Setting("title-hider-start") - private String titleHiderStart = Strings.a("&bROLE: HIDER"); + private String titleHiderStart = Strings.colorize("&bROLE: HIDER"); @Setting("subtitle-hider-start") - private String subtitleHiderStart = Strings.a("&6Don't get caught by the Seeker!"); + private String subtitleHiderStart = Strings.colorize("&6Don't get caught by the Seeker!"); @Setting("title-hider-killed") - private String titleHiderKilled = Strings.a("&cYou are now a Seeker!"); + private String titleHiderKilled = Strings.colorize("&cYou are now a Seeker!"); @Setting("subtitle-hider-killed") - private Text subtitleHiderKilled = TextParser.a("&a%killer% &7discovered you!"); + private Text subtitleHiderKilled = TextParser.parse("&a%killer% &7discovered you!"); @Setting("subtitle-hider-grace-period-expired") - private String subtitleHiderGracePeriodExpired = Strings.a("&cThe Seeker is on the loose!"); + private String subtitleHiderGracePeriodExpired = Strings.colorize("&cThe Seeker is on the loose!"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-hider-wins") - private String statisticHiderWins = Strings.a("Hider Wins"); + private String statisticHiderWins = Strings.colorize("Hider Wins"); @Setting("statistic-seeker-wins") - private String statisticSeekerWins = Strings.a("Seeker Wins"); + private String statisticSeekerWins = Strings.colorize("Seeker Wins"); @Setting("team-hider") - private String teamHider = Strings.a("Hider"); + private String teamHider = Strings.colorize("Hider"); @Setting("team-seeker") - private String teamSeeker = Strings.a("Seeker"); + private String teamSeeker = Strings.colorize("Seeker"); @Setting("team-spectator") - private String teamSpectator = Strings.a("Spectator"); + private String teamSpectator = Strings.colorize("Spectator"); @Setting("actionBarAbility") - private Text actionbarability = TextParser.a("&e&lLEFT CLICK&e to use &a%ability% &e&lRIGHT CLICK a prop to swap!"); + private Text actionbarability = TextParser.parse("&e&lLEFT CLICK&e to use &a%ability% &e&lRIGHT CLICK a prop to swap!"); @Setting("actionBarAbilityCooldown") - private Text actionbarabilitycooldown = TextParser.a("&7LEFT CLICK to use %ability% (&c%ability_cooldown%&7) &e&lRIGHT CLICK a prop to swap!"); + private Text actionbarabilitycooldown = TextParser.parse("&7LEFT CLICK to use %ability% (&c%ability_cooldown%&7) &e&lRIGHT CLICK a prop to swap!"); @Setting("hider-discovered-by-killer") - private Text hiderDiscoveredByKiller = TextParser.a("&7%player% was discovered by %killer%"); + private Text hiderDiscoveredByKiller = TextParser.parse("&7%player% was discovered by %killer%"); @Setting("item-prop-stick") - private String itemPropStick = Strings.a("&6Prop Stick"); + private String itemPropStick = Strings.colorize("&6Prop Stick"); @Setting("item-seeker-sword") - private String itemSeekerSword = Strings.a("&cSeeker's Sword"); + private String itemSeekerSword = Strings.colorize("&cSeeker's Sword"); @Setting("item-seeker-bow") - private String itemSeekerBow = Strings.a("&cSeeker's Bow"); + private String itemSeekerBow = Strings.colorize("&cSeeker's Bow"); @Setting("item-seeker-marking-tool") - private String itemSeekerMarkingTool = Strings.a("&6Marking Tool"); + private String itemSeekerMarkingTool = Strings.colorize("&6Marking Tool"); @Setting("item-seeker-marking-tool-lore") - private List itemSeekerMarkingToolLore = Strings.a(new String[]{"&7Click to cycle marking a", "&7prop as &achecked&7,", "&csuspicious&7 or unmarked."}); + private List itemSeekerMarkingToolLore = Strings.colorizeLines(new String[]{"&7Click to cycle marking a", "&7prop as &achecked&7,", "&csuspicious&7 or unmarked."}); @Setting("heartbeat-1st") - private String heartbeat1st = Strings.a("&c(❤)"); + private String heartbeat1st = Strings.colorize("&c(❤)"); @Setting("heartbeat-2nd") - private String heartbeat2nd = Strings.a("&c( ❤ )"); + private String heartbeat2nd = Strings.colorize("&c( ❤ )"); @Setting("mark-prop-checked") - private String markPropChecked = Strings.a("&a◆ CHECKED"); + private String markPropChecked = Strings.colorize("&a◆ CHECKED"); @Setting("mark-prop-suspicious") - private String markPropSuspicious = Strings.a("&c◆ SUSPICIOUS"); + private String markPropSuspicious = Strings.colorize("&c◆ SUSPICIOUS"); @Setting("marked-as-checked") - private Text markedAsChecked = TextParser.a("&eYou marked &a%disguise% &eas &achecked&e. Remember, Hiders can swap what they are disguised as!"); + private Text markedAsChecked = TextParser.parse("&eYou marked &a%disguise% &eas &achecked&e. Remember, Hiders can swap what they are disguised as!"); @Setting("marked-as-suspicious") - private Text markedAsSuspicious = TextParser.a("&eYou marked &a%disguise% &eas &csuspicious&e. Remember, Hiders can swap what they are disguised as!"); + private Text markedAsSuspicious = TextParser.parse("&eYou marked &a%disguise% &eas &csuspicious&e. Remember, Hiders can swap what they are disguised as!"); @Setting("marked-as-node") - private Text markedAsNode = TextParser.a("&eYou unmarked &a%disguise%"); + private Text markedAsNode = TextParser.parse("&eYou unmarked &a%disguise%"); @Setting("prop-already-owned") - private Text propAlreadyOwned = TextParser.a("&cThat prop is already controlled by %owner%&c!"); + private Text propAlreadyOwned = TextParser.parse("&cThat prop is already controlled by %owner%&c!"); @Setting("prop-disguised-as") - private Text propDisguisedAs = TextParser.a("&aYou have disguised yourself as &e%disguise%&a!"); + private Text propDisguisedAs = TextParser.parse("&aYou have disguised yourself as &e%disguise%&a!"); @Setting("ability-exploded-used-on-you") - private Text abilityExplodedUsedOnYou = TextParser.a("&7%player% &cused &eExplode&c on you!"); + private Text abilityExplodedUsedOnYou = TextParser.parse("&7%player% &cused &eExplode&c on you!"); @Setting("ability-exploded-used-by-you") - private String abilityExplodedUsedByYou = Strings.a("&aYou used &eExplode&a!"); + private String abilityExplodedUsedByYou = Strings.colorize("&aYou used &eExplode&a!"); @Setting("ability-exploded-no-hit") - private String abilityExplodedNoHit = Strings.a("&cYou did not hit any Seekers with Explode!"); + private String abilityExplodedNoHit = Strings.colorize("&cYou did not hit any Seekers with Explode!"); @Setting("ability-exploded-you-hit") - private Text abilityExplodedYouHit = TextParser.a("&aYou hit &c%hit%&a with &eExplode&a!"); + private Text abilityExplodedYouHit = TextParser.parse("&aYou hit &c%hit%&a with &eExplode&a!"); @Setting("ability-stun-used-on-you") - private Text abilityStunUsedOnYou = TextParser.a("&7%player% &cused &eStun&c on you!"); + private Text abilityStunUsedOnYou = TextParser.parse("&7%player% &cused &eStun&c on you!"); @Setting("ability-stunned-for") - private String abilityStunnedFor = Strings.a("&cYou have been stunned for &e3s&c!"); + private String abilityStunnedFor = Strings.colorize("&cYou have been stunned for &e3s&c!"); @Setting("ability-stun-used-by-you") - private String abilityStunUsedByYou = Strings.a("&aYou used &eStun&a!"); + private String abilityStunUsedByYou = Strings.colorize("&aYou used &eStun&a!"); @Setting("ability-stun-no-hit") - private String abilityStunNoHit = Strings.a("&cYou did not hit any Seekers with Stun!"); + private String abilityStunNoHit = Strings.colorize("&cYou did not hit any Seekers with Stun!"); @Setting("ability-stun-you-hit") - private Text abilityStunYouHit = TextParser.a("&aYou hit &c%hit%&a with &eStun&a!"); + private Text abilityStunYouHit = TextParser.parse("&aYou hit &c%hit%&a with &eStun&a!"); @Setting("ability-cooldown") - private Text abilityCooldown = TextParser.a("&cPlease wait &e%ability_cooldown%s&c before using &e%ability%&c!"); + private Text abilityCooldown = TextParser.parse("&cPlease wait &e%ability_cooldown%s&c before using &e%ability%&c!"); @Setting("hider-grace-period-timer") - private Text hiderGracePeriodTimer = TextParser.a("&cThe Seeker will be released in &e%grace_period%s&c!"); + private Text hiderGracePeriodTimer = TextParser.parse("&cThe Seeker will be released in &e%grace_period%s&c!"); @Setting("hider-ability-explode-lore") - private List hiderAbilityExplodeLore = Strings.a( + private List hiderAbilityExplodeLore = Strings.colorizeLines( new String[]{ "&7Ability: &aExplode", " &8▪ &7Knockback nearby Seekers by", @@ -131,7 +131,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("hider-ability-camouflage-lore") - private List hiderAbilityCamouflageLore = Strings.a( + private List hiderAbilityCamouflageLore = Strings.colorizeLines( new String[]{ "&7Ability: &aCamouflage", " &8▪ &7Blend in with the map by", @@ -144,7 +144,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("hider-ability-stun-lore") - private List hiderAbilityStunLore = Strings.a( + private List hiderAbilityStunLore = Strings.colorizeLines( new String[]{ "&7Ability: &aStun", " &8▪ &7Stun nearby Seekers, temporarily", @@ -157,7 +157,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("hider-start") - private List hiderStart = TextParser.a( + private List hiderStart = TextParser.parseAll( new String[]{ "&a%line%", " &lProp Hunt", @@ -175,7 +175,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("seeker-start") - private List seekerStart = TextParser.a( + private List seekerStart = TextParser.parseAll( new String[]{ "&a%line%", " &lProp Hunt", @@ -191,7 +191,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lProp Hunt", @@ -206,7 +206,7 @@ public class PropHuntMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -254,8 +254,8 @@ public class PropHuntMessages extends BaseGameMessages { ); public PropHuntMessages() { - this.chatInGame = TextParser.a("%team_color%[%team%] &7%player%&f: %message%"); - this.statisticsView = TextParser.a( + this.chatInGame = TextParser.parse("%team_color%[%team%] &7%player%&f: %message%"); + this.statisticsView = TextParser.parseAll( new String[]{ " ", " &l%display_name% Statistics", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/lifecycle/PropHuntLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/lifecycle/PropHuntLifecycle.java index eb8e082..c25a03f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/lifecycle/PropHuntLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/lifecycle/PropHuntLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class PropHuntLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public PropHuntLifecycle(PropHuntGame propHuntGame) { this.phase = new WaitingPhase(propHuntGame); - this.phase2 = new PropHuntPlayingPhase(propHuntGame); - this.phase3 = new EndingPhase(propHuntGame); - this.phase4 = new ResettingPhase(propHuntGame); + this.playingPhase = new PropHuntPlayingPhase(propHuntGame); + this.endingPhase = new EndingPhase(propHuntGame); + this.resettingPhase = new ResettingPhase(propHuntGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class PropHuntLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/listener/PropHuntListener.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/listener/PropHuntListener.java index 776e204..76a1850 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/listener/PropHuntListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/listener/PropHuntListener.java @@ -31,77 +31,77 @@ import ro.fr33styler.arcade.api.engine.event.packet.AsyncPacketEntityInteractEve import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class PropHuntListener extends GameListener { - private final PropHuntManager manager2; + private final PropHuntManager propHuntManager; public PropHuntListener(PropHuntManager manager22) { super(manager22); - this.manager2 = manager22; + this.propHuntManager = manager22; } @EventHandler - public void a(ProjectileHitEvent event) { - if (event.getEntity().getShooter() instanceof Player var2 && this.a(var2, PropHuntGamer.class) != null) { + public void onProjectileHit(ProjectileHitEvent event) { + if (event.getEntity().getShooter() instanceof Player var2 && this.getActiveGamer(var2, PropHuntGamer.class) != null) { event.getEntity().remove(); } } @EventHandler - public void a(EntityDamageEvent event) { - if (event.getCause() != DamageCause.CUSTOM && this.a(event.getEntity(), PropHuntGamer.class) != null) { + public void onEntityDamage(EntityDamageEvent event) { + if (event.getCause() != DamageCause.CUSTOM && this.getActiveGamer(event.getEntity(), PropHuntGamer.class) != null) { event.setCancelled(true); } } @EventHandler - public void a(EntityDamageByEntityEvent event) { + public void onEntityDamageByProjectile(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Projectile var2 && var2.getShooter() instanceof Player var3) { - PropHuntGamer propHuntGamer = this.a(var3, PropHuntGamer.class); - if (propHuntGamer == null || propHuntGamer.f()) { + PropHuntGamer propHuntGamer = this.getActiveGamer(var3, PropHuntGamer.class); + if (propHuntGamer == null || propHuntGamer.isSpectator()) { return; } PropHuntGame propHuntGame = propHuntGamer.getGame(); - if (propHuntGamer.getTeam6() != propHuntGame.getTeam2()) { + if (propHuntGamer.getTeam() != propHuntGame.getSeekerTeam()) { event.setCancelled(true); return; } - PropHuntGamer propHuntGamer2 = this.a(event.getEntity(), PropHuntGamer.class); + PropHuntGamer propHuntGamer2 = this.getActiveGamer(event.getEntity(), PropHuntGamer.class); if (propHuntGamer2 == null) { - PropHuntProp propHuntProp = propHuntGame.a(event.getEntity().getLocation()); + PropHuntProp propHuntProp = propHuntGame.findPropAt(event.getEntity().getLocation()); if (propHuntProp != null && propHuntProp.getOwner() != null) { - propHuntGamer2 = this.a(propHuntProp.getOwner(), PropHuntGamer.class); + propHuntGamer2 = this.getActiveGamer(propHuntProp.getOwner(), PropHuntGamer.class); } } - if (propHuntGamer2 == null || propHuntGamer2.f()) { + if (propHuntGamer2 == null || propHuntGamer2.isSpectator()) { return; } event.setCancelled(true); - propHuntGamer.a(propHuntGamer2, 2.0); + propHuntGamer.damageHider(propHuntGamer2, 2.0); } } @EventHandler - public void b(EntityDamageByEntityEvent event) { + public void onEntityDamageByPlayer(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player var2) { - PropHuntGamer propHuntGamer = this.a(var2, PropHuntGamer.class); - if (propHuntGamer == null || propHuntGamer.f()) { + PropHuntGamer propHuntGamer = this.getActiveGamer(var2, PropHuntGamer.class); + if (propHuntGamer == null || propHuntGamer.isSpectator()) { return; } PropHuntGame propHuntGame = propHuntGamer.getGame(); - if (propHuntGamer.getTeam6() == propHuntGame.getTeam4()) { - propHuntGamer.x(); + if (propHuntGamer.getTeam() == propHuntGame.getHiderTeam()) { + propHuntGamer.handleLeftClick(); } - if (propHuntGamer.getTeam6() == propHuntGame.getTeam4() || propHuntGamer.v() > 0) { + if (propHuntGamer.getTeam() == propHuntGame.getHiderTeam() || propHuntGamer.getStunTimer() > 0) { event.setCancelled(true); return; } - PropHuntProp propHuntProp = propHuntGame.b(var2.getEyeLocation()); + PropHuntProp propHuntProp = propHuntGame.raycastProp(var2.getEyeLocation()); if (propHuntProp == null || propHuntProp.getOwner() == null) { event.setCancelled(true); return; @@ -113,36 +113,36 @@ public class PropHuntListener extends GameListener { } event.setCancelled(true); - propHuntGamer.a(propHuntGamer2, 2.0); + propHuntGamer.damageHider(propHuntGamer2, 2.0); } } @EventHandler - public void a(AsyncPacketEntityInteractEvent event) { - Bukkit.getScheduler().runTask(this.manager2.getEngine().getPlugin(), () -> { + public void onAsyncPacketEntityInteract(AsyncPacketEntityInteractEvent event) { + Bukkit.getScheduler().runTask(this.propHuntManager.getEngine().getPlugin(), () -> { Player player = event.getPlayer(); - PropHuntGamer propHuntGamer = this.a(player, PropHuntGamer.class); - if (propHuntGamer != null && !propHuntGamer.f()) { + PropHuntGamer propHuntGamer = this.getActiveGamer(player, PropHuntGamer.class); + if (propHuntGamer != null && !propHuntGamer.isSpectator()) { PropHuntGame propHuntGame = propHuntGamer.getGame(); - for (PropHuntInspectionMarker propHuntInspectionMarker : propHuntGamer.getMap34().values()) { + for (PropHuntInspectionMarker propHuntInspectionMarker : propHuntGamer.getInspectionMarkers().values()) { if (propHuntInspectionMarker.getHologramEntity().getEntity().getEntityId() == event.getId()) { if (event.isAttack()) { - PropHuntProp propHuntProp = propHuntGame.b(player.getEyeLocation()); - if (propHuntProp == null || propHuntProp.getOwner() == null || propHuntGamer.getTeam6() != propHuntGame.getTeam2()) { + PropHuntProp propHuntProp = propHuntGame.raycastProp(player.getEyeLocation()); + if (propHuntProp == null || propHuntProp.getOwner() == null || propHuntGamer.getTeam() != propHuntGame.getSeekerTeam()) { return; } PropHuntGamer propHuntGamer2 = (PropHuntGamer)propHuntGame.getGamers().c(propHuntProp.getOwner()); if (propHuntGamer2 != null) { - if (propHuntGamer2.u() > 0) { + if (propHuntGamer2.getCamouflageTimer() > 0) { player.leaveVehicle(); } - propHuntGamer.a(propHuntGamer2, 2.0); + propHuntGamer.damageHider(propHuntGamer2, 2.0); } } else { - propHuntGamer.y(); + propHuntGamer.handleRightClick(); } break; } @@ -154,31 +154,31 @@ public class PropHuntListener extends GameListener { } @EventHandler - public void b(PlayerInteractAtEntityEvent event) { + public void onPropInteractAtEntity(PlayerInteractAtEntityEvent event) { Player player = event.getPlayer(); - PropHuntGamer propHuntGamer = this.a(player, PropHuntGamer.class); - if (propHuntGamer != null && !propHuntGamer.f() && VersionAdapters.get().isMainHandInteract(this.manager2.getEngine().getPlatform(), event)) { - propHuntGamer.y(); + PropHuntGamer propHuntGamer = this.getActiveGamer(player, PropHuntGamer.class); + if (propHuntGamer != null && !propHuntGamer.isSpectator() && VersionAdapters.get().isMainHandInteract(this.propHuntManager.getEngine().getPlatform(), event)) { + propHuntGamer.handleRightClick(); event.setCancelled(true); } } @EventHandler - public void a(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - PropHuntGamer propHuntGamer = this.a(player, PropHuntGamer.class); - if (propHuntGamer != null && !propHuntGamer.f()) { - if (!VersionAdapters.get().isMainHandInteract(this.manager2.getEngine().getPlatform(), event)) { + PropHuntGamer propHuntGamer = this.getActiveGamer(player, PropHuntGamer.class); + if (propHuntGamer != null && !propHuntGamer.isSpectator()) { + if (!VersionAdapters.get().isMainHandInteract(this.propHuntManager.getEngine().getPlatform(), event)) { event.setCancelled(true); } else { - if (System.currentTimeMillis() - propHuntGamer.toUser().f() > 100L) { - if (EngineUtils.a(event.getAction())) { - propHuntGamer.x(); - } else if (EngineUtils.b(event.getAction())) { - propHuntGamer.y(); + if (System.currentTimeMillis() - propHuntGamer.toUser().getLastInteractionTime() > 100L) { + if (EngineUtils.isLeftClick(event.getAction())) { + propHuntGamer.handleLeftClick(); + } else if (EngineUtils.isRightClick(event.getAction())) { + propHuntGamer.handleRightClick(); } - propHuntGamer.toUser().a(System.currentTimeMillis()); + propHuntGamer.toUser().setLastInteractionTime(System.currentTimeMillis()); } if (event.getMaterial() != Material.BOW) { @@ -189,20 +189,20 @@ public class PropHuntListener extends GameListener { } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - PropHuntGamer propHuntGamer = this.a(player, PropHuntGamer.class); - if (propHuntGamer != null && location != null && !Locations.a(location, event.getFrom())) { + PropHuntGamer propHuntGamer = this.getActiveGamer(player, PropHuntGamer.class); + if (propHuntGamer != null && location != null && !Locations.isSameBlock(location, event.getFrom())) { PropHuntGame propHuntGame = propHuntGamer.getGame(); - if (propHuntGamer.f()) { - if (!propHuntGame.getMap().getPlayZone().a(location)) { + if (propHuntGamer.isSpectator()) { + if (!propHuntGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - propHuntGamer.a(propHuntGame.getMap().getSpectator()); + propHuntGamer.teleport(propHuntGame.getMap().getSpectator()); } - } else if (propHuntGamer.getTeam6() == propHuntGame.getTeam4()) { + } else if (propHuntGamer.getTeam() == propHuntGame.getHiderTeam()) { PropHuntProp propHuntProp = propHuntGamer.getProp(); - List list = (List)propHuntGame.x().get(propHuntProp.getUniqueId()); + List list = (List)propHuntGame.getPropInspectors().get(propHuntProp.getUniqueId()); if (list == null) { return; } @@ -210,9 +210,9 @@ public class PropHuntListener extends GameListener { for (UUID uuid : new ArrayList(list)) { PropHuntGamer propHuntGamer2 = (PropHuntGamer)propHuntGame.getGamers().a(uuid); if (propHuntGamer2 != null) { - PropHuntInspectionMarker propHuntInspectionMarker = (PropHuntInspectionMarker)propHuntGamer2.getMap34().get(propHuntProp.getUniqueId()); + PropHuntInspectionMarker propHuntInspectionMarker = (PropHuntInspectionMarker)propHuntGamer2.getInspectionMarkers().get(propHuntProp.getUniqueId()); if (propHuntInspectionMarker != null) { - propHuntGamer2.a(propHuntProp.getUniqueId(), propHuntInspectionMarker); + propHuntGamer2.removeInspectionMarker(propHuntProp.getUniqueId(), propHuntInspectionMarker); } } } @@ -221,12 +221,12 @@ public class PropHuntListener extends GameListener { } @EventHandler - public void a(EntityDismountEvent event) { - PropHuntGamer propHuntGamer = this.a(event.getEntity(), PropHuntGamer.class); - if (propHuntGamer != null && !propHuntGamer.f()) { - PropHuntProp propHuntProp = (PropHuntProp)propHuntGamer.getGame().s().get(event.getDismounted().getUniqueId()); + public void onEntityDismount(EntityDismountEvent event) { + PropHuntGamer propHuntGamer = this.getActiveGamer(event.getEntity(), PropHuntGamer.class); + if (propHuntGamer != null && !propHuntGamer.isSpectator()) { + PropHuntProp propHuntProp = (PropHuntProp)propHuntGamer.getGame().getProps().get(event.getDismounted().getUniqueId()); if (propHuntProp != null) { - propHuntGamer.f(0); + propHuntGamer.setCamouflageTimer(0); Player player = propHuntGamer.toPlayer(); player.setExp(0.0F); player.setLevel(0); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/phase/PropHuntPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/phase/PropHuntPlayingPhase.java index 58a8127..07275e7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/phase/PropHuntPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/phase/PropHuntPlayingPhase.java @@ -30,92 +30,92 @@ public class PropHuntPlayingPhase implements Phase { } public void start() { - this.game.a(this.game.getSettings().getTimeDuration()); - this.game.setGamers((PropHuntGamer[])this.game.getGamers().a(new PropHuntGamer[this.game.getGamers().size()])); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getEngine().getPlugin(), chunk)); + this.game.setTimeLeft(this.game.getSettings().getTimeDuration()); + this.game.setGamers((PropHuntGamer[])this.game.getGamers().toArray(new PropHuntGamer[this.game.getGamers().size()])); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getEngine().getPlugin(), chunk)); for (Location location : this.game.getMap().getToolSpawns()) { - ItemBuilder itemBuilder = new ItemBuilder((Material)Randoms.a(this.game.getSettings().getToolsMaterial())); + ItemBuilder itemBuilder = new ItemBuilder((Material)Randoms.pickRandom(this.game.getSettings().getToolsMaterial())); if (this.game.getSettings().getPropToolCustomModelData() > 0) { itemBuilder.setCustomModelData(this.game.getSettings().getPropToolCustomModelData()); } PropHuntProp propHuntProp = this.game.getManager().getPropHuntPropFactory().createProp(PropHuntPropType.TOOL, itemBuilder.build(), location); - this.game.s().put(propHuntProp.getUniqueId(), propHuntProp); + this.game.getProps().put(propHuntProp.getUniqueId(), propHuntProp); } for (Location location2 : this.game.getMap().getBlockSpawns()) { - Material material = (Material)Randoms.a(this.game.getSettings().getBlocksMaterial()); + Material material = (Material)Randoms.pickRandom(this.game.getSettings().getBlocksMaterial()); ItemBuilder itemBuilder2 = new ItemBuilder(material); if (this.game.getSettings().getPropBlockCustomModelData() > 0) { itemBuilder2.setCustomModelData(this.game.getSettings().getPropBlockCustomModelData()); } PropHuntProp propHuntProp2 = this.game.getManager().getPropHuntPropFactory().createProp(material == Material.TNT ? PropHuntPropType.TNT : PropHuntPropType.BLOCK, itemBuilder2.build(), location2); - this.game.s().put(propHuntProp2.getUniqueId(), propHuntProp2); + this.game.getProps().put(propHuntProp2.getUniqueId(), propHuntProp2); } - List list = this.game.getGamers().d(); - PropHuntGamer propHuntGamer = (PropHuntGamer)Randoms.a(list); - this.a(propHuntGamer); - ArrayDeque arrayDeque = new ArrayDeque(this.game.s().values()); + List list = this.game.getGamers().toList(); + PropHuntGamer propHuntGamer = (PropHuntGamer)Randoms.pickRandom(list); + this.assignSeeker(propHuntGamer); + ArrayDeque arrayDeque = new ArrayDeque(this.game.getProps().values()); for (PropHuntGamer propHuntGamer2 : list) { if (propHuntGamer != propHuntGamer2 && !arrayDeque.isEmpty()) { - this.a(propHuntGamer2, (PropHuntProp)arrayDeque.poll()); + this.assignHider(propHuntGamer2, (PropHuntProp)arrayDeque.poll()); } } - for (PropHuntGamer propHuntGamer3 : this.game.getTeam4().getList()) { + for (PropHuntGamer propHuntGamer3 : this.game.getHiderTeam().getList()) { DefaultEngine defaultEngine = this.game.getManager().getEngine(); - PlayerVisibility.b(this.game.getEngine().getPlugin(), propHuntGamer3.toPlayer(), this.game.getGamers()); - this.game.getTeam4().getScoreboardTeam().sendPacket(defaultEngine.getPlatform(), propHuntGamer3.toPlayer(), "§a", "", TeamVisibility.ALWAYS); + PlayerVisibility.hideFromRegistry(this.game.getEngine().getPlugin(), propHuntGamer3.toPlayer(), this.game.getGamers()); + this.game.getHiderTeam().getScoreboardTeam().sendPacket(defaultEngine.getPlatform(), propHuntGamer3.toPlayer(), "§a", "", TeamVisibility.ALWAYS); } } - private void a(PropHuntGamer propHuntGamer) { + private void assignSeeker(PropHuntGamer propHuntGamer) { Player player = propHuntGamer.toPlayer(); - propHuntGamer.setTeam(this.game.getTeam2()); - this.game.getTeam2().getList().add(propHuntGamer); - this.game.getTeam2().getScoreboardTeam().addEntry(player.getName()); - propHuntGamer.e(this.game.getSettings().getGracePeriod()); - propHuntGamer.a(this.game.getMap().getSeekerGraceSpawn()); + propHuntGamer.setTeam(this.game.getSeekerTeam()); + this.game.getSeekerTeam().getList().add(propHuntGamer); + this.game.getSeekerTeam().getScoreboardTeam().addEntry(player.getName()); + propHuntGamer.setGracePeriod(this.game.getSettings().getGracePeriod()); + propHuntGamer.teleport(this.game.getMap().getSeekerGraceSpawn()); VersionAdapters.get().setMaxHealth(player, 20.0); player.setHealth(20.0); player.setGameMode(GameMode.SURVIVAL); this.game.getManager().getEngine().getPlatform().sendHealthUpdate(player); - propHuntGamer.z(); - propHuntGamer.a(this.game.getMessages().getSeekerStart()); - propHuntGamer.sendTitle(this.game.getMessages().getTitleSeekerStart(), this.game.getMessages().getSubtitleSeekerStart().a(propHuntGamer), 0, 40, 0); + propHuntGamer.giveSeekerKit(); + propHuntGamer.sendMessages(this.game.getMessages().getSeekerStart()); + propHuntGamer.sendTitle(this.game.getMessages().getTitleSeekerStart(), this.game.getMessages().getSubtitleSeekerStart().render(propHuntGamer), 0, 40, 0); propHuntGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); } - private void a(PropHuntGamer propHuntGamer, PropHuntProp propHuntProp) { + private void assignHider(PropHuntGamer propHuntGamer, PropHuntProp propHuntProp) { Player player = propHuntGamer.toPlayer(); - propHuntGamer.setTeam(this.game.getTeam4()); - this.game.getTeam4().getList().add(propHuntGamer); - this.game.getTeam4().getScoreboardTeam().addEntry(player.getName()); - propHuntGamer.a(propHuntProp.getLocation()); + propHuntGamer.setTeam(this.game.getHiderTeam()); + this.game.getHiderTeam().getList().add(propHuntGamer); + this.game.getHiderTeam().getScoreboardTeam().addEntry(player.getName()); + propHuntGamer.teleport(propHuntProp.getLocation()); propHuntGamer.setProp(propHuntProp); propHuntProp.setOwner(player); VersionAdapters.get().setMaxHealth(player, 6.0); player.setHealth(6.0); - propHuntGamer.A(); + propHuntGamer.givePropStick(); player.addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, true, true)); - propHuntGamer.a(this.game.getMessages().getHiderStart()); + propHuntGamer.sendMessages(this.game.getMessages().getHiderStart()); propHuntGamer.sendTitle(this.game.getMessages().getTitleHiderStart(), this.game.getMessages().getSubtitleHiderStart(), 0, 40, 0); propHuntGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); } public void stop() { - this.game.getTeam4().getList().forEach(propHuntGamer -> PlayerVisibility.a(this.game.getEngine().getPlugin(), propHuntGamer.toPlayer(), this.game.getGamers())); - this.game.getTeam4().d(); - this.game.getTeam2().getList().forEach(PropHuntGamer::w); - this.game.getTeam2().d(); - this.game.s().values().forEach(PropHuntProp::destroy); - this.game.s().clear(); + this.game.getHiderTeam().getList().forEach(propHuntGamer -> PlayerVisibility.showToRegistry(this.game.getEngine().getPlugin(), propHuntGamer.toPlayer(), this.game.getGamers())); + this.game.getHiderTeam().clear(); + this.game.getSeekerTeam().getList().forEach(PropHuntGamer::clearInspectionMarkers); + this.game.getSeekerTeam().clear(); + this.game.getProps().values().forEach(PropHuntProp::destroy); + this.game.getProps().clear(); this.game.setGamers((ro.fr33styler.arcade.game.prophunt.player.PropHuntGamer[])null); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getEngine().getPlugin(), chunk)); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getEngine().getPlugin(), chunk)); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -129,8 +129,8 @@ public class PropHuntPlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.game.o() <= 0) { - this.game.a(this.game.getTeam4()); + if (this.game.getTimeLeft() <= 0) { + this.game.finishGame(this.game.getHiderTeam()); for (PropHuntGamer propHuntGamer : this.game.getGamers()) { propHuntGamer.sendTitle(this.game.getMessages().getTitleHidersWon(), this.game.getMessages().getTitleHidersWonOnTime(), 0, 80, 0); @@ -140,16 +140,16 @@ public class PropHuntPlayingPhase implements Phase { } for (PropHuntGamer propHuntGamer2 : this.game.getGamers()) { - propHuntGamer2.B(); - propHuntGamer2.a(this.game.getMessages().getSidebarPlaying(), propHuntGamer2); + propHuntGamer2.tickSecond(); + propHuntGamer2.updateSidebar(this.game.getMessages().getSidebarPlaying(), propHuntGamer2); } - this.game.a(this.game.o() - 1); + this.game.setTimeLeft(this.game.getTimeLeft() - 1); } if (longVal % 5L == 0L) { - for (PropHuntGamer propHuntGamer3 : this.game.getTeam2().getList()) { - propHuntGamer3.C(); + for (PropHuntGamer propHuntGamer3 : this.game.getSeekerTeam().getList()) { + propHuntGamer3.tickHeartbeat(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamer.java index 23be67e..5071fa8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamer.java @@ -40,16 +40,16 @@ import ro.fr33styler.arcade.platform.compat.VersionAdapters; import ro.fr33styler.arcade.api.engine.text.Context; public class PropHuntGamer extends BaseGamer { - private int b; - private int c; - private int d; + private int kills; + private int hiderWins; + private int seekerWins; private PropHuntTeam team; private PropHuntProp prop; - private int g; - private int h; - private int i = -1; - private int j = -1; - private int k = -1; + private int heartbeatTicks; + private int abilityCooldown; + private int stunTimer = -1; + private int camouflageTimer = -1; + private int gracePeriod = -1; private final PropHuntGame game; private final Map map = new HashMap<>(); @@ -62,31 +62,31 @@ public class PropHuntGamer extends BaseGamer { return this.game; } - public Map getMap34() { + public Map getInspectionMarkers() { return this.map; } - public int n() { - return this.b; + public int getKills() { + return this.kills; } - public int o() { - return this.c; + public int getHiderWins() { + return this.hiderWins; } - public void c(int index) { - this.c = index; + public void setHiderWins(int index) { + this.hiderWins = index; } - public int q() { - return this.d; + public int getSeekerWins() { + return this.seekerWins; } - public void d(int index) { - this.d = index; + public void setSeekerWins(int index) { + this.seekerWins = index; } - public PropHuntTeam getTeam6() { + public PropHuntTeam getTeam() { return this.team; } @@ -102,46 +102,46 @@ public class PropHuntGamer extends BaseGamer { this.prop = prop2; } - public void e(int index) { - this.k = index; + public void setGracePeriod(int index) { + this.gracePeriod = index; } - public int t() { - return this.h; + public int getAbilityCooldown() { + return this.abilityCooldown; } - public int u() { - return this.j; + public int getCamouflageTimer() { + return this.camouflageTimer; } - public void f(int index) { - this.j = index; + public void setCamouflageTimer(int index) { + this.camouflageTimer = index; } - public int v() { - return this.i; + public int getStunTimer() { + return this.stunTimer; } - public void g(int index) { - this.i = index; + public void setStunTimer(int index) { + this.stunTimer = index; } - public void w() { + public void clearInspectionMarkers() { if (!this.map.isEmpty()) { for (Entry entry : new ArrayList<>(this.map.entrySet())) { - this.a((UUID)entry.getKey(), (PropHuntInspectionMarker)entry.getValue()); + this.removeInspectionMarker((UUID)entry.getKey(), (PropHuntInspectionMarker)entry.getValue()); } } } - public void b(PropHuntProp propHuntProp) { - Context context = Contexts.a((VariableProvider) text -> text.equals("disguise") ? this.game.getMessages().getMaterialNames().getOrDefault(propHuntProp.getItem().getType().name(), propHuntProp.getPropType().name()) : null); + public void cyclePropInspection(PropHuntProp propHuntProp) { + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("disguise") ? this.game.getMessages().getMaterialNames().getOrDefault(propHuntProp.getItem().getType().name(), propHuntProp.getPropType().name()) : null); PropHuntInspectionMarker propHuntInspectionMarker = this.map.get(propHuntProp.getUniqueId()); if (propHuntInspectionMarker == null) { - this.c(propHuntProp); + this.createInspectionMarker(propHuntProp); VersionAdapters.get().playSound(this.player, ArcadeSound.NOTE_PLING, 1.0F, 1.0F); this.sendMessage(this.game.getMessages().getMarkedAsChecked(), context); - List list = this.game.x().computeIfAbsent(propHuntProp.getUniqueId(), uuid -> new ArrayList()); + List list = this.game.getPropInspectors().computeIfAbsent(propHuntProp.getUniqueId(), uuid -> new ArrayList()); list.add(this.player.getUniqueId()); } else if (propHuntInspectionMarker.getPropHuntInspection() == PropHuntInspection.CHECKED) { propHuntInspectionMarker.setPropHuntInspection(PropHuntInspection.SUSPICIOUS); @@ -152,11 +152,11 @@ public class PropHuntGamer extends BaseGamer { } else if (propHuntInspectionMarker.getPropHuntInspection() == PropHuntInspection.SUSPICIOUS) { VersionAdapters.get().playSound(this.player, ArcadeSound.NOTE_PLING, 1.0F, 1.0F); this.sendMessage(this.game.getMessages().getMarkedAsNode(), context); - this.a(propHuntProp.getUniqueId(), propHuntInspectionMarker); + this.removeInspectionMarker(propHuntProp.getUniqueId(), propHuntInspectionMarker); } } - private void c(PropHuntProp propHuntProp) { + private void createInspectionMarker(PropHuntProp propHuntProp) { Location location = propHuntProp.getLocation().add(0.0, 0.7, 0.0); if (propHuntProp.getPropType() == PropHuntPropType.TOOL) { location.add(location.getDirection().multiply(0.5)); @@ -166,26 +166,26 @@ public class PropHuntGamer extends BaseGamer { VersionAdapters.get().setLivingCollidable(hologramEntity.getEntity(), false); hologramEntity.setText(this.game.getMessages().getMarkPropChecked()); hologramEntity.setVisible(this.player, true); - this.getMap34().put(propHuntProp.getUniqueId(), new PropHuntInspectionMarker(hologramEntity, PropHuntInspection.CHECKED)); + this.getInspectionMarkers().put(propHuntProp.getUniqueId(), new PropHuntInspectionMarker(hologramEntity, PropHuntInspection.CHECKED)); } - public void a(UUID uuid, PropHuntInspectionMarker propHuntInspectionMarker) { + public void removeInspectionMarker(UUID uuid, PropHuntInspectionMarker propHuntInspectionMarker) { propHuntInspectionMarker.getHologramEntity().setVisible(this.player, false); this.map.remove(uuid); - List list = (List)this.game.x().get(uuid); + List list = (List)this.game.getPropInspectors().get(uuid); if (list.remove(this.player.getUniqueId()) && list.isEmpty()) { - this.game.x().remove(uuid); + this.game.getPropInspectors().remove(uuid); } } - private void D() { + private void useExplodeAbility() { ArrayList list = new ArrayList(); for (PropHuntGamer propHuntGamer : this.game.getGamers()) { propHuntGamer.playSound(ArcadeSound.GENERIC_EXPLODE, 1.0F, 1.0F); - if (propHuntGamer.getTeam6() == this.game.getTeam2()) { + if (propHuntGamer.getTeam() == this.game.getSeekerTeam()) { Player player = propHuntGamer.toPlayer(); - if (Locations.b(player.getLocation(), this.prop.getLocation()) <= 25.0) { + if (Locations.distanceSquared(player.getLocation(), this.prop.getLocation()) <= 25.0) { player.setVelocity(this.player.getEyeLocation().getDirection().setY(0.5).multiply(1.2)); propHuntGamer.sendMessage(this.game.getMessages().getAbilityExplodedUsedOnYou(), this); list.add(propHuntGamer.getName()); @@ -197,15 +197,15 @@ public class PropHuntGamer extends BaseGamer { if (list.isEmpty()) { this.sendMessage(this.game.getMessages().getAbilityExplodedNoHit()); } else { - Context context = Contexts.a((VariableProvider) text -> text.equals("hit") ? String.join(",", list) : null); + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("hit") ? String.join(",", list) : null); this.sendMessage(this.game.getMessages().getAbilityExplodedYouHit(), context); } - this.h = this.game.getSettings().getAbilityCooldown() + 1; - this.w(); + this.abilityCooldown = this.game.getSettings().getAbilityCooldown() + 1; + this.clearInspectionMarkers(); } - private void E() { + private void useCamouflageAbility() { Location location = this.player.getLocation(); Block block = location.getBlock(); if (block.isEmpty()) { @@ -217,19 +217,19 @@ public class PropHuntGamer extends BaseGamer { this.player.teleport(location); this.prop.teleport(location); this.prop.attachOwner(); - this.j = this.game.getSettings().getStunDuration2(); - this.h = this.game.getSettings().getAbilityCooldown() + 1; + this.camouflageTimer = this.game.getSettings().getStunDuration2(); + this.abilityCooldown = this.game.getSettings().getAbilityCooldown() + 1; } } - private void F() { + private void useStunAbility() { ArrayList list = new ArrayList(); - for (PropHuntGamer propHuntGamer : this.game.getTeam2().getList()) { - if (Locations.b(propHuntGamer.toPlayer().getLocation(), this.prop.getLocation()) <= 25.0) { + for (PropHuntGamer propHuntGamer : this.game.getSeekerTeam().getList()) { + if (Locations.distanceSquared(propHuntGamer.toPlayer().getLocation(), this.prop.getLocation()) <= 25.0) { propHuntGamer.toPlayer().setWalkSpeed(0.05F); propHuntGamer.toPlayer().getInventory().clear(); - propHuntGamer.g(this.game.getSettings().getStunDuration()); + propHuntGamer.setStunTimer(this.game.getSettings().getStunDuration()); propHuntGamer.playSound(ArcadeSound.ANVIL_LAND, 1.0F, 1.0F); propHuntGamer.sendMessage(this.game.getMessages().getAbilityStunUsedOnYou(), this); propHuntGamer.sendMessage(this.game.getMessages().getAbilityStunnedFor()); @@ -242,58 +242,58 @@ public class PropHuntGamer extends BaseGamer { if (list.isEmpty()) { this.sendMessage(this.game.getMessages().getAbilityStunNoHit()); } else { - Context context = Contexts.a((VariableProvider) text -> text.equals("hit") ? String.join(",", list) : null); + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("hit") ? String.join(",", list) : null); this.sendMessage(this.game.getMessages().getAbilityStunYouHit(), context); } - this.h = this.game.getSettings().getAbilityCooldown() + 1; + this.abilityCooldown = this.game.getSettings().getAbilityCooldown() + 1; } - public void x() { - if (this.team == this.game.getTeam4()) { - if (this.h > 0) { - this.a(this.game.getMessages().getAbilityCooldown()); + public void handleLeftClick() { + if (this.team == this.game.getHiderTeam()) { + if (this.abilityCooldown > 0) { + this.sendMessage(this.game.getMessages().getAbilityCooldown()); this.playSound(ArcadeSound.ENDERMAN_TELEPORT, 1.0F, 1.0F); } else { - switch (PropHuntGamerSwitchTable.a[this.prop.getPropType().ordinal()]) { + switch (PropHuntGamerSwitchTable.PROP_TYPE_SWITCH_MAP[this.prop.getPropType().ordinal()]) { case 1: - this.D(); + this.useExplodeAbility(); break; case 2: - this.E(); + this.useCamouflageAbility(); break; case 3: - this.F(); + this.useStunAbility(); } - this.w(); + this.clearInspectionMarkers(); } - } else if (this.team == this.game.getTeam2()) { - PropHuntProp propHuntProp = this.game.b(this.player.getEyeLocation()); + } else if (this.team == this.game.getSeekerTeam()) { + PropHuntProp propHuntProp = this.game.raycastProp(this.player.getEyeLocation()); if (propHuntProp == null || propHuntProp.getOwner() == null) { return; } PropHuntGamer propHuntGamer = (PropHuntGamer)this.game.getGamers().c(propHuntProp.getOwner()); - if (propHuntGamer == null || propHuntGamer.f()) { + if (propHuntGamer == null || propHuntGamer.isSpectator()) { return; } - if (propHuntGamer.u() > 0) { + if (propHuntGamer.getCamouflageTimer() > 0) { this.player.leaveVehicle(); } - this.a(propHuntGamer, 2.0); + this.damageHider(propHuntGamer, 2.0); } } - public void y() { - PropHuntProp propHuntProp = this.game.b(this.player.getEyeLocation()); + public void handleRightClick() { + PropHuntProp propHuntProp = this.game.raycastProp(this.player.getEyeLocation()); if (propHuntProp != null) { - if (this.team == this.game.getTeam2()) { + if (this.team == this.game.getSeekerTeam()) { ItemStack mainHand = VersionAdapters.get().getMainHandItem(this.game.getEngine().getPlatform(), this.player); if (mainHand != null && mainHand.getType() == Material.BLAZE_ROD) { - this.b(propHuntProp); + this.cyclePropInspection(propHuntProp); } } else { if (propHuntProp.getOwner() == this.player) { @@ -302,22 +302,22 @@ public class PropHuntGamer extends BaseGamer { if (propHuntProp.getOwner() != null) { VersionAdapters.get().playSound(this.player, ArcadeSound.ENDERMAN_TELEPORT, 1.0F, 1.0F); - Context context = Contexts.a((VariableProvider) text -> text.equals("owner") ? propHuntProp.getOwner().getName() : null); + Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("owner") ? propHuntProp.getOwner().getName() : null); this.sendMessage(this.game.getMessages().getPropAlreadyOwned(), context); } else { this.player.leaveVehicle(); this.getProp().setOwner((org.bukkit.entity.Player)null); - this.a(propHuntProp.getLocation()); + this.teleport(propHuntProp.getLocation()); this.setProp(propHuntProp); propHuntProp.setOwner(this.player); - this.A(); - this.a(this.game.getMessages().getPropDisguisedAs()); + this.givePropStick(); + this.sendMessage(this.game.getMessages().getPropDisguisedAs()); } } } } - public void z() { + public void giveSeekerKit() { this.player.setWalkSpeed(0.23F); this.player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setDisplayName(this.game.getMessages().getItemSeekerSword()).build()); if (this.game.getSettings().isGiveBow()) { @@ -330,7 +330,7 @@ public class PropHuntGamer extends BaseGamer { } } - public void A() { + public void givePropStick() { List list = this.game.getMessages().getHiderAbilityStunLore(); if (this.prop.getPropType() == PropHuntPropType.TNT) { list = this.game.getMessages().getHiderAbilityExplodeLore(); @@ -343,144 +343,144 @@ public class PropHuntGamer extends BaseGamer { } } - public void a(PropHuntGamer propHuntGamer, double doubleVal) { - if (propHuntGamer.getTeam6() != this.game.getTeam2()) { - propHuntGamer.w(); + public void damageHider(PropHuntGamer propHuntGamer, double doubleVal) { + if (propHuntGamer.getTeam() != this.game.getSeekerTeam()) { + propHuntGamer.clearInspectionMarkers(); Player player = propHuntGamer.toPlayer(); player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); this.playSound(ArcadeSound.ARROW_HIT_PLAYER, 1.0F, 1.0F); - if (propHuntGamer.t() > 0) { + if (propHuntGamer.getAbilityCooldown() > 0) { player.leaveVehicle(); } if (player.getHealth() > doubleVal) { player.damage(doubleVal); } else { - Context context = Contexts.a(propHuntGamer, text -> text.equals("killer") ? this.getName() : null); - this.game.getGamers().a(this.game.getMessages().getHiderDiscoveredByKiller(), context); + Context context = Contexts.withVariables(propHuntGamer, text -> text.equals("killer") ? this.getName() : null); + this.game.getGamers().broadcast(this.game.getMessages().getHiderDiscoveredByKiller(), context); PropHuntProp propHuntProp = propHuntGamer.getProp(); propHuntProp.destroy(); - this.game.s().remove(propHuntProp.getUniqueId()); + this.game.getProps().remove(propHuntProp.getUniqueId()); propHuntGamer.setProp((PropHuntProp)null); - propHuntGamer.b(1); - this.b++; - this.game.getTeam4().getList().remove(propHuntGamer); - this.game.getTeam4().getScoreboardTeam().removeEntry(player.getName()); + propHuntGamer.setLoses(1); + this.kills++; + this.game.getHiderTeam().getList().remove(propHuntGamer); + this.game.getHiderTeam().getScoreboardTeam().removeEntry(player.getName()); player.removePotionEffect(PotionEffectType.INVISIBILITY); if (this.game.getSettings().isSpectateOnDeath()) { - this.b(true); + this.setSpectator(true); this.game.getSpectatorTeam().addEntry(propHuntGamer.getName()); } else { - this.game.getTeam2().getScoreboardTeam().addEntry(player.getName()); - propHuntGamer.setTeam(this.game.getTeam2()); - this.game.getTeam2().getList().add(propHuntGamer); - propHuntGamer.a(this.game.getMap().getSeekerSpawn()); - Players.a(propHuntGamer); - propHuntGamer.z(); - propHuntGamer.sendTitle(this.game.getMessages().getTitleHiderKilled(), this.game.getMessages().getSubtitleHiderKilled().a(context), 0, 30, 5); + this.game.getSeekerTeam().getScoreboardTeam().addEntry(player.getName()); + propHuntGamer.setTeam(this.game.getSeekerTeam()); + this.game.getSeekerTeam().getList().add(propHuntGamer); + propHuntGamer.teleport(this.game.getMap().getSeekerSpawn()); + Players.reset(propHuntGamer); + propHuntGamer.giveSeekerKit(); + propHuntGamer.sendTitle(this.game.getMessages().getTitleHiderKilled(), this.game.getMessages().getSubtitleHiderKilled().render(context), 0, 30, 5); DefaultEngine defaultEngine = this.game.getManager().getEngine(); - PlayerVisibility.a(this.game.getEngine().getPlugin(), player, this.game.getGamers()); - this.game.getTeam2().getScoreboardTeam().sendPacket(defaultEngine.getPlatform(), player, "§a", "", TeamVisibility.ALWAYS); + PlayerVisibility.showToRegistry(this.game.getEngine().getPlugin(), player, this.game.getGamers()); + this.game.getSeekerTeam().getScoreboardTeam().sendPacket(defaultEngine.getPlatform(), player, "§a", "", TeamVisibility.ALWAYS); } - this.game.y(); + this.game.checkWinCondition(); } } } - public void B() { - if (this.team == this.game.getTeam4()) { - if (this.h == 0) { - this.b(this.game.getMessages().getActionbarability()); + public void tickSecond() { + if (this.team == this.game.getHiderTeam()) { + if (this.abilityCooldown == 0) { + this.sendActionBar(this.game.getMessages().getActionbarability()); } else { - this.b(this.game.getMessages().getActionbarabilitycooldown()); + this.sendActionBar(this.game.getMessages().getActionbarabilitycooldown()); } - if (this.h > 0) { - this.h--; + if (this.abilityCooldown > 0) { + this.abilityCooldown--; } VersionAdapters.get().spawnPropDisguiseParticle(this.player, this.game.getManager().getPropHuntPropFactory(), this.player.getEyeLocation().add(0.0, 0.5, 0.0)); } - if (this.i > 0) { - this.i--; - } else if (this.i == 0) { - this.i = -1; - this.z(); + if (this.stunTimer > 0) { + this.stunTimer--; + } else if (this.stunTimer == 0) { + this.stunTimer = -1; + this.giveSeekerKit(); this.player.setWalkSpeed(0.2F); } - if (this.j > 0) { - this.player.setLevel(this.j); - this.player.setExp((float)this.j / this.game.getSettings().getStunDuration2()); - this.j--; - } else if (this.j == 0) { - this.j = -1; + if (this.camouflageTimer > 0) { + this.player.setLevel(this.camouflageTimer); + this.player.setExp((float)this.camouflageTimer / this.game.getSettings().getStunDuration2()); + this.camouflageTimer--; + } else if (this.camouflageTimer == 0) { + this.camouflageTimer = -1; this.player.leaveVehicle(); } - if (this.k > 0) { - if (this.k % 10 == 0 || this.k <= 5) { - for (PropHuntGamer propHuntGamer : this.game.getTeam4().getList()) { + if (this.gracePeriod > 0) { + if (this.gracePeriod % 10 == 0 || this.gracePeriod <= 5) { + for (PropHuntGamer propHuntGamer : this.game.getHiderTeam().getList()) { propHuntGamer.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F); propHuntGamer.sendMessage(this.game.getMessages().getHiderGracePeriodTimer(), this); } this.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F); - this.sendTitle("", this.game.getMessages().getSubtitleSeekerStart().a(this), 0, 40, 5); + this.sendTitle("", this.game.getMessages().getSubtitleSeekerStart().render(this), 0, 40, 5); } - this.k--; - } else if (this.k == 0) { - this.k = -1; + this.gracePeriod--; + } else if (this.gracePeriod == 0) { + this.gracePeriod = -1; this.player.teleport(this.game.getMap().getSeekerSpawn()); this.sendTitle("", this.game.getMessages().getSubtitleSeekerGracePeriodExpired(), 0, 40, 0); - this.game.getTeam4().getList().forEach(propHuntGamer2 -> propHuntGamer2.sendTitle("", this.game.getMessages().getSubtitleHiderGracePeriodExpired(), 0, 40, 0)); + this.game.getHiderTeam().getList().forEach(propHuntGamer2 -> propHuntGamer2.sendTitle("", this.game.getMessages().getSubtitleHiderGracePeriodExpired(), 0, 40, 0)); } } - public void C() { - if (this.g > 0) { - if (this.g == 3) { + public void tickHeartbeat() { + if (this.heartbeatTicks > 0) { + if (this.heartbeatTicks == 3) { this.sendActionBar(this.game.getMessages().getHeartbeat1st()); this.playSound(ArcadeSound.NOTE_BASEDRUM, 1.0F, 1.0F); } - this.g--; - if (this.g == 1) { + this.heartbeatTicks--; + if (this.heartbeatTicks == 1) { this.sendActionBar(this.game.getMessages().getHeartbeat2nd()); this.playSound(ArcadeSound.NOTE_BASEDRUM, 1.0F, 1.2F); } } else { - for (PropHuntGamer propHuntGamer : this.game.getTeam4().getList()) { - if (Locations.b(propHuntGamer.toPlayer().getLocation(), this.player.getLocation()) <= 25.0) { - this.g = 3; + for (PropHuntGamer propHuntGamer : this.game.getHiderTeam().getList()) { + if (Locations.distanceSquared(propHuntGamer.toPlayer().getLocation(), this.player.getLocation()) <= 25.0) { + this.heartbeatTicks = 3; break; } } } } - private void G() { + private void saveStatistics() { PropHuntStatistics propHuntStatistics = this.game.getManager().getData(this.getUUID()); - if (propHuntStatistics.a()) { - propHuntStatistics.a(propHuntStatistics.getWins() + this.getWins()); + if (propHuntStatistics.isLoaded()) { + propHuntStatistics.setWins(propHuntStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - propHuntStatistics.d(propHuntStatistics.getCurrentWinStreak() + 1); + propHuntStatistics.setCurrentWinStreak(propHuntStatistics.getCurrentWinStreak() + 1); if (propHuntStatistics.getWinStreak() < propHuntStatistics.getCurrentWinStreak()) { - propHuntStatistics.c(propHuntStatistics.getCurrentWinStreak()); + propHuntStatistics.setWinStreak(propHuntStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - propHuntStatistics.d(0); + propHuntStatistics.setCurrentWinStreak(0); } - propHuntStatistics.b(propHuntStatistics.getLoses() + this.getLoses()); - propHuntStatistics.e(propHuntStatistics.d() + this.c); - propHuntStatistics.f(propHuntStatistics.e() + this.d); - this.b(propHuntStatistics.getMap()); - this.game.getManager().getStorage().e().b(propHuntStatistics); - this.game.getManager().getStorage().e().a(this); + propHuntStatistics.setLoses(propHuntStatistics.getLoses() + this.getLoses()); + propHuntStatistics.setHiderWins(propHuntStatistics.getHiderWins() + this.hiderWins); + propHuntStatistics.setSeekerWins(propHuntStatistics.getSeekerWins() + this.seekerWins); + this.saveProperties(propHuntStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(propHuntStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @@ -488,7 +488,7 @@ public class PropHuntGamer extends BaseGamer { public String getVariable(String text) { if (this.prop != null) { if (text.equals("ability")) { - return switch (PropHuntGamerSwitchTable.a[this.prop.getPropType().ordinal()]) { + return switch (PropHuntGamerSwitchTable.PROP_TYPE_SWITCH_MAP[this.prop.getPropType().ordinal()]) { case 1 -> this.game.getMessages().getAbilityExplode(); case 2 -> this.game.getMessages().getAbilityCamouflage(); case 3 -> this.game.getMessages().getAbilityStun(); @@ -501,24 +501,24 @@ public class PropHuntGamer extends BaseGamer { } } return switch (text) { - case "kills" -> String.valueOf(this.b); - case "team" -> this.team == null ? this.game.getMessages().getTeamSpectator() : this.team.a(); - case "team_color" -> (this.team == null ? ChatColor.GOLD : (this.team == this.game.getTeam4() ? ChatColor.AQUA : ChatColor.RED)).toString(); - case "ability_cooldown" -> Strings.a(this.h, this.game.getSettings().getAbilityCooldown()); - case "grace_period" -> Strings.a(this.k, this.game.getSettings().getGracePeriod()); + case "kills" -> String.valueOf(this.kills); + case "team" -> this.team == null ? this.game.getMessages().getTeamSpectator() : this.team.getName(); + case "team_color" -> (this.team == null ? ChatColor.GOLD : (this.team == this.game.getHiderTeam() ? ChatColor.AQUA : ChatColor.RED)).toString(); + case "ability_cooldown" -> Strings.formatProgressColor(this.abilityCooldown, this.game.getSettings().getAbilityCooldown()); + case "grace_period" -> Strings.formatProgressColor(this.gracePeriod, this.game.getSettings().getGracePeriod()); default -> super.getVariable(text); }; } @Override public Boolean getCondition(String text) { - return !text.equals("SEEKER") ? super.getCondition(text) : this.team == null || this.team == this.game.getTeam2(); + return !text.equals("SEEKER") ? super.getCondition(text) : this.team == null || this.team == this.game.getSeekerTeam(); } @Override public void leave() { - this.G(); - this.game.getGamers().b(this); + this.saveStatistics(); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { if (this.prop != null) { this.prop.setOwner((org.bukkit.entity.Player)null); @@ -529,7 +529,7 @@ public class PropHuntGamer extends BaseGamer { this.team.getScoreboardTeam().removeEntry(this.getName()); } - this.game.y(); + this.game.checkWinCondition(); } super.leave(); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamerSwitchTable.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamerSwitchTable.java index 2d92fed..cfd2784 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamerSwitchTable.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/player/PropHuntGamerSwitchTable.java @@ -3,21 +3,21 @@ package ro.fr33styler.arcade.game.prophunt.player; import ro.fr33styler.arcade.game.prophunt.prop.PropHuntPropType; class PropHuntGamerSwitchTable { - static final int[] a = new int[PropHuntPropType.values().length]; + static final int[] PROP_TYPE_SWITCH_MAP = new int[PropHuntPropType.values().length]; static { try { - a[PropHuntPropType.TNT.ordinal()] = 1; + PROP_TYPE_SWITCH_MAP[PropHuntPropType.TNT.ordinal()] = 1; } catch (NoSuchFieldError var3) { } try { - a[PropHuntPropType.BLOCK.ordinal()] = 2; + PROP_TYPE_SWITCH_MAP[PropHuntPropType.BLOCK.ordinal()] = 2; } catch (NoSuchFieldError var2) { } try { - a[PropHuntPropType.TOOL.ordinal()] = 3; + PROP_TYPE_SWITCH_MAP[PropHuntPropType.TOOL.ordinal()] = 3; } catch (NoSuchFieldError var1) { } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntInspection.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntInspection.java index f33f94a..58f7112 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntInspection.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntInspection.java @@ -5,5 +5,5 @@ public enum PropHuntInspection { SUSPICIOUS, NONE; - private static final PropHuntInspection[] d = {CHECKED, SUSPICIOUS, NONE}; + private static final PropHuntInspection[] VALUES = {CHECKED, SUSPICIOUS, NONE}; } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntPropType.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntPropType.java index e574115..5da60f5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntPropType.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/prop/PropHuntPropType.java @@ -5,5 +5,5 @@ public enum PropHuntPropType { TNT, TOOL; - private static final PropHuntPropType[] d = {BLOCK, TNT, TOOL}; + private static final PropHuntPropType[] VALUES = {BLOCK, TNT, TOOL}; } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSession.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSession.java index 7a6f823..332216b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSession.java @@ -23,10 +23,10 @@ public class PropHuntSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { PropHuntGamer propHuntGamer = new PropHuntGamer(this.game, defaultUser); - this.game.getGamers().a(propHuntGamer); - propHuntGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(propHuntGamer); + propHuntGamer.teleport(this.game.getMap().getLobby()); return propHuntGamer; }); } @@ -40,7 +40,7 @@ public class PropHuntSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof PropHuntGamer var2) { PropHuntGame propHuntGame = var2.getGame(); - if (propHuntGame.getPhase() != propHuntGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (propHuntGame.getPhase() != propHuntGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, propHuntGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,16 +50,16 @@ public class PropHuntSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { PropHuntGamer propHuntGamer = new PropHuntGamer(this.game, defaultUser); - this.game.getGamers().a(propHuntGamer); - propHuntGamer.a(this.game.getMap().getSpectator()); - propHuntGamer.b(true); - propHuntGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(propHuntGamer); + propHuntGamer.teleport(this.game.getMap().getSpectator()); + propHuntGamer.setSpectator(true); + propHuntGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(propHuntGamer.getName()); - for (PropHuntGamer propHuntGamer2 : this.game.getTeam4().getList()) { - PlayerVisibility.b(this.game.getEngine().getPlugin(), propHuntGamer2.toPlayer(), this.game.getGamers()); + for (PropHuntGamer propHuntGamer2 : this.game.getHiderTeam().getList()) { + PlayerVisibility.hideFromRegistry(this.game.getEngine().getPlugin(), propHuntGamer2.toPlayer(), this.game.getGamers()); } return propHuntGamer; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSessions.java index 2ae79c9..d7b9903 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/session/PropHuntSessions.java @@ -9,46 +9,46 @@ import ro.fr33styler.arcade.game.prophunt.map.PropHuntMap; import org.bukkit.World; public class PropHuntSessions extends BaseSessions { - private final PropHuntManager a; + private final PropHuntManager manager; public PropHuntSessions(PropHuntManager propHuntManager) { super(propHuntManager); - this.a = propHuntManager; + this.manager = propHuntManager; } public PropHuntManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(propHuntMap -> this.registerGame(new PropHuntGame(this.a, propHuntMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(propHuntMap -> this.registerGame(new PropHuntGame(this.manager, propHuntMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected PropHuntMap h(String text) { + protected PropHuntMap createMap(String text) { PropHuntMap propHuntMap = new PropHuntMap(); propHuntMap.setId(text); return propHuntMap; } - protected PropHuntGame a(PropHuntMap propHuntMap) { - return new PropHuntGame(this.a, propHuntMap); + protected PropHuntGame createGame(PropHuntMap propHuntMap) { + return new PropHuntGame(this.manager, propHuntMap); } public PropHuntSession createSession(PropHuntGame propHuntGame) { return propHuntGame == null ? null : new PropHuntSession(propHuntGame); } - protected void a(PropHuntMap propHuntMap, World world, PropHuntMap propHuntMap2) { - super.a(propHuntMap, world, propHuntMap2); - propHuntMap2.setSpectator(Locations.a(world, propHuntMap.getSpectator())); - propHuntMap2.setPlayZone(propHuntMap.getPlayZone().a(world)); - propHuntMap2.setSeekerSpawn(Locations.a(world, propHuntMap.getSeekerSpawn())); - propHuntMap2.setSeekerGraceSpawn(Locations.a(world, propHuntMap.getSeekerGraceSpawn())); + protected void copyMap(PropHuntMap propHuntMap, World world, PropHuntMap propHuntMap2) { + super.copyMap(propHuntMap, world, propHuntMap2); + propHuntMap2.setSpectator(Locations.withWorld(world, propHuntMap.getSpectator())); + propHuntMap2.setPlayZone(propHuntMap.getPlayZone().withWorld(world)); + propHuntMap2.setSeekerSpawn(Locations.withWorld(world, propHuntMap.getSeekerSpawn())); + propHuntMap2.setSeekerGraceSpawn(Locations.withWorld(world, propHuntMap.getSeekerGraceSpawn())); propHuntMap2.getToolSpawns().clear(); - propHuntMap2.getToolSpawns().addAll(Locations.a(world, propHuntMap.getToolSpawns())); + propHuntMap2.getToolSpawns().addAll(Locations.withWorld(world, propHuntMap.getToolSpawns())); propHuntMap2.getBlockSpawns().clear(); - propHuntMap2.getBlockSpawns().addAll(Locations.a(world, propHuntMap.getBlockSpawns())); + propHuntMap2.getBlockSpawns().addAll(Locations.withWorld(world, propHuntMap.getBlockSpawns())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/PropHuntSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/PropHuntSetup.java index 2d02f87..3d5f6b0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/PropHuntSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/PropHuntSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class PropHuntSetup extends ArenaSetup { private final PropHuntMap map; - private final PropHuntManager d; + private final PropHuntManager manager; private final SetupTarget setupTarget; public PropHuntSetup(DefaultUser defaultUser, PropHuntMap map2, PropHuntManager propHuntManager, SetupTarget setupTarget2) { super(defaultUser, propHuntManager.getName()); - this.d = propHuntManager; + this.manager = propHuntManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new PropHuntSetArenaNameStep(this); } - public PropHuntMap getMap35() { + public PropHuntMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class PropHuntSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new PropHuntGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new PropHuntGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddBlockPropSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddBlockPropSpawnStep.java index 242a6c0..409e9fa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddBlockPropSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddBlockPropSpawnStep.java @@ -18,7 +18,7 @@ public class PropHuntAddBlockPropSpawnStep implements ClickSetupStep, Repeatable this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the block props"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -26,31 +26,31 @@ public class PropHuntAddBlockPropSpawnStep implements ClickSetupStep, Repeatable defaultUser.sendMessage("§e yellow dye to continue."); } - public void b() { - this.propHuntSetup.getMap35().getToolSpawns().clear(); + public void onUndo() { + this.propHuntSetup.getMap().getToolSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.propHuntSetup.getMap35().getPlayZone().a(location)) { - this.propHuntSetup.getMap35().getBlockSpawns().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.propHuntSetup.getMap35().getBlockSpawns().size() + "§8)"); - if (this.propHuntSetup.getMap35().getBlockSpawns().size() == this.propHuntSetup.getMap35().getMaximumPlayers()) { - this.e(); + if (this.propHuntSetup.getMap().getPlayZone().contains(location)) { + this.propHuntSetup.getMap().getBlockSpawns().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.propHuntSetup.getMap().getBlockSpawns().size() + "§8)"); + if (this.propHuntSetup.getMap().getBlockSpawns().size() == this.propHuntSetup.getMap().getMaximumPlayers()) { + this.addFinishButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.propHuntSetup.getHotbar().a(1, () -> { - this.b(); + this.propHuntSetup.getHotbar().setSlot(1, () -> { + this.onUndo(); player.sendMessage("§eBlock spawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset block spawns").build()); } - private void e() { - this.propHuntSetup.getHotbar().a(2, () -> this.propHuntSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish setup").build()); + private void addFinishButton() { + this.propHuntSetup.getHotbar().setSlot(2, () -> this.propHuntSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish setup").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddToolPropSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddToolPropSpawnStep.java index 6a14e7c..4b4c083 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddToolPropSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntAddToolPropSpawnStep.java @@ -17,7 +17,7 @@ public class PropHuntAddToolPropSpawnStep implements ClickSetupStep, RepeatableS this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the tool props"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -25,31 +25,31 @@ public class PropHuntAddToolPropSpawnStep implements ClickSetupStep, RepeatableS defaultUser.sendMessage("§e yellow dye to continue."); } - public void b() { - this.propHuntSetup.getMap35().getToolSpawns().clear(); + public void onUndo() { + this.propHuntSetup.getMap().getToolSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.propHuntSetup.getMap35().getPlayZone().a(location)) { - this.propHuntSetup.getMap35().getToolSpawns().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.propHuntSetup.getMap35().getToolSpawns().size() + "§8)"); - if (this.propHuntSetup.getMap35().getToolSpawns().size() == this.propHuntSetup.getMap35().getMaximumPlayers()) { - this.e(); + if (this.propHuntSetup.getMap().getPlayZone().contains(location)) { + this.propHuntSetup.getMap().getToolSpawns().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.propHuntSetup.getMap().getToolSpawns().size() + "§8)"); + if (this.propHuntSetup.getMap().getToolSpawns().size() == this.propHuntSetup.getMap().getMaximumPlayers()) { + this.addNextStepButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.propHuntSetup.getHotbar().a(1, () -> { - this.b(); + this.propHuntSetup.getHotbar().setSlot(1, () -> { + this.onUndo(); player.sendMessage("§eTool spawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset tool spawns").build()); } - private void e() { - this.propHuntSetup.getHotbar().a(2, () -> this.propHuntSetup.a(new PropHuntAddBlockPropSpawnStep(this.propHuntSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lNext Step").build()); + private void addNextStepButton() { + this.propHuntSetup.getHotbar().setSlot(2, () -> this.propHuntSetup.advanceStep(new PropHuntAddBlockPropSpawnStep(this.propHuntSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lNext Step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetArenaNameStep.java index 875d0fd..519fd69 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetArenaNameStep.java @@ -10,12 +10,12 @@ public class PropHuntSetArenaNameStep implements ChatSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { this.propHuntSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.propHuntSetup.getMap35().setName(text); - this.propHuntSetup.a(new PropHuntSetLobbySpawnStep(this.propHuntSetup)); + public void onChatInput(String text) { + this.propHuntSetup.getMap().setName(text); + this.propHuntSetup.advanceStep(new PropHuntSetLobbySpawnStep(this.propHuntSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbyRemovalRegionStep.java index 23415c1..fda3323 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class PropHuntSetLobbyRemovalRegionStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class PropHuntSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.propHuntSetup.getUser(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.propHuntSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.propHuntSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.propHuntSetup.getMap35().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.propHuntSetup.a(new PropHuntSetPlayZoneStep(this.propHuntSetup)); + this.propHuntSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.propHuntSetup.advanceStep(new PropHuntSetPlayZoneStep(this.propHuntSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.propHuntSetup.getHotbar().a(2, () -> { - this.propHuntSetup.getMap35().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.propHuntSetup.a(new PropHuntSetPlayZoneStep(this.propHuntSetup)); + this.propHuntSetup.getHotbar().setSlot(2, () -> { + this.propHuntSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.propHuntSetup.advanceStep(new PropHuntSetPlayZoneStep(this.propHuntSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbySpawnStep.java index 20e21f9..845fe6f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class PropHuntSetLobbySpawnStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { - this.propHuntSetup.getMap35().setLobby(player.getLocation()); - this.propHuntSetup.a(new PropHuntSetLobbyRemovalRegionStep(this.propHuntSetup)); + this.propHuntSetup.getHotbar().setSlot(0, () -> { + this.propHuntSetup.getMap().setLobby(player.getLocation()); + this.propHuntSetup.advanceStep(new PropHuntSetLobbyRemovalRegionStep(this.propHuntSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetPlayZoneStep.java index 4ab1b3f..f7ccd73 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class PropHuntSetPlayZoneStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.propHuntSetup.getUser(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.propHuntSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.propHuntSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.propHuntSetup.getMap35().setPlayZone(new Cuboid(block, block2)); - this.propHuntSetup.a(new PropHuntSetSpectatorSpawnStep(this.propHuntSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.propHuntSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.propHuntSetup.advanceStep(new PropHuntSetSpectatorSpawnStep(this.propHuntSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerGraceSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerGraceSpawnStep.java index efaf148..9b72262 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerGraceSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerGraceSpawnStep.java @@ -16,19 +16,19 @@ public class PropHuntSetSeekerGraceSpawnStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the seekers"); defaultUser.sendMessage("§e are teleported during the grace period."); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.propHuntSetup.getMap35().getPlayZone().a(location)) { - this.propHuntSetup.getMap35().setSeekerGraceSpawn(location); - this.propHuntSetup.a(new PropHuntAddToolPropSpawnStep(this.propHuntSetup)); + if (this.propHuntSetup.getMap().getPlayZone().contains(location)) { + this.propHuntSetup.getMap().setSeekerGraceSpawn(location); + this.propHuntSetup.advanceStep(new PropHuntAddToolPropSpawnStep(this.propHuntSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerSpawnStep.java index 10a943b..1ee8418 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSeekerSpawnStep.java @@ -16,19 +16,19 @@ public class PropHuntSetSeekerSpawnStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the seekers"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.propHuntSetup.getMap35().getPlayZone().a(location)) { - this.propHuntSetup.getMap35().setSeekerSpawn(location); - this.propHuntSetup.a(new PropHuntSetSeekerGraceSpawnStep(this.propHuntSetup)); + if (this.propHuntSetup.getMap().getPlayZone().contains(location)) { + this.propHuntSetup.getMap().setSeekerSpawn(location); + this.propHuntSetup.advanceStep(new PropHuntSetSeekerGraceSpawnStep(this.propHuntSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSpectatorSpawnStep.java index 2673e57..24064de 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/setup/step/PropHuntSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class PropHuntSetSpectatorSpawnStep implements ClickSetupStep { this.propHuntSetup = propHuntSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.propHuntSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.propHuntSetup.getUser().toPlayer(); - this.propHuntSetup.getHotbar().a(0, () -> { + this.propHuntSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.propHuntSetup.getMap35().getPlayZone().a(location)) { - this.propHuntSetup.getMap35().setSpectator(location); - this.propHuntSetup.a(new PropHuntSetSeekerSpawnStep(this.propHuntSetup)); + if (this.propHuntSetup.getMap().getPlayZone().contains(location)) { + this.propHuntSetup.getMap().setSpectator(location); + this.propHuntSetup.advanceStep(new PropHuntSetSeekerSpawnStep(this.propHuntSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/PropHuntStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/PropHuntStatistics.java index 921f9a3..843b9ad 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/PropHuntStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/PropHuntStatistics.java @@ -6,44 +6,44 @@ import ro.fr33styler.arcade.game.prophunt.PropHuntManager; import java.util.UUID; public class PropHuntStatistics extends BaseGameStatistics { - private int b; - private int c; + private int hiderWins; + private int seekerWins; public PropHuntStatistics(PropHuntManager propHuntManager, UUID uuid, String text) { super(propHuntManager, uuid, text); } - public int d() { - return this.b; + public int getHiderWins() { + return this.hiderWins; } - public void e(int index) { - this.b = index; + public void setHiderWins(int index) { + this.hiderWins = index; } - public int e() { - return this.c; + public int getSeekerWins() { + return this.seekerWins; } - public void f(int index) { - this.c = index; + public void setSeekerWins(int index) { + this.seekerWins = index; } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { if (text.equals("stats_hider_wins")) { - return String.valueOf(this.b); + return String.valueOf(this.hiderWins); } else { - return text.equals("stats_seeker_wins") ? String.valueOf(this.c) : super.a(text); + return text.equals("stats_seeker_wins") ? String.valueOf(this.seekerWins) : super.resolvePlaceholder(text); } } @Override public String getVariable(String text) { if (text.equals("hider_wins")) { - return String.valueOf(this.b); + return String.valueOf(this.hiderWins); } else { - return text.equals("seeker_wins") ? String.valueOf(this.c) : super.getVariable(text); + return text.equals("seeker_wins") ? String.valueOf(this.seekerWins) : super.getVariable(text); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/storage/PropHuntStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/storage/PropHuntStatisticsRepository.java index ef0be5c..fae4875 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/storage/PropHuntStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/statistics/storage/PropHuntStatisticsRepository.java @@ -14,122 +14,122 @@ public class PropHuntStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a( + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); } - public void a(PropHuntStatistics propHuntStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(PropHuntStatistics propHuntStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, propHuntStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(propHuntStatistics, var3); + this.readStatistics(propHuntStatistics, var3); } - propHuntStatistics.a(true); + propHuntStatistics.setLoaded(true); } }); } - private void a(PropHuntStatistics propHuntStatistics, ResultSet resultSet) throws java.sql.SQLException { - propHuntStatistics.b(resultSet.getString("options")); - propHuntStatistics.a(resultSet.getInt("wins")); - propHuntStatistics.c(resultSet.getInt("win_streak")); - propHuntStatistics.d(resultSet.getInt("current_win_streak")); - propHuntStatistics.b(resultSet.getInt("loses")); - propHuntStatistics.e(resultSet.getInt("hider_wins")); - propHuntStatistics.f(resultSet.getInt("seeker_wins")); + private void readStatistics(PropHuntStatistics propHuntStatistics, ResultSet resultSet) throws java.sql.SQLException { + propHuntStatistics.deserializeProperties(resultSet.getString("options")); + propHuntStatistics.setWins(resultSet.getInt("wins")); + propHuntStatistics.setWinStreak(resultSet.getInt("win_streak")); + propHuntStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + propHuntStatistics.setLoses(resultSet.getInt("loses")); + propHuntStatistics.setHiderWins(resultSet.getInt("hider_wins")); + propHuntStatistics.setSeekerWins(resultSet.getInt("seeker_wins")); } - public void b(PropHuntStatistics propHuntStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(PropHuntStatistics propHuntStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, propHuntStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(propHuntStatistics); + this.updateStatistics(propHuntStatistics); } else { - this.c(propHuntStatistics); + this.insertStatistics(propHuntStatistics); } } }); } - private void c(PropHuntStatistics propHuntStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(PropHuntStatistics propHuntStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, propHuntStatistics.getUUID().toString()); - preparedStatement.setString(2, propHuntStatistics.c()); + preparedStatement.setString(2, propHuntStatistics.serializeProperties()); preparedStatement.setInt(3, propHuntStatistics.getWins()); preparedStatement.setInt(4, propHuntStatistics.getWinStreak()); preparedStatement.setInt(5, propHuntStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, propHuntStatistics.getLoses()); - preparedStatement.setInt(7, propHuntStatistics.d()); - preparedStatement.setInt(8, propHuntStatistics.e()); + preparedStatement.setInt(7, propHuntStatistics.getHiderWins()); + preparedStatement.setInt(8, propHuntStatistics.getSeekerWins()); preparedStatement.executeUpdate(); }); } - private void d(PropHuntStatistics propHuntStatistics) { - this.a() - .a( + private void updateStatistics(PropHuntStatistics propHuntStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, hider_wins = ?, seeker_wins = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, propHuntStatistics.c()); + preparedStatement.setString(1, propHuntStatistics.serializeProperties()); preparedStatement.setInt(2, propHuntStatistics.getWins()); preparedStatement.setInt(3, propHuntStatistics.getWinStreak()); preparedStatement.setInt(4, propHuntStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, propHuntStatistics.getLoses()); - preparedStatement.setInt(6, propHuntStatistics.d()); - preparedStatement.setInt(7, propHuntStatistics.e()); + preparedStatement.setInt(6, propHuntStatistics.getHiderWins()); + preparedStatement.setInt(7, propHuntStatistics.getSeekerWins()); preparedStatement.setString(8, propHuntStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(PropHuntGamer propHuntGamer) { - this.a(this.b + "_weekly", propHuntGamer); - this.a(this.b + "_monthly", propHuntGamer); + public void savePeriodicStatistics(PropHuntGamer propHuntGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", propHuntGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", propHuntGamer); } - private void a(String text, PropHuntGamer propHuntGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, PropHuntGamer propHuntGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, propHuntGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, propHuntGamer); + this.updatePeriodicStatistics(text, propHuntGamer); } else { - this.c(text, propHuntGamer); + this.insertPeriodicStatistics(text, propHuntGamer); } } }); } - private void b(String text, PropHuntGamer propHuntGamer) { + private void updatePeriodicStatistics(String text, PropHuntGamer propHuntGamer) { String text2 = "current_win_streak"; if (propHuntGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -137,9 +137,9 @@ public class PropHuntStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -149,86 +149,86 @@ public class PropHuntStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, hider_wins = hider_wins + ?, seeker_wins = seeker_wins + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, propHuntGamer.getWins()); preparedStatement.setInt(2, propHuntGamer.getLoses()); - preparedStatement.setInt(3, propHuntGamer.o()); - preparedStatement.setInt(4, propHuntGamer.q()); + preparedStatement.setInt(3, propHuntGamer.getHiderWins()); + preparedStatement.setInt(4, propHuntGamer.getSeekerWins()); preparedStatement.setString(5, propHuntGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, PropHuntGamer propHuntGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, PropHuntGamer propHuntGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, propHuntGamer.getUUID().toString()); preparedStatement.setInt(2, propHuntGamer.getWins()); preparedStatement.setInt(3, propHuntGamer.getWins()); preparedStatement.setInt(4, propHuntGamer.getWins()); preparedStatement.setInt(5, propHuntGamer.getLoses()); - preparedStatement.setInt(6, propHuntGamer.o()); - preparedStatement.setInt(7, propHuntGamer.q()); + preparedStatement.setInt(6, propHuntGamer.getHiderWins()); + preparedStatement.setInt(7, propHuntGamer.getSeekerWins()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, hider_wins INT, seeker_wins INT);" ); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -239,22 +239,22 @@ public class PropHuntStatisticsRepository extends GameStatisticsRepository { int index2 = var4.getInt("loses"); int index3 = var4.getInt("hider_wins"); int index4 = var4.getInt("seeker_wins"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -269,14 +269,14 @@ public class PropHuntStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/storage/PropHuntStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/storage/PropHuntStorage.java index 1173ab7..f6aed78 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/storage/PropHuntStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/storage/PropHuntStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.prophunt.statistics.storage.PropHuntStatisticsR public class PropHuntStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final PropHuntStatisticsRepository propHuntStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public PropHuntStorage(PropHuntManager propHuntManager) { super(propHuntManager); this.storage = new GameMapStorage(propHuntManager.getConfigManager(), this.file, PropHuntMap::new); - this.storage2 = new NpcStorage(propHuntManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(propHuntManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(propHuntManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(propHuntManager.getConfigManager(), this.file); this.propHuntStatisticsRepository = new PropHuntStatisticsRepository(propHuntManager.getEngine()); - this.storage4 = new LeaderboardStorage(propHuntManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(propHuntManager.getConfigManager(), this.file, PropHuntMap::new); + this.leaderboardStorage = new LeaderboardStorage(propHuntManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(propHuntManager.getConfigManager(), this.file, PropHuntMap::new); } @Override @@ -34,26 +34,26 @@ public class PropHuntStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public PropHuntStatisticsRepository e() { + public PropHuntStatisticsRepository getStatisticsRepository() { return this.propHuntStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/team/PropHuntTeam.java b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/team/PropHuntTeam.java index 5c00338..3d96930 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/prophunt/team/PropHuntTeam.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/prophunt/team/PropHuntTeam.java @@ -9,18 +9,18 @@ import java.util.List; import ro.fr33styler.arcade.platform.compat.TeamRule; public class PropHuntTeam { - private final String a; + private final String name; private final ScoreboardTeam scoreboardTeam; private final List list = new ArrayList<>(); public PropHuntTeam(String text, GameScoreboard gameScoreboard) { - this.a = text; + this.name = text; this.scoreboardTeam = gameScoreboard.createTeam(text); this.scoreboardTeam.setCollisionRule(TeamRule.FOR_OTHER_TEAMS); } - public String a() { - return this.a; + public String getName() { + return this.name; } public ScoreboardTeam getScoreboardTeam() { @@ -31,7 +31,7 @@ public class PropHuntTeam { return this.list; } - public void d() { + public void clear() { this.scoreboardTeam.clearEntries(); this.list.clear(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeGame.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeGame.java index 10943f4..eeb8d4a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeGame.java @@ -24,13 +24,13 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class QuakeGame extends AbstractGame implements GameEventHandler { - private int c; + private int timeLeft; private QuakeGamer[] gamers; private final QuakeMap map; private final QuakeManager manager; private final ScoreboardTeam scoreboardTeam; private final Lifecycle lifecycle = new QuakeLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); private final Set set = EnumSet.allOf(GameAction.class); public QuakeGame(QuakeManager manager2, QuakeMap map2) { @@ -58,17 +58,17 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { return this.manager.getMessages(); } - private QuakeConfiguration x() { - QuakeConfiguration quakeConfiguration = (QuakeConfiguration)this.getManager().G().get(this.getMap().getId()); - return quakeConfiguration == null ? this.getManager().getConfiguration5() : quakeConfiguration; + private QuakeConfiguration getActiveConfiguration() { + QuakeConfiguration quakeConfiguration = (QuakeConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return quakeConfiguration == null ? this.getManager().getConfiguration() : quakeConfiguration; } public QuakeSettings getSettings() { - return this.x().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public QuakeRewards s() { - return this.x().getRewards(); + public QuakeRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public QuakeManager getManager() { @@ -79,7 +79,7 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { return this.set; } - public QuakeGamer[] getGamers8() { + public QuakeGamer[] getStandings() { return this.gamers; } @@ -87,23 +87,23 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { this.gamers = gamers3; } - public int v() { - return this.c; + public int getTimeLeft() { + return this.timeLeft; } - public void a(int index) { - this.c = index; + public void setTimeLeft(int index) { + this.timeLeft = index; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { if (text.equals("time_left")) { - return Strings.a(this.c); + return Strings.formatDuration(this.timeLeft); } if (this.gamers != null) { @@ -112,7 +112,7 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { } if (this.gamers.length > 0 && text.equals("first_kills")) { - return String.valueOf(this.gamers[0].m()); + return String.valueOf(this.gamers[0].getKills()); } if (this.gamers.length > 1 && text.equals("second")) { @@ -120,11 +120,11 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { } if (this.gamers.length > 1 && text.equals("second_kills")) { - return String.valueOf(this.gamers[1].m()); + return String.valueOf(this.gamers[1].getKills()); } if (this.gamers.length > 2 && text.equals("third_kills")) { - return String.valueOf(this.gamers[2].m()); + return String.valueOf(this.gamers[2].getKills()); } if (this.gamers.length > 2 && text.equals("third")) { @@ -145,25 +145,25 @@ public class QuakeGame extends AbstractGame implements GameEventHandler { }; } - public void w() { - Arrays.sort(this.gamers, Comparator.comparingInt(QuakeGamer::m).reversed()); - Context context = Contexts.a(this.manager, this.gamers); + public void finishGame() { + Arrays.sort(this.gamers, Comparator.comparingInt(QuakeGamer::getKills).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (QuakeGamer quakeGamer : this.gamers2) { + for (QuakeGamer quakeGamer : this.gamerSet) { quakeGamer.sendMessages(this.getMessages().getEndingTop(), context); - quakeGamer.a(this.getMessages().getSidebarPlaying(), quakeGamer); - if (!quakeGamer.getSpectatorOptions().g()) { + quakeGamer.updateSidebar(this.getMessages().getSidebarPlaying(), quakeGamer); + if (!quakeGamer.getSpectatorOptions().isExternal()) { if (this.gamers[0] == quakeGamer) { - quakeGamer.a(1); + quakeGamer.setWins(1); quakeGamer.sendTitle(this.getMessages().getTitleWon(), "", 0, 80, 0); - if (this.s().isEnabled()) { - quakeGamer.b(this.s().getWinner()); + if (this.getRewards().isEnabled()) { + quakeGamer.setRewardCommands(this.getRewards().getWinner()); } } else { - quakeGamer.b(1); + quakeGamer.setLoses(1); quakeGamer.sendTitle(this.getMessages().getTitleLost(), "", 0, 80, 0); - if (this.s().isEnabled()) { - quakeGamer.b(this.s().getLosers()); + if (this.getRewards().isEnabled()) { + quakeGamer.setRewardCommands(this.getRewards().getLosers()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeManager.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeManager.java index 82cef04..88e21c2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/QuakeManager.java @@ -30,12 +30,12 @@ public class QuakeManager extends AbstractGameManager { private final Command command; private final QuakeStorage storage; private final QuakeMessages messages = new QuakeMessages(); - private final Map f = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final QuakeConfiguration configuration = new QuakeConfiguration(); private final QuakeListener listener = new QuakeListener(this); - private final Map i = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final QuakeSessions sessions = new QuakeSessions(this); - private final Map> k = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "kills", this.messages::getStatisticKills, "deaths", this.messages::getStatisticDeaths ); @@ -64,7 +64,7 @@ public class QuakeManager extends AbstractGameManager { return this.sessions; } - public QuakeConfiguration getConfiguration5() { + public QuakeConfiguration getConfiguration() { return this.configuration; } @@ -79,21 +79,21 @@ public class QuakeManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { QuakeStatistics quakeStatistics = new QuakeStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(quakeStatistics); - this.f.put(player.getUniqueId(), quakeStatistics); + this.storage.getStatisticsRepository().loadStatistics(quakeStatistics); + this.playerStatistics.put(player.getUniqueId(), quakeStatistics); } public QuakeStatistics getData(UUID uuid) { - return this.f.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.f.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map G() { - return this.i; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -110,7 +110,7 @@ public class QuakeManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.k; + return this.leaderboardSources; } @Override @@ -118,16 +118,16 @@ public class QuakeManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "quake"); } - private void H() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); QuakeConfiguration quakeConfiguration = new QuakeConfiguration(); - quakeConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.i.put("id_1", this.configuration); - Files.a(file, file2 -> { + quakeConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { QuakeConfiguration quakeConfiguration2 = new QuakeConfiguration(); - quakeConfiguration2.a(this.getConfigManager(), file2); - this.i.put(file2.getName(), quakeConfiguration2); + quakeConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), quakeConfiguration2); } }); } @@ -135,15 +135,15 @@ public class QuakeManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.H(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/command/QuakeCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/command/QuakeCreateCommand.java index 9bb934c..2efd350 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/command/QuakeCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/command/QuakeCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class QuakeCreateCommand implements CommandExecutor { - private final QuakeManager a; + private final QuakeManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public QuakeCreateCommand(QuakeManager quakeManager) { - this.a = quakeManager; + this.manager = quakeManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class QuakeCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); QuakeMap quakeMap = new QuakeMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class QuakeCreateCommand implements CommandExecutor { } quakeMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } quakeMap.setId(text2); quakeMap.setMaximumPlayers(index3); - defaultUser.a(new QuakeSetup(defaultUser, quakeMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new QuakeSetup(defaultUser, quakeMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/config/QuakeConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/config/QuakeConfiguration.java index 5553e62..3e04750 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/config/QuakeConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/config/QuakeConfiguration.java @@ -9,7 +9,7 @@ public class QuakeConfiguration { private final QuakeRewards rewards = new QuakeRewards(); private final QuakeSettings settings = new QuakeSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/config/message/QuakeMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/config/message/QuakeMessages.java index d7b7a4d..d6716af 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/config/message/QuakeMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/config/message/QuakeMessages.java @@ -11,39 +11,39 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class QuakeMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Quake"); + private String displayName = Strings.colorize("Quake"); @Setting("rail-gun") - private String railGun = Strings.a("&eRailgun"); + private String railGun = Strings.colorize("&eRailgun"); @Setting("rail-gun-lore") private List railGunLore = new ArrayList<>(List.of("&eRight-click to shoot!", "&eLeft-click to dash forward!")); @Setting("rail-gun-cooldown") - private Text railGunCooldown = TextParser.a("&8[&a%shot_cooldown_bar%&8] &6%shot_remaining% seconds"); + private Text railGunCooldown = TextParser.parse("&8[&a%shot_cooldown_bar%&8] &6%shot_remaining% seconds"); @Setting("tracking-device") - private String trackingDevice = Strings.a("&aTracking Device"); + private String trackingDevice = Strings.colorize("&aTracking Device"); @Setting("title-won") - private String titleWon = Strings.a("&aYOU WON!"); + private String titleWon = Strings.colorize("&aYOU WON!"); @Setting("title-lost") - private String titleLost = Strings.a("&cYOU LOST!"); + private String titleLost = Strings.colorize("&cYOU LOST!"); @Setting("player-gibbed") - private Text playerGibbed = TextParser.a("&7%killer% &7gibbed&7 %player%"); + private Text playerGibbed = TextParser.parse("&7%killer% &7gibbed&7 %player%"); @Setting("sneaking-disabled") - private String sneakingDisabled = Strings.a("&cSneaking is disabled, your name is still visible!"); + private String sneakingDisabled = Strings.colorize("&cSneaking is disabled, your name is still visible!"); @Setting("dash-cooldown") - private Text dashCooldown = TextParser.a("&cYour Dash will be available in &e%dash_remaining%s&c!"); + private Text dashCooldown = TextParser.parse("&cYour Dash will be available in &e%dash_remaining%s&c!"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-kills") - private String statisticKills = Strings.a("Kills"); + private String statisticKills = Strings.colorize("Kills"); @Setting("statistic-deaths") - private String statisticDeaths = Strings.a("Deaths"); + private String statisticDeaths = Strings.colorize("Deaths"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lQuake", @@ -55,7 +55,7 @@ public class QuakeMessages extends BaseGameMessages { } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lQuake", @@ -68,7 +68,7 @@ public class QuakeMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -85,7 +85,7 @@ public class QuakeMessages extends BaseGameMessages { ); public QuakeMessages() { - this.statisticsView = TextParser.a( + this.statisticsView = TextParser.parseAll( new String[]{ " ", " &l%display_name% Statistics", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/lifecycle/QuakeLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/lifecycle/QuakeLifecycle.java index 17d61c1..d642a71 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/lifecycle/QuakeLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/lifecycle/QuakeLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class QuakeLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public QuakeLifecycle(QuakeGame quakeGame) { this.phase = new WaitingPhase(quakeGame); - this.phase2 = new QuakePlayingPhase(quakeGame); - this.phase3 = new EndingPhase(quakeGame); - this.phase4 = new ResettingPhase(quakeGame); + this.playingPhase = new QuakePlayingPhase(quakeGame); + this.endingPhase = new EndingPhase(quakeGame); + this.resettingPhase = new ResettingPhase(quakeGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class QuakeLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/listener/QuakeListener.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/listener/QuakeListener.java index fa63245..d63e92a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/listener/QuakeListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/listener/QuakeListener.java @@ -36,9 +36,9 @@ public class QuakeListener extends GameListener { @EventHandler @Override - public void a(PlayerToggleSneakEvent event) { - QuakeGamer quakeGamer = this.a(event.getPlayer(), QuakeGamer.class); - if (quakeGamer != null && !quakeGamer.f()) { + public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { + QuakeGamer quakeGamer = this.getActiveGamer(event.getPlayer(), QuakeGamer.class); + if (quakeGamer != null && !quakeGamer.isSpectator()) { if (event.isSneaking()) { event.getPlayer().sendMessage(quakeGamer.getGame().getMessages().getSneakingDisabled()); event.setCancelled(true); @@ -47,25 +47,25 @@ public class QuakeListener extends GameListener { } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - QuakeGamer quakeGamer = this.a(player, QuakeGamer.class); - if (quakeGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + QuakeGamer quakeGamer = this.getActiveGamer(player, QuakeGamer.class); + if (quakeGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { QuakeGame quakeGame = quakeGamer.getGame(); - if (quakeGamer.f()) { - if (!quakeGame.getMap().getPlayZone().a(location)) { + if (quakeGamer.isSpectator()) { + if (!quakeGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - quakeGamer.a(quakeGame.getMap().getSpectator()); + quakeGamer.teleport(quakeGame.getMap().getSpectator()); } } else { - if (location.getBlock().getRelative(BlockFace.DOWN).isEmpty() && quakeGamer.q() == 0) { + if (location.getBlock().getRelative(BlockFace.DOWN).isEmpty() && quakeGamer.getDashCooldown() == 0) { player.setAllowFlight(true); } - if (location.getBlock().isLiquid() || !quakeGame.getMap().getPlayZone().a(location)) { - event.setTo((Location)Randoms.a(quakeGame.getMap().getSpawns())); - quakeGamer.d(quakeGamer.n() + 1); + if (location.getBlock().isLiquid() || !quakeGame.getMap().getPlayZone().contains(location)) { + event.setTo((Location)Randoms.pickRandom(quakeGame.getMap().getSpawns())); + quakeGamer.setDeaths(quakeGamer.getDeaths() + 1); player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, quakeGame.getSettings().getInvincibility(), 1, false, false)); } } @@ -73,29 +73,29 @@ public class QuakeListener extends GameListener { } @EventHandler - public void a(PlayerToggleFlightEvent event) { + public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - QuakeGamer quakeGamer = this.a(player, QuakeGamer.class); - if (quakeGamer != null && !quakeGamer.f()) { + QuakeGamer quakeGamer = this.getActiveGamer(player, QuakeGamer.class); + if (quakeGamer != null && !quakeGamer.isSpectator()) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); QuakeGame quakeGame = quakeGamer.getGame(); - if (quakeGamer.q() > 0) { - quakeGamer.a(quakeGame.getMessages().getDashCooldown()); + if (quakeGamer.getDashCooldown() > 0) { + quakeGamer.sendMessage(quakeGame.getMessages().getDashCooldown()); } else { quakeGamer.playSound(ArcadeSound.ENDER_DRAGON_FLAP, 1.0F, 1.0F); player.setVelocity(player.getEyeLocation().getDirection().multiply(quakeGame.getSettings().getDashDistance()).setY(quakeGame.getSettings().getDashHeight())); - quakeGamer.f(quakeGame.getSettings().getDashCooldown()); + quakeGamer.setDashCooldown(quakeGame.getSettings().getDashCooldown()); } } } @EventHandler - public void a(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - QuakeGamer quakeGamer = this.a(player, QuakeGamer.class); - if (quakeGamer != null && !quakeGamer.f()) { + QuakeGamer quakeGamer = this.getActiveGamer(player, QuakeGamer.class); + if (quakeGamer != null && !quakeGamer.isSpectator()) { QuakeGame quakeGame = quakeGamer.getGame(); if (event.getAction() == Action.PHYSICAL) { Block block = event.getClickedBlock(); @@ -116,8 +116,8 @@ public class QuakeListener extends GameListener { return; } - if (EngineUtils.b(event.getAction())) { - if (quakeGamer.o() == 0) { + if (EngineUtils.isRightClick(event.getAction())) { + if (quakeGamer.getShotCooldown() == 0) { Location location = player.getEyeLocation(); Vector vector = location.getDirection(); quakeGamer.playSound(ArcadeSound.BLAZE_HURT, 1.0F, 2.0F); @@ -129,7 +129,7 @@ public class QuakeListener extends GameListener { QuakeGamer quakeGamer2 = null; for (QuakeGamer quakeGamer3 : quakeGame.getGamers()) { - if (quakeGamer3 != quakeGamer && !quakeGamer3.f()) { + if (quakeGamer3 != quakeGamer && !quakeGamer3.isSpectator()) { Player player2 = quakeGamer3.toPlayer(); if (!player2.hasPotionEffect(PotionEffectType.INVISIBILITY) && player2.getWorld() == player.getWorld()) { double doubleVal2 = player2.getEyeHeight() / 2.0; @@ -145,15 +145,15 @@ public class QuakeListener extends GameListener { if (quakeGamer2 != null) { VersionAdapters.get().playSound(player.getWorld(), location, ArcadeSound.BLAZE_DEATH, 1.0F, 2.0F); - Context context = Contexts.a(quakeGamer2, text -> text.equals("killer") ? quakeGamer.getName() : null); - quakeGame.getGamers().a(quakeGame.getMessages().getPlayerGibbed(), context); - Fireworks.a(quakeGame.getEngine().getPlatform(), location, quakeGame.getSettings().getExplodeColor()); - quakeGamer2.a((Location)Randoms.a(quakeGame.getMap().getSpawns())); - quakeGamer2.d(quakeGamer2.n() + 1); - quakeGamer.c(quakeGamer.m() + 1); + Context context = Contexts.withVariables(quakeGamer2, text -> text.equals("killer") ? quakeGamer.getName() : null); + quakeGame.getGamers().broadcast(quakeGame.getMessages().getPlayerGibbed(), context); + Fireworks.detonateColored(quakeGame.getEngine().getPlatform(), location, quakeGame.getSettings().getExplodeColor()); + quakeGamer2.teleport((Location)Randoms.pickRandom(quakeGame.getMap().getSpawns())); + quakeGamer2.setDeaths(quakeGamer2.getDeaths() + 1); + quakeGamer.setKills(quakeGamer.getKills() + 1); quakeGamer2.toPlayer().addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.INVISIBILITY, quakeGame.getSettings().getInvincibility(), 1, false, false, true)); - if (quakeGamer.m() >= quakeGame.getSettings().getKillsToWin()) { - quakeGame.w(); + if (quakeGamer.getKills() >= quakeGame.getSettings().getKillsToWin()) { + quakeGame.finishGame(); } break; } @@ -161,15 +161,15 @@ public class QuakeListener extends GameListener { location.add(vector); } - quakeGamer.e(quakeGame.getSettings().getShotCooldown()); + quakeGamer.setShotCooldown(quakeGame.getSettings().getShotCooldown()); } - } else if (EngineUtils.a(event.getAction())) { - if (quakeGamer.q() > 0) { - quakeGamer.a(quakeGame.getMessages().getDashCooldown()); + } else if (EngineUtils.isLeftClick(event.getAction())) { + if (quakeGamer.getDashCooldown() > 0) { + quakeGamer.sendMessage(quakeGame.getMessages().getDashCooldown()); } else { quakeGamer.playSound(ArcadeSound.ENDER_DRAGON_FLAP, 1.0F, 1.0F); player.setVelocity(player.getEyeLocation().getDirection().multiply(quakeGame.getSettings().getDashDistance()).setY(quakeGame.getSettings().getDashHeight())); - quakeGamer.f(quakeGame.getSettings().getDashCooldown()); + quakeGamer.setDashCooldown(quakeGame.getSettings().getDashCooldown()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/phase/QuakePlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/phase/QuakePlayingPhase.java index fb702a9..0e2fe26 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/phase/QuakePlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/phase/QuakePlayingPhase.java @@ -24,14 +24,14 @@ public class QuakePlayingPhase implements Phase { } public void start() { - this.game.a(this.game.getSettings().getTimeDuration()); - this.game.setGamers((QuakeGamer[])this.game.getGamers().a(new QuakeGamer[this.game.getGamers().size()])); + this.game.setTimeLeft(this.game.getSettings().getTimeDuration()); + this.game.setGamers((QuakeGamer[])this.game.getGamers().toArray(new QuakeGamer[this.game.getGamers().size()])); int index = 0; List list = this.game.getMap().getSpawns(); Collections.shuffle(list); for (QuakeGamer quakeGamer : this.game.getGamers()) { - quakeGamer.a((Location)list.get(index++ % list.size())); + quakeGamer.teleport((Location)list.get(index++ % list.size())); this.game.getScoreboardTeam().addEntry(quakeGamer.getName()); quakeGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); quakeGamer.toPlayer().addPotionEffect(VersionAdapters.get().createPotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false, false)); @@ -57,32 +57,32 @@ public class QuakePlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.game.v() > 0) { - Arrays.sort(this.game.getGamers8(), Comparator.comparingInt(QuakeGamer::m).reversed()); + if (this.game.getTimeLeft() > 0) { + Arrays.sort(this.game.getStandings(), Comparator.comparingInt(QuakeGamer::getKills).reversed()); for (QuakeGamer quakeGamer : this.game.getGamers()) { - quakeGamer.r(); - quakeGamer.a(this.game.getMessages().getSidebarPlaying(), quakeGamer); + quakeGamer.updateCompassTarget(); + quakeGamer.updateSidebar(this.game.getMessages().getSidebarPlaying(), quakeGamer); } - this.game.a(this.game.v() - 1); + this.game.setTimeLeft(this.game.getTimeLeft() - 1); } else { - this.game.w(); + this.game.finishGame(); } } for (QuakeGamer quakeGamer2 : this.game.getGamers()) { - if (quakeGamer2.o() > 0) { - quakeGamer2.e(quakeGamer2.o() - 1); - if (quakeGamer2.o() > 0) { - quakeGamer2.b(this.game.getMessages().getRailGunCooldown()); + if (quakeGamer2.getShotCooldown() > 0) { + quakeGamer2.setShotCooldown(quakeGamer2.getShotCooldown() - 1); + if (quakeGamer2.getShotCooldown() > 0) { + quakeGamer2.sendActionBar(this.game.getMessages().getRailGunCooldown()); } else { quakeGamer2.sendActionBar(""); } } - if (quakeGamer2.q() > 0) { - quakeGamer2.f(quakeGamer2.q() - 1); + if (quakeGamer2.getDashCooldown() > 0) { + quakeGamer2.setDashCooldown(quakeGamer2.getDashCooldown() - 1); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/player/QuakeGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/player/QuakeGamer.java index 4d4526e..39dabef 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/player/QuakeGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/player/QuakeGamer.java @@ -9,13 +9,13 @@ import ro.fr33styler.arcade.support.text.Strings; public class QuakeGamer extends BaseGamer { - private int b; + private int kills; - private int c; + private int deaths; - private int d; + private int shotCooldown; - private int e; + private int dashCooldown; private final QuakeGame game; @@ -28,56 +28,56 @@ public class QuakeGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getKills() { + return this.kills; } - public void c(int index) { - this.b = index; + public void setKills(int index) { + this.kills = index; } - public int n() { - return this.c; + public int getDeaths() { + return this.deaths; } - public void d(int index) { - this.c = index; + public void setDeaths(int index) { + this.deaths = index; } - public int o() { - return this.d; + public int getShotCooldown() { + return this.shotCooldown; } - public void e(int index) { - this.d = index; + public void setShotCooldown(int index) { + this.shotCooldown = index; } - public int q() { - return this.e; + public int getDashCooldown() { + return this.dashCooldown; } - public void f(int index) { - this.e = index; + public void setDashCooldown(int index) { + this.dashCooldown = index; } - private void s() { + private void saveStatistics() { QuakeStatistics quakeStatistics = this.game.getManager().getData(this.getUUID()); - if (quakeStatistics.a()) { - quakeStatistics.a(quakeStatistics.getWins() + this.getWins()); + if (quakeStatistics.isLoaded()) { + quakeStatistics.setWins(quakeStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - quakeStatistics.d(quakeStatistics.getCurrentWinStreak() + 1); + quakeStatistics.setCurrentWinStreak(quakeStatistics.getCurrentWinStreak() + 1); if (quakeStatistics.getWinStreak() < quakeStatistics.getCurrentWinStreak()) { - quakeStatistics.c(quakeStatistics.getCurrentWinStreak()); + quakeStatistics.setWinStreak(quakeStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - quakeStatistics.d(0); + quakeStatistics.setCurrentWinStreak(0); } - quakeStatistics.b(quakeStatistics.getLoses() + this.getLoses()); - quakeStatistics.e(quakeStatistics.d() + this.b); - quakeStatistics.f(quakeStatistics.e() + this.c); - this.b(quakeStatistics.getMap()); - this.game.getManager().getStorage().e().b(quakeStatistics); - this.game.getManager().getStorage().e().a(this); + quakeStatistics.setLoses(quakeStatistics.getLoses() + this.getLoses()); + quakeStatistics.setKills(quakeStatistics.getKills() + this.kills); + quakeStatistics.setDeaths(quakeStatistics.getDeaths() + this.deaths); + this.saveProperties(quakeStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(quakeStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @@ -85,13 +85,13 @@ public class QuakeGamer extends BaseGamer { public String getVariable(String text) { return switch(text) { case "kills" -> - String.valueOf(this.b); + String.valueOf(this.kills); case "shot_cooldown_bar" -> - Strings.a('■', 10, (double) this.d / this.game.getSettings().getShotCooldown()); + Strings.formatProgressBar('■', 10, (double) this.shotCooldown / this.game.getSettings().getShotCooldown()); case "shot_remaining" -> - Strings.a(this.d / 20.0F, 1); + Strings.formatFixedDecimal(this.shotCooldown / 20.0F, 1); case "dash_remaining" -> - Strings.a(this.e / 20.0F, 1); + Strings.formatFixedDecimal(this.dashCooldown / 20.0F, 1); default -> super.getVariable(text); }; @@ -100,7 +100,7 @@ public class QuakeGamer extends BaseGamer { @Override public Boolean getCondition(String text) { if (text.equals("IN_TOP")) { - QuakeGamer[] quakeGamers = this.game.getGamers8(); + QuakeGamer[] quakeGamers = this.game.getStandings(); if (quakeGamers == null) { return null; } @@ -114,12 +114,12 @@ public class QuakeGamer extends BaseGamer { } return false; } else { - return text.equals("HAS_DASH") ? this.e > 0 : super.getCondition(text); + return text.equals("HAS_DASH") ? this.dashCooldown > 0 : super.getCondition(text); } } - public void r() { - if (!this.f()) { + public void updateCompassTarget() { + if (!this.isSpectator()) { double doubleVal = 0.0; Location location = null; Location location2 = this.player.getLocation(); @@ -141,15 +141,15 @@ public class QuakeGamer extends BaseGamer { @Override public void leave() { - this.s(); - this.game.getGamers().b(this); - if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying() && this.game.getGamers().a() == 1) { + this.saveStatistics(); + this.game.getGamers().remove(this); + if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying() && this.game.getGamers().getAliveCount() == 1) { for (QuakeGamer quakeGamer : this.game.getGamers()) { - if (!quakeGamer.f()) { - quakeGamer.c(this.game.getSettings().getKillsToWin()); + if (!quakeGamer.isSpectator()) { + quakeGamer.setKills(this.game.getSettings().getKillsToWin()); } } - this.game.w(); + this.game.finishGame(); } super.leave(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSession.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSession.java index c113417..2076436 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSession.java @@ -22,11 +22,11 @@ public class QuakeSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { QuakeGamer quakeGamer = new QuakeGamer(this.game, defaultUser); - this.game.getGamers().a(quakeGamer); - quakeGamer.a(this.game.getMessages().getStart()); - quakeGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(quakeGamer); + quakeGamer.sendMessages(this.game.getMessages().getStart()); + quakeGamer.teleport(this.game.getMap().getLobby()); return quakeGamer; }); } @@ -40,7 +40,7 @@ public class QuakeSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof QuakeGamer var2) { QuakeGame quakeGame = var2.getGame(); - if (quakeGame.getPhase() != quakeGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (quakeGame.getPhase() != quakeGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, quakeGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class QuakeSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { QuakeGamer quakeGamer = new QuakeGamer(this.game, defaultUser); - this.game.getGamers().a(quakeGamer); - quakeGamer.a(this.game.getMap().getSpectator()); - quakeGamer.b(true); - quakeGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(quakeGamer); + quakeGamer.teleport(this.game.getMap().getSpectator()); + quakeGamer.setSpectator(true); + quakeGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(quakeGamer.getName()); return quakeGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSessions.java index 55124e4..f87a398 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/session/QuakeSessions.java @@ -9,42 +9,42 @@ import ro.fr33styler.arcade.game.quake.map.QuakeMap; import org.bukkit.World; public class QuakeSessions extends BaseSessions { - private final QuakeManager a; + private final QuakeManager manager; public QuakeSessions(QuakeManager quakeManager) { super(quakeManager); - this.a = quakeManager; + this.manager = quakeManager; } public QuakeManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(quakeMap -> this.registerGame(new QuakeGame(this.a, quakeMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(quakeMap -> this.registerGame(new QuakeGame(this.manager, quakeMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected QuakeMap h(String text) { + protected QuakeMap createMap(String text) { QuakeMap quakeMap = new QuakeMap(); quakeMap.setId(text); return quakeMap; } - protected QuakeGame a(QuakeMap quakeMap) { - return new QuakeGame(this.a, quakeMap); + protected QuakeGame createGame(QuakeMap quakeMap) { + return new QuakeGame(this.manager, quakeMap); } public QuakeSession createSession(QuakeGame quakeGame) { return quakeGame == null ? null : new QuakeSession(quakeGame); } - protected void a(QuakeMap quakeMap, World world, QuakeMap quakeMap2) { - super.a(quakeMap, world, quakeMap2); + protected void copyMap(QuakeMap quakeMap, World world, QuakeMap quakeMap2) { + super.copyMap(quakeMap, world, quakeMap2); quakeMap2.getSpawns().clear(); - quakeMap2.getSpawns().addAll(Locations.a(world, quakeMap.getSpawns())); - quakeMap2.setSpectator(Locations.a(world, quakeMap.getSpectator())); - quakeMap2.setPlayZone(quakeMap.getPlayZone().a(world)); + quakeMap2.getSpawns().addAll(Locations.withWorld(world, quakeMap.getSpawns())); + quakeMap2.setSpectator(Locations.withWorld(world, quakeMap.getSpectator())); + quakeMap2.setPlayZone(quakeMap.getPlayZone().withWorld(world)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/QuakeSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/QuakeSetup.java index d5ef3ee..cc0d626 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/QuakeSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/QuakeSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class QuakeSetup extends ArenaSetup { private final QuakeMap map; - private final QuakeManager d; + private final QuakeManager manager; private final SetupTarget setupTarget; public QuakeSetup(DefaultUser defaultUser, QuakeMap map2, QuakeManager quakeManager, SetupTarget setupTarget2) { super(defaultUser, quakeManager.getName()); - this.d = quakeManager; + this.manager = quakeManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new QuakeSetArenaNameStep(this); } - public QuakeMap getMap37() { + public QuakeMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class QuakeSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new QuakeGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new QuakeGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeAddPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeAddPlayerSpawnStep.java index 82ebc45..0628660 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeAddPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeAddPlayerSpawnStep.java @@ -18,7 +18,7 @@ public class QuakeAddPlayerSpawnStep implements ClickSetupStep, RepeatableSetupS this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.quakeSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -26,31 +26,31 @@ public class QuakeAddPlayerSpawnStep implements ClickSetupStep, RepeatableSetupS defaultUser.sendMessage("§e yellow dye to continue."); } - public void b() { - this.quakeSetup.getMap37().getSpawns().clear(); + public void onUndo() { + this.quakeSetup.getMap().getSpawns().clear(); } - public void a() { + public void configureHotbar() { Player player = this.quakeSetup.getUser().toPlayer(); - this.quakeSetup.getHotbar().a(0, () -> { + this.quakeSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.quakeSetup.getMap37().getPlayZone().a(location)) { - this.quakeSetup.getMap37().getSpawns().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.quakeSetup.getMap37().getSpawns().size() + "§8)"); - if (this.quakeSetup.getMap37().getSpawns().size() == 1) { - this.e(); + if (this.quakeSetup.getMap().getPlayZone().contains(location)) { + this.quakeSetup.getMap().getSpawns().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.quakeSetup.getMap().getSpawns().size() + "§8)"); + if (this.quakeSetup.getMap().getSpawns().size() == 1) { + this.addFinishButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.quakeSetup.getHotbar().a(1, () -> { - this.quakeSetup.getMap37().getSpawns().clear(); + this.quakeSetup.getHotbar().setSlot(1, () -> { + this.quakeSetup.getMap().getSpawns().clear(); player.sendMessage("§eSpawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset spawns").build()); } - private void e() { - this.quakeSetup.getHotbar().a(2, () -> this.quakeSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish Setup").build()); + private void addFinishButton() { + this.quakeSetup.getHotbar().setSlot(2, () -> this.quakeSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish Setup").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetArenaNameStep.java index 41c58fb..9501df6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetArenaNameStep.java @@ -10,12 +10,12 @@ public class QuakeSetArenaNameStep implements ChatSetupStep { this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { this.quakeSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.quakeSetup.getMap37().setName(text); - this.quakeSetup.a(new QuakeSetLobbySpawnStep(this.quakeSetup)); + public void onChatInput(String text) { + this.quakeSetup.getMap().setName(text); + this.quakeSetup.advanceStep(new QuakeSetLobbySpawnStep(this.quakeSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbyRemovalRegionStep.java index 4e2273b..139bac4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class QuakeSetLobbyRemovalRegionStep implements ClickSetupStep { this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.quakeSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class QuakeSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.quakeSetup.getUser(); - this.quakeSetup.getHotbar().a(0, () -> { + this.quakeSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.quakeSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.quakeSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.quakeSetup.getMap37().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.quakeSetup.a(new QuakeSetPlayZoneStep(this.quakeSetup)); + this.quakeSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.quakeSetup.advanceStep(new QuakeSetPlayZoneStep(this.quakeSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.quakeSetup.getHotbar().a(2, () -> { - this.quakeSetup.getMap37().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.quakeSetup.a(new QuakeSetPlayZoneStep(this.quakeSetup)); + this.quakeSetup.getHotbar().setSlot(2, () -> { + this.quakeSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.quakeSetup.advanceStep(new QuakeSetPlayZoneStep(this.quakeSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbySpawnStep.java index a169cdc..416ecce 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class QuakeSetLobbySpawnStep implements ClickSetupStep { this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.quakeSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.quakeSetup.getUser().toPlayer(); - this.quakeSetup.getHotbar().a(0, () -> { - this.quakeSetup.getMap37().setLobby(player.getLocation()); - this.quakeSetup.a(new QuakeSetLobbyRemovalRegionStep(this.quakeSetup)); + this.quakeSetup.getHotbar().setSlot(0, () -> { + this.quakeSetup.getMap().setLobby(player.getLocation()); + this.quakeSetup.advanceStep(new QuakeSetLobbyRemovalRegionStep(this.quakeSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetPlayZoneStep.java index 002c2b3..05bd93f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class QuakeSetPlayZoneStep implements ClickSetupStep { this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.quakeSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.quakeSetup.getUser(); - this.quakeSetup.getHotbar().a(0, () -> { + this.quakeSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.quakeSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.quakeSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.quakeSetup.getMap37().setPlayZone(new Cuboid(block, block2)); - this.quakeSetup.a(new QuakeSetSpectatorSpawnStep(this.quakeSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.quakeSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.quakeSetup.advanceStep(new QuakeSetSpectatorSpawnStep(this.quakeSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetSpectatorSpawnStep.java index 7beedc0..d3b90a6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/setup/step/QuakeSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class QuakeSetSpectatorSpawnStep implements ClickSetupStep { this.quakeSetup = quakeSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.quakeSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.quakeSetup.getUser().toPlayer(); - this.quakeSetup.getHotbar().a(0, () -> { + this.quakeSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.quakeSetup.getMap37().getPlayZone().a(location)) { - this.quakeSetup.getMap37().setSpectator(location); - this.quakeSetup.a(new QuakeAddPlayerSpawnStep(this.quakeSetup)); + if (this.quakeSetup.getMap().getPlayZone().contains(location)) { + this.quakeSetup.getMap().setSpectator(location); + this.quakeSetup.advanceStep(new QuakeAddPlayerSpawnStep(this.quakeSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/QuakeStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/QuakeStatistics.java index 189a342..70d9766 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/QuakeStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/QuakeStatistics.java @@ -6,44 +6,44 @@ import ro.fr33styler.arcade.game.quake.QuakeManager; import java.util.UUID; public class QuakeStatistics extends BaseGameStatistics { - private int b; - private int c; + private int kills; + private int deaths; public QuakeStatistics(QuakeManager quakeManager, UUID uuid, String text) { super(quakeManager, uuid, text); } - public int d() { - return this.b; + public int getKills() { + return this.kills; } - public void e(int index) { - this.b = index; + public void setKills(int index) { + this.kills = index; } - public int e() { - return this.c; + public int getDeaths() { + return this.deaths; } - public void f(int index) { - this.c = index; + public void setDeaths(int index) { + this.deaths = index; } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { if (text.equals("stats_kills")) { - return String.valueOf(this.b); + return String.valueOf(this.kills); } else { - return text.equals("stats_deaths") ? String.valueOf(this.c) : super.a(text); + return text.equals("stats_deaths") ? String.valueOf(this.deaths) : super.resolvePlaceholder(text); } } @Override public String getVariable(String text) { if (text.equals("kills")) { - return String.valueOf(this.b); + return String.valueOf(this.kills); } else { - return text.equals("deaths") ? String.valueOf(this.c) : super.getVariable(text); + return text.equals("deaths") ? String.valueOf(this.deaths) : super.getVariable(text); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/storage/QuakeStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/storage/QuakeStatisticsRepository.java index 58a5ff2..e11b296 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/storage/QuakeStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/statistics/storage/QuakeStatisticsRepository.java @@ -14,122 +14,122 @@ public class QuakeStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a( + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); } - public void a(QuakeStatistics quakeStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(QuakeStatistics quakeStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, quakeStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(quakeStatistics, var3); + this.readStatistics(quakeStatistics, var3); } - quakeStatistics.a(true); + quakeStatistics.setLoaded(true); } }); } - private void a(QuakeStatistics quakeStatistics, ResultSet resultSet) throws java.sql.SQLException { - quakeStatistics.b(resultSet.getString("options")); - quakeStatistics.a(resultSet.getInt("wins")); - quakeStatistics.c(resultSet.getInt("win_streak")); - quakeStatistics.d(resultSet.getInt("current_win_streak")); - quakeStatistics.b(resultSet.getInt("loses")); - quakeStatistics.e(resultSet.getInt("kills")); - quakeStatistics.f(resultSet.getInt("deaths")); + private void readStatistics(QuakeStatistics quakeStatistics, ResultSet resultSet) throws java.sql.SQLException { + quakeStatistics.deserializeProperties(resultSet.getString("options")); + quakeStatistics.setWins(resultSet.getInt("wins")); + quakeStatistics.setWinStreak(resultSet.getInt("win_streak")); + quakeStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + quakeStatistics.setLoses(resultSet.getInt("loses")); + quakeStatistics.setKills(resultSet.getInt("kills")); + quakeStatistics.setDeaths(resultSet.getInt("deaths")); } - public void b(QuakeStatistics quakeStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(QuakeStatistics quakeStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, quakeStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.c(quakeStatistics); + this.insertStatistics(quakeStatistics); } else { - this.d(quakeStatistics); + this.updateStatistics(quakeStatistics); } } }); } - private void d(QuakeStatistics quakeStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void updateStatistics(QuakeStatistics quakeStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, quakeStatistics.getUUID().toString()); - preparedStatement.setString(2, quakeStatistics.c()); + preparedStatement.setString(2, quakeStatistics.serializeProperties()); preparedStatement.setInt(3, quakeStatistics.getWins()); preparedStatement.setInt(4, quakeStatistics.getWinStreak()); preparedStatement.setInt(5, quakeStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, quakeStatistics.getLoses()); - preparedStatement.setInt(7, quakeStatistics.d()); - preparedStatement.setInt(8, quakeStatistics.e()); + preparedStatement.setInt(7, quakeStatistics.getKills()); + preparedStatement.setInt(8, quakeStatistics.getDeaths()); preparedStatement.executeUpdate(); }); } - public void c(QuakeStatistics quakeStatistics) { - this.a() - .a( + public void insertStatistics(QuakeStatistics quakeStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, kills = ?, deaths = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, quakeStatistics.c()); + preparedStatement.setString(1, quakeStatistics.serializeProperties()); preparedStatement.setInt(2, quakeStatistics.getWins()); preparedStatement.setInt(3, quakeStatistics.getWinStreak()); preparedStatement.setInt(4, quakeStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, quakeStatistics.getLoses()); - preparedStatement.setInt(6, quakeStatistics.d()); - preparedStatement.setInt(7, quakeStatistics.e()); + preparedStatement.setInt(6, quakeStatistics.getKills()); + preparedStatement.setInt(7, quakeStatistics.getDeaths()); preparedStatement.setString(8, quakeStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(QuakeGamer quakeGamer) { - this.a(this.b + "_weekly", quakeGamer); - this.a(this.b + "_monthly", quakeGamer); + public void savePeriodicStatistics(QuakeGamer quakeGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", quakeGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", quakeGamer); } - private void a(String text, QuakeGamer quakeGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, QuakeGamer quakeGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, quakeGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, quakeGamer); + this.updatePeriodicStatistics(text, quakeGamer); } else { - this.c(text, quakeGamer); + this.insertPeriodicStatistics(text, quakeGamer); } } }); } - private void b(String text, QuakeGamer quakeGamer) { + private void updatePeriodicStatistics(String text, QuakeGamer quakeGamer) { String text2 = "current_win_streak"; if (quakeGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -137,9 +137,9 @@ public class QuakeStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -149,86 +149,86 @@ public class QuakeStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, kills = kills + ?, deaths = deaths + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, quakeGamer.getWins()); preparedStatement.setInt(2, quakeGamer.getLoses()); - preparedStatement.setInt(3, quakeGamer.m()); - preparedStatement.setInt(4, quakeGamer.n()); + preparedStatement.setInt(3, quakeGamer.getKills()); + preparedStatement.setInt(4, quakeGamer.getDeaths()); preparedStatement.setString(5, quakeGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, QuakeGamer quakeGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, QuakeGamer quakeGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, quakeGamer.getUUID().toString()); preparedStatement.setInt(2, quakeGamer.getWins()); preparedStatement.setInt(3, quakeGamer.getWins()); preparedStatement.setInt(4, quakeGamer.getWins()); preparedStatement.setInt(5, quakeGamer.getLoses()); - preparedStatement.setInt(6, quakeGamer.m()); - preparedStatement.setInt(7, quakeGamer.n()); + preparedStatement.setInt(6, quakeGamer.getKills()); + preparedStatement.setInt(7, quakeGamer.getDeaths()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT, deaths INT);" ); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -239,22 +239,22 @@ public class QuakeStatisticsRepository extends GameStatisticsRepository { int index2 = var4.getInt("loses"); int index3 = var4.getInt("kills"); int index4 = var4.getInt("deaths"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -269,14 +269,14 @@ public class QuakeStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/quake/storage/QuakeStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/quake/storage/QuakeStorage.java index c587fc0..e4c2ac8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/quake/storage/QuakeStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/quake/storage/QuakeStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.quake.statistics.storage.QuakeStatisticsReposit public class QuakeStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final QuakeStatisticsRepository quakeStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public QuakeStorage(QuakeManager quakeManager) { super(quakeManager); this.storage = new GameMapStorage(quakeManager.getConfigManager(), this.file, QuakeMap::new); - this.storage2 = new NpcStorage(quakeManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(quakeManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(quakeManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(quakeManager.getConfigManager(), this.file); this.quakeStatisticsRepository = new QuakeStatisticsRepository(quakeManager.getEngine()); - this.storage4 = new LeaderboardStorage(quakeManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(quakeManager.getConfigManager(), this.file, QuakeMap::new); + this.leaderboardStorage = new LeaderboardStorage(quakeManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(quakeManager.getConfigManager(), this.file, QuakeMap::new); } @Override @@ -34,26 +34,26 @@ public class QuakeStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public QuakeStatisticsRepository e() { + public QuakeStatisticsRepository getStatisticsRepository() { return this.quakeStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggGame.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggGame.java index b6aa2da..2460196 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggGame.java @@ -26,23 +26,23 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class SpleggGame extends AbstractGame implements GameEventHandler { - private int c; + private int timeLeft; private SpleggGamer[] gamers; - private final SpleggMap e; + private final SpleggMap map; private final SpleggManager manager; - private final Map g = new HashMap<>(); + private final Map activeEggs = new HashMap<>(); private final Set set = EnumSet.allOf(GameAction.class); private final Lifecycle lifecycle = new SpleggLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); public SpleggGame(SpleggManager manager2, SpleggMap spleggMap) { - this.e = spleggMap; + this.map = spleggMap; this.manager = manager2; this.setPhase(this.lifecycle.getWaiting()); } public SpleggMap getMap() { - return this.e; + return this.map; } public Lifecycle getPhaseLifecycle() { @@ -53,17 +53,17 @@ public class SpleggGame extends AbstractGame implements GameEventHandler { return this.manager.getMessages(); } - private SpleggConfiguration y() { - SpleggConfiguration spleggConfiguration = (SpleggConfiguration)this.getManager().G().get(this.getMap().getId()); - return spleggConfiguration == null ? this.getManager().getConfiguration6() : spleggConfiguration; + private SpleggConfiguration getActiveConfiguration() { + SpleggConfiguration spleggConfiguration = (SpleggConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return spleggConfiguration == null ? this.getManager().getConfiguration() : spleggConfiguration; } public SpleggSettings getSettings() { - return this.y().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public SpleggRewards r() { - return this.y().getRewards(); + public SpleggRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public SpleggManager getManager() { @@ -74,7 +74,7 @@ public class SpleggGame extends AbstractGame implements GameEventHandler { return this.set; } - public SpleggGamer[] getGamers10() { + public SpleggGamer[] getStandings() { return this.gamers; } @@ -82,29 +82,29 @@ public class SpleggGame extends AbstractGame implements GameEventHandler { this.gamers = gamers3; } - public Map u() { - return this.g; + public Map getActiveEggs() { + return this.activeEggs; } - public int v() { - return this.c; + public int getTimeLeft() { + return this.timeLeft; } - public void a(int index) { - this.c = index; + public void setTimeLeft(int index) { + this.timeLeft = index; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { if (text.equals("time_left")) { - return Strings.a(this.c); + return Strings.formatDuration(this.timeLeft); } else { - return text.equals("alive") ? String.valueOf(this.gamers2.a()) : super.getVariable(text); + return text.equals("alive") ? String.valueOf(this.gamerSet.getAliveCount()) : super.getVariable(text); } } @@ -118,35 +118,35 @@ public class SpleggGame extends AbstractGame implements GameEventHandler { }; } - public void w() { - if (this.gamers2.a() <= 1) { - this.x(); + public void checkWinCondition() { + if (this.gamerSet.getAliveCount() <= 1) { + this.finishGame(); } } - public void x() { - Arrays.sort(this.gamers, Comparator.comparingInt(SpleggGamer::o).reversed()); - Context context = Contexts.a(this.manager, this.gamers); + public void finishGame() { + Arrays.sort(this.gamers, Comparator.comparingInt(SpleggGamer::getPlacementScore).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (SpleggGamer spleggGamer : this.gamers2) { + for (SpleggGamer spleggGamer : this.gamerSet) { spleggGamer.sendMessages(this.getMessages().getEndingTop(), context); - spleggGamer.a(this.getMessages().getSidebarPlaying(), spleggGamer); - if (!spleggGamer.getSpectatorOptions().g()) { - if (this.c <= 0) { - spleggGamer.b(1); + spleggGamer.updateSidebar(this.getMessages().getSidebarPlaying(), spleggGamer); + if (!spleggGamer.getSpectatorOptions().isExternal()) { + if (this.timeLeft <= 0) { + spleggGamer.setLoses(1); spleggGamer.sendTitle(this.getMessages().getTitleDraw(), this.getMessages().getSubtitleDraw(), 0, 80, 0); - spleggGamer.b(this.r().getLosers()); + spleggGamer.setRewardCommands(this.getRewards().getLosers()); } else if (this.gamers[0] == spleggGamer) { - spleggGamer.a(1); + spleggGamer.setWins(1); spleggGamer.sendTitle(this.getMessages().getTitleWon(), "", 0, 80, 0); - if (this.r().isEnabled()) { - spleggGamer.b(this.r().getWinner()); + if (this.getRewards().isEnabled()) { + spleggGamer.setRewardCommands(this.getRewards().getWinner()); } } else { - spleggGamer.b(1); + spleggGamer.setLoses(1); spleggGamer.sendTitle(this.getMessages().getTitleLost(), "", 0, 80, 0); - if (this.r().isEnabled()) { - spleggGamer.b(this.r().getLosers()); + if (this.getRewards().isEnabled()) { + spleggGamer.setRewardCommands(this.getRewards().getLosers()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggManager.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggManager.java index e163b8c..9649319 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/SpleggManager.java @@ -30,12 +30,12 @@ public class SpleggManager extends AbstractGameManager { private final Command command; private final SpleggStorage storage; private final SpleggMessages messages = new SpleggMessages(); - private final Map f = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final SpleggConfiguration configuration = new SpleggConfiguration(); private final SpleggListener listener = new SpleggListener(this); - private final Map i = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final SpleggSessions sessions = new SpleggSessions(this); - private final Map> k = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "blocks_hit", this.messages::getStatisticBlocksHit, "eggs_fired", this.messages::getStatisticEggsFired ); @@ -64,7 +64,7 @@ public class SpleggManager extends AbstractGameManager { return this.sessions; } - public SpleggConfiguration getConfiguration6() { + public SpleggConfiguration getConfiguration() { return this.configuration; } @@ -79,21 +79,21 @@ public class SpleggManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { SpleggStatistics spleggStatistics = new SpleggStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(spleggStatistics); - this.f.put(player.getUniqueId(), spleggStatistics); + this.storage.getStatisticsRepository().loadStatistics(spleggStatistics); + this.playerStatistics.put(player.getUniqueId(), spleggStatistics); } public SpleggStatistics getData(UUID uuid) { - return this.f.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.f.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map G() { - return this.i; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -110,7 +110,7 @@ public class SpleggManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.k; + return this.leaderboardSources; } @Override @@ -118,16 +118,16 @@ public class SpleggManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "splegg"); } - private void H() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); SpleggConfiguration spleggConfiguration = new SpleggConfiguration(); - spleggConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.i.put("id_1", this.configuration); - Files.a(file, file2 -> { + spleggConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { SpleggConfiguration spleggConfiguration2 = new SpleggConfiguration(); - spleggConfiguration2.a(this.getConfigManager(), file2); - this.i.put(file2.getName(), spleggConfiguration2); + spleggConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), spleggConfiguration2); } }); } @@ -135,15 +135,15 @@ public class SpleggManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.H(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/command/SpleggCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/command/SpleggCreateCommand.java index a4e66d2..3ebaadb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/command/SpleggCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/command/SpleggCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class SpleggCreateCommand implements CommandExecutor { - private final SpleggManager a; + private final SpleggManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public SpleggCreateCommand(SpleggManager spleggManager) { - this.a = spleggManager; + this.manager = spleggManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class SpleggCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); SpleggMap spleggMap = new SpleggMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class SpleggCreateCommand implements CommandExecutor { } spleggMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } spleggMap.setId(text2); spleggMap.setMaximumPlayers(index3); - defaultUser.a(new SpleggSetup(defaultUser, spleggMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new SpleggSetup(defaultUser, spleggMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/SpleggConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/SpleggConfiguration.java index 7bfb2d3..f2361b6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/SpleggConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/SpleggConfiguration.java @@ -9,7 +9,7 @@ public class SpleggConfiguration { private final SpleggRewards rewards = new SpleggRewards(); private final SpleggSettings settings = new SpleggSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/message/SpleggMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/message/SpleggMessages.java index 48306ab..d2a1a02 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/message/SpleggMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/config/message/SpleggMessages.java @@ -10,39 +10,39 @@ import ro.fr33styler.arcade.api.engine.config.annotation.Setting; public class SpleggMessages extends BaseGameMessages { @Setting("display-name") - private String displayName = Strings.a("Splegg"); + private String displayName = Strings.colorize("Splegg"); @Setting("title-won") - private String titleWon = Strings.a("&aYOU WON!"); + private String titleWon = Strings.colorize("&aYOU WON!"); @Setting("title-lost") - private String titleLost = Strings.a("&cYOU LOST!"); + private String titleLost = Strings.colorize("&cYOU LOST!"); @Setting("title-draw") - private String titleDraw = Strings.a("&6&lDRAW"); + private String titleDraw = Strings.colorize("&6&lDRAW"); @Setting("subtitle-draw") - private String subtitleDraw = Strings.a("&cThe time has run out!"); + private String subtitleDraw = Strings.colorize("&cThe time has run out!"); @Setting("egg-launcher") - private String eggLauncher = Strings.a("&aEgg Launcher &7(Right Click)"); + private String eggLauncher = Strings.colorize("&aEgg Launcher &7(Right Click)"); @Setting("player-eliminated") - private Text playerEliminated = TextParser.a("&7%player% &ehas been eliminated!"); + private Text playerEliminated = TextParser.parse("&7%player% &ehas been eliminated!"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-blocks-hit") - private String statisticBlocksHit = Strings.a("Blocks Hit"); + private String statisticBlocksHit = Strings.colorize("Blocks Hit"); @Setting("statistic-eggs-fired") - private String statisticEggsFired = Strings.a("Eggs Fired"); + private String statisticEggsFired = Strings.colorize("Eggs Fired"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lSplegg", " ", " &eUse your egg launcher to destroy the blocks", " &eunder your enemies in order to make them fall.", "&a%line%" } ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lSplegg", @@ -55,7 +55,7 @@ public class SpleggMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -70,7 +70,7 @@ public class SpleggMessages extends BaseGameMessages { ); public SpleggMessages() { - this.statisticsView = TextParser.a( + this.statisticsView = TextParser.parseAll( new String[]{ " ", " &l%display_name% Statistics", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/lifecycle/SpleggLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/lifecycle/SpleggLifecycle.java index 702c432..2d4b3e1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/lifecycle/SpleggLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/lifecycle/SpleggLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class SpleggLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public SpleggLifecycle(SpleggGame spleggGame) { this.phase = new WaitingPhase(spleggGame); - this.phase2 = new SpleggPlayingPhase(spleggGame); - this.phase3 = new EndingPhase(spleggGame); - this.phase4 = new ResettingPhase(spleggGame); + this.playingPhase = new SpleggPlayingPhase(spleggGame); + this.endingPhase = new EndingPhase(spleggGame); + this.resettingPhase = new ResettingPhase(spleggGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class SpleggLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/listener/SpleggListener.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/listener/SpleggListener.java index 4436fcb..85ba813 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/listener/SpleggListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/listener/SpleggListener.java @@ -25,18 +25,18 @@ import ro.fr33styler.arcade.platform.compat.ArcadeSound; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class SpleggListener extends GameListener { - private final SpleggManager manager2; + private final SpleggManager spleggManager; public SpleggListener(SpleggManager manager22) { super(manager22); - this.manager2 = manager22; + this.spleggManager = manager22; } @EventHandler - public void a(EntitySpawnEvent event) { + public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.CHICKEN) { - for (SpleggGame spleggGame : this.manager2.getSessions().d().values()) { - if (spleggGame.getMap().getPlayZone().a(event.getLocation())) { + for (SpleggGame spleggGame : this.spleggManager.getSessions().getGames().values()) { + if (spleggGame.getMap().getPlayZone().contains(event.getLocation())) { event.setCancelled(true); break; } @@ -45,60 +45,60 @@ public class SpleggListener extends GameListener { } @EventHandler - public void a(PlayerInteractEvent event) { - if (VersionAdapters.get().isMainHandInteract(this.manager2.getEngine().getPlatform(), event) && EngineUtils.b(event.getAction())) { + public void onPlayerInteract(PlayerInteractEvent event) { + if (VersionAdapters.get().isMainHandInteract(this.spleggManager.getEngine().getPlatform(), event) && EngineUtils.isRightClick(event.getAction())) { Player player = event.getPlayer(); - SpleggGamer spleggGamer = this.a(player, SpleggGamer.class); - if (spleggGamer != null && !spleggGamer.f() && player.getInventory().getHeldItemSlot() == 0) { - spleggGamer.e(spleggGamer.getGame().getSettings().getEggBurst()); + SpleggGamer spleggGamer = this.getActiveGamer(player, SpleggGamer.class); + if (spleggGamer != null && !spleggGamer.isSpectator() && player.getInventory().getHeldItemSlot() == 0) { + spleggGamer.setEggBurstRemaining(spleggGamer.getGame().getSettings().getEggBurst()); } } } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - SpleggGamer spleggGamer = this.a(player, SpleggGamer.class); - if (spleggGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + SpleggGamer spleggGamer = this.getActiveGamer(player, SpleggGamer.class); + if (spleggGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { SpleggGame spleggGame = spleggGamer.getGame(); - if (!spleggGame.getMap().getPlayZone().a(location)) { - if (spleggGamer.f()) { + if (!spleggGame.getMap().getPlayZone().contains(location)) { + if (spleggGamer.isSpectator()) { player.setFlying(true); event.setTo(spleggGame.getMap().getSpectator()); } else { - spleggGamer.r(); + spleggGamer.eliminate(); } } } } @EventHandler - public void a(ProjectileHitEvent event) { + public void onProjectileHit(ProjectileHitEvent event) { Projectile projectile = event.getEntity(); if (event.getEntityType() == EntityType.EGG && projectile.getShooter() instanceof Player var3) { - SpleggGamer spleggGamer = this.a(var3, SpleggGamer.class); - if (spleggGamer == null || spleggGamer.f()) { + SpleggGamer spleggGamer = this.getActiveGamer(var3, SpleggGamer.class); + if (spleggGamer == null || spleggGamer.isSpectator()) { return; } SpleggGame spleggGame = spleggGamer.getGame(); Block block = VersionAdapters.get().getProjectileHitBlock(event); - if (block != null && spleggGame.getMap().getPlayZone().a(block)) { + if (block != null && spleggGame.getMap().getPlayZone().contains(block)) { projectile.remove(); Location location = block.getLocation(); if (block.getType() == Material.TNT) { VersionAdapters.get().spawnParticle(var3.getWorld(), ArcadeParticle.EXPLOSION_HUGE, location, 10, 0.0, 0.0, 0.0, 0.0); VersionAdapters.get().playSound(var3.getWorld(), location, ArcadeSound.GENERIC_EXPLODE, 1.0F, 1.0F); - BlockFloodFill.a(4, block, block2 -> { + BlockFloodFill.forEachInRadius(4, block, block2 -> { spleggGame.getRollbackQueue().add(block2.getState()); block2.setType(Material.AIR); - spleggGamer.c(spleggGamer.m() + 1); + spleggGamer.setBrokenBlocks(spleggGamer.getBrokenBlocks() + 1); }); } else { spleggGame.getRollbackQueue().add(block.getState()); block.setType(Material.AIR); - spleggGamer.c(spleggGamer.m() + 1); + spleggGamer.setBrokenBlocks(spleggGamer.getBrokenBlocks() + 1); if (spleggGame.getSettings().isParticleEffect()) { var3.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 5); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/phase/SpleggPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/phase/SpleggPlayingPhase.java index 705d79d..dc3a285 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/phase/SpleggPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/phase/SpleggPlayingPhase.java @@ -25,23 +25,23 @@ public class SpleggPlayingPhase implements Phase { } public void start() { - this.game.a(this.game.getSettings().getTimeDuration()); - this.game.setGamers((SpleggGamer[])this.game.getGamers().a(new SpleggGamer[this.game.getGamers().size()])); + this.game.setTimeLeft(this.game.getSettings().getTimeDuration()); + this.game.setGamers((SpleggGamer[])this.game.getGamers().toArray(new SpleggGamer[this.game.getGamers().size()])); int index = 0; List list = this.game.getMap().getSpawn(); Collections.shuffle(list); for (SpleggGamer spleggGamer : this.game.getGamers()) { - spleggGamer.a((Location)list.get(index++ % list.size())); + spleggGamer.teleport((Location)list.get(index++ % list.size())); spleggGamer.toPlayer().getInventory().setItem(0, new ItemBuilder(ArcadeMaterial.IRON_SHOVEL).setDisplayName(this.game.getMessages().getEggLauncher()).build()); } } public void stop() { - this.game.u().values().forEach(Entity::remove); - this.game.u().clear(); + this.game.getActiveEggs().values().forEach(Entity::remove); + this.game.getActiveEggs().clear(); this.game.setGamers((ro.fr33styler.arcade.game.splegg.player.SpleggGamer[])null); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -55,27 +55,27 @@ public class SpleggPlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.game.v() > 0) { - this.game.a(this.game.v() - 1); - this.game.getGamers().a(this.game.getMessages().getSidebarPlaying()); + if (this.game.getTimeLeft() > 0) { + this.game.setTimeLeft(this.game.getTimeLeft() - 1); + this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarPlaying()); } else { - this.game.x(); + this.game.finishGame(); } } for (SpleggGamer spleggGamer : this.game.getGamers()) { - if (!spleggGamer.f() && longVal % this.game.getSettings().getShootDelay() == 0L && spleggGamer.q() > 0) { + if (!spleggGamer.isSpectator() && longVal % this.game.getSettings().getShootDelay() == 0L && spleggGamer.getEggBurstRemaining() > 0) { Player player = spleggGamer.toPlayer(); Location location = player.getEyeLocation(); spleggGamer.playSound(ArcadeSound.GHAST_SHOOT, 0.4F, 2.0F); - spleggGamer.e(spleggGamer.q() - 1); - spleggGamer.d(spleggGamer.n() + 1); + spleggGamer.setEggBurstRemaining(spleggGamer.getEggBurstRemaining() - 1); + spleggGamer.setEggsFired(spleggGamer.getEggsFired() + 1); Vector vector = location.getDirection(); Location spawnLoc = VersionAdapters.get().isSpleggEggSpawnOffset() ? location.add(vector) : location; Egg egg = player.getWorld().spawn(spawnLoc, Egg.class); egg.setShooter(player); egg.setVelocity(vector.multiply(this.game.getSettings().getEggSpeed())); - this.game.u().put(egg.getUniqueId(), egg); + this.game.getActiveEggs().put(egg.getUniqueId(), egg); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/player/SpleggGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/player/SpleggGamer.java index 8e314ab..b518c8a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/player/SpleggGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/player/SpleggGamer.java @@ -9,13 +9,13 @@ import ro.fr33styler.arcade.game.splegg.statistics.SpleggStatistics; public class SpleggGamer extends BaseGamer { - private int b; + private int brokenBlocks; - private int c; + private int eggsFired; - private int d = 1; + private int placementScore = 1; - private int e; + private int eggBurstRemaining; private final SpleggGame game; @@ -28,77 +28,77 @@ public class SpleggGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getBrokenBlocks() { + return this.brokenBlocks; } - public void c(int index) { - this.b = index; + public void setBrokenBlocks(int index) { + this.brokenBlocks = index; } - public int n() { - return this.c; + public int getEggsFired() { + return this.eggsFired; } - public void d(int index) { - this.c = index; + public void setEggsFired(int index) { + this.eggsFired = index; } - public int o() { - return this.d; + public int getPlacementScore() { + return this.placementScore; } - public int q() { - return this.e; + public int getEggBurstRemaining() { + return this.eggBurstRemaining; } - public void e(int index) { - this.e = index; + public void setEggBurstRemaining(int index) { + this.eggBurstRemaining = index; } - private void s() { + private void saveStatistics() { SpleggStatistics spleggStatistics = this.game.getManager().getData(this.getUUID()); - if (spleggStatistics.a()) { - spleggStatistics.a(spleggStatistics.getWins() + this.getWins()); + if (spleggStatistics.isLoaded()) { + spleggStatistics.setWins(spleggStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - spleggStatistics.d(spleggStatistics.getCurrentWinStreak() + 1); + spleggStatistics.setCurrentWinStreak(spleggStatistics.getCurrentWinStreak() + 1); if (spleggStatistics.getWinStreak() < spleggStatistics.getCurrentWinStreak()) { - spleggStatistics.c(spleggStatistics.getCurrentWinStreak()); + spleggStatistics.setWinStreak(spleggStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - spleggStatistics.d(0); + spleggStatistics.setCurrentWinStreak(0); } - spleggStatistics.b(spleggStatistics.getLoses() + this.getLoses()); - spleggStatistics.e(spleggStatistics.d() + this.b); - spleggStatistics.f(spleggStatistics.e() + this.c); - this.b(spleggStatistics.getMap()); - this.game.getManager().getStorage().e().b(spleggStatistics); - this.game.getManager().getStorage().e().a(this); + spleggStatistics.setLoses(spleggStatistics.getLoses() + this.getLoses()); + spleggStatistics.setBlocksHit(spleggStatistics.getBlocksHit() + this.brokenBlocks); + spleggStatistics.setEggsFired(spleggStatistics.getEggsFired() + this.eggsFired); + this.saveProperties(spleggStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(spleggStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } - public void r() { - this.b(this.getLoses() + 1); - this.b(true); + public void eliminate() { + this.setLoses(this.getLoses() + 1); + this.setSpectator(true); this.game.getSpectatorTeam().addEntry(this.player.getName()); - this.a(this.game.getMap().getSpectator()); + this.teleport(this.game.getMap().getSpectator()); this.playSound(ArcadeSound.LIGHTNING_THUNDER, 100.0F, 1.0F); for (SpleggGamer spleggGamer : this.game.getGamers()) { spleggGamer.sendMessage(this.game.getMessages().getPlayerEliminated(), this); - if (!spleggGamer.f()) { - spleggGamer.d++; + if (!spleggGamer.isSpectator()) { + spleggGamer.placementScore++; } } - this.game.w(); + this.game.checkWinCondition(); } @Override public String getVariable(String text) { return switch(text) { case "eggs_fired" -> - String.valueOf(this.c); + String.valueOf(this.eggsFired); case "broken_blocks" -> - String.valueOf(this.b); + String.valueOf(this.brokenBlocks); default -> super.getVariable(text); }; @@ -107,7 +107,7 @@ public class SpleggGamer extends BaseGamer { @Override public Boolean getCondition(String text) { if (text.equals("IN_TOP")) { - SpleggGamer[] spleggGamers = this.game.getGamers10(); + SpleggGamer[] spleggGamers = this.game.getStandings(); if (spleggGamers == null) { return null; } @@ -127,10 +127,10 @@ public class SpleggGamer extends BaseGamer { @Override public void leave() { - this.s(); - this.game.getGamers().b(this); + this.saveStatistics(); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.w(); + this.game.checkWinCondition(); } super.leave(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSession.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSession.java index bc7351d..1945d3d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSession.java @@ -22,11 +22,11 @@ public class SpleggSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { SpleggGamer spleggGamer = new SpleggGamer(this.game, defaultUser); - this.game.getGamers().a(spleggGamer); - spleggGamer.a(this.game.getMessages().getStart()); - spleggGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(spleggGamer); + spleggGamer.sendMessages(this.game.getMessages().getStart()); + spleggGamer.teleport(this.game.getMap().getLobby()); return spleggGamer; }); } @@ -40,7 +40,7 @@ public class SpleggSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof SpleggGamer var2) { SpleggGame spleggGame = var2.getGame(); - if (spleggGame.getPhase() != spleggGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (spleggGame.getPhase() != spleggGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, spleggGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class SpleggSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { SpleggGamer spleggGamer = new SpleggGamer(this.game, defaultUser); - this.game.getGamers().a(spleggGamer); - spleggGamer.a(this.game.getMap().getSpectator()); - spleggGamer.b(true); - spleggGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(spleggGamer); + spleggGamer.teleport(this.game.getMap().getSpectator()); + spleggGamer.setSpectator(true); + spleggGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(spleggGamer.getName()); return spleggGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSessions.java index a1351f7..8df0c64 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/session/SpleggSessions.java @@ -9,42 +9,42 @@ import ro.fr33styler.arcade.game.splegg.map.SpleggMap; import org.bukkit.World; public class SpleggSessions extends BaseSessions { - private final SpleggManager a; + private final SpleggManager manager; public SpleggSessions(SpleggManager spleggManager) { super(spleggManager); - this.a = spleggManager; + this.manager = spleggManager; } public SpleggManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(spleggMap -> this.registerGame(new SpleggGame(this.a, spleggMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(spleggMap -> this.registerGame(new SpleggGame(this.manager, spleggMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected SpleggMap h(String text) { + protected SpleggMap createMap(String text) { SpleggMap spleggMap = new SpleggMap(); spleggMap.setId(text); return spleggMap; } - protected SpleggGame a(SpleggMap spleggMap) { - return new SpleggGame(this.a, spleggMap); + protected SpleggGame createGame(SpleggMap spleggMap) { + return new SpleggGame(this.manager, spleggMap); } public SpleggSession createSession(SpleggGame spleggGame) { return spleggGame == null ? null : new SpleggSession(spleggGame); } - protected void a(SpleggMap spleggMap, World world, SpleggMap spleggMap2) { - super.a(spleggMap, world, spleggMap2); + protected void copyMap(SpleggMap spleggMap, World world, SpleggMap spleggMap2) { + super.copyMap(spleggMap, world, spleggMap2); spleggMap2.getSpawn().clear(); - spleggMap2.getSpawn().addAll(Locations.a(world, spleggMap.getSpawn())); - spleggMap2.setSpectator(Locations.a(world, spleggMap.getSpectator())); - spleggMap2.setPlayZone(spleggMap.getPlayZone().a(world)); + spleggMap2.getSpawn().addAll(Locations.withWorld(world, spleggMap.getSpawn())); + spleggMap2.setSpectator(Locations.withWorld(world, spleggMap.getSpectator())); + spleggMap2.setPlayZone(spleggMap.getPlayZone().withWorld(world)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/SpleggSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/SpleggSetup.java index 3c4fd7b..471b706 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/SpleggSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/SpleggSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class SpleggSetup extends ArenaSetup { private final SpleggMap map; - private final SpleggManager d; + private final SpleggManager manager; private final SetupTarget setupTarget; public SpleggSetup(DefaultUser defaultUser, SpleggMap map2, SpleggManager spleggManager, SetupTarget setupTarget2) { super(defaultUser, spleggManager.getName()); - this.d = spleggManager; + this.manager = spleggManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new SpleggSetArenaNameStep(this); } - public SpleggMap getMap38() { + public SpleggMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class SpleggSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new SpleggGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new SpleggGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggAddPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggAddPlayerSpawnStep.java index d6330c4..b9561e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggAddPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggAddPlayerSpawnStep.java @@ -18,7 +18,7 @@ public class SpleggAddPlayerSpawnStep implements ClickSetupStep, RepeatableSetup this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.spleggSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -26,31 +26,31 @@ public class SpleggAddPlayerSpawnStep implements ClickSetupStep, RepeatableSetup defaultUser.sendMessage("§e yellow dye to continue."); } - public void b() { - this.spleggSetup.getMap38().getSpawn().clear(); + public void onUndo() { + this.spleggSetup.getMap().getSpawn().clear(); } - public void a() { + public void configureHotbar() { Player player = this.spleggSetup.getUser().toPlayer(); - this.spleggSetup.getHotbar().a(0, () -> { + this.spleggSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.spleggSetup.getMap38().getPlayZone().a(location)) { - this.spleggSetup.getMap38().getSpawn().add(location); - player.sendMessage("§eSpawn location added. §8(§b" + this.spleggSetup.getMap38().getSpawn().size() + "§8)"); - if (this.spleggSetup.getMap38().getSpawn().size() == 1) { - this.e(); + if (this.spleggSetup.getMap().getPlayZone().contains(location)) { + this.spleggSetup.getMap().getSpawn().add(location); + player.sendMessage("§eSpawn location added. §8(§b" + this.spleggSetup.getMap().getSpawn().size() + "§8)"); + if (this.spleggSetup.getMap().getSpawn().size() == 1) { + this.addFinishButton(); } } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd spawn").build()); - this.spleggSetup.getHotbar().a(1, () -> { - this.spleggSetup.getMap38().getSpawn().clear(); + this.spleggSetup.getHotbar().setSlot(1, () -> { + this.spleggSetup.getMap().getSpawn().clear(); player.sendMessage("§eSpawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset spawns").build()); } - private void e() { - this.spleggSetup.getHotbar().a(2, () -> this.spleggSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish Setup").build()); + private void addFinishButton() { + this.spleggSetup.getHotbar().setSlot(2, () -> this.spleggSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lFinish Setup").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetArenaNameStep.java index f12145a..9cf7d48 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetArenaNameStep.java @@ -10,12 +10,12 @@ public class SpleggSetArenaNameStep implements ChatSetupStep { this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { this.spleggSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.spleggSetup.getMap38().setName(text); - this.spleggSetup.a(new SpleggSetLobbySpawnStep(this.spleggSetup)); + public void onChatInput(String text) { + this.spleggSetup.getMap().setName(text); + this.spleggSetup.advanceStep(new SpleggSetLobbySpawnStep(this.spleggSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbyRemovalRegionStep.java index 1cefba7..ad2add5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class SpleggSetLobbyRemovalRegionStep implements ClickSetupStep { this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.spleggSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class SpleggSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.spleggSetup.getUser(); - this.spleggSetup.getHotbar().a(0, () -> { + this.spleggSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.spleggSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.spleggSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.spleggSetup.getMap38().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.spleggSetup.a(new SpleggSetPlayZoneStep(this.spleggSetup)); + this.spleggSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.spleggSetup.advanceStep(new SpleggSetPlayZoneStep(this.spleggSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.spleggSetup.getHotbar().a(2, () -> { - this.spleggSetup.getMap38().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.spleggSetup.a(new SpleggSetPlayZoneStep(this.spleggSetup)); + this.spleggSetup.getHotbar().setSlot(2, () -> { + this.spleggSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.spleggSetup.advanceStep(new SpleggSetPlayZoneStep(this.spleggSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbySpawnStep.java index 30c5dc8..fd349b4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class SpleggSetLobbySpawnStep implements ClickSetupStep { this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.spleggSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.spleggSetup.getUser().toPlayer(); - this.spleggSetup.getHotbar().a(0, () -> { - this.spleggSetup.getMap38().setLobby(player.getLocation()); - this.spleggSetup.a(new SpleggSetLobbyRemovalRegionStep(this.spleggSetup)); + this.spleggSetup.getHotbar().setSlot(0, () -> { + this.spleggSetup.getMap().setLobby(player.getLocation()); + this.spleggSetup.advanceStep(new SpleggSetLobbyRemovalRegionStep(this.spleggSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetPlayZoneStep.java index bed7e69..7d79ae8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class SpleggSetPlayZoneStep implements ClickSetupStep { this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.spleggSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.spleggSetup.getUser(); - this.spleggSetup.getHotbar().a(0, () -> { + this.spleggSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.spleggSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.spleggSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.spleggSetup.getMap38().setPlayZone(new Cuboid(block, block2)); - this.spleggSetup.a(new SpleggSetSpectatorSpawnStep(this.spleggSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.spleggSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.spleggSetup.advanceStep(new SpleggSetSpectatorSpawnStep(this.spleggSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetSpectatorSpawnStep.java index 389b9c2..ec4b36e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/setup/step/SpleggSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class SpleggSetSpectatorSpawnStep implements ClickSetupStep { this.spleggSetup = spleggSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.spleggSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.spleggSetup.getUser().toPlayer(); - this.spleggSetup.getHotbar().a(0, () -> { + this.spleggSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.spleggSetup.getMap38().getPlayZone().a(location)) { - this.spleggSetup.getMap38().setSpectator(location); - this.spleggSetup.a(new SpleggAddPlayerSpawnStep(this.spleggSetup)); + if (this.spleggSetup.getMap().getPlayZone().contains(location)) { + this.spleggSetup.getMap().setSpectator(location); + this.spleggSetup.advanceStep(new SpleggAddPlayerSpawnStep(this.spleggSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/SpleggStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/SpleggStatistics.java index 71b81aa..ab807fa 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/SpleggStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/SpleggStatistics.java @@ -6,44 +6,44 @@ import ro.fr33styler.arcade.game.splegg.SpleggManager; import java.util.UUID; public class SpleggStatistics extends BaseGameStatistics { - private int b; - private int c; + private int blocksHit; + private int eggsFired; public SpleggStatistics(SpleggManager spleggManager, UUID uuid, String text) { super(spleggManager, uuid, text); } - public int d() { - return this.b; + public int getBlocksHit() { + return this.blocksHit; } - public void e(int index) { - this.b = index; + public void setBlocksHit(int index) { + this.blocksHit = index; } - public int e() { - return this.c; + public int getEggsFired() { + return this.eggsFired; } - public void f(int index) { - this.c = index; + public void setEggsFired(int index) { + this.eggsFired = index; } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { if (text.equals("stats_blocks_hit")) { - return String.valueOf(this.b); + return String.valueOf(this.blocksHit); } else { - return text.equals("stats_eggs_fired") ? String.valueOf(this.c) : super.a(text); + return text.equals("stats_eggs_fired") ? String.valueOf(this.eggsFired) : super.resolvePlaceholder(text); } } @Override public String getVariable(String text) { if (text.equals("blocks_hit")) { - return String.valueOf(this.b); + return String.valueOf(this.blocksHit); } else { - return text.equals("eggs_fired") ? String.valueOf(this.c) : super.getVariable(text); + return text.equals("eggs_fired") ? String.valueOf(this.eggsFired) : super.getVariable(text); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/storage/SpleggStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/storage/SpleggStatisticsRepository.java index ffec425..550d692 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/storage/SpleggStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/statistics/storage/SpleggStatisticsRepository.java @@ -14,122 +14,122 @@ public class SpleggStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a( + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); } - public void a(SpleggStatistics spleggStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(SpleggStatistics spleggStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, spleggStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(spleggStatistics, var3); + this.readStatistics(spleggStatistics, var3); } - spleggStatistics.a(true); + spleggStatistics.setLoaded(true); } }); } - private void a(SpleggStatistics spleggStatistics, ResultSet resultSet) throws java.sql.SQLException { - spleggStatistics.b(resultSet.getString("options")); - spleggStatistics.a(resultSet.getInt("wins")); - spleggStatistics.c(resultSet.getInt("win_streak")); - spleggStatistics.d(resultSet.getInt("current_win_streak")); - spleggStatistics.b(resultSet.getInt("loses")); - spleggStatistics.e(resultSet.getInt("blocks_hit")); - spleggStatistics.f(resultSet.getInt("eggs_fired")); + private void readStatistics(SpleggStatistics spleggStatistics, ResultSet resultSet) throws java.sql.SQLException { + spleggStatistics.deserializeProperties(resultSet.getString("options")); + spleggStatistics.setWins(resultSet.getInt("wins")); + spleggStatistics.setWinStreak(resultSet.getInt("win_streak")); + spleggStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + spleggStatistics.setLoses(resultSet.getInt("loses")); + spleggStatistics.setBlocksHit(resultSet.getInt("blocks_hit")); + spleggStatistics.setEggsFired(resultSet.getInt("eggs_fired")); } - public void b(SpleggStatistics spleggStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(SpleggStatistics spleggStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, spleggStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(spleggStatistics); + this.updateStatistics(spleggStatistics); } else { - this.c(spleggStatistics); + this.insertStatistics(spleggStatistics); } } }); } - private void c(SpleggStatistics spleggStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(SpleggStatistics spleggStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, spleggStatistics.getUUID().toString()); - preparedStatement.setString(2, spleggStatistics.c()); + preparedStatement.setString(2, spleggStatistics.serializeProperties()); preparedStatement.setInt(3, spleggStatistics.getWins()); preparedStatement.setInt(4, spleggStatistics.getWinStreak()); preparedStatement.setInt(5, spleggStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, spleggStatistics.getLoses()); - preparedStatement.setInt(7, spleggStatistics.d()); - preparedStatement.setInt(8, spleggStatistics.e()); + preparedStatement.setInt(7, spleggStatistics.getBlocksHit()); + preparedStatement.setInt(8, spleggStatistics.getEggsFired()); preparedStatement.executeUpdate(); }); } - private void d(SpleggStatistics spleggStatistics) { - this.a() - .a( + private void updateStatistics(SpleggStatistics spleggStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, blocks_hit = ?, eggs_fired = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, spleggStatistics.c()); + preparedStatement.setString(1, spleggStatistics.serializeProperties()); preparedStatement.setInt(2, spleggStatistics.getWins()); preparedStatement.setInt(3, spleggStatistics.getWinStreak()); preparedStatement.setInt(4, spleggStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, spleggStatistics.getLoses()); - preparedStatement.setInt(6, spleggStatistics.d()); - preparedStatement.setInt(7, spleggStatistics.e()); + preparedStatement.setInt(6, spleggStatistics.getBlocksHit()); + preparedStatement.setInt(7, spleggStatistics.getEggsFired()); preparedStatement.setString(8, spleggStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(SpleggGamer spleggGamer) { - this.a(this.b + "_weekly", spleggGamer); - this.a(this.b + "_monthly", spleggGamer); + public void savePeriodicStatistics(SpleggGamer spleggGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", spleggGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", spleggGamer); } - private void a(String text, SpleggGamer spleggGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, SpleggGamer spleggGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, spleggGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, spleggGamer); + this.updatePeriodicStatistics(text, spleggGamer); } else { - this.c(text, spleggGamer); + this.insertPeriodicStatistics(text, spleggGamer); } } }); } - private void b(String text, SpleggGamer spleggGamer) { + private void updatePeriodicStatistics(String text, SpleggGamer spleggGamer) { String text2 = "current_win_streak"; if (spleggGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -137,9 +137,9 @@ public class SpleggStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -149,86 +149,86 @@ public class SpleggStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, blocks_hit = blocks_hit + ?, eggs_fired = eggs_fired + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, spleggGamer.getWins()); preparedStatement.setInt(2, spleggGamer.getLoses()); - preparedStatement.setInt(3, spleggGamer.m()); - preparedStatement.setInt(4, spleggGamer.n()); + preparedStatement.setInt(3, spleggGamer.getBrokenBlocks()); + preparedStatement.setInt(4, spleggGamer.getEggsFired()); preparedStatement.setString(5, spleggGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, SpleggGamer spleggGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, SpleggGamer spleggGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, spleggGamer.getUUID().toString()); preparedStatement.setInt(2, spleggGamer.getWins()); preparedStatement.setInt(3, spleggGamer.getWins()); preparedStatement.setInt(4, spleggGamer.getWins()); preparedStatement.setInt(5, spleggGamer.getLoses()); - preparedStatement.setInt(6, spleggGamer.m()); - preparedStatement.setInt(7, spleggGamer.n()); + preparedStatement.setInt(6, spleggGamer.getBrokenBlocks()); + preparedStatement.setInt(7, spleggGamer.getEggsFired()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, blocks_hit INT, eggs_fired INT);" ); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -239,22 +239,22 @@ public class SpleggStatisticsRepository extends GameStatisticsRepository { int index2 = var4.getInt("loses"); int index3 = var4.getInt("blocks_hit"); int index4 = var4.getInt("eggs_fired"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -269,14 +269,14 @@ public class SpleggStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/splegg/storage/SpleggStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/splegg/storage/SpleggStorage.java index ab07a65..c04172b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/splegg/storage/SpleggStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/splegg/storage/SpleggStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.splegg.statistics.storage.SpleggStatisticsRepos public class SpleggStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final SpleggStatisticsRepository spleggStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public SpleggStorage(SpleggManager spleggManager) { super(spleggManager); this.storage = new GameMapStorage(spleggManager.getConfigManager(), this.file, SpleggMap::new); - this.storage2 = new NpcStorage(spleggManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(spleggManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(spleggManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(spleggManager.getConfigManager(), this.file); this.spleggStatisticsRepository = new SpleggStatisticsRepository(spleggManager.getEngine()); - this.storage4 = new LeaderboardStorage(spleggManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(spleggManager.getConfigManager(), this.file, SpleggMap::new); + this.leaderboardStorage = new LeaderboardStorage(spleggManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(spleggManager.getConfigManager(), this.file, SpleggMap::new); } @Override @@ -34,26 +34,26 @@ public class SpleggStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public SpleggStatisticsRepository e() { + public SpleggStatisticsRepository getStatisticsRepository() { return this.spleggStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunGame.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunGame.java index e6d7b96..083929b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunGame.java @@ -27,19 +27,19 @@ import ro.fr33styler.arcade.api.engine.game.phase.Lifecycle; import ro.fr33styler.arcade.api.engine.text.Context; public class TempleRunGame extends AbstractGame implements GameEventHandler { - private int c; + private int timeLeft; private TempleRunGamer[] gamers; private final ScoreboardTeam scoreboardTeam; - private final ScoreboardTeam scoreboardTeam2; - private final TempleRunMap g; + private final ScoreboardTeam finishedTeam; + private final TempleRunMap map; private final TempleRunManager manager; private final Lifecycle lifecycle = new TempleRunLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); private final Set set = EnumSet.allOf(GameAction.class); - private final Map l = new HashMap<>(); + private final Map spawnedItems = new HashMap<>(); public TempleRunGame(TempleRunManager manager2, TempleRunMap templeRunMap) { - this.g = templeRunMap; + this.map = templeRunMap; this.manager = manager2; this.setPhase(this.lifecycle.getWaiting()); this.scoreboardTeam = this.getScoreboard().createTeam("Playing"); @@ -47,44 +47,44 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { if (!ro.fr33styler.arcade.platform.compat.VersionAdapters.get().isLatestVariant()) { this.scoreboardTeam.setPrefix(ChatColor.RED.toString()); } - this.scoreboardTeam2 = this.getScoreboard().createTeam("Finished"); - this.scoreboardTeam2.setColor(ChatColor.GREEN); + this.finishedTeam = this.getScoreboard().createTeam("Finished"); + this.finishedTeam.setColor(ChatColor.GREEN); if (!ro.fr33styler.arcade.platform.compat.VersionAdapters.get().isLatestVariant()) { - this.scoreboardTeam2.setPrefix(ChatColor.GREEN.toString()); + this.finishedTeam.setPrefix(ChatColor.GREEN.toString()); } } public TempleRunMap getMap() { - return this.g; + return this.map; } public Lifecycle getPhaseLifecycle() { return this.lifecycle; } - public ScoreboardTeam getScoreboardTeam5() { + public ScoreboardTeam getPlayingTeam() { return this.scoreboardTeam; } - public ScoreboardTeam getScoreboardTeam2() { - return this.scoreboardTeam2; + public ScoreboardTeam getFinishedTeam() { + return this.finishedTeam; } public TempleRunMessages getMessages() { return this.manager.getMessages(); } - private TempleRunConfiguration B() { - TempleRunConfiguration templeRunConfiguration = (TempleRunConfiguration)this.getManager().G().get(this.getMap().getId()); - return templeRunConfiguration == null ? this.getManager().getConfiguration7() : templeRunConfiguration; + private TempleRunConfiguration getActiveConfiguration() { + TempleRunConfiguration templeRunConfiguration = (TempleRunConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return templeRunConfiguration == null ? this.getManager().getConfiguration() : templeRunConfiguration; } public TempleRunSettings getSettings() { - return this.B().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public TempleRunRewards t() { - return this.B().getRewards(); + public TempleRunRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public TempleRunManager getManager() { @@ -95,7 +95,7 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { return this.set; } - public TempleRunGamer[] getGamers12() { + public TempleRunGamer[] getStandings() { return this.gamers; } @@ -103,27 +103,27 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { this.gamers = gamers3; } - public Map w() { - return this.l; + public Map getSpawnedItems() { + return this.spawnedItems; } - public int x() { - return this.c; + public int getTimeLeft() { + return this.timeLeft; } - public void a(int index) { - this.c = index; + public void setTimeLeft(int index) { + this.timeLeft = index; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { if (text.equals("time_left")) { - return Strings.a(this.c); + return Strings.formatDuration(this.timeLeft); } if (this.gamers != null) { @@ -132,7 +132,7 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { } if (this.gamers.length > 0 && text.equals("first_position")) { - return this.gamers[0].x(); + return this.gamers[0].getPositionDisplay(); } if (this.gamers.length > 1 && text.equals("second")) { @@ -140,7 +140,7 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { } if (this.gamers.length > 1 && text.equals("second_position")) { - return this.gamers[1].x(); + return this.gamers[1].getPositionDisplay(); } if (this.gamers.length > 2 && text.equals("third")) { @@ -148,7 +148,7 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { } if (this.gamers.length > 2 && text.equals("third_position")) { - return this.gamers[2].x(); + return this.gamers[2].getPositionDisplay(); } } @@ -165,56 +165,56 @@ public class TempleRunGame extends AbstractGame implements GameEventHandler { }; } - public void y() { - if (this.gamers2.a() == 0) { - this.A(); + public void checkEndCondition() { + if (this.gamerSet.getAliveCount() == 0) { + this.finishGame(); } else { int index = 0; - for (TempleRunGamer templeRunGamer : this.gamers2) { - if (templeRunGamer.s()) { + for (TempleRunGamer templeRunGamer : this.gamerSet) { + if (templeRunGamer.isFinished()) { index++; } } - if (this.gamers2.size() > 3 && index == 3) { - this.c = 30; - this.gamers2.a(this.getMessages().getEndingSoon()); + if (this.gamerSet.size() > 3 && index == 3) { + this.timeLeft = 30; + this.gamerSet.broadcast(this.getMessages().getEndingSoon()); } } } - public void z() { + public void sortStandings() { Arrays.sort(this.gamers, (templeRunGamer, templeRunGamer2) -> { - if (templeRunGamer.s() && templeRunGamer2.s()) { - return Integer.compare(templeRunGamer.m(), templeRunGamer2.m()); - } else if (!templeRunGamer.s() && !templeRunGamer2.s()) { - return Double.compare(templeRunGamer2.w(), templeRunGamer.w()); + if (templeRunGamer.isFinished() && templeRunGamer2.isFinished()) { + return Integer.compare(templeRunGamer.getRank(), templeRunGamer2.getRank()); + } else if (!templeRunGamer.isFinished() && !templeRunGamer2.isFinished()) { + return Double.compare(templeRunGamer2.getProgressPercent(), templeRunGamer.getProgressPercent()); } else { - return templeRunGamer.s() ? -1 : 1; + return templeRunGamer.isFinished() ? -1 : 1; } }); } - public void A() { - this.z(); - Context context = Contexts.a(this.manager, this.gamers); + public void finishGame() { + this.sortStandings(); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (TempleRunGamer templeRunGamer : this.gamers2) { + for (TempleRunGamer templeRunGamer : this.gamerSet) { templeRunGamer.sendMessages(this.getMessages().getEndingTop(), context); - templeRunGamer.a(this.getMessages().getSidebarPlaying(), templeRunGamer); - if (!templeRunGamer.getSpectatorOptions().g()) { + templeRunGamer.updateSidebar(this.getMessages().getSidebarPlaying(), templeRunGamer); + if (!templeRunGamer.getSpectatorOptions().isExternal()) { if (this.gamers[0] == templeRunGamer) { - templeRunGamer.a(1); + templeRunGamer.setWins(1); templeRunGamer.sendTitle(this.getMessages().getTitleWon(), "", 0, 80, 0); - if (this.t().isEnabled()) { - templeRunGamer.b(this.t().getWinner()); + if (this.getRewards().isEnabled()) { + templeRunGamer.setRewardCommands(this.getRewards().getWinner()); } } else { - templeRunGamer.b(1); + templeRunGamer.setLoses(1); templeRunGamer.sendTitle(this.getMessages().getTitleLost(), "", 0, 80, 0); - if (this.t().isEnabled()) { - templeRunGamer.b(this.t().getLosers()); + if (this.getRewards().isEnabled()) { + templeRunGamer.setRewardCommands(this.getRewards().getLosers()); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunManager.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunManager.java index 8e24390..75fd5fb 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/TempleRunManager.java @@ -30,12 +30,12 @@ public class TempleRunManager extends AbstractGameManager { private final Command command; private final TempleRunStorage storage; private final TempleRunMessages messages = new TempleRunMessages(); - private final Map f = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final TempleRunConfiguration configuration = new TempleRunConfiguration(); private final TempleRunListener listener = new TempleRunListener(this); - private final Map i = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final TempleRunSessions sessions = new TempleRunSessions(this); - private final Map> k = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", @@ -75,7 +75,7 @@ public class TempleRunManager extends AbstractGameManager { return this.sessions; } - public TempleRunConfiguration getConfiguration7() { + public TempleRunConfiguration getConfiguration() { return this.configuration; } @@ -90,21 +90,21 @@ public class TempleRunManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { TempleRunStatistics templeRunStatistics = new TempleRunStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(templeRunStatistics); - this.f.put(player.getUniqueId(), templeRunStatistics); + this.storage.getStatisticsRepository().loadStatistics(templeRunStatistics); + this.playerStatistics.put(player.getUniqueId(), templeRunStatistics); } public TempleRunStatistics getData(UUID uuid) { - return this.f.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.f.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map G() { - return this.i; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -121,7 +121,7 @@ public class TempleRunManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.k; + return this.leaderboardSources; } @Override @@ -129,16 +129,16 @@ public class TempleRunManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "temple_run"); } - private void H() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); TempleRunConfiguration templeRunConfiguration = new TempleRunConfiguration(); - templeRunConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.i.put("id_1", this.configuration); - Files.a(file, file2 -> { + templeRunConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { TempleRunConfiguration templeRunConfiguration2 = new TempleRunConfiguration(); - templeRunConfiguration2.a(this.getConfigManager(), file2); - this.i.put(file2.getName(), templeRunConfiguration2); + templeRunConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), templeRunConfiguration2); } }); } @@ -146,18 +146,18 @@ public class TempleRunManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.H(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { - this.storage.e().b(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); + this.storage.getStatisticsRepository().createTables(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); this.getConfigManager().tryLoad(this.messages, new File(this.getDataFolder(), "messages.yml")); - this.H(); + this.loadPerGameConfigurations(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/command/TempleRunCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/command/TempleRunCreateCommand.java index c7e9f55..1fb3e5b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/command/TempleRunCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/command/TempleRunCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class TempleRunCreateCommand implements CommandExecutor { - private final TempleRunManager a; + private final TempleRunManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public TempleRunCreateCommand(TempleRunManager templeRunManager) { - this.a = templeRunManager; + this.manager = templeRunManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class TempleRunCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); TempleRunMap templeRunMap = new TempleRunMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class TempleRunCreateCommand implements CommandExecutor { } templeRunMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } templeRunMap.setId(text2); templeRunMap.setMaximumPlayers(index3); - defaultUser.a(new TempleRunSetup(defaultUser, templeRunMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new TempleRunSetup(defaultUser, templeRunMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/TempleRunConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/TempleRunConfiguration.java index 88a580e..91d83d5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/TempleRunConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/TempleRunConfiguration.java @@ -9,7 +9,7 @@ public class TempleRunConfiguration { private final TempleRunRewards rewards = new TempleRunRewards(); private final TempleRunSettings settings = new TempleRunSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/message/TempleRunMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/message/TempleRunMessages.java index 79cb54c..98cd181 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/message/TempleRunMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/config/message/TempleRunMessages.java @@ -12,37 +12,37 @@ public class TempleRunMessages extends BaseGameMessages { @Setting("display-name") private String displayName = "Temple Run"; @Setting("title-won") - private String titleWon = Strings.a("&aYOU WON!"); + private String titleWon = Strings.colorize("&aYOU WON!"); @Setting("title-lost") - private String titleLost = Strings.a("&cYOU LOST!"); + private String titleLost = Strings.colorize("&cYOU LOST!"); @Setting("player-finished") - private Text playerFinished = TextParser.a("&7%player% &ehas finished! &a%time%"); + private Text playerFinished = TextParser.parse("&7%player% &ehas finished! &a%time%"); @Setting("ending-soon") - private String endingSoon = Strings.a("&eThe game has ended, You have 30 seconds to finish!"); + private String endingSoon = Strings.colorize("&eThe game has ended, You have 30 seconds to finish!"); @Setting("checkpointReached") - private String checkpointreached = Strings.a("&eThe &ccheckpoint&e has been reached!"); + private String checkpointreached = Strings.colorize("&eThe &ccheckpoint&e has been reached!"); @Setting("power-up-activated") - private Text powerUpActivated = TextParser.a("&eThe powerup &c%power_up% &ehas been activated."); + private Text powerUpActivated = TextParser.parse("&eThe powerup &c%power_up% &ehas been activated."); @Setting("power-up-coin-booster") - private String powerUpCoinBooster = Strings.a("Coin Booster"); + private String powerUpCoinBooster = Strings.colorize("Coin Booster"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-attempts") - private String statisticAttempts = Strings.a("Attempts"); + private String statisticAttempts = Strings.colorize("Attempts"); @Setting("statistic-coins-collecteed") - private String statisticCoinsCollecteed = Strings.a("Coins Collected"); + private String statisticCoinsCollecteed = Strings.colorize("Coins Collected"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{"&a%line%", " &lTemple Run", " ", " &eCollect coins while you run for your life.", " &eFirst to reach the end wins!", "&a%line%"} ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lTemple Run", @@ -55,7 +55,7 @@ public class TempleRunMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7%month%/%day%/%year%", " ", @@ -75,7 +75,7 @@ public class TempleRunMessages extends BaseGameMessages { ); public TempleRunMessages() { - this.statisticsView = TextParser.a( + this.statisticsView = TextParser.parseAll( new String[]{ " ", " &l%display_name% Statistics", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/lifecycle/TempleRunLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/lifecycle/TempleRunLifecycle.java index 4c91398..fa98bca 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/lifecycle/TempleRunLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/lifecycle/TempleRunLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class TempleRunLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public TempleRunLifecycle(TempleRunGame templeRunGame) { this.phase = new WaitingPhase(templeRunGame); - this.phase2 = new TempleRunPlayingPhase(templeRunGame); - this.phase3 = new EndingPhase(templeRunGame); - this.phase4 = new ResettingPhase(templeRunGame); + this.playingPhase = new TempleRunPlayingPhase(templeRunGame); + this.endingPhase = new EndingPhase(templeRunGame); + this.resettingPhase = new ResettingPhase(templeRunGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class TempleRunLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/listener/TempleRunListener.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/listener/TempleRunListener.java index f2fb85c..ca259a3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/listener/TempleRunListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/listener/TempleRunListener.java @@ -27,19 +27,19 @@ import ro.fr33styler.arcade.platform.compat.ColoredBlockType; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class TempleRunListener extends GameListener { - private final TempleRunManager manager2; + private final TempleRunManager templeRunManager; public TempleRunListener(TempleRunManager manager22) { super(manager22); - this.manager2 = manager22; + this.templeRunManager = manager22; VersionAdapters.get().registerItemPickupListener(manager22.getEngine().getPlugin(), this::onItemPickup); } @EventHandler - public void a(ItemMergeEvent event) { - for (TempleRunGame templeRunGame : this.manager2.getSessions().d().values()) { + public void onItemMerge(ItemMergeEvent event) { + for (TempleRunGame templeRunGame : this.templeRunManager.getSessions().getGames().values()) { Item item = event.getEntity(); - if (templeRunGame.getMap().getPlayZone().a(item.getLocation()) && templeRunGame.w().containsKey(item.getUniqueId())) { + if (templeRunGame.getMap().getPlayZone().contains(item.getLocation()) && templeRunGame.getSpawnedItems().containsKey(item.getUniqueId())) { event.setCancelled(true); break; } @@ -47,10 +47,10 @@ public class TempleRunListener extends GameListener { } @EventHandler - public void a(ItemDespawnEvent event) { - for (TempleRunGame templeRunGame : this.manager2.getSessions().d().values()) { + public void onItemDespawn(ItemDespawnEvent event) { + for (TempleRunGame templeRunGame : this.templeRunManager.getSessions().getGames().values()) { Item item = event.getEntity(); - if (templeRunGame.getMap().getPlayZone().a(item.getLocation()) && templeRunGame.w().containsKey(item.getUniqueId())) { + if (templeRunGame.getMap().getPlayZone().contains(item.getLocation()) && templeRunGame.getSpawnedItems().containsKey(item.getUniqueId())) { event.setCancelled(true); break; } @@ -58,88 +58,88 @@ public class TempleRunListener extends GameListener { } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); Location location = event.getTo(); - TempleRunGamer templeRunGamer = this.a(player, TempleRunGamer.class); - if (templeRunGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + TempleRunGamer templeRunGamer = this.getActiveGamer(player, TempleRunGamer.class); + if (templeRunGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { TempleRunGame templeRunGame = templeRunGamer.getGame(); - if (templeRunGamer.f()) { - if (!templeRunGame.getMap().getPlayZone().a(location)) { + if (templeRunGamer.isSpectator()) { + if (!templeRunGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - templeRunGamer.a(templeRunGame.getMap().getSpectator()); + templeRunGamer.teleport(templeRunGame.getMap().getSpectator()); } } else { - Location location2 = templeRunGame.getMap().getFinishZone().b(); - templeRunGamer.a(location.distanceSquared(templeRunGame.getMap().getSpawn()) / templeRunGame.getMap().getSpawn().distanceSquared(location2) * 100.0); - if (!templeRunGame.getMap().getPlayZone().a(location) || location.getBlock().isLiquid()) { - event.setTo(templeRunGamer.getLocation7()); - if (!templeRunGamer.s()) { - templeRunGamer.f(templeRunGamer.q() + 1); + Location location2 = templeRunGame.getMap().getFinishZone().getMin(); + templeRunGamer.setProgressPercent(location.distanceSquared(templeRunGame.getMap().getSpawn()) / templeRunGame.getMap().getSpawn().distanceSquared(location2) * 100.0); + if (!templeRunGame.getMap().getPlayZone().contains(location) || location.getBlock().isLiquid()) { + event.setTo(templeRunGamer.getCheckpoint()); + if (!templeRunGamer.isFinished()) { + templeRunGamer.setAttempts(templeRunGamer.getAttempts() + 1); templeRunGamer.playSound(ArcadeSound.NOTE_BASS, 1.0F, 1.0F); - templeRunGamer.d(templeRunGamer.n() - templeRunGamer.o()); - templeRunGamer.u().removeAll(templeRunGamer.v()); - templeRunGamer.v().clear(); - templeRunGamer.e(0); - templeRunGamer.a((ro.fr33styler.arcade.game.templerun.powerup.TempleRunPowerup)null); + templeRunGamer.setCoinsCollected(templeRunGamer.getCoinsCollected() - templeRunGamer.getCheckpointCoins()); + templeRunGamer.getCollectedItems().removeAll(templeRunGamer.getCheckpointCollectedItems()); + templeRunGamer.getCheckpointCollectedItems().clear(); + templeRunGamer.setCheckpointCoins(0); + templeRunGamer.setPowerup((ro.fr33styler.arcade.game.templerun.powerup.TempleRunPowerup)null); } - } else if (!templeRunGamer.s() && templeRunGame.getMap().getFinishZone().a(location)) { - Fireworks.a(templeRunGame.getEngine().getPlatform(), templeRunGamer.toPlayer().getEyeLocation()); - templeRunGamer.c(true); - templeRunGamer.b(true); + } else if (!templeRunGamer.isFinished() && templeRunGame.getMap().getFinishZone().contains(location)) { + Fireworks.detonateRandom(templeRunGame.getEngine().getPlatform(), templeRunGamer.toPlayer().getEyeLocation()); + templeRunGamer.setFinished(true); + templeRunGamer.setSpectator(true); templeRunGame.getSpectatorTeam().addEntry(templeRunGamer.getName()); - templeRunGamer.setLocation7(location); - templeRunGamer.e(0); - templeRunGamer.u().clear(); - templeRunGamer.a(100.0); - templeRunGamer.v().clear(); - templeRunGame.getScoreboardTeam5().removeEntry(player.getName()); - templeRunGame.getScoreboardTeam2().addEntry(player.getName()); - String text = Strings.a(templeRunGame.getSettings().getTimeDuration() - templeRunGame.x()); - Context context = Contexts.a(templeRunGamer, text2 -> text2.equals("time") ? text : null); + templeRunGamer.setCheckpoint(location); + templeRunGamer.setCheckpointCoins(0); + templeRunGamer.getCollectedItems().clear(); + templeRunGamer.setProgressPercent(100.0); + templeRunGamer.getCheckpointCollectedItems().clear(); + templeRunGame.getPlayingTeam().removeEntry(player.getName()); + templeRunGame.getFinishedTeam().addEntry(player.getName()); + String text = Strings.formatDuration(templeRunGame.getSettings().getTimeDuration() - templeRunGame.getTimeLeft()); + Context context = Contexts.withVariables(templeRunGamer, text2 -> text2.equals("time") ? text : null); for (TempleRunGamer templeRunGamer2 : templeRunGame.getGamers()) { - if (!templeRunGamer2.s() && !templeRunGamer2.f()) { - templeRunGamer2.c(templeRunGamer2.m() + 1); + if (!templeRunGamer2.isFinished() && !templeRunGamer2.isSpectator()) { + templeRunGamer2.setRank(templeRunGamer2.getRank() + 1); } templeRunGamer2.sendMessage(templeRunGame.getMessages().getPlayerFinished(), context); } - templeRunGame.y(); + templeRunGame.checkEndCondition(); } } } } private boolean onItemPickup(Player picker, Item item) { - TempleRunGamer templeRunGamer = this.a(picker, TempleRunGamer.class); - if (templeRunGamer != null && !templeRunGamer.f()) { + TempleRunGamer templeRunGamer = this.getActiveGamer(picker, TempleRunGamer.class); + if (templeRunGamer != null && !templeRunGamer.isSpectator()) { TempleRunGame templeRunGame = templeRunGamer.getGame(); - if (templeRunGame.w().containsKey(item.getUniqueId())) { - if (!templeRunGamer.s() && templeRunGamer.u().add(item.getUniqueId())) { + if (templeRunGame.getSpawnedItems().containsKey(item.getUniqueId())) { + if (!templeRunGamer.isFinished() && templeRunGamer.getCollectedItems().add(item.getUniqueId())) { Player player = templeRunGamer.toPlayer(); - templeRunGamer.v().add(item.getUniqueId()); - if (templeRunGamer.v().size() >= templeRunGame.getSettings().getCheckpointAt()) { - templeRunGamer.e(0); - templeRunGamer.v().clear(); - templeRunGamer.setLocation7(player.getLocation()); + templeRunGamer.getCheckpointCollectedItems().add(item.getUniqueId()); + if (templeRunGamer.getCheckpointCollectedItems().size() >= templeRunGame.getSettings().getCheckpointAt()) { + templeRunGamer.setCheckpointCoins(0); + templeRunGamer.getCheckpointCollectedItems().clear(); + templeRunGamer.setCheckpoint(player.getLocation()); templeRunGamer.sendMessage(templeRunGame.getMessages().getCheckpointreached()); } ItemStack item2 = item.getItemStack(); if (item2.getType() == Material.GOLD_NUGGET) { if (templeRunGamer.getTempleRunPowerup() instanceof TempleRunCoinBooster) { - templeRunGamer.d(templeRunGamer.n() + 2); - templeRunGamer.e(templeRunGamer.o() + 2); + templeRunGamer.setCoinsCollected(templeRunGamer.getCoinsCollected() + 2); + templeRunGamer.setCheckpointCoins(templeRunGamer.getCheckpointCoins() + 2); } else { - templeRunGamer.d(templeRunGamer.n() + 1); - templeRunGamer.e(templeRunGamer.o() + 1); + templeRunGamer.setCoinsCollected(templeRunGamer.getCoinsCollected() + 1); + templeRunGamer.setCheckpointCoins(templeRunGamer.getCheckpointCoins() + 1); } templeRunGamer.playSound(ArcadeSound.ARROW_HIT_PLAYER, 0.7F, 1.0F); } else if (templeRunGamer.getTempleRunPowerup() == null && VersionAdapters.get().isColoredItemStack(item2, ColoredBlockType.WOOL, ArcadeColor.RED)) { - templeRunGamer.a(new TempleRunCoinBooster(templeRunGame.getSettings().getCoinBoosterDuration())); + templeRunGamer.setPowerup(new TempleRunCoinBooster(templeRunGame.getSettings().getCoinBoosterDuration())); } } return true; diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/phase/TempleRunPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/phase/TempleRunPlayingPhase.java index 2f4ec62..034377c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/phase/TempleRunPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/phase/TempleRunPlayingPhase.java @@ -26,41 +26,41 @@ public class TempleRunPlayingPhase implements Phase { } public void start() { - this.game.a(this.game.getSettings().getTimeDuration()); - this.game.setGamers((TempleRunGamer[])this.game.getGamers().a(new TempleRunGamer[this.game.getGamers().size()])); + this.game.setTimeLeft(this.game.getSettings().getTimeDuration()); + this.game.setGamers((TempleRunGamer[])this.game.getGamers().toArray(new TempleRunGamer[this.game.getGamers().size()])); for (TempleRunGamer templeRunGamer : this.game.getGamers()) { - templeRunGamer.setLocation7(this.game.getMap().getSpawn()); - templeRunGamer.a(this.game.getMap().getSpawn()); - this.game.getScoreboardTeam5().addEntry(templeRunGamer.getName()); + templeRunGamer.setCheckpoint(this.game.getMap().getSpawn()); + templeRunGamer.teleport(this.game.getMap().getSpawn()); + this.game.getPlayingTeam().addEntry(templeRunGamer.getName()); templeRunGamer.playSound(ArcadeSound.NOTE_PLING, 1.0F, 2.0F); } - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); - int index = Randoms.a().nextInt(10, 20); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().loadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + int index = Randoms.current().nextInt(10, 20); for (Location location : this.game.getMap().getCoinLocations()) { ItemStack item = new ItemStack(Material.GOLD_NUGGET); if (index > 0) { index--; } else { - index = Randoms.a().nextInt(10, 20); - item = VersionAdapters.get().createColoredItemStack(ColoredBlockType.WOOL, ((TempleRunBooster)Randoms.a(TempleRunBooster.values())).getColor(), 1); + index = Randoms.current().nextInt(10, 20); + item = VersionAdapters.get().createColoredItemStack(ColoredBlockType.WOOL, ((TempleRunBooster)Randoms.pickRandom(TempleRunBooster.values())).getColor(), 1); } Item item2 = location.getWorld().dropItem(location, item); item2.setVelocity(new Vector(0, 0, 0)); - this.game.w().put(item2.getUniqueId(), item2); + this.game.getSpawnedItems().put(item2.getUniqueId(), item2); } } public void stop() { - this.game.w().values().forEach(Entity::remove); - this.game.w().clear(); - this.game.getScoreboardTeam5().clearEntries(); - this.game.getScoreboardTeam2().clearEntries(); + this.game.getSpawnedItems().values().forEach(Entity::remove); + this.game.getSpawnedItems().clear(); + this.game.getPlayingTeam().clearEntries(); + this.game.getFinishedTeam().clearEntries(); this.game.setGamers((ro.fr33styler.arcade.game.templerun.player.TempleRunGamer[])null); - this.game.getMap().getPlayZone().b(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); + this.game.getMap().getPlayZone().forEachChunk(chunk -> VersionAdapters.get().unloadArenaChunk(this.game.getManager().getEngine().getPlugin(), chunk)); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -74,24 +74,24 @@ public class TempleRunPlayingPhase implements Phase { public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.game.x() > 0) { - this.game.a(this.game.x() - 1); - this.game.z(); + if (this.game.getTimeLeft() > 0) { + this.game.setTimeLeft(this.game.getTimeLeft() - 1); + this.game.sortStandings(); for (TempleRunGamer templeRunGamer : this.game.getGamers()) { TempleRunPowerup templeRunPowerup = templeRunGamer.getTempleRunPowerup(); if (templeRunPowerup != null) { - if (templeRunPowerup.b() > 0) { - templeRunPowerup.a(templeRunPowerup.b() - 1); + if (templeRunPowerup.getRemainingTicks() > 0) { + templeRunPowerup.setRemainingTicks(templeRunPowerup.getRemainingTicks() - 1); } else { - templeRunGamer.a((ro.fr33styler.arcade.game.templerun.powerup.TempleRunPowerup)null); + templeRunGamer.setPowerup((ro.fr33styler.arcade.game.templerun.powerup.TempleRunPowerup)null); } } - templeRunGamer.a(this.game.getMessages().getSidebarPlaying(), templeRunGamer); + templeRunGamer.updateSidebar(this.game.getMessages().getSidebarPlaying(), templeRunGamer); } } else { - this.game.A(); + this.game.finishGame(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/player/TempleRunGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/player/TempleRunGamer.java index b19f21b..49a628a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/player/TempleRunGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/player/TempleRunGamer.java @@ -15,25 +15,25 @@ import org.bukkit.Location; public class TempleRunGamer extends BaseGamer { - private int b; + private int coinsCollected; - private int c; + private int checkpointCoins; - private int d; + private int attempts; - private int e = 1; + private int rank = 1; private TempleRunPowerup templeRunPowerup; - private boolean g; + private boolean finished; private Location location; - private double i; + private double progressPercent; - private final Set j = new HashSet<>(); + private final Set collectedItems = new HashSet<>(); - private final Set k = new HashSet<>(); + private final Set checkpointCollectedItems = new HashSet<>(); private final TempleRunGame game; @@ -46,104 +46,104 @@ public class TempleRunGamer extends BaseGamer { return this.game; } - public int m() { - return this.e; + public int getRank() { + return this.rank; } - public void c(int index) { - this.e = index; + public void setRank(int index) { + this.rank = index; } - public int n() { - return this.b; + public int getCoinsCollected() { + return this.coinsCollected; } - public void d(int index) { - this.b = index; + public void setCoinsCollected(int index) { + this.coinsCollected = index; } - public int o() { - return this.c; + public int getCheckpointCoins() { + return this.checkpointCoins; } - public void e(int index) { - this.c = index; + public void setCheckpointCoins(int index) { + this.checkpointCoins = index; } - public int q() { - return this.d; + public int getAttempts() { + return this.attempts; } - public void f(int index) { - this.d = index; + public void setAttempts(int index) { + this.attempts = index; } - public Location getLocation7() { + public Location getCheckpoint() { return this.location; } - public void setLocation7(Location location2) { + public void setCheckpoint(Location location2) { this.location = location2; } - public boolean s() { - return this.g; + public boolean isFinished() { + return this.finished; } - public void c(boolean flag) { - this.g = flag; + public void setFinished(boolean flag) { + this.finished = flag; } public TempleRunPowerup getTempleRunPowerup() { return this.templeRunPowerup; } - public void a(TempleRunPowerup templeRunPowerup2) { + public void setPowerup(TempleRunPowerup templeRunPowerup2) { this.templeRunPowerup = templeRunPowerup2; if (templeRunPowerup2 != null) { this.playSound(ArcadeSound.PLAYER_LEVELUP, 1.0F, 1.0F); - this.a(this.game.getMessages().getPowerUpActivated()); + this.sendMessage(this.game.getMessages().getPowerUpActivated()); } } - public Set u() { - return this.j; + public Set getCollectedItems() { + return this.collectedItems; } - public Set v() { - return this.k; + public Set getCheckpointCollectedItems() { + return this.checkpointCollectedItems; } - public double w() { - return this.i; + public double getProgressPercent() { + return this.progressPercent; } - public void a(double doubleVal) { - this.i = doubleVal; + public void setProgressPercent(double doubleVal) { + this.progressPercent = doubleVal; } - public String x() { - return this.g ? String.valueOf(this.e) : Strings.a(this.w(), 1) + "%"; + public String getPositionDisplay() { + return this.finished ? String.valueOf(this.rank) : Strings.formatFixedDecimal(this.getProgressPercent(), 1) + "%"; } - private void y() { + private void saveStatistics() { TempleRunStatistics templeRunStatistics = this.game.getManager().getData(this.getUUID()); - if (templeRunStatistics.a()) { - templeRunStatistics.a(templeRunStatistics.getWins() + this.getWins()); + if (templeRunStatistics.isLoaded()) { + templeRunStatistics.setWins(templeRunStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - templeRunStatistics.d(templeRunStatistics.getCurrentWinStreak() + 1); + templeRunStatistics.setCurrentWinStreak(templeRunStatistics.getCurrentWinStreak() + 1); if (templeRunStatistics.getWinStreak() < templeRunStatistics.getCurrentWinStreak()) { - templeRunStatistics.c(templeRunStatistics.getCurrentWinStreak()); + templeRunStatistics.setWinStreak(templeRunStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - templeRunStatistics.d(0); + templeRunStatistics.setCurrentWinStreak(0); } - templeRunStatistics.b(templeRunStatistics.getLoses() + this.getLoses()); - templeRunStatistics.e(templeRunStatistics.d() + this.d); - templeRunStatistics.f(templeRunStatistics.e() + this.b); - this.b(templeRunStatistics.getMap()); - this.game.getManager().getStorage().e().b(templeRunStatistics); - this.game.getManager().getStorage().e().a(this); + templeRunStatistics.setLoses(templeRunStatistics.getLoses() + this.getLoses()); + templeRunStatistics.setAttempts(templeRunStatistics.getAttempts() + this.attempts); + templeRunStatistics.setCoinsCollected(templeRunStatistics.getCoinsCollected() + this.coinsCollected); + this.saveProperties(templeRunStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(templeRunStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @@ -151,15 +151,15 @@ public class TempleRunGamer extends BaseGamer { public String getVariable(String text) { return switch(text) { case "coins_collected" -> - String.valueOf(this.b); + String.valueOf(this.coinsCollected); case "attempts" -> - String.valueOf(this.d); + String.valueOf(this.attempts); case "power_up" -> - this.templeRunPowerup == null ? null : this.templeRunPowerup.a(this.game.getMessages()); + this.templeRunPowerup == null ? null : this.templeRunPowerup.getDisplayName(this.game.getMessages()); case "position" -> - this.x(); + this.getPositionDisplay(); case "power_up_percentage_bar" -> - this.templeRunPowerup == null ? null : Strings.a('▊', 10, this.templeRunPowerup.a()); + this.templeRunPowerup == null ? null : Strings.formatProgressBar('▊', 10, this.templeRunPowerup.getProgressRatio()); default -> super.getVariable(text); }; @@ -168,7 +168,7 @@ public class TempleRunGamer extends BaseGamer { @Override public Boolean getCondition(String text) { if (text.equals("IN_TOP")) { - TempleRunGamer[] templeRunGamers = this.game.getGamers12(); + TempleRunGamer[] templeRunGamers = this.game.getStandings(); if (templeRunGamers == null) { return null; } @@ -188,10 +188,10 @@ public class TempleRunGamer extends BaseGamer { @Override public void leave() { - this.y(); - this.game.getGamers().b(this); + this.saveStatistics(); + this.game.getGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.y(); + this.game.checkEndCondition(); } super.leave(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunCoinBooster.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunCoinBooster.java index 0bad2fc..d1943cd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunCoinBooster.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunCoinBooster.java @@ -3,27 +3,27 @@ package ro.fr33styler.arcade.game.templerun.powerup; import ro.fr33styler.arcade.game.templerun.config.message.TempleRunMessages; public class TempleRunCoinBooster implements TempleRunPowerup { - private int a; - private final double b; + private int remainingTicks; + private final double maxTicks; public TempleRunCoinBooster(int index) { - this.a = index; - this.b = index; + this.remainingTicks = index; + this.maxTicks = index; } - public String a(TempleRunMessages templeRunMessages) { + public String getDisplayName(TempleRunMessages templeRunMessages) { return templeRunMessages.getPowerUpCoinBooster(); } - public double a() { - return this.a / this.b; + public double getProgressRatio() { + return this.remainingTicks / this.maxTicks; } - public int b() { - return this.a; + public int getRemainingTicks() { + return this.remainingTicks; } - public void a(int index) { - this.a = index; + public void setRemainingTicks(int index) { + this.remainingTicks = index; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunPowerup.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunPowerup.java index 098bda2..d572349 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunPowerup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/powerup/TempleRunPowerup.java @@ -3,11 +3,11 @@ package ro.fr33styler.arcade.game.templerun.powerup; import ro.fr33styler.arcade.game.templerun.config.message.TempleRunMessages; public interface TempleRunPowerup { - String a(TempleRunMessages var1); + String getDisplayName(TempleRunMessages var1); - double a(); + double getProgressRatio(); - int b(); + int getRemainingTicks(); - void a(int var1); + void setRemainingTicks(int var1); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSession.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSession.java index 10e0aba..308048c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSession.java @@ -22,11 +22,11 @@ public class TempleRunSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TempleRunGamer templeRunGamer = new TempleRunGamer(this.game, defaultUser); - this.game.getGamers().a(templeRunGamer); - templeRunGamer.a(this.game.getMessages().getStart()); - templeRunGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(templeRunGamer); + templeRunGamer.sendMessages(this.game.getMessages().getStart()); + templeRunGamer.teleport(this.game.getMap().getLobby()); return templeRunGamer; }); } @@ -40,7 +40,7 @@ public class TempleRunSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof TempleRunGamer var2) { TempleRunGame templeRunGame = var2.getGame(); - if (templeRunGame.getPhase() != templeRunGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (templeRunGame.getPhase() != templeRunGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, templeRunGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class TempleRunSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TempleRunGamer templeRunGamer = new TempleRunGamer(this.game, defaultUser); - this.game.getGamers().a(templeRunGamer); - templeRunGamer.a(this.game.getMap().getSpectator()); - templeRunGamer.b(true); - templeRunGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(templeRunGamer); + templeRunGamer.teleport(this.game.getMap().getSpectator()); + templeRunGamer.setSpectator(true); + templeRunGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(templeRunGamer.getName()); return templeRunGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSessions.java index c13d504..8f5ec67 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/session/TempleRunSessions.java @@ -9,44 +9,44 @@ import ro.fr33styler.arcade.game.templerun.map.TempleRunMap; import org.bukkit.World; public class TempleRunSessions extends BaseSessions { - private final TempleRunManager a; + private final TempleRunManager manager; public TempleRunSessions(TempleRunManager templeRunManager) { super(templeRunManager); - this.a = templeRunManager; + this.manager = templeRunManager; } public TempleRunManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(templeRunMap -> this.registerGame(new TempleRunGame(this.a, templeRunMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(templeRunMap -> this.registerGame(new TempleRunGame(this.manager, templeRunMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected TempleRunMap h(String text) { + protected TempleRunMap createMap(String text) { TempleRunMap templeRunMap = new TempleRunMap(); templeRunMap.setId(text); return templeRunMap; } - protected TempleRunGame a(TempleRunMap templeRunMap) { - return new TempleRunGame(this.a, templeRunMap); + protected TempleRunGame createGame(TempleRunMap templeRunMap) { + return new TempleRunGame(this.manager, templeRunMap); } public TempleRunSession createSession(TempleRunGame templeRunGame) { return templeRunGame == null ? null : new TempleRunSession(templeRunGame); } - protected void a(TempleRunMap templeRunMap, World world, TempleRunMap templeRunMap2) { - super.a(templeRunMap, world, templeRunMap2); - templeRunMap2.setSpawn(Locations.a(world, templeRunMap.getSpawn())); - templeRunMap2.setSpectator(Locations.a(world, templeRunMap.getSpectator())); - templeRunMap2.setPlayZone(templeRunMap.getPlayZone().a(world)); - templeRunMap2.setFinishZone(templeRunMap.getFinishZone().a(world)); + protected void copyMap(TempleRunMap templeRunMap, World world, TempleRunMap templeRunMap2) { + super.copyMap(templeRunMap, world, templeRunMap2); + templeRunMap2.setSpawn(Locations.withWorld(world, templeRunMap.getSpawn())); + templeRunMap2.setSpectator(Locations.withWorld(world, templeRunMap.getSpectator())); + templeRunMap2.setPlayZone(templeRunMap.getPlayZone().withWorld(world)); + templeRunMap2.setFinishZone(templeRunMap.getFinishZone().withWorld(world)); templeRunMap2.getCoinLocations().clear(); - templeRunMap2.getCoinLocations().addAll(Locations.a(world, templeRunMap.getCoinLocations())); + templeRunMap2.getCoinLocations().addAll(Locations.withWorld(world, templeRunMap.getCoinLocations())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/TempleRunSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/TempleRunSetup.java index 94dcce7..0c01545 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/TempleRunSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/TempleRunSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class TempleRunSetup extends ArenaSetup { private final TempleRunMap map; - private final TempleRunManager d; + private final TempleRunManager manager; private final SetupTarget setupTarget; public TempleRunSetup(DefaultUser defaultUser, TempleRunMap map2, TempleRunManager templeRunManager, SetupTarget setupTarget2) { super(defaultUser, templeRunManager.getName()); - this.d = templeRunManager; + this.manager = templeRunManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new TempleRunSetArenaNameStep(this); } - public TempleRunMap getMap39() { + public TempleRunMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class TempleRunSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new TempleRunGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new TempleRunGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunAddCoinSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunAddCoinSpawnStep.java index dfceb56..64a2106 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunAddCoinSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunAddCoinSpawnStep.java @@ -16,7 +16,7 @@ public class TempleRunAddCoinSpawnStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the coins"); defaultUser.sendMessage("§e spawn at. If you made a mistake click the"); @@ -24,21 +24,21 @@ public class TempleRunAddCoinSpawnStep implements ClickSetupStep { defaultUser.sendMessage("§e yellow dye to continue."); } - public void a() { + public void configureHotbar() { Player player = this.templeRunSetup.getUser().toPlayer(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.templeRunSetup.getMap39().getPlayZone().a(location)) { - this.templeRunSetup.getMap39().getCoinLocations().add(location); - player.sendMessage("§eDrop location added. §8(§b" + this.templeRunSetup.getMap39().getCoinLocations().size() + "§8)"); + if (this.templeRunSetup.getMap().getPlayZone().contains(location)) { + this.templeRunSetup.getMap().getCoinLocations().add(location); + player.sendMessage("§eDrop location added. §8(§b" + this.templeRunSetup.getMap().getCoinLocations().size() + "§8)"); } else { player.sendMessage("§cMust be inside the Play Zone!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lAdd coin").build()); - this.templeRunSetup.getHotbar().a(1, () -> { - this.templeRunSetup.getMap39().getCoinLocations().clear(); + this.templeRunSetup.getHotbar().setSlot(1, () -> { + this.templeRunSetup.getMap().getCoinLocations().clear(); player.sendMessage("§eCoin spawns have been reset!"); }, new ItemBuilder(ArcadeMaterial.RED_DYE).setDisplayName("§c§lReset coin spawns").build()); - this.templeRunSetup.getHotbar().a(2, () -> this.templeRunSetup.a(new TempleRunSetFinishZoneStep(this.templeRunSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); + this.templeRunSetup.getHotbar().setSlot(2, () -> this.templeRunSetup.advanceStep(new TempleRunSetFinishZoneStep(this.templeRunSetup)), new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§e§lGo to the next step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetArenaNameStep.java index e741128..9e71f78 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetArenaNameStep.java @@ -10,12 +10,12 @@ public class TempleRunSetArenaNameStep implements ChatSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { this.templeRunSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.templeRunSetup.getMap39().setName(text); - this.templeRunSetup.a(new TempleRunSetLobbySpawnStep(this.templeRunSetup)); + public void onChatInput(String text) { + this.templeRunSetup.getMap().setName(text); + this.templeRunSetup.advanceStep(new TempleRunSetLobbySpawnStep(this.templeRunSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetFinishZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetFinishZoneStep.java index 0b6947b..178cfd6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetFinishZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetFinishZoneStep.java @@ -18,31 +18,31 @@ public class TempleRunSetFinishZoneStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the finish zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.templeRunSetup.getUser(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.templeRunSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.templeRunSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); Cuboid cuboid = new Cuboid(block, block2); - if (this.templeRunSetup.getMap39().getPlayZone().a(cuboid)) { - this.templeRunSetup.getMap39().setFinishZone(cuboid); - this.templeRunSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.templeRunSetup.getMap().getPlayZone().contains(cuboid)) { + this.templeRunSetup.getMap().setFinishZone(cuboid); + this.templeRunSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { defaultUser.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbyRemovalRegionStep.java index ad161df..0691d30 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class TempleRunSetLobbyRemovalRegionStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class TempleRunSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.templeRunSetup.getUser(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.templeRunSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.templeRunSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.templeRunSetup.getMap39().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.templeRunSetup.a(new TempleRunSetPlayZoneStep(this.templeRunSetup)); + this.templeRunSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.templeRunSetup.advanceStep(new TempleRunSetPlayZoneStep(this.templeRunSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.templeRunSetup.getHotbar().a(2, () -> { - this.templeRunSetup.getMap39().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.templeRunSetup.a(new TempleRunSetPlayZoneStep(this.templeRunSetup)); + this.templeRunSetup.getHotbar().setSlot(2, () -> { + this.templeRunSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.templeRunSetup.advanceStep(new TempleRunSetPlayZoneStep(this.templeRunSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbySpawnStep.java index f846cb5..d9ad444 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class TempleRunSetLobbySpawnStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.templeRunSetup.getUser().toPlayer(); - this.templeRunSetup.getHotbar().a(0, () -> { - this.templeRunSetup.getMap39().setLobby(player.getLocation()); - this.templeRunSetup.a(new TempleRunSetLobbyRemovalRegionStep(this.templeRunSetup)); + this.templeRunSetup.getHotbar().setSlot(0, () -> { + this.templeRunSetup.getMap().setLobby(player.getLocation()); + this.templeRunSetup.advanceStep(new TempleRunSetLobbyRemovalRegionStep(this.templeRunSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayZoneStep.java index 7c0cb28..1c3f23a 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class TempleRunSetPlayZoneStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.templeRunSetup.getUser(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.templeRunSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.templeRunSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.templeRunSetup.getMap39().setPlayZone(new Cuboid(block, block2)); - this.templeRunSetup.a(new TempleRunSetSpectatorSpawnStep(this.templeRunSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.templeRunSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.templeRunSetup.advanceStep(new TempleRunSetSpectatorSpawnStep(this.templeRunSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayerSpawnStep.java index f1e434c..34aeac6 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetPlayerSpawnStep.java @@ -16,19 +16,19 @@ public class TempleRunSetPlayerSpawnStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at."); } - public void a() { + public void configureHotbar() { Player player = this.templeRunSetup.getUser().toPlayer(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.templeRunSetup.getMap39().getPlayZone().a(location)) { - this.templeRunSetup.getMap39().setSpawn(location); - this.templeRunSetup.a(new TempleRunAddCoinSpawnStep(this.templeRunSetup)); + if (this.templeRunSetup.getMap().getPlayZone().contains(location)) { + this.templeRunSetup.getMap().setSpawn(location); + this.templeRunSetup.advanceStep(new TempleRunAddCoinSpawnStep(this.templeRunSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetSpectatorSpawnStep.java index 3b628e2..4c510bd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/setup/step/TempleRunSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class TempleRunSetSpectatorSpawnStep implements ClickSetupStep { this.templeRunSetup = templeRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.templeRunSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.templeRunSetup.getUser().toPlayer(); - this.templeRunSetup.getHotbar().a(0, () -> { + this.templeRunSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.templeRunSetup.getMap39().getPlayZone().a(location)) { - this.templeRunSetup.getMap39().setSpectator(location); - this.templeRunSetup.a(new TempleRunSetPlayerSpawnStep(this.templeRunSetup)); + if (this.templeRunSetup.getMap().getPlayZone().contains(location)) { + this.templeRunSetup.getMap().setSpectator(location); + this.templeRunSetup.advanceStep(new TempleRunSetPlayerSpawnStep(this.templeRunSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/TempleRunStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/TempleRunStatistics.java index ca81dd2..a85207b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/TempleRunStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/TempleRunStatistics.java @@ -6,44 +6,44 @@ import ro.fr33styler.arcade.game.templerun.TempleRunManager; import java.util.UUID; public class TempleRunStatistics extends BaseGameStatistics { - private int b; - private int c; + private int attempts; + private int coinsCollected; public TempleRunStatistics(TempleRunManager templeRunManager, UUID uuid, String text) { super(templeRunManager, uuid, text); } - public int d() { - return this.b; + public int getAttempts() { + return this.attempts; } - public void e(int index) { - this.b = index; + public void setAttempts(int index) { + this.attempts = index; } - public int e() { - return this.c; + public int getCoinsCollected() { + return this.coinsCollected; } - public void f(int index) { - this.c = index; + public void setCoinsCollected(int index) { + this.coinsCollected = index; } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { if (text.equals("stats_attempts")) { - return String.valueOf(this.b); + return String.valueOf(this.attempts); } else { - return text.equals("stats_coins_collected") ? String.valueOf(this.c) : super.a(text); + return text.equals("stats_coins_collected") ? String.valueOf(this.coinsCollected) : super.resolvePlaceholder(text); } } @Override public String getVariable(String text) { if (text.equals("attempts")) { - return String.valueOf(this.b); + return String.valueOf(this.attempts); } else { - return text.equals("coins_collected") ? String.valueOf(this.c) : super.getVariable(text); + return text.equals("coins_collected") ? String.valueOf(this.coinsCollected) : super.getVariable(text); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/storage/TempleRunStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/storage/TempleRunStatisticsRepository.java index b00f333..ac76bde 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/storage/TempleRunStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/statistics/storage/TempleRunStatisticsRepository.java @@ -14,122 +14,122 @@ public class TempleRunStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a( + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); - this.a() - .a( + this.getDatabase() + .executeAsync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); } - public void a(TempleRunStatistics templeRunStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(TempleRunStatistics templeRunStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, templeRunStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(templeRunStatistics, var3); + this.readStatistics(templeRunStatistics, var3); } - templeRunStatistics.a(true); + templeRunStatistics.setLoaded(true); } }); } - private void a(TempleRunStatistics templeRunStatistics, ResultSet resultSet) throws java.sql.SQLException { - templeRunStatistics.b(resultSet.getString("options")); - templeRunStatistics.a(resultSet.getInt("wins")); - templeRunStatistics.c(resultSet.getInt("win_streak")); - templeRunStatistics.d(resultSet.getInt("current_win_streak")); - templeRunStatistics.b(resultSet.getInt("loses")); - templeRunStatistics.e(resultSet.getInt("attempts")); - templeRunStatistics.f(resultSet.getInt("coins_collected")); + private void readStatistics(TempleRunStatistics templeRunStatistics, ResultSet resultSet) throws java.sql.SQLException { + templeRunStatistics.deserializeProperties(resultSet.getString("options")); + templeRunStatistics.setWins(resultSet.getInt("wins")); + templeRunStatistics.setWinStreak(resultSet.getInt("win_streak")); + templeRunStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + templeRunStatistics.setLoses(resultSet.getInt("loses")); + templeRunStatistics.setAttempts(resultSet.getInt("attempts")); + templeRunStatistics.setCoinsCollected(resultSet.getInt("coins_collected")); } - public void b(TempleRunStatistics templeRunStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(TempleRunStatistics templeRunStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, templeRunStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.c(templeRunStatistics); + this.insertStatistics(templeRunStatistics); } else { - this.d(templeRunStatistics); + this.updateStatistics(templeRunStatistics); } } }); } - private void d(TempleRunStatistics templeRunStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void updateStatistics(TempleRunStatistics templeRunStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, templeRunStatistics.getUUID().toString()); - preparedStatement.setString(2, templeRunStatistics.c()); + preparedStatement.setString(2, templeRunStatistics.serializeProperties()); preparedStatement.setInt(3, templeRunStatistics.getWins()); preparedStatement.setInt(4, templeRunStatistics.getWinStreak()); preparedStatement.setInt(5, templeRunStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, templeRunStatistics.getLoses()); - preparedStatement.setInt(7, templeRunStatistics.d()); - preparedStatement.setInt(8, templeRunStatistics.e()); + preparedStatement.setInt(7, templeRunStatistics.getAttempts()); + preparedStatement.setInt(8, templeRunStatistics.getCoinsCollected()); preparedStatement.executeUpdate(); }); } - public void c(TempleRunStatistics templeRunStatistics) { - this.a() - .a( + public void insertStatistics(TempleRunStatistics templeRunStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, attempts = ?, coins_collected = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, templeRunStatistics.c()); + preparedStatement.setString(1, templeRunStatistics.serializeProperties()); preparedStatement.setInt(2, templeRunStatistics.getWins()); preparedStatement.setInt(3, templeRunStatistics.getWinStreak()); preparedStatement.setInt(4, templeRunStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, templeRunStatistics.getLoses()); - preparedStatement.setInt(6, templeRunStatistics.d()); - preparedStatement.setInt(7, templeRunStatistics.e()); + preparedStatement.setInt(6, templeRunStatistics.getAttempts()); + preparedStatement.setInt(7, templeRunStatistics.getCoinsCollected()); preparedStatement.setString(8, templeRunStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(TempleRunGamer templeRunGamer) { - this.a(this.b + "_weekly", templeRunGamer); - this.a(this.b + "_monthly", templeRunGamer); + public void savePeriodicStatistics(TempleRunGamer templeRunGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", templeRunGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", templeRunGamer); } - private void a(String text, TempleRunGamer templeRunGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, TempleRunGamer templeRunGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, templeRunGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, templeRunGamer); + this.updatePeriodicStatistics(text, templeRunGamer); } else { - this.c(text, templeRunGamer); + this.insertPeriodicStatistics(text, templeRunGamer); } } }); } - private void b(String text, TempleRunGamer templeRunGamer) { + private void updatePeriodicStatistics(String text, TempleRunGamer templeRunGamer) { String text2 = "current_win_streak"; if (templeRunGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -137,9 +137,9 @@ public class TempleRunStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -149,86 +149,86 @@ public class TempleRunStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, attempts = attempts + ?, coins_collected = coins_collected + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, templeRunGamer.getWins()); preparedStatement.setInt(2, templeRunGamer.getLoses()); - preparedStatement.setInt(3, templeRunGamer.q()); - preparedStatement.setInt(4, templeRunGamer.n()); + preparedStatement.setInt(3, templeRunGamer.getAttempts()); + preparedStatement.setInt(4, templeRunGamer.getCoinsCollected()); preparedStatement.setString(5, templeRunGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, TempleRunGamer templeRunGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, TempleRunGamer templeRunGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, templeRunGamer.getUUID().toString()); preparedStatement.setInt(2, templeRunGamer.getWins()); preparedStatement.setInt(3, templeRunGamer.getWins()); preparedStatement.setInt(4, templeRunGamer.getWins()); preparedStatement.setInt(5, templeRunGamer.getLoses()); - preparedStatement.setInt(6, templeRunGamer.q()); - preparedStatement.setInt(7, templeRunGamer.n()); + preparedStatement.setInt(6, templeRunGamer.getAttempts()); + preparedStatement.setInt(7, templeRunGamer.getCoinsCollected()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); - this.a() - .b( + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, attempts INT, coins_collected INT);" ); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -239,22 +239,22 @@ public class TempleRunStatisticsRepository extends GameStatisticsRepository { int index2 = var4.getInt("loses"); int index3 = var4.getInt("attempts"); int index4 = var4.getInt("coins"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -269,14 +269,14 @@ public class TempleRunStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/templerun/storage/TempleRunStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/templerun/storage/TempleRunStorage.java index cc1ebcd..406a5f4 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/templerun/storage/TempleRunStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/templerun/storage/TempleRunStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.templerun.statistics.storage.TempleRunStatistic public class TempleRunStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final TempleRunStatisticsRepository templeRunStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public TempleRunStorage(TempleRunManager templeRunManager) { super(templeRunManager); this.storage = new GameMapStorage(templeRunManager.getConfigManager(), this.file, TempleRunMap::new); - this.storage2 = new NpcStorage(templeRunManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(templeRunManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(templeRunManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(templeRunManager.getConfigManager(), this.file); this.templeRunStatisticsRepository = new TempleRunStatisticsRepository(templeRunManager.getEngine()); - this.storage4 = new LeaderboardStorage(templeRunManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(templeRunManager.getConfigManager(), this.file, TempleRunMap::new); + this.leaderboardStorage = new LeaderboardStorage(templeRunManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(templeRunManager.getConfigManager(), this.file, TempleRunMap::new); } @Override @@ -34,26 +34,26 @@ public class TempleRunStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public TempleRunStatisticsRepository e() { + public TempleRunStatisticsRepository getStatisticsRepository() { return this.templeRunStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunGame.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunGame.java index d46a743..74b7da2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunGame.java @@ -27,36 +27,36 @@ import ro.fr33styler.arcade.game.tntrun.player.TNTRunGamer; public class TNTRunGame extends AbstractGame implements GameEventHandler { - private int c; + private int elapsedSeconds; private TNTRunGamer[] gamers; - private final TNTRunMap e; + private final TNTRunMap map; - private final TNTRunManager f; + private final TNTRunManager manager; private final List list = new ArrayList<>(); private final Lifecycle lifecycle = new TNTRunLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); private final Set set = EnumSet.allOf(GameAction.class); - private final Map k = new LinkedHashMap<>(); + private final Map crumblingBlocks = new LinkedHashMap<>(); public TNTRunGame(TNTRunManager tNTRunManager, TNTRunMap tNTRunMap) { - this.e = tNTRunMap; - this.f = tNTRunManager; + this.map = tNTRunMap; + this.manager = tNTRunManager; this.setPhase(this.lifecycle.getWaiting()); } - public List getList19() { + public List getAliveGamers() { return this.list; } public TNTRunMap getMap() { - return this.e; + return this.map; } public Lifecycle getPhaseLifecycle() { @@ -64,82 +64,82 @@ public class TNTRunGame extends AbstractGame implements GameEventHandler { } public TNTRunMessages getMessages() { - return this.f.getMessages(); + return this.manager.getMessages(); } - private TNTRunConfiguration y() { - TNTRunConfiguration tNTRunConfiguration = (TNTRunConfiguration) this.getManager().G().get(this.getMap().getId()); - return tNTRunConfiguration == null ? this.getManager().getConfiguration8() : tNTRunConfiguration; + private TNTRunConfiguration getActiveConfiguration() { + TNTRunConfiguration tNTRunConfiguration = (TNTRunConfiguration) this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return tNTRunConfiguration == null ? this.getManager().getConfiguration() : tNTRunConfiguration; } public TNTRunSettings getSettings() { - return this.y().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public TNTRunRewards s() { - return this.y().getRewards(); + public TNTRunRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public TNTRunManager getManager() { - return this.f; + return this.manager; } public Set getBlockedActions() { return this.set; } - public int u() { - return this.c; + public int getElapsedSeconds() { + return this.elapsedSeconds; } - public void a(int index) { - this.c = index; + public void setElapsedSeconds(int index) { + this.elapsedSeconds = index; } public void setGamers(TNTRunGamer[] gamers3) { this.gamers = gamers3; } - public Map v() { - return this.k; + public Map getCrumblingBlocks() { + return this.crumblingBlocks; } @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } @Override public String getVariable(String text) { if (text.equals("duration")) { - return String.valueOf(this.c); + return String.valueOf(this.elapsedSeconds); } else { return text.equals("players_alive") ? String.valueOf(this.list.size()) : super.getVariable(text); } } - public void a(Block block) { + public void queueCrumbleBlock(Block block) { Block block2 = block.getRelative(0, -1, 0); if (block2.getRelative(0, -1, 0).getType() == Material.TNT) { - this.k.putIfAbsent(block2, this.getSettings().getRemovalDelayInTicks()); + this.crumblingBlocks.putIfAbsent(block2, this.getSettings().getRemovalDelayInTicks()); } } - public void w() { + public void checkWinCondition() { if (this.list.size() <= 1) { - this.x(); + this.finishGame(); } } - public void x() { + public void finishGame() { TNTRunGamer tNTRunGamer = this.list.get(0); - tNTRunGamer.a(1); - Arrays.sort(this.gamers, Comparator.comparingInt(TNTRunGamer::m).reversed()); - Context context = Contexts.a(this.f, this.gamers); - for (TNTRunGamer tNTRunGamer2 : this.gamers2) { + tNTRunGamer.setWins(1); + Arrays.sort(this.gamers, Comparator.comparingInt(TNTRunGamer::getPlacementScore).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); + for (TNTRunGamer tNTRunGamer2 : this.gamerSet) { tNTRunGamer2.sendMessages(this.getMessages().getEndingTop(), context); - if (!tNTRunGamer2.getSpectatorOptions().g() && this.s().isEnabled()) { - tNTRunGamer2.b(tNTRunGamer == tNTRunGamer2 ? this.s().getWinner() : this.s().getLosers()); + if (!tNTRunGamer2.getSpectatorOptions().isExternal() && this.getRewards().isEnabled()) { + tNTRunGamer2.setRewardCommands(tNTRunGamer == tNTRunGamer2 ? this.getRewards().getWinner() : this.getRewards().getLosers()); } } this.getPhase().stop(); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunManager.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunManager.java index 82faeb1..b61c2c9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/TNTRunManager.java @@ -30,12 +30,12 @@ public class TNTRunManager extends AbstractGameManager { private final Command command; private final TNTRunStorage storage; private final TNTRunMessages messages = new TNTRunMessages(); - private final Map f = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final TNTRunConfiguration configuration = new TNTRunConfiguration(); private final TNTRunListener listener = new TNTRunListener(this); - private final Map i = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final TNTRunSessions sessions = new TNTRunSessions(this); - private final Map> k = Map.of("wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses); + private final Map> leaderboardSources = Map.of("wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses); public TNTRunManager(DefaultEngine defaultEngine) { super(defaultEngine, "tnt-run", "TNT Run"); @@ -62,7 +62,7 @@ public class TNTRunManager extends AbstractGameManager { return this.sessions; } - public TNTRunConfiguration getConfiguration8() { + public TNTRunConfiguration getConfiguration() { return this.configuration; } @@ -77,21 +77,21 @@ public class TNTRunManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { TNTRunStatistics tNTRunStatistics = new TNTRunStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(tNTRunStatistics); - this.f.put(player.getUniqueId(), tNTRunStatistics); + this.storage.getStatisticsRepository().loadStatistics(tNTRunStatistics); + this.playerStatistics.put(player.getUniqueId(), tNTRunStatistics); } public TNTRunStatistics getData(UUID uuid) { - return this.f.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.f.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map G() { - return this.i; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -108,7 +108,7 @@ public class TNTRunManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.k; + return this.leaderboardSources; } @Override @@ -116,16 +116,16 @@ public class TNTRunManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "tnt_run"); } - private void H() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); TNTRunConfiguration tNTRunConfiguration = new TNTRunConfiguration(); - tNTRunConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.i.put("id_1", this.configuration); - Files.a(file, file2 -> { + tNTRunConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { TNTRunConfiguration tNTRunConfiguration2 = new TNTRunConfiguration(); - tNTRunConfiguration2.a(this.getConfigManager(), file2); - this.i.put(file2.getName(), tNTRunConfiguration2); + tNTRunConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), tNTRunConfiguration2); } }); } @@ -133,15 +133,15 @@ public class TNTRunManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.H(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/command/TNTRunCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/command/TNTRunCreateCommand.java index 22523a6..eb7a824 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/command/TNTRunCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/command/TNTRunCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class TNTRunCreateCommand implements CommandExecutor { - private final TNTRunManager a; + private final TNTRunManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public TNTRunCreateCommand(TNTRunManager tNTRunManager) { - this.a = tNTRunManager; + this.manager = tNTRunManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class TNTRunCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); TNTRunMap tNTRunMap = new TNTRunMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class TNTRunCreateCommand implements CommandExecutor { } tNTRunMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } tNTRunMap.setId(text2); tNTRunMap.setMaximumPlayers(index3); - defaultUser.a(new TNTRunSetup(defaultUser, tNTRunMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new TNTRunSetup(defaultUser, tNTRunMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/TNTRunConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/TNTRunConfiguration.java index 0d34d61..e618f11 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/TNTRunConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/TNTRunConfiguration.java @@ -9,7 +9,7 @@ public class TNTRunConfiguration { private final TNTRunRewards rewards = new TNTRunRewards(); private final TNTRunSettings settings = new TNTRunSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/message/TNTRunMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/message/TNTRunMessages.java index ab03e0f..9b57ca5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/message/TNTRunMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/config/message/TNTRunMessages.java @@ -12,25 +12,25 @@ public class TNTRunMessages extends BaseGameMessages { @Setting("display-name") private String displayName = "TNT Run"; @Setting("player-died") - private Text playerDied = TextParser.a("&7%player% &cdied!"); + private Text playerDied = TextParser.parse("&7%player% &cdied!"); @Setting("players-left") - private Text playersLeft = TextParser.a("&e%players_alive% players remaining!"); + private Text playersLeft = TextParser.parse("&e%players_alive% players remaining!"); @Setting("item-double-jump") - private String itemDoubleJump = Strings.a("&a&lDouble Jump"); + private String itemDoubleJump = Strings.colorize("&a&lDouble Jump"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{"&a%line%", " &lTNT Run", " ", " &eAvoid the falling blocks and try to", " &esurvive longer than everyone else!", "&a%line%"} ); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lTNT Run", @@ -43,7 +43,7 @@ public class TNTRunMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7Duration: %duration%s", " ", diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/lifecycle/TNTRunLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/lifecycle/TNTRunLifecycle.java index d420605..345abc2 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/lifecycle/TNTRunLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/lifecycle/TNTRunLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class TNTRunLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public TNTRunLifecycle(TNTRunGame tNTRunGame) { this.phase = new WaitingPhase(tNTRunGame); - this.phase2 = new TNTRunPlayingPhase(tNTRunGame); - this.phase3 = new EndingPhase(tNTRunGame); - this.phase4 = new ResettingPhase(tNTRunGame); + this.playingPhase = new TNTRunPlayingPhase(tNTRunGame); + this.endingPhase = new EndingPhase(tNTRunGame); + this.resettingPhase = new ResettingPhase(tNTRunGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class TNTRunLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/listener/TNTRunListener.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/listener/TNTRunListener.java index 11a5378..88f9d51 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/listener/TNTRunListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/listener/TNTRunListener.java @@ -18,60 +18,60 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import ro.fr33styler.arcade.platform.compat.VersionAdapters; public class TNTRunListener extends GameListener { - private final TNTRunManager manager2; + private final TNTRunManager tntRunManager; public TNTRunListener(TNTRunManager tNTRunManager) { super(tNTRunManager); - this.manager2 = tNTRunManager; + this.tntRunManager = tNTRunManager; } @EventHandler - public void a(PlayerInteractEvent event) { + public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); - TNTRunGamer tNTRunGamer = this.a(player, TNTRunGamer.class); - if (tNTRunGamer != null && !tNTRunGamer.f() && EngineUtils.b(event.getAction()) && VersionAdapters.get().isMainHandInteract(this.manager2.getEngine().getPlatform(), event)) { - if (tNTRunGamer.n() > 0 && event.getItem() != null && event.getItem().getType() == Material.FEATHER) { + TNTRunGamer tNTRunGamer = this.getActiveGamer(player, TNTRunGamer.class); + if (tNTRunGamer != null && !tNTRunGamer.isSpectator() && EngineUtils.isRightClick(event.getAction()) && VersionAdapters.get().isMainHandInteract(this.tntRunManager.getEngine().getPlatform(), event)) { + if (tNTRunGamer.getDoubleJumpsRemaining() > 0 && event.getItem() != null && event.getItem().getType() == Material.FEATHER) { TNTRunGame tNTRunGame = tNTRunGamer.getGame(); player.setVelocity(player.getEyeLocation().getDirection().multiply(tNTRunGame.getSettings().getJumpDistance()).setY(tNTRunGame.getSettings().getJumpDistance())); - tNTRunGamer.d(tNTRunGamer.n() - 1); + tNTRunGamer.setDoubleJumpsRemaining(tNTRunGamer.getDoubleJumpsRemaining() - 1); } } } @EventHandler - public void a(PlayerToggleFlightEvent event) { + public void onPlayerToggleFlight(PlayerToggleFlightEvent event) { Player player = event.getPlayer(); - TNTRunGamer tNTRunGamer = this.a(player, TNTRunGamer.class); - if (tNTRunGamer != null && !tNTRunGamer.f()) { + TNTRunGamer tNTRunGamer = this.getActiveGamer(player, TNTRunGamer.class); + if (tNTRunGamer != null && !tNTRunGamer.isSpectator()) { event.setCancelled(true); player.setAllowFlight(false); player.setFlying(false); - if (tNTRunGamer.n() > 0) { + if (tNTRunGamer.getDoubleJumpsRemaining() > 0) { TNTRunGame tNTRunGame = tNTRunGamer.getGame(); player.setVelocity(player.getEyeLocation().getDirection().multiply(tNTRunGame.getSettings().getJumpDistance()).setY(tNTRunGame.getSettings().getJumpDistance())); - tNTRunGamer.d(tNTRunGamer.n() - 1); + tNTRunGamer.setDoubleJumpsRemaining(tNTRunGamer.getDoubleJumpsRemaining() - 1); } } } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - TNTRunGamer tNTRunGamer = this.a(player, TNTRunGamer.class); - if (tNTRunGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + TNTRunGamer tNTRunGamer = this.getActiveGamer(player, TNTRunGamer.class); + if (tNTRunGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { TNTRunGame tNTRunGame = tNTRunGamer.getGame(); - if (tNTRunGamer.f()) { - if (!tNTRunGame.getMap().getPlayZone().a(location)) { + if (tNTRunGamer.isSpectator()) { + if (!tNTRunGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - tNTRunGamer.a(tNTRunGame.getMap().getSpectator()); + tNTRunGamer.teleport(tNTRunGame.getMap().getSpectator()); } - } else if (tNTRunGame.u() >= tNTRunGame.getSettings().getSafeDuration()) { - if (!tNTRunGame.getMap().getPlayZone().a(location)) { - tNTRunGamer.o(); + } else if (tNTRunGame.getElapsedSeconds() >= tNTRunGame.getSettings().getSafeDuration()) { + if (!tNTRunGame.getMap().getPlayZone().contains(location)) { + tNTRunGamer.eliminate(); } else { - tNTRunGame.a(location.getBlock()); - if (tNTRunGamer.n() > 0 && location.getBlock().getRelative(BlockFace.DOWN).isEmpty()) { + tNTRunGame.queueCrumbleBlock(location.getBlock()); + if (tNTRunGamer.getDoubleJumpsRemaining() > 0 && location.getBlock().getRelative(BlockFace.DOWN).isEmpty()) { player.setAllowFlight(true); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/phase/TNTRunPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/phase/TNTRunPlayingPhase.java index 2b4cf44..1d2ba6b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/phase/TNTRunPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/phase/TNTRunPlayingPhase.java @@ -19,11 +19,11 @@ public class TNTRunPlayingPhase implements Phase { } public void start() { - this.game.a(0); - this.game.setGamers((TNTRunGamer[]) this.game.getGamers().a(new TNTRunGamer[this.game.getGamers().size()])); + this.game.setElapsedSeconds(0); + this.game.setGamers((TNTRunGamer[]) this.game.getGamers().toArray(new TNTRunGamer[this.game.getGamers().size()])); for (TNTRunGamer tNTRunGamer : this.game.getGamers()) { - this.game.getList19().add(tNTRunGamer); - tNTRunGamer.d(this.game.getSettings().getDoubleJumps()); + this.game.getAliveGamers().add(tNTRunGamer); + tNTRunGamer.setDoubleJumpsRemaining(this.game.getSettings().getDoubleJumps()); Player player = tNTRunGamer.toPlayer(); player.setGameMode(GameMode.ADVENTURE); player.teleport(this.game.getMap().getSpawn()); @@ -32,9 +32,9 @@ public class TNTRunPlayingPhase implements Phase { } public void stop() { - this.game.getGamers().a(this.game.getMessages().getSidebarPlaying()); - this.game.getList19().clear(); - this.game.v().clear(); + this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarPlaying()); + this.game.getAliveGamers().clear(); + this.game.getCrumblingBlocks().clear(); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -47,8 +47,8 @@ public class TNTRunPlayingPhase implements Phase { } public void onTick(long longVal) { - if (!this.game.v().isEmpty()) { - this.game.v().entrySet().removeIf(entry -> { + if (!this.game.getCrumblingBlocks().isEmpty()) { + this.game.getCrumblingBlocks().entrySet().removeIf(entry -> { if ((Integer) entry.getValue() > 0) { entry.setValue((Integer) entry.getValue() - 1); return false; @@ -64,9 +64,9 @@ public class TNTRunPlayingPhase implements Phase { }); } if (longVal % 20L == 0L) { - this.game.a(this.game.u() + 1); + this.game.setElapsedSeconds(this.game.getElapsedSeconds() + 1); for (TNTRunGamer tNTRunGamer : this.game.getGamers()) { - tNTRunGamer.q(); + tNTRunGamer.tickPlaying(); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/player/TNTRunGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/player/TNTRunGamer.java index e177fe2..1f1dfd7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/player/TNTRunGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/player/TNTRunGamer.java @@ -8,9 +8,9 @@ import ro.fr33styler.arcade.game.tntrun.statistics.TNTRunStatistics; public class TNTRunGamer extends BaseGamer { - private int b; + private int placementScore; - private int c; + private int doubleJumpsRemaining; private Location location; @@ -25,61 +25,61 @@ public class TNTRunGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getPlacementScore() { + return this.placementScore; } - public void c(int index) { - this.b = index; + public void setPlacementScore(int index) { + this.placementScore = index; } - public int n() { - return this.c; + public int getDoubleJumpsRemaining() { + return this.doubleJumpsRemaining; } - public void d(int index) { - this.c = index; + public void setDoubleJumpsRemaining(int index) { + this.doubleJumpsRemaining = index; } - private void r() { + private void saveStatistics() { TNTRunStatistics tNTRunStatistics = this.game.getManager().getData(this.getUUID()); - if (tNTRunStatistics.a()) { - tNTRunStatistics.a(tNTRunStatistics.getWins() + this.getWins()); + if (tNTRunStatistics.isLoaded()) { + tNTRunStatistics.setWins(tNTRunStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - tNTRunStatistics.d(tNTRunStatistics.getCurrentWinStreak() + 1); + tNTRunStatistics.setCurrentWinStreak(tNTRunStatistics.getCurrentWinStreak() + 1); if (tNTRunStatistics.getWinStreak() < tNTRunStatistics.getCurrentWinStreak()) { - tNTRunStatistics.c(tNTRunStatistics.getCurrentWinStreak()); + tNTRunStatistics.setWinStreak(tNTRunStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - tNTRunStatistics.d(0); + tNTRunStatistics.setCurrentWinStreak(0); } - tNTRunStatistics.b(tNTRunStatistics.getLoses() + this.getLoses()); - this.b(tNTRunStatistics.getMap()); - this.game.getManager().getStorage().e().b(tNTRunStatistics); - this.game.getManager().getStorage().e().a(this); + tNTRunStatistics.setLoses(tNTRunStatistics.getLoses() + this.getLoses()); + this.saveProperties(tNTRunStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(tNTRunStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } - public void o() { - this.b(this.getLoses() + 1); - this.b(true); + public void eliminate() { + this.setLoses(this.getLoses() + 1); + this.setSpectator(true); this.game.getSpectatorTeam().addEntry(this.player.getName()); this.player.teleport(this.game.getMap().getSpectator()); - this.game.getList19().remove(this); + this.game.getAliveGamers().remove(this); for (TNTRunGamer tNTRunGamer : this.game.getGamers()) { tNTRunGamer.sendMessage(this.game.getMessages().getPlayerDied(), this); - tNTRunGamer.a(this.game.getMessages().getPlayersLeft()); - if (!tNTRunGamer.f()) { - tNTRunGamer.c(tNTRunGamer.m() + 1); + tNTRunGamer.sendMessage(this.game.getMessages().getPlayersLeft()); + if (!tNTRunGamer.isSpectator()) { + tNTRunGamer.setPlacementScore(tNTRunGamer.getPlacementScore() + 1); } } - this.game.w(); + this.game.checkWinCondition(); } @Override public String getVariable(String text) { if (text.equals("double_jumps_remaining")) { - return String.valueOf(this.c); + return String.valueOf(this.doubleJumpsRemaining); } else { return text.equals("double_jumps") ? String.valueOf(this.game.getSettings().getDoubleJumps()) : super.getVariable(text); } @@ -87,17 +87,17 @@ public class TNTRunGamer extends BaseGamer { @Override public void leave() { - this.r(); - this.game.getGamers().b(this); - this.game.getList19().remove(this); + this.saveStatistics(); + this.game.getGamers().remove(this); + this.game.getAliveGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.w(); + this.game.checkWinCondition(); } super.leave(); } - public void q() { - if (!this.f() && this.game.u() >= this.game.getSettings().getSafeDuration()) { + public void tickPlaying() { + if (!this.isSpectator() && this.game.getElapsedSeconds() >= this.game.getSettings().getSafeDuration()) { Location location2 = this.player.getLocation(); if (this.location != null && !(this.location.distanceSquared(location2) >= 4.0)) { int index = location2.getBlockY(); @@ -105,13 +105,13 @@ public class TNTRunGamer extends BaseGamer { int index2 = Location.locToBlock(location2.getX() + doubleVal); for (double doubleVal2 = -0.3; doubleVal2 <= 0.3; doubleVal2 += 0.3) { int index3 = Location.locToBlock(location2.getZ() + doubleVal2); - this.game.a(this.player.getWorld().getBlockAt(index2, index, index3)); + this.game.queueCrumbleBlock(this.player.getWorld().getBlockAt(index2, index, index3)); } } } else { this.location = location2; } } - this.a(this.game.getMessages().getSidebarPlaying(), this); + this.updateSidebar(this.game.getMessages().getSidebarPlaying(), this); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSession.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSession.java index 0f87cc3..c1b9485 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSession.java @@ -22,11 +22,11 @@ public class TNTRunSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TNTRunGamer tNTRunGamer = new TNTRunGamer(this.game, defaultUser); - this.game.getGamers().a(tNTRunGamer); - tNTRunGamer.a(this.game.getMessages().getStart()); - tNTRunGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(tNTRunGamer); + tNTRunGamer.sendMessages(this.game.getMessages().getStart()); + tNTRunGamer.teleport(this.game.getMap().getLobby()); return tNTRunGamer; }); } @@ -40,7 +40,7 @@ public class TNTRunSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof TNTRunGamer var2) { TNTRunGame tNTRunGame = var2.getGame(); - if (tNTRunGame.getPhase() != tNTRunGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (tNTRunGame.getPhase() != tNTRunGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, tNTRunGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class TNTRunSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TNTRunGamer tNTRunGamer = new TNTRunGamer(this.game, defaultUser); - this.game.getGamers().a(tNTRunGamer); - tNTRunGamer.a(this.game.getMap().getSpectator()); - tNTRunGamer.b(true); - tNTRunGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(tNTRunGamer); + tNTRunGamer.teleport(this.game.getMap().getSpectator()); + tNTRunGamer.setSpectator(true); + tNTRunGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(tNTRunGamer.getName()); return tNTRunGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSessions.java index a48ce75..af2bd02 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/session/TNTRunSessions.java @@ -9,41 +9,41 @@ import ro.fr33styler.arcade.game.tntrun.map.TNTRunMap; import org.bukkit.World; public class TNTRunSessions extends BaseSessions { - private final TNTRunManager a; + private final TNTRunManager manager; public TNTRunSessions(TNTRunManager tNTRunManager) { super(tNTRunManager); - this.a = tNTRunManager; + this.manager = tNTRunManager; } public TNTRunManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(tNTRunMap -> this.registerGame(new TNTRunGame(this.a, tNTRunMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(tNTRunMap -> this.registerGame(new TNTRunGame(this.manager, tNTRunMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected TNTRunMap h(String text) { + protected TNTRunMap createMap(String text) { TNTRunMap tNTRunMap = new TNTRunMap(); tNTRunMap.setId(text); return tNTRunMap; } - protected TNTRunGame a(TNTRunMap tNTRunMap) { - return new TNTRunGame(this.a, tNTRunMap); + protected TNTRunGame createGame(TNTRunMap tNTRunMap) { + return new TNTRunGame(this.manager, tNTRunMap); } public TNTRunSession createSession(TNTRunGame tNTRunGame) { return tNTRunGame == null ? null : new TNTRunSession(tNTRunGame); } - protected void a(TNTRunMap tNTRunMap, World world, TNTRunMap tNTRunMap2) { - super.a(tNTRunMap, world, tNTRunMap2); - tNTRunMap2.setSpawn(Locations.a(world, tNTRunMap.getSpawn())); - tNTRunMap2.setPlayZone(tNTRunMap.getPlayZone().a(world)); - tNTRunMap2.setSpectator(Locations.a(world, tNTRunMap.getSpectator())); + protected void copyMap(TNTRunMap tNTRunMap, World world, TNTRunMap tNTRunMap2) { + super.copyMap(tNTRunMap, world, tNTRunMap2); + tNTRunMap2.setSpawn(Locations.withWorld(world, tNTRunMap.getSpawn())); + tNTRunMap2.setPlayZone(tNTRunMap.getPlayZone().withWorld(world)); + tNTRunMap2.setSpectator(Locations.withWorld(world, tNTRunMap.getSpectator())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/TNTRunSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/TNTRunSetup.java index bee8c28..603bc2f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/TNTRunSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/TNTRunSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class TNTRunSetup extends ArenaSetup { private final TNTRunMap map; - private final TNTRunManager d; + private final TNTRunManager manager; private final SetupTarget setupTarget; public TNTRunSetup(DefaultUser defaultUser, TNTRunMap map2, TNTRunManager tNTRunManager, SetupTarget setupTarget2) { super(defaultUser, tNTRunManager.getName()); - this.d = tNTRunManager; + this.manager = tNTRunManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new TNTRunSetArenaNameStep(this); } - public TNTRunMap getMap40() { + public TNTRunMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class TNTRunSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new TNTRunGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new TNTRunGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetArenaNameStep.java index 33ac3d3..ba28e12 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetArenaNameStep.java @@ -10,12 +10,12 @@ public class TNTRunSetArenaNameStep implements ChatSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { this.tNTRunSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.tNTRunSetup.getMap40().setName(text); - this.tNTRunSetup.a(new TNTRunSetLobbySpawnStep(this.tNTRunSetup)); + public void onChatInput(String text) { + this.tNTRunSetup.getMap().setName(text); + this.tNTRunSetup.advanceStep(new TNTRunSetLobbySpawnStep(this.tNTRunSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbyRemovalRegionStep.java index 801a111..9315998 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class TNTRunSetLobbyRemovalRegionStep implements ClickSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class TNTRunSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); - this.tNTRunSetup.getHotbar().a(0, () -> { + this.tNTRunSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.tNTRunSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.tNTRunSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.tNTRunSetup.getMap40().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.tNTRunSetup.a(new TNTRunSetPlayZoneStep(this.tNTRunSetup)); + this.tNTRunSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.tNTRunSetup.advanceStep(new TNTRunSetPlayZoneStep(this.tNTRunSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.tNTRunSetup.getHotbar().a(2, () -> { - this.tNTRunSetup.getMap40().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.tNTRunSetup.a(new TNTRunSetPlayZoneStep(this.tNTRunSetup)); + this.tNTRunSetup.getHotbar().setSlot(2, () -> { + this.tNTRunSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.tNTRunSetup.advanceStep(new TNTRunSetPlayZoneStep(this.tNTRunSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbySpawnStep.java index 17591c6..7faef9e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class TNTRunSetLobbySpawnStep implements ClickSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.tNTRunSetup.getUser().toPlayer(); - this.tNTRunSetup.getHotbar().a(0, () -> { - this.tNTRunSetup.getMap40().setLobby(player.getLocation()); - this.tNTRunSetup.a(new TNTRunSetLobbyRemovalRegionStep(this.tNTRunSetup)); + this.tNTRunSetup.getHotbar().setSlot(0, () -> { + this.tNTRunSetup.getMap().setLobby(player.getLocation()); + this.tNTRunSetup.advanceStep(new TNTRunSetLobbyRemovalRegionStep(this.tNTRunSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayZoneStep.java index bc3bd18..29fa843 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class TNTRunSetPlayZoneStep implements ClickSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); - this.tNTRunSetup.getHotbar().a(0, () -> { + this.tNTRunSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.tNTRunSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.tNTRunSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.tNTRunSetup.getMap40().setPlayZone(new Cuboid(block, block2)); - this.tNTRunSetup.a(new TNTRunSetSpectatorSpawnStep(this.tNTRunSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.tNTRunSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.tNTRunSetup.advanceStep(new TNTRunSetSpectatorSpawnStep(this.tNTRunSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayerSpawnStep.java index 32702f8..1310999 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetPlayerSpawnStep.java @@ -17,19 +17,19 @@ public class TNTRunSetPlayerSpawnStep implements ClickSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at."); } - public void a() { + public void configureHotbar() { Player player = this.tNTRunSetup.getUser().toPlayer(); - this.tNTRunSetup.getHotbar().a(0, () -> { + this.tNTRunSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.tNTRunSetup.getMap40().getPlayZone().a(location)) { - this.tNTRunSetup.getMap40().setSpawn(location); - this.tNTRunSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.tNTRunSetup.getMap().getPlayZone().contains(location)) { + this.tNTRunSetup.getMap().setSpawn(location); + this.tNTRunSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetSpectatorSpawnStep.java index 3aa6549..484ed9f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/setup/step/TNTRunSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class TNTRunSetSpectatorSpawnStep implements ClickSetupStep { this.tNTRunSetup = tNTRunSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTRunSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.tNTRunSetup.getUser().toPlayer(); - this.tNTRunSetup.getHotbar().a(0, () -> { + this.tNTRunSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.tNTRunSetup.getMap40().getPlayZone().a(location)) { - this.tNTRunSetup.getMap40().setSpectator(location); - this.tNTRunSetup.a(new TNTRunSetPlayerSpawnStep(this.tNTRunSetup)); + if (this.tNTRunSetup.getMap().getPlayZone().contains(location)) { + this.tNTRunSetup.getMap().setSpectator(location); + this.tNTRunSetup.advanceStep(new TNTRunSetPlayerSpawnStep(this.tNTRunSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/statistics/storage/TNTRunStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/statistics/storage/TNTRunStatisticsRepository.java index 26604b2..29bf4bf 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/statistics/storage/TNTRunStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/statistics/storage/TNTRunStatisticsRepository.java @@ -14,53 +14,53 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); } - public void a(TNTRunStatistics tNTRunStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(TNTRunStatistics tNTRunStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTRunStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(tNTRunStatistics, var3); + this.readStatistics(tNTRunStatistics, var3); } - tNTRunStatistics.a(true); + tNTRunStatistics.setLoaded(true); } }); } - private void a(TNTRunStatistics tNTRunStatistics, ResultSet resultSet) throws java.sql.SQLException { - tNTRunStatistics.b(resultSet.getString("options")); - tNTRunStatistics.a(resultSet.getInt("wins")); - tNTRunStatistics.c(resultSet.getInt("win_streak")); - tNTRunStatistics.d(resultSet.getInt("current_win_streak")); - tNTRunStatistics.b(resultSet.getInt("loses")); + private void readStatistics(TNTRunStatistics tNTRunStatistics, ResultSet resultSet) throws java.sql.SQLException { + tNTRunStatistics.deserializeProperties(resultSet.getString("options")); + tNTRunStatistics.setWins(resultSet.getInt("wins")); + tNTRunStatistics.setWinStreak(resultSet.getInt("win_streak")); + tNTRunStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + tNTRunStatistics.setLoses(resultSet.getInt("loses")); } - public void b(TNTRunStatistics tNTRunStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(TNTRunStatistics tNTRunStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTRunStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(tNTRunStatistics); + this.updateStatistics(tNTRunStatistics); } else { - this.c(tNTRunStatistics); + this.insertStatistics(tNTRunStatistics); } } }); } - private void c(TNTRunStatistics tNTRunStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(TNTRunStatistics tNTRunStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, tNTRunStatistics.getUUID().toString()); - preparedStatement.setString(2, tNTRunStatistics.c()); + preparedStatement.setString(2, tNTRunStatistics.serializeProperties()); preparedStatement.setInt(3, tNTRunStatistics.getWins()); preparedStatement.setInt(4, tNTRunStatistics.getWinStreak()); preparedStatement.setInt(5, tNTRunStatistics.getCurrentWinStreak()); @@ -69,16 +69,16 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { }); } - private void d(TNTRunStatistics tNTRunStatistics) { - this.a() - .a( + private void updateStatistics(TNTRunStatistics tNTRunStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, tNTRunStatistics.c()); + preparedStatement.setString(1, tNTRunStatistics.serializeProperties()); preparedStatement.setInt(2, tNTRunStatistics.getWins()); preparedStatement.setInt(3, tNTRunStatistics.getWinStreak()); preparedStatement.setInt(4, tNTRunStatistics.getCurrentWinStreak()); @@ -89,26 +89,26 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { ); } - public void a(TNTRunGamer tNTRunGamer) { - this.a(this.b + "_weekly", tNTRunGamer); - this.a(this.b + "_monthly", tNTRunGamer); + public void savePeriodicStatistics(TNTRunGamer tNTRunGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", tNTRunGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", tNTRunGamer); } - private void a(String text, TNTRunGamer tNTRunGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, TNTRunGamer tNTRunGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTRunGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, tNTRunGamer); + this.updatePeriodicStatistics(text, tNTRunGamer); } else { - this.c(text, tNTRunGamer); + this.insertPeriodicStatistics(text, tNTRunGamer); } } }); } - private void b(String text, TNTRunGamer tNTRunGamer) { + private void updatePeriodicStatistics(String text, TNTRunGamer tNTRunGamer) { String text2 = "current_win_streak"; if (tNTRunGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -116,9 +116,9 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -128,7 +128,7 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, tNTRunGamer.getWins()); @@ -139,8 +139,8 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { ); } - private void c(String text, TNTRunGamer tNTRunGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, TNTRunGamer tNTRunGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, tNTRunGamer.getUUID().toString()); preparedStatement.setInt(2, tNTRunGamer.getWins()); preparedStatement.setInt(3, tNTRunGamer.getWins()); @@ -150,45 +150,45 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { }); } - private void e() { - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); - this.a().b("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + private void createMigrationTables() { + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); + this.getDatabase().executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT);"); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -197,22 +197,22 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { String text3 = var4.getString("name"); int index = var4.getInt("wins"); int index2 = var4.getInt("loses"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -225,9 +225,9 @@ public class TNTRunStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( - "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", + this.getDatabase() + .executeSync( + "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); preparedStatement3.setInt(2, index); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/storage/TNTRunStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/storage/TNTRunStorage.java index 2d98a2f..5215588 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tntrun/storage/TNTRunStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tntrun/storage/TNTRunStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.tntrun.statistics.storage.TNTRunStatisticsRepos public class TNTRunStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final TNTRunStatisticsRepository tNTRunStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public TNTRunStorage(TNTRunManager tNTRunManager) { super(tNTRunManager); this.storage = new GameMapStorage(tNTRunManager.getConfigManager(), this.file, TNTRunMap::new); - this.storage2 = new NpcStorage(tNTRunManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(tNTRunManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(tNTRunManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(tNTRunManager.getConfigManager(), this.file); this.tNTRunStatisticsRepository = new TNTRunStatisticsRepository(tNTRunManager.getEngine()); - this.storage4 = new LeaderboardStorage(tNTRunManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(tNTRunManager.getConfigManager(), this.file, TNTRunMap::new); + this.leaderboardStorage = new LeaderboardStorage(tNTRunManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(tNTRunManager.getConfigManager(), this.file, TNTRunMap::new); } @Override @@ -34,26 +34,26 @@ public class TNTRunStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public TNTRunStatisticsRepository e() { + public TNTRunStatisticsRepository getStatisticsRepository() { return this.tNTRunStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagGame.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagGame.java index c129028..262aa93 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagGame.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagGame.java @@ -27,25 +27,25 @@ public class TNTTagGame extends AbstractGame implements GameEventHandler { private TNTTagGamer[] gamers; private final ScoreboardTeam scoreboardTeam; private final TNTTagMap map; - private final TNTTagManager f; + private final TNTTagManager manager; private final List list = new ArrayList<>(); private final Lifecycle lifecycle = new TNTTagLifecycle(this); - private final DefaultGamerSet gamers2 = new DefaultGamerSet(); + private final DefaultGamerSet gamerSet = new DefaultGamerSet(); private final Set set = EnumSet.of(GameAction.HUNGER, GameAction.ENTITY_INTERACT, GameAction.INTERACT, GameAction.CLICK, GameAction.ITEM_DROP, GameAction.ITEM_PICKUP); public TNTTagGame(TNTTagManager tNTTagManager, TNTTagMap map2) { this.map = map2; - this.f = tNTTagManager; + this.manager = tNTTagManager; this.setPhase(this.lifecycle.getWaiting()); this.scoreboardTeam = this.getScoreboard().createTeam("It"); this.scoreboardTeam.setPrefix(tNTTagManager.getMessages().getItNameTag()); } - public ScoreboardTeam getScoreboardTeam7() { + public ScoreboardTeam getItTeam() { return this.scoreboardTeam; } - public List getList20() { + public List getAliveGamers() { return this.list; } @@ -62,24 +62,24 @@ public class TNTTagGame extends AbstractGame implements GameEventHandler { } public TNTTagMessages getMessages() { - return this.f.getMessages(); + return this.manager.getMessages(); } - private TNTTagConfiguration w() { - TNTTagConfiguration tNTTagConfiguration = (TNTTagConfiguration)this.getManager().G().get(this.getMap().getId()); - return tNTTagConfiguration == null ? this.getManager().getConfiguration9() : tNTTagConfiguration; + private TNTTagConfiguration getActiveConfiguration() { + TNTTagConfiguration tNTTagConfiguration = (TNTTagConfiguration)this.getManager().getPerGameConfigurations().get(this.getMap().getId()); + return tNTTagConfiguration == null ? this.getManager().getConfiguration() : tNTTagConfiguration; } public TNTTagSettings getSettings() { - return this.w().getSettings(); + return this.getActiveConfiguration().getSettings(); } - public TNTTagRewards t() { - return this.w().getRewards(); + public TNTTagRewards getRewards() { + return this.getActiveConfiguration().getRewards(); } public TNTTagManager getManager() { - return this.f; + return this.manager; } public Set getBlockedActions() { @@ -88,38 +88,38 @@ public class TNTTagGame extends AbstractGame implements GameEventHandler { @Override public DefaultGamerSet getGamers() { - return this.gamers2; + return this.gamerSet; } - public void v() { + public void checkWinCondition() { if (this.list.size() == 1) { - this.a(this.list.get(0)); + this.finishWithWinner(this.list.get(0)); } else if (this.list.isEmpty()) { - this.x(); + this.finishWithDraw(); } } - private void x() { + private void finishWithDraw() { this.getPhase().stop(); - for (TNTTagGamer tNTTagGamer : this.gamers2) { - tNTTagGamer.a(this.getMessages().getEndingDraw()); - if (this.t().isEnabled()) { - tNTTagGamer.b(this.t().getLosers()); + for (TNTTagGamer tNTTagGamer : this.gamerSet) { + tNTTagGamer.sendMessages(this.getMessages().getEndingDraw()); + if (this.getRewards().isEnabled()) { + tNTTagGamer.setRewardCommands(this.getRewards().getLosers()); } } } - private void a(TNTTagGamer tNTTagGamer) { - tNTTagGamer.a(1); - Arrays.sort(this.gamers, Comparator.comparingInt(TNTTagGamer::n).reversed()); - Context context = Contexts.a(this.f, this.gamers); + private void finishWithWinner(TNTTagGamer tNTTagGamer) { + tNTTagGamer.setWins(1); + Arrays.sort(this.gamers, Comparator.comparingInt(TNTTagGamer::getPlacementScore).reversed()); + Context context = Contexts.withPodium(this.manager, this.gamers); - for (TNTTagGamer tNTTagGamer2 : this.gamers2) { + for (TNTTagGamer tNTTagGamer2 : this.gamerSet) { tNTTagGamer2.sendMessages(this.getMessages().getEndingTop(), context); - tNTTagGamer2.a(this.getMessages().getSidebarPlaying(), tNTTagGamer2); - if (!tNTTagGamer2.getSpectatorOptions().g() && this.t().isEnabled()) { - tNTTagGamer2.b(tNTTagGamer2 == tNTTagGamer ? this.t().getWinner() : this.t().getLosers()); + tNTTagGamer2.updateSidebar(this.getMessages().getSidebarPlaying(), tNTTagGamer2); + if (!tNTTagGamer2.getSpectatorOptions().isExternal() && this.getRewards().isEnabled()) { + tNTTagGamer2.setRewardCommands(tNTTagGamer2 == tNTTagGamer ? this.getRewards().getWinner() : this.getRewards().getLosers()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagManager.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagManager.java index f07f677..ea6fe05 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/TNTTagManager.java @@ -30,12 +30,12 @@ public class TNTTagManager extends AbstractGameManager { private final Command command; private final TNTTagStorage storage; private final TNTTagMessages messages = new TNTTagMessages(); - private final Map f = new HashMap<>(); + private final Map playerStatistics = new HashMap<>(); private final TNTTagConfiguration configuration = new TNTTagConfiguration(); private final TNTTagListener listener = new TNTTagListener(this); - private final Map i = new HashMap<>(); + private final Map perGameConfigurations = new HashMap<>(); private final TNTTagSessions sessions = new TNTTagSessions(this); - private final Map> k = Map.of( + private final Map> leaderboardSources = Map.of( "wins", this.messages::getStatisticWins, "win_streak", this.messages::getStatisticWinStreak, "current_win_streak", this.messages::getStatisticCurrentWinStreak, "loses", this.messages::getStatisticLoses, "kills", this.messages::getStatisticKills, "deaths", this.messages::getStatisticDeaths ); @@ -64,7 +64,7 @@ public class TNTTagManager extends AbstractGameManager { return this.sessions; } - public TNTTagConfiguration getConfiguration9() { + public TNTTagConfiguration getConfiguration() { return this.configuration; } @@ -79,21 +79,21 @@ public class TNTTagManager extends AbstractGameManager { @Override public void loadPlayerData(Player player) { TNTTagStatistics tNTTagStatistics = new TNTTagStatistics(this, player.getUniqueId(), player.getName()); - this.storage.e().a(tNTTagStatistics); - this.f.put(player.getUniqueId(), tNTTagStatistics); + this.storage.getStatisticsRepository().loadStatistics(tNTTagStatistics); + this.playerStatistics.put(player.getUniqueId(), tNTTagStatistics); } public TNTTagStatistics getData(UUID uuid) { - return this.f.get(uuid); + return this.playerStatistics.get(uuid); } @Override public void unloadPlayerData(UUID uuid) { - this.f.remove(uuid); + this.playerStatistics.remove(uuid); } - public Map G() { - return this.i; + public Map getPerGameConfigurations() { + return this.perGameConfigurations; } @Override @@ -110,7 +110,7 @@ public class TNTTagManager extends AbstractGameManager { @Override public Map> getLeaderboardSources() { - return this.k; + return this.leaderboardSources; } @Override @@ -118,16 +118,16 @@ public class TNTTagManager extends AbstractGameManager { return new StoredLeaderboard(this, gameLeaderboardSettings, "tnt_tag"); } - private void H() { + private void loadPerGameConfigurations() { File file = new File(this.getDataFolder(), "tweaks/per game/"); TNTTagConfiguration tNTTagConfiguration = new TNTTagConfiguration(); - tNTTagConfiguration.a(this.getConfigManager(), new File(file, "id_1")); - this.i.put("id_1", this.configuration); - Files.a(file, file2 -> { + tNTTagConfiguration.load(this.getConfigManager(), new File(file, "id_1")); + this.perGameConfigurations.put("id_1", this.configuration); + Files.forEachChild(file, file2 -> { if (file2.isDirectory()) { TNTTagConfiguration tNTTagConfiguration2 = new TNTTagConfiguration(); - tNTTagConfiguration2.a(this.getConfigManager(), file2); - this.i.put(file2.getName(), tNTTagConfiguration2); + tNTTagConfiguration2.load(this.getConfigManager(), file2); + this.perGameConfigurations.put(file2.getName(), tNTTagConfiguration2); } }); } @@ -135,15 +135,15 @@ public class TNTTagManager extends AbstractGameManager { @Override protected void reloadConfig() { super.reloadConfig(); - this.configuration.a(this.getEngine().getConfigManager(), this.getDataFolder()); - this.H(); + this.configuration.load(this.getEngine().getConfigManager(), this.getDataFolder()); + this.loadPerGameConfigurations(); } @Override public void start() { - this.storage.e().b(); + this.storage.getStatisticsRepository().createTables(); super.start(); - this.getMenuPage().page().a(35, null, null); + this.getMenuPage().page().setSlot(35, null, null); this.getEngine().getAddonManager().registerListener(this.listener); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/command/TNTTagCreateCommand.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/command/TNTTagCreateCommand.java index 7781caa..09b623d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/command/TNTTagCreateCommand.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/command/TNTTagCreateCommand.java @@ -17,18 +17,18 @@ import ro.fr33styler.arcade.api.engine.command.argument.Argument; import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet; public class TNTTagCreateCommand implements CommandExecutor { - private final TNTTagManager a; + private final TNTTagManager manager; private final ArgumentSet arguments = new DefaultArgumentSet( new Argument[]{ new StringArgument("id"), new NumericArgument("minimum_players"), new NumericArgument("maximum_players"), - new CollectionArgument("format", null, SetupTarget.a()) + new CollectionArgument("format", null, SetupTarget.getTargetNames()) } ); public TNTTagCreateCommand(TNTTagManager tNTTagManager) { - this.a = tNTTagManager; + this.manager = tNTTagManager; } public ArgumentSet getArguments() { @@ -36,26 +36,26 @@ public class TNTTagCreateCommand implements CommandExecutor { } public boolean hasPermission(CommandSender sender) { - return sender.hasPermission(this.a.getId() + ".admin"); + return sender.hasPermission(this.manager.getId() + ".admin"); } public void execute(CommandSender sender, String text, String[] texts, int index) { String text2 = texts[index]; if (sender instanceof Player var6) { - if (this.a.getSessions().a(text2)) { + if (this.manager.getSessions().hasGame(text2)) { sender.sendMessage("§cThere is already a game using this id!"); } else { - DefaultUser defaultUser = (DefaultUser)this.a.getEngine().getUsers().c(var6); + DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c(var6); if (defaultUser == null) { return; } - if (defaultUser.g()) { + if (defaultUser.isInSetup()) { sender.sendMessage("§cYou have a setup already!"); } else { int index2 = Integer.parseInt(texts[index + 1]); int index3 = Integer.parseInt(texts[index + 2]); - SetupTarget setupTarget = SetupTarget.a(texts[index + 3]); + SetupTarget setupTarget = SetupTarget.fromName(texts[index + 3]); TNTTagMap tNTTagMap = new TNTTagMap(); if (index2 < 2 || index2 > index3) { defaultUser.sendMessage("§cThe minimum of players must be between 2 and " + index3); @@ -63,14 +63,14 @@ public class TNTTagCreateCommand implements CommandExecutor { } tNTTagMap.setMinimumPlayers(index2); - if (!this.a.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { + if (!this.manager.hasWorldProvider() && setupTarget == SetupTarget.TEMPLATE) { defaultUser.sendMessage("§cYou cannot create templates at this time because Slime World plugin is missing!"); return; } tNTTagMap.setId(text2); tNTTagMap.setMaximumPlayers(index3); - defaultUser.a(new TNTTagSetup(defaultUser, tNTTagMap, this.a, setupTarget)); + defaultUser.setArenaSetup(new TNTTagSetup(defaultUser, tNTTagMap, this.manager, setupTarget)); } } } else { diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/TNTTagConfiguration.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/TNTTagConfiguration.java index 83f4b88..1290e5e 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/TNTTagConfiguration.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/TNTTagConfiguration.java @@ -9,7 +9,7 @@ public class TNTTagConfiguration { private final TNTTagRewards rewards = new TNTTagRewards(); private final TNTTagSettings settings = new TNTTagSettings(); - public void a(ConfigManager configManager, File file) { + public void load(ConfigManager configManager, File file) { configManager.tryLoad(this.rewards, new File(file, "reward.yml")); configManager.tryLoad(this.settings, new File(file, "settings.yml")); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/message/TNTTagMessages.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/message/TNTTagMessages.java index ec6fa9c..25700e3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/message/TNTTagMessages.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/config/message/TNTTagMessages.java @@ -16,33 +16,33 @@ public class TNTTagMessages extends BaseGameMessages { @Setting("delimiter-final") private String delimiterFinal = " &eand "; @Setting("it-name-tag") - private String itNameTag = Strings.a("&c[It] "); + private String itNameTag = Strings.colorize("&c[It] "); @Setting("player-is-it") - private Text playerIsIt = TextParser.a("%player% &7is IT!"); + private Text playerIsIt = TextParser.parse("%player% &7is IT!"); @Setting("player-blew-up") - private Text playerBlewUp = TextParser.a("%player% &eblew up!"); + private Text playerBlewUp = TextParser.parse("%player% &eblew up!"); @Setting("player-tagged") - private Text playerTagged = TextParser.a("&7%player% &ctagged you!"); + private Text playerTagged = TextParser.parse("&7%player% &ctagged you!"); @Setting("player-you-tagged") - private Text playerYouTagged = TextParser.a("&aYou tagged &7%player%&a!"); + private Text playerYouTagged = TextParser.parse("&aYou tagged &7%player%&a!"); @Setting("nearest-player") - private String nearestPlayer = Strings.a("&aNearest Player"); + private String nearestPlayer = Strings.colorize("&aNearest Player"); @Setting("action-bar") - private Text actionBar = TextParser.a("You're IT, tag someone!#&aRun away!>"); + private Text actionBar = TextParser.parse("You're IT, tag someone!#&aRun away!>"); @Setting("statistic-wins") - private String statisticWins = Strings.a("Wins"); + private String statisticWins = Strings.colorize("Wins"); @Setting("statistic-win-streak") - private String statisticWinStreak = Strings.a("Win Streak"); + private String statisticWinStreak = Strings.colorize("Win Streak"); @Setting("statistic-current-win-streak") - private String statisticCurrentWinStreak = Strings.a("Current Win Streak"); + private String statisticCurrentWinStreak = Strings.colorize("Current Win Streak"); @Setting("statistic-loses") - private String statisticLoses = Strings.a("Loses"); + private String statisticLoses = Strings.colorize("Loses"); @Setting("statistic-kills") - private String statisticKills = Strings.a("Kills"); + private String statisticKills = Strings.colorize("Kills"); @Setting("statistic-deaths") - private String statisticDeaths = Strings.a("Deaths"); + private String statisticDeaths = Strings.colorize("Deaths"); @Setting("start") - private List start = TextParser.a( + private List start = TextParser.parseAll( new String[]{ "&a%line%", " &lTNT Tag", @@ -54,7 +54,7 @@ public class TNTTagMessages extends BaseGameMessages { } ); @Setting("round-start") - private List roundStart = TextParser.a( + private List roundStart = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -66,7 +66,7 @@ public class TNTTagMessages extends BaseGameMessages { } ); @Setting("round-deathmatch") - private List roundDeathmatch = TextParser.a( + private List roundDeathmatch = TextParser.parseAll( new String[]{ "&a%line%", " ", @@ -79,9 +79,9 @@ public class TNTTagMessages extends BaseGameMessages { } ); @Setting("ending-draw") - private List endingDraw = TextParser.a(new String[]{"&a%line%", " &lTNT Tag", " ", "&e Winner &7- &cDRAW!", " ", "&a%line%"}); + private List endingDraw = TextParser.parseAll(new String[]{"&a%line%", " &lTNT Tag", " ", "&e Winner &7- &cDRAW!", " ", "&a%line%"}); @Setting("ending-top") - private List endingTop = TextParser.a( + private List endingTop = TextParser.parseAll( new String[]{ "&a%line%", " &lTNT Tag", @@ -94,7 +94,7 @@ public class TNTTagMessages extends BaseGameMessages { } ); @Setting("sidebar-playing") - private List sidebarPlaying = TextParser.a( + private List sidebarPlaying = TextParser.parseAll( new String[]{ "&7Round #%round%", " ", @@ -110,7 +110,7 @@ public class TNTTagMessages extends BaseGameMessages { ); public TNTTagMessages() { - this.statisticsView = TextParser.a( + this.statisticsView = TextParser.parseAll( new String[]{" ", " &l%display_name% Statistics", " ", " Wins&a: %wins%", " Loses&a: %loses%", " Played&a: %played%", " Kills&a: %kills%", " "} ); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/lifecycle/TNTTagLifecycle.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/lifecycle/TNTTagLifecycle.java index 5aa7eb7..2335797 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/lifecycle/TNTTagLifecycle.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/lifecycle/TNTTagLifecycle.java @@ -11,15 +11,15 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase; public class TNTTagLifecycle implements Lifecycle { private final Phase phase; - private final Phase phase2; - private final Phase phase3; - private final Phase phase4; + private final Phase playingPhase; + private final Phase endingPhase; + private final Phase resettingPhase; public TNTTagLifecycle(TNTTagGame tNTTagGame) { this.phase = new WaitingPhase(tNTTagGame); - this.phase2 = new TNTTagPlayingPhase(tNTTagGame); - this.phase3 = new EndingPhase(tNTTagGame); - this.phase4 = new ResettingPhase(tNTTagGame); + this.playingPhase = new TNTTagPlayingPhase(tNTTagGame); + this.endingPhase = new EndingPhase(tNTTagGame); + this.resettingPhase = new ResettingPhase(tNTTagGame); } public Phase getWaiting() { @@ -27,14 +27,14 @@ public class TNTTagLifecycle implements Lifecycle { } public Phase getPlaying() { - return this.phase2; + return this.playingPhase; } public Phase getEnding() { - return this.phase3; + return this.endingPhase; } public Phase getResetting() { - return this.phase4; + return this.resettingPhase; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/listener/TNTTagListener.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/listener/TNTTagListener.java index faab944..217f196 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/listener/TNTTagListener.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/listener/TNTTagListener.java @@ -23,42 +23,42 @@ public class TNTTagListener extends GameListener { } @EventHandler - public void a(EntityDamageEvent event) { - TNTTagGamer tNTTagGamer = this.a(event.getEntity(), TNTTagGamer.class); - if (tNTTagGamer != null && !tNTTagGamer.f()) { + public void onEntityDamage(EntityDamageEvent event) { + TNTTagGamer tNTTagGamer = this.getActiveGamer(event.getEntity(), TNTTagGamer.class); + if (tNTTagGamer != null && !tNTTagGamer.isSpectator()) { tNTTagGamer.toPlayer().setHealth(20.0); event.setDamage(0.1); } } @EventHandler - public void a(PlayerMoveEvent event) { + public void onPlayerMove(PlayerMoveEvent event) { Location location = event.getTo(); Player player = event.getPlayer(); - TNTTagGamer tNTTagGamer = this.a(player, TNTTagGamer.class); - if (tNTTagGamer != null && location != null && !Locations.a(event.getFrom(), location)) { + TNTTagGamer tNTTagGamer = this.getActiveGamer(player, TNTTagGamer.class); + if (tNTTagGamer != null && location != null && !Locations.isSameBlock(event.getFrom(), location)) { TNTTagGame tNTTagGame = tNTTagGamer.getGame(); - if (tNTTagGamer.f() && !tNTTagGame.getMap().getPlayZone().a(location)) { + if (tNTTagGamer.isSpectator() && !tNTTagGame.getMap().getPlayZone().contains(location)) { player.setFlying(true); - tNTTagGamer.a(tNTTagGame.getMap().getSpectator()); + tNTTagGamer.teleport(tNTTagGame.getMap().getSpectator()); } } } @EventHandler - public void a(EntityDamageByEntityEvent event) { - TNTTagGamer tNTTagGamer = this.a(event.getEntity(), TNTTagGamer.class); - if (tNTTagGamer != null && !tNTTagGamer.f()) { + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + TNTTagGamer tNTTagGamer = this.getActiveGamer(event.getEntity(), TNTTagGamer.class); + if (tNTTagGamer != null && !tNTTagGamer.isSpectator()) { Player player = tNTTagGamer.toPlayer(); - TNTTagGamer tNTTagGamer2 = this.a(event.getDamager(), TNTTagGamer.class); - if (tNTTagGamer2 != null && !tNTTagGamer2.f()) { + TNTTagGamer tNTTagGamer2 = this.getActiveGamer(event.getDamager(), TNTTagGamer.class); + if (tNTTagGamer2 != null && !tNTTagGamer2.isSpectator()) { TNTTagGame tNTTagGame = tNTTagGamer.getGame(); - if (tNTTagGamer2.q() && !tNTTagGamer.q()) { - tNTTagGamer2.s(); - tNTTagGamer.a(tNTTagGamer2); + if (tNTTagGamer2.isIt() && !tNTTagGamer.isIt()) { + tNTTagGamer2.clearItState(); + tNTTagGamer.tagFrom(tNTTagGamer2); tNTTagGamer.sendMessage(tNTTagGame.getMessages().getPlayerTagged(), tNTTagGamer2); tNTTagGamer2.sendMessage(tNTTagGame.getMessages().getPlayerYouTagged(), tNTTagGamer); - Firework firework = Fireworks.a(player.getEyeLocation().add(0.0, 0.3, 0.0), tNTTagGame.getSettings().getFireworkType(), tNTTagGame.getSettings().getFireworkColors()); + Firework firework = Fireworks.spawn(player.getEyeLocation().add(0.0, 0.3, 0.0), tNTTagGame.getSettings().getFireworkType(), tNTTagGame.getSettings().getFireworkColors()); FireworkMeta fireworkMeta = firework.getFireworkMeta(); fireworkMeta.setPower(tNTTagGame.getSettings().getFireworkPower()); firework.setFireworkMeta(fireworkMeta); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/phase/TNTTagPlayingPhase.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/phase/TNTTagPlayingPhase.java index 8cb9420..9aff918 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/phase/TNTTagPlayingPhase.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/phase/TNTTagPlayingPhase.java @@ -17,11 +17,11 @@ import ro.fr33styler.arcade.support.text.Strings; public class TNTTagPlayingPhase implements Phase { - private int a; + private int round; - private int b; + private int intermissionCountdown; - private int c; + private int roundCountdown; private final TNTTagGame game; @@ -30,18 +30,18 @@ public class TNTTagPlayingPhase implements Phase { } public void start() { - this.a = 0; - this.game.setGamers((TNTTagGamer[]) this.game.getGamers().a(new TNTTagGamer[this.game.getGamers().size()])); + this.round = 0; + this.game.setGamers((TNTTagGamer[]) this.game.getGamers().toArray(new TNTTagGamer[this.game.getGamers().size()])); for (TNTTagGamer tNTTagGamer : this.game.getGamers()) { - this.game.getList20().add(tNTTagGamer); - tNTTagGamer.a(this.game.getMap().getSpawn()); + this.game.getAliveGamers().add(tNTTagGamer); + tNTTagGamer.teleport(this.game.getMap().getSpawn()); tNTTagGamer.toPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1)); } - this.a(); + this.startNextRound(); } public void stop() { - this.game.getList20().clear(); + this.game.getAliveGamers().clear(); this.game.setPhase(this.game.getPhaseLifecycle().getEnding()); } @@ -56,92 +56,92 @@ public class TNTTagPlayingPhase implements Phase { public String getVariable(String text) { return switch(text) { case "players_alive" -> - String.valueOf(this.game.getList20().size()); + String.valueOf(this.game.getAliveGamers().size()); case "round" -> - String.valueOf(this.a); + String.valueOf(this.round); case "countdown" -> - Strings.a(this.c, this.game.getSettings().getCountdown()); + Strings.formatProgressColor(this.roundCountdown, this.game.getSettings().getCountdown()); default -> null; }; } public Boolean getCondition(String text) { - return text.equals("TICKING") ? this.c % 2 == 0 : null; + return text.equals("TICKING") ? this.roundCountdown % 2 == 0 : null; } - public void a() { - this.a++; - this.c = this.game.getManager().getSettings().getCountdown(); - if (this.game.getList20().size() > this.game.getManager().getSettings().getDeathmatchAt()) { - this.b(); + public void startNextRound() { + this.round++; + this.roundCountdown = this.game.getManager().getSettings().getCountdown(); + if (this.game.getAliveGamers().size() > this.game.getManager().getSettings().getDeathmatchAt()) { + this.selectNormalRoundTaggers(); } else { - this.c(); + this.startDeathmatchRound(); } } - private void b() { - Collections.shuffle(this.game.getList20()); + private void selectNormalRoundTaggers() { + Collections.shuffle(this.game.getAliveGamers()); TNTTagSettings tNTTagSettings = this.game.getSettings(); int index = tNTTagSettings.getMinItEachRound(); int index2 = tNTTagSettings.getMaxItEachRound(); - int index3 = index == index2 ? index : Randoms.a().nextInt(index, index2); - List list = this.game.getList20().subList(0, index3); - list.forEach(TNTTagGamer::r); + int index3 = index == index2 ? index : Randoms.current().nextInt(index, index2); + List list = this.game.getAliveGamers().subList(0, index3); + list.forEach(TNTTagGamer::markAsIt); String text = this.game.getMessages().getDelimiter(); String text2 = this.game.getMessages().getDelimiterFinal(); - String text3 = Strings.a(text, text2, list, PlayerHandle::getName); + String text3 = Strings.join(text, text2, list, PlayerHandle::getName); for (TNTTagGamer tNTTagGamer : this.game.getGamers()) { - Context context = Contexts.a(tNTTagGamer, text4 -> text4.equals("it") ? text3 : null); + Context context = Contexts.withVariables(tNTTagGamer, text4 -> text4.equals("it") ? text3 : null); tNTTagGamer.sendMessages(this.game.getMessages().getRoundStart(), context); } } - private void c() { - TNTTagGamer tNTTagGamer = (TNTTagGamer) Randoms.a(this.game.getList20()); - tNTTagGamer.r(); + private void startDeathmatchRound() { + TNTTagGamer tNTTagGamer = (TNTTagGamer) Randoms.pickRandom(this.game.getAliveGamers()); + tNTTagGamer.markAsIt(); for (TNTTagGamer tNTTagGamer2 : this.game.getGamers()) { - tNTTagGamer2.a(this.game.getMap().getSpawn()); - Context context = Contexts.a(tNTTagGamer2, text -> text.equals("it") ? tNTTagGamer.getName() : null); + tNTTagGamer2.teleport(this.game.getMap().getSpawn()); + Context context = Contexts.withVariables(tNTTagGamer2, text -> text.equals("it") ? tNTTagGamer.getName() : null); tNTTagGamer2.sendMessages(this.game.getMessages().getRoundDeathmatch(), context); } } - private void d() { - this.b--; - if (this.b <= 0) { - this.a(); + private void tickIntermission() { + this.intermissionCountdown--; + if (this.intermissionCountdown <= 0) { + this.startNextRound(); } } - private void e() { - if (this.c > 0) { - this.c--; + private void tickRoundCountdown() { + if (this.roundCountdown > 0) { + this.roundCountdown--; } else { for (TNTTagGamer tNTTagGamer : this.game.getGamers()) { - if (tNTTagGamer.q() && !tNTTagGamer.f()) { - tNTTagGamer.o(); + if (tNTTagGamer.isIt() && !tNTTagGamer.isSpectator()) { + tNTTagGamer.detonate(); if (this.game.getPhase() != this) { return; } } } - this.b = 6; + this.intermissionCountdown = 6; } } public void onTick(long longVal) { if (longVal % 20L == 0L) { - if (this.b > 0) { - this.d(); + if (this.intermissionCountdown > 0) { + this.tickIntermission(); } else { - this.e(); + this.tickRoundCountdown(); } if (this.game.getPhase() != this) { return; } for (TNTTagGamer tNTTagGamer : this.game.getGamers()) { - tNTTagGamer.c(this.c); + tNTTagGamer.onSecondTick(this.roundCountdown); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/player/TNTTagGamer.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/player/TNTTagGamer.java index d542d65..3733b94 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/player/TNTTagGamer.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/player/TNTTagGamer.java @@ -17,10 +17,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class TNTTagGamer extends BaseGamer { - private int b; - private int c; - private boolean d; - private TNTTagGamer e; + private int kills; + private int placementScore; + private boolean it; + private TNTTagGamer lastTagger; private final TNTTagGame game; public TNTTagGamer(TNTTagGame game2, DefaultUser defaultUser) { @@ -32,69 +32,69 @@ public class TNTTagGamer extends BaseGamer { return this.game; } - public int m() { - return this.b; + public int getKills() { + return this.kills; } - public int n() { - return this.c; + public int getPlacementScore() { + return this.placementScore; } - public void o() { + public void detonate() { Location location = this.player.getLocation(); - this.b(this.e); - this.a(this.e, location); - this.game.v(); + this.eliminateBy(this.lastTagger); + this.explodeNearbyPlayers(this.lastTagger, location); + this.game.checkWinCondition(); } - private void b(TNTTagGamer tNTTagGamer) { - this.b(this.getLoses() + 1); + private void eliminateBy(TNTTagGamer tNTTagGamer) { + this.setLoses(this.getLoses() + 1); if (tNTTagGamer != null) { - tNTTagGamer.b++; + tNTTagGamer.kills++; } - this.game.getList20().remove(this); - this.b(true); + this.game.getAliveGamers().remove(this); + this.setSpectator(true); this.game.getSpectatorTeam().addEntry(this.player.getName()); - this.s(); + this.clearItState(); Location location = this.player.getEyeLocation(); VersionAdapters.get().spawnParticle(this.player.getWorld(), ArcadeParticle.EXPLOSION_LARGE, location, 3, 0.0, 0.0, 0.0, 0.0); VersionAdapters.get().playSound(this.player.getWorld(), location, ArcadeSound.GENERIC_EXPLODE, 1.0F, 1.0F); this.player.teleport(this.game.getMap().getSpectator()); for (TNTTagGamer tNTTagGamer2 : this.game.getGamers()) { - if (!tNTTagGamer2.f()) { - tNTTagGamer2.c++; + if (!tNTTagGamer2.isSpectator()) { + tNTTagGamer2.placementScore++; } tNTTagGamer2.sendMessage(this.game.getMessages().getPlayerBlewUp(), this); } } - private void a(TNTTagGamer tNTTagGamer, Location location) { + private void explodeNearbyPlayers(TNTTagGamer tNTTagGamer, Location location) { for (TNTTagGamer tNTTagGamer2 : this.game.getGamers()) { - if (!tNTTagGamer2.f() && !tNTTagGamer2.q() && location.distanceSquared(tNTTagGamer2.toPlayer().getLocation()) <= this.game.getSettings().getExplodeRadius()) { - tNTTagGamer2.b(tNTTagGamer); + if (!tNTTagGamer2.isSpectator() && !tNTTagGamer2.isIt() && location.distanceSquared(tNTTagGamer2.toPlayer().getLocation()) <= this.game.getSettings().getExplodeRadius()) { + tNTTagGamer2.eliminateBy(tNTTagGamer); } } } - public boolean q() { - return this.d; + public boolean isIt() { + return this.it; } - public void a(TNTTagGamer tNTTagGamer) { + public void tagFrom(TNTTagGamer tNTTagGamer) { if (tNTTagGamer != null) { - this.e = tNTTagGamer; - tNTTagGamer.e = null; + this.lastTagger = tNTTagGamer; + tNTTagGamer.lastTagger = null; } - this.r(); + this.markAsIt(); } - public void r() { - this.d = true; - this.game.getScoreboardTeam7().addEntry(this.player.getName()); + public void markAsIt() { + this.it = true; + this.game.getItTeam().addEntry(this.player.getName()); if (VersionAdapters.get().isPlayerHeadMaterial(this.game.getSettings().getItHead())) { this.player.getInventory().setHelmet(new ItemBuilder(ArcadeMaterial.PLAYER_HEAD).setConfiguredSkull(this.game.getManager().getEngine().getPlatform(), "IT_HEAD", this.game.getSettings().getItPlayerHeadUrl()).build()); } else { @@ -103,15 +103,15 @@ public class TNTTagGamer extends BaseGamer { this.player.getInventory().setItem(0, new ItemStack(this.game.getSettings().getItHand())); this.player.getInventory().setItem(1, new ItemBuilder(Material.COMPASS).setDisplayName(this.game.getMessages().getNearestPlayer()).build()); - this.game.getGamers().a(this.game.getMessages().getPlayerIsIt(), this); + this.game.getGamers().broadcast(this.game.getMessages().getPlayerIsIt(), this); this.player.removePotionEffect(PotionEffectType.SPEED); this.player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 63636366, 3)); } - public void s() { - this.d = false; - this.e = null; - this.game.getScoreboardTeam7().removeEntry(this.player.getName()); + public void clearItState() { + this.it = false; + this.lastTagger = null; + this.game.getItTeam().removeEntry(this.player.getName()); this.player.getInventory().setHelmet((org.bukkit.inventory.ItemStack)null); this.player.getInventory().setItem(0, null); this.player.getInventory().setItem(1, null); @@ -121,60 +121,60 @@ public class TNTTagGamer extends BaseGamer { @Override public Boolean getCondition(String text) { - return text.equals("IT") ? this.d : super.getCondition(text); + return text.equals("IT") ? this.it : super.getCondition(text); } - private void t() { + private void saveStatistics() { TNTTagStatistics tNTTagStatistics = this.game.getManager().getData(this.getUUID()); - if (tNTTagStatistics.a()) { - tNTTagStatistics.a(tNTTagStatistics.getWins() + this.getWins()); + if (tNTTagStatistics.isLoaded()) { + tNTTagStatistics.setWins(tNTTagStatistics.getWins() + this.getWins()); if (this.getWins() > 0) { - tNTTagStatistics.d(tNTTagStatistics.getCurrentWinStreak() + 1); + tNTTagStatistics.setCurrentWinStreak(tNTTagStatistics.getCurrentWinStreak() + 1); if (tNTTagStatistics.getWinStreak() < tNTTagStatistics.getCurrentWinStreak()) { - tNTTagStatistics.c(tNTTagStatistics.getCurrentWinStreak()); + tNTTagStatistics.setWinStreak(tNTTagStatistics.getCurrentWinStreak()); } } else if (this.getLoses() > 0) { - tNTTagStatistics.d(0); + tNTTagStatistics.setCurrentWinStreak(0); } - tNTTagStatistics.b(tNTTagStatistics.getLoses() + this.getLoses()); - tNTTagStatistics.e(tNTTagStatistics.d() + this.b); - this.b(tNTTagStatistics.getMap()); - this.game.getManager().getStorage().e().b(tNTTagStatistics); - this.game.getManager().getStorage().e().a(this); + tNTTagStatistics.setLoses(tNTTagStatistics.getLoses() + this.getLoses()); + tNTTagStatistics.setKills(tNTTagStatistics.getKills() + this.kills); + this.saveProperties(tNTTagStatistics.getMap()); + this.game.getManager().getStorage().getStatisticsRepository().saveStatistics(tNTTagStatistics); + this.game.getManager().getStorage().getStatisticsRepository().savePeriodicStatistics(this); } } @Override public void leave() { - this.t(); - this.game.getGamers().b(this); - this.game.getList20().remove(this); + this.saveStatistics(); + this.game.getGamers().remove(this); + this.game.getAliveGamers().remove(this); if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - this.game.v(); + this.game.checkWinCondition(); } super.leave(); } - private boolean c(TNTTagGamer tNTTagGamer) { - return !tNTTagGamer.q() && !tNTTagGamer.f(); + private boolean isUntaggedAlive(TNTTagGamer tNTTagGamer) { + return !tNTTagGamer.isIt() && !tNTTagGamer.isSpectator(); } - public void c(int index) { + public void onSecondTick(int index) { if (this.game.getPhase() == this.game.getPhaseLifecycle().getPlaying()) { - if (!this.f()) { - if (this.d) { + if (!this.isSpectator()) { + if (this.it) { Location location = this.player.getLocation(); - TNTTagGamer tNTTagGamer = (TNTTagGamer)this.game.getGamers().a(location, this::c); + TNTTagGamer tNTTagGamer = (TNTTagGamer)this.game.getGamers().getNearest(location, this::isUntaggedAlive); this.player.setCompassTarget(tNTTagGamer.toPlayer().getLocation()); } this.player.setExp(index / (this.game.getSettings().getCountdown() + 0.01F)); - this.b(this.game.getMessages().getActionBar()); + this.sendActionBar(this.game.getMessages().getActionBar()); } - this.a(this.game.getMessages().getSidebarPlaying(), this); + this.updateSidebar(this.game.getMessages().getSidebarPlaying(), this); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSession.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSession.java index adb808a..f4e010c 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSession.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSession.java @@ -22,11 +22,11 @@ public class TNTTagSession extends BaseSession { @Override public void addPlayer(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TNTTagGamer tNTTagGamer = new TNTTagGamer(this.game, defaultUser); - this.game.getGamers().a(tNTTagGamer); - tNTTagGamer.a(this.game.getMessages().getStart()); - tNTTagGamer.a(this.game.getMap().getLobby()); + this.game.getGamers().add(tNTTagGamer); + tNTTagGamer.sendMessages(this.game.getMessages().getStart()); + tNTTagGamer.teleport(this.game.getMap().getLobby()); return tNTTagGamer; }); } @@ -40,7 +40,7 @@ public class TNTTagSession extends BaseSession { public Result canSpectate(User user) { if (user.getGamer() instanceof TNTTagGamer var2) { TNTTagGame tNTTagGame = var2.getGame(); - if (tNTTagGame.getPhase() != tNTTagGame.getPhaseLifecycle().getEnding() || !var2.g()) { + if (tNTTagGame.getPhase() != tNTTagGame.getPhaseLifecycle().getEnding() || !var2.isActiveSpectator()) { return new Result(false, tNTTagGame.getMessages().getJoinAlreadyInGame()); } } @@ -50,12 +50,12 @@ public class TNTTagSession extends BaseSession { @Override public void addSpectator(User user) { - this.a(user, defaultUser -> { + this.joinGamer(user, defaultUser -> { TNTTagGamer tNTTagGamer = new TNTTagGamer(this.game, defaultUser); - this.game.getGamers().a(tNTTagGamer); - tNTTagGamer.a(this.game.getMap().getSpectator()); - tNTTagGamer.b(true); - tNTTagGamer.getSpectatorOptions().e(true); + this.game.getGamers().add(tNTTagGamer); + tNTTagGamer.teleport(this.game.getMap().getSpectator()); + tNTTagGamer.setSpectator(true); + tNTTagGamer.getSpectatorOptions().setExternal(true); this.game.getSpectatorTeam().addEntry(tNTTagGamer.getName()); return tNTTagGamer; }); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSessions.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSessions.java index 2d4428b..65b6947 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSessions.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/session/TNTTagSessions.java @@ -9,41 +9,41 @@ import ro.fr33styler.arcade.game.tnttag.map.TNTTagMap; import org.bukkit.World; public class TNTTagSessions extends BaseSessions { - private final TNTTagManager a; + private final TNTTagManager manager; public TNTTagSessions(TNTTagManager tNTTagManager) { super(tNTTagManager); - this.a = tNTTagManager; + this.manager = tNTTagManager; } public TNTTagManager getManager() { - return this.a; + return this.manager; } @Override - public void a() { - this.a.getStorage().getStorage().a(tNTTagMap -> this.registerGame(new TNTTagGame(this.a, tNTTagMap))); - this.a.getStorage().getStorage5().a(this::b); + public void load() { + this.manager.getStorage().getStorage().loadAll(tNTTagMap -> this.registerGame(new TNTTagGame(this.manager, tNTTagMap))); + this.manager.getStorage().getTemplateStorage().loadAll(this::registerTemplate); } - protected TNTTagMap h(String text) { + protected TNTTagMap createMap(String text) { TNTTagMap tNTTagMap = new TNTTagMap(); tNTTagMap.setId(text); return tNTTagMap; } - protected TNTTagGame a(TNTTagMap tNTTagMap) { - return new TNTTagGame(this.a, tNTTagMap); + protected TNTTagGame createGame(TNTTagMap tNTTagMap) { + return new TNTTagGame(this.manager, tNTTagMap); } public TNTTagSession createSession(TNTTagGame tNTTagGame) { return tNTTagGame == null ? null : new TNTTagSession(tNTTagGame); } - protected void a(TNTTagMap tNTTagMap, World world, TNTTagMap tNTTagMap2) { - super.a(tNTTagMap, world, tNTTagMap2); - tNTTagMap2.setSpawn(Locations.a(world, tNTTagMap.getSpawn())); - tNTTagMap2.setPlayZone(tNTTagMap.getPlayZone().a(world)); - tNTTagMap2.setSpectator(Locations.a(world, tNTTagMap.getSpectator())); + protected void copyMap(TNTTagMap tNTTagMap, World world, TNTTagMap tNTTagMap2) { + super.copyMap(tNTTagMap, world, tNTTagMap2); + tNTTagMap2.setSpawn(Locations.withWorld(world, tNTTagMap.getSpawn())); + tNTTagMap2.setPlayZone(tNTTagMap.getPlayZone().withWorld(world)); + tNTTagMap2.setSpectator(Locations.withWorld(world, tNTTagMap.getSpectator())); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/TNTTagSetup.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/TNTTagSetup.java index 95ca844..26da20f 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/TNTTagSetup.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/TNTTagSetup.java @@ -13,24 +13,24 @@ import org.bukkit.World; public class TNTTagSetup extends ArenaSetup { private final TNTTagMap map; - private final TNTTagManager d; + private final TNTTagManager manager; private final SetupTarget setupTarget; public TNTTagSetup(DefaultUser defaultUser, TNTTagMap map2, TNTTagManager tNTTagManager, SetupTarget setupTarget2) { super(defaultUser, tNTTagManager.getName()); - this.d = tNTTagManager; + this.manager = tNTTagManager; this.map = map2; this.setupTarget = setupTarget2; this.setupStep = new TNTTagSetArenaNameStep(this); } - public TNTTagMap getMap42() { + public TNTTagMap getMap() { return this.map; } @Override - public void f() { - super.f(); + public void finish() { + super.finish(); if (this.setupTarget == SetupTarget.TEMPLATE) { World world = this.map.getLobby().getWorld(); if (world == null) { @@ -38,11 +38,11 @@ public class TNTTagSetup extends ArenaSetup { } GameTemplate gameTemplate = new GameTemplate(this.map.getId(), this.map); - this.d.getSessions().b(gameTemplate); - this.d.getWorldProvider().a(gameTemplate); + this.manager.getSessions().registerTemplate(gameTemplate); + this.manager.getWorldProvider().saveTemplate(gameTemplate); } else if (this.setupTarget == SetupTarget.MAP) { - this.d.getSessions().registerGame(new TNTTagGame(this.d, this.map)); - this.d.getStorage().getStorage().a(this.map); + this.manager.getSessions().registerGame(new TNTTagGame(this.manager, this.map)); + this.manager.getStorage().getStorage().save(this.map); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetArenaNameStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetArenaNameStep.java index 0049146..e1ae6ab 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetArenaNameStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetArenaNameStep.java @@ -10,12 +10,12 @@ public class TNTTagSetArenaNameStep implements ChatSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { this.tNTTagSetup.getUser().sendMessage("§e Type the arena name in chat."); } - public void a(String text) { - this.tNTTagSetup.getMap42().setName(text); - this.tNTTagSetup.a(new TNTTagSetLobbySpawnStep(this.tNTTagSetup)); + public void onChatInput(String text) { + this.tNTTagSetup.getMap().setName(text); + this.tNTTagSetup.advanceStep(new TNTTagSetLobbySpawnStep(this.tNTTagSetup)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbyRemovalRegionStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbyRemovalRegionStep.java index c835b24..5fa6ea1 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbyRemovalRegionStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbyRemovalRegionStep.java @@ -17,7 +17,7 @@ public class TNTTagSetLobbyRemovalRegionStep implements ClickSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the lobby for removal"); @@ -25,29 +25,29 @@ public class TNTTagSetLobbyRemovalRegionStep implements ClickSetupStep { defaultUser.sendMessage("§e click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); - this.tNTTagSetup.getHotbar().a(0, () -> { + this.tNTTagSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.tNTTagSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.tNTTagSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - this.tNTTagSetup.getMap42().setLobbyZone(new Cuboid(block, block2)); - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.tNTTagSetup.a(new TNTTagSetPlayZoneStep(this.tNTTagSetup)); + this.tNTTagSetup.getMap().setLobbyZone(new Cuboid(block, block2)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.tNTTagSetup.advanceStep(new TNTTagSetPlayZoneStep(this.tNTTagSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby zone").build()); - this.tNTTagSetup.getHotbar().a(2, () -> { - this.tNTTagSetup.getMap42().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); - this.tNTTagSetup.a(new TNTTagSetPlayZoneStep(this.tNTTagSetup)); + this.tNTTagSetup.getHotbar().setSlot(2, () -> { + this.tNTTagSetup.getMap().setLobbyZone((ro.fr33styler.arcade.engine.world.region.Cuboid) null); + this.tNTTagSetup.advanceStep(new TNTTagSetPlayZoneStep(this.tNTTagSetup)); }, new ItemBuilder(ArcadeMaterial.YELLOW_DYE).setDisplayName("§a§lSkip step").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbySpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbySpawnStep.java index 6d054cf..9732ef7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbySpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetLobbySpawnStep.java @@ -15,17 +15,17 @@ public class TNTTagSetLobbySpawnStep implements ClickSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); defaultUser.sendMessage("§e Please click the green dye to set where the"); defaultUser.sendMessage("§e players spawn in the lobby."); } - public void a() { + public void configureHotbar() { Player player = this.tNTTagSetup.getUser().toPlayer(); - this.tNTTagSetup.getHotbar().a(0, () -> { - this.tNTTagSetup.getMap42().setLobby(player.getLocation()); - this.tNTTagSetup.a(new TNTTagSetLobbyRemovalRegionStep(this.tNTTagSetup)); + this.tNTTagSetup.getHotbar().setSlot(0, () -> { + this.tNTTagSetup.getMap().setLobby(player.getLocation()); + this.tNTTagSetup.advanceStep(new TNTTagSetLobbyRemovalRegionStep(this.tNTTagSetup)); }, new ItemBuilder(ArcadeMaterial.LIME_DYE).setDisplayName("§a§lSet lobby").build()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayZoneStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayZoneStep.java index 2c53133..157dc44 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayZoneStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayZoneStep.java @@ -17,29 +17,29 @@ public class TNTTagSetPlayZoneStep implements ClickSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); defaultUser.sendMessage("§e Make a selection using the selection tool, then"); defaultUser.sendMessage("§e click the lime dye to set the play zone. If you"); defaultUser.sendMessage("§e can't click a block, your feet will be used."); } - public boolean d() { + public boolean usesSelectionTool() { return true; } - public void a() { + public void configureHotbar() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); - this.tNTTagSetup.getHotbar().a(0, () -> { + this.tNTTagSetup.getHotbar().setSlot(0, () -> { }, new ItemBuilder(Material.DIAMOND_SWORD).setDisplayName("§a§lSelection Tool").build()); - this.tNTTagSetup.getHotbar().a(1, () -> { - Block block = defaultUser.k(); - Block block2 = defaultUser.l(); + this.tNTTagSetup.getHotbar().setSlot(1, () -> { + Block block = defaultUser.getSelectionPos1(); + Block block2 = defaultUser.getSelectionPos2(); if (block != null && block2 != null && block.getWorld() == block2.getWorld()) { - defaultUser.a((org.bukkit.block.Block) null); - defaultUser.b((org.bukkit.block.Block) null); - this.tNTTagSetup.getMap42().setPlayZone(new Cuboid(block, block2)); - this.tNTTagSetup.a(new TNTTagSetSpectatorSpawnStep(this.tNTTagSetup)); + defaultUser.setSelectionPos1((org.bukkit.block.Block) null); + defaultUser.setSelectionPos2((org.bukkit.block.Block) null); + this.tNTTagSetup.getMap().setPlayZone(new Cuboid(block, block2)); + this.tNTTagSetup.advanceStep(new TNTTagSetSpectatorSpawnStep(this.tNTTagSetup)); } else { defaultUser.sendMessage("§cMust make a selection!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayerSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayerSpawnStep.java index 5657f89..e81bbc0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayerSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetPlayerSpawnStep.java @@ -17,19 +17,19 @@ public class TNTTagSetPlayerSpawnStep implements ClickSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the players"); defaultUser.sendMessage("§e spawn at."); } - public void a() { + public void configureHotbar() { Player player = this.tNTTagSetup.getUser().toPlayer(); - this.tNTTagSetup.getHotbar().a(0, () -> { + this.tNTTagSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.tNTTagSetup.getMap42().getPlayZone().a(location)) { - this.tNTTagSetup.getMap42().setSpawn(location); - this.tNTTagSetup.a((ro.fr33styler.arcade.engine.setup.SetupStep) null); + if (this.tNTTagSetup.getMap().getPlayZone().contains(location)) { + this.tNTTagSetup.getMap().setSpawn(location); + this.tNTTagSetup.advanceStep((ro.fr33styler.arcade.engine.setup.SetupStep) null); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetSpectatorSpawnStep.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetSpectatorSpawnStep.java index d48d994..66b41c7 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetSpectatorSpawnStep.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/setup/step/TNTTagSetSpectatorSpawnStep.java @@ -16,19 +16,19 @@ public class TNTTagSetSpectatorSpawnStep implements ClickSetupStep { this.tNTTagSetup = tNTTagSetup2; } - public void c() { + public void sendInstructions() { DefaultUser defaultUser = this.tNTTagSetup.getUser(); defaultUser.sendMessage("§e Click the green dye to set where the spectators"); defaultUser.sendMessage("§e are teleported to."); } - public void a() { + public void configureHotbar() { Player player = this.tNTTagSetup.getUser().toPlayer(); - this.tNTTagSetup.getHotbar().a(0, () -> { + this.tNTTagSetup.getHotbar().setSlot(0, () -> { Location location = player.getLocation(); - if (this.tNTTagSetup.getMap42().getPlayZone().a(location)) { - this.tNTTagSetup.getMap42().setSpectator(location); - this.tNTTagSetup.a(new TNTTagSetPlayerSpawnStep(this.tNTTagSetup)); + if (this.tNTTagSetup.getMap().getPlayZone().contains(location)) { + this.tNTTagSetup.getMap().setSpectator(location); + this.tNTTagSetup.advanceStep(new TNTTagSetPlayerSpawnStep(this.tNTTagSetup)); } else { player.sendMessage("§cMust be inside the Play Zone!"); } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/TNTTagStatistics.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/TNTTagStatistics.java index 92ffdc7..97a9120 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/TNTTagStatistics.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/TNTTagStatistics.java @@ -8,32 +8,32 @@ import ro.fr33styler.arcade.game.tnttag.player.TNTTagGamer; import java.util.UUID; public class TNTTagStatistics extends BaseGameStatistics { - private int b; + private int kills; public TNTTagStatistics(TNTTagManager tNTTagManager, UUID uuid, String text) { super(tNTTagManager, uuid, text); } - public int d() { - return this.b; + public int getKills() { + return this.kills; } - public void e(int index) { - this.b = index; + public void setKills(int index) { + this.kills = index; } @Override - public String a(String text) { + public String resolvePlaceholder(String text) { if (text.equals("it")) { DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(this.getUUID()); - return defaultUser != null && defaultUser.getGamer() instanceof TNTTagGamer var3 ? String.valueOf(var3.q()) : "false"; + return defaultUser != null && defaultUser.getGamer() instanceof TNTTagGamer var3 ? String.valueOf(var3.isIt()) : "false"; } else { - return text.equals("stats_kills") ? String.valueOf(this.b) : super.a(text); + return text.equals("stats_kills") ? String.valueOf(this.kills) : super.resolvePlaceholder(text); } } @Override public String getVariable(String text) { - return text.equals("kills") ? String.valueOf(this.b) : super.getVariable(text); + return text.equals("kills") ? String.valueOf(this.kills) : super.getVariable(text); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/storage/TNTTagStatisticsRepository.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/storage/TNTTagStatisticsRepository.java index 5d5edb4..94ba01d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/storage/TNTTagStatisticsRepository.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/statistics/storage/TNTTagStatisticsRepository.java @@ -14,105 +14,105 @@ public class TNTTagStatisticsRepository extends GameStatisticsRepository { } @Override - public void b() { - this.g(); - this.a() - .a("CREATE TABLE IF NOT EXISTS " + this.b + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a().a("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + public void createTables() { + this.migrateLegacyTables(); + this.getDatabase() + .executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + " (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase().executeAsync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); } - public void a(TNTTagStatistics tNTTagStatistics) { - this.a().a("SELECT * FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void loadStatistics(TNTTagStatistics tNTTagStatistics) { + this.getDatabase().executeAsync("SELECT * FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTTagStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.a(tNTTagStatistics, var3); + this.readStatistics(tNTTagStatistics, var3); } - tNTTagStatistics.a(true); + tNTTagStatistics.setLoaded(true); } }); } - private void a(TNTTagStatistics tNTTagStatistics, ResultSet resultSet) throws java.sql.SQLException { - tNTTagStatistics.b(resultSet.getString("options")); - tNTTagStatistics.a(resultSet.getInt("wins")); - tNTTagStatistics.c(resultSet.getInt("win_streak")); - tNTTagStatistics.d(resultSet.getInt("current_win_streak")); - tNTTagStatistics.b(resultSet.getInt("loses")); - tNTTagStatistics.e(resultSet.getInt("kills")); + private void readStatistics(TNTTagStatistics tNTTagStatistics, ResultSet resultSet) throws java.sql.SQLException { + tNTTagStatistics.deserializeProperties(resultSet.getString("options")); + tNTTagStatistics.setWins(resultSet.getInt("wins")); + tNTTagStatistics.setWinStreak(resultSet.getInt("win_streak")); + tNTTagStatistics.setCurrentWinStreak(resultSet.getInt("current_win_streak")); + tNTTagStatistics.setLoses(resultSet.getInt("loses")); + tNTTagStatistics.setKills(resultSet.getInt("kills")); } - public void b(TNTTagStatistics tNTTagStatistics) { - this.a().a("SELECT id FROM " + this.b + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + public void saveStatistics(TNTTagStatistics tNTTagStatistics) { + this.getDatabase().executeAsync("SELECT id FROM " + this.tableName + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTTagStatistics.getUUID().toString()); try (ResultSet var3 = preparedStatement.executeQuery()) { if (var3.next()) { - this.d(tNTTagStatistics); + this.updateStatistics(tNTTagStatistics); } else { - this.c(tNTTagStatistics); + this.insertStatistics(tNTTagStatistics); } } }); } - private void c(TNTTagStatistics tNTTagStatistics) { - this.a().a("INSERT INTO " + this.b + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertStatistics(TNTTagStatistics tNTTagStatistics) { + this.getDatabase().executeAsync("INSERT INTO " + this.tableName + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, tNTTagStatistics.getUUID().toString()); - preparedStatement.setString(2, tNTTagStatistics.c()); + preparedStatement.setString(2, tNTTagStatistics.serializeProperties()); preparedStatement.setInt(3, tNTTagStatistics.getWins()); preparedStatement.setInt(4, tNTTagStatistics.getWinStreak()); preparedStatement.setInt(5, tNTTagStatistics.getCurrentWinStreak()); preparedStatement.setInt(6, tNTTagStatistics.getLoses()); - preparedStatement.setInt(7, tNTTagStatistics.d()); + preparedStatement.setInt(7, tNTTagStatistics.getKills()); preparedStatement.executeUpdate(); }); } - private void d(TNTTagStatistics tNTTagStatistics) { - this.a() - .a( + private void updateStatistics(TNTTagStatistics tNTTagStatistics) { + this.getDatabase() + .executeAsync( "UPDATE " - + this.b + + this.tableName + " SET options = ?, wins = ?, win_streak = ?, current_win_streak = ?, loses = ?, kills = ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { - preparedStatement.setString(1, tNTTagStatistics.c()); + preparedStatement.setString(1, tNTTagStatistics.serializeProperties()); preparedStatement.setInt(2, tNTTagStatistics.getWins()); preparedStatement.setInt(3, tNTTagStatistics.getWinStreak()); preparedStatement.setInt(4, tNTTagStatistics.getCurrentWinStreak()); preparedStatement.setInt(5, tNTTagStatistics.getLoses()); - preparedStatement.setInt(6, tNTTagStatistics.d()); + preparedStatement.setInt(6, tNTTagStatistics.getKills()); preparedStatement.setString(7, tNTTagStatistics.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - public void a(TNTTagGamer tNTTagGamer) { - this.a(this.b + "_weekly", tNTTagGamer); - this.a(this.b + "_monthly", tNTTagGamer); + public void savePeriodicStatistics(TNTTagGamer tNTTagGamer) { + this.upsertPeriodicStatistics(this.tableName + "_weekly", tNTTagGamer); + this.upsertPeriodicStatistics(this.tableName + "_monthly", tNTTagGamer); } - private void a(String text, TNTTagGamer tNTTagGamer) { - this.a().a("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.a().b() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { + private void upsertPeriodicStatistics(String text, TNTTagGamer tNTTagGamer) { + this.getDatabase().executeAsync("SELECT id FROM " + text + " WHERE id IN (SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?) LIMIT 1;", preparedStatement -> { preparedStatement.setString(1, tNTTagGamer.getUUID().toString()); try (ResultSet var4 = preparedStatement.executeQuery()) { if (var4.next()) { - this.b(text, tNTTagGamer); + this.updatePeriodicStatistics(text, tNTTagGamer); } else { - this.c(text, tNTTagGamer); + this.insertPeriodicStatistics(text, tNTTagGamer); } } }); } - private void b(String text, TNTTagGamer tNTTagGamer) { + private void updatePeriodicStatistics(String text, TNTTagGamer tNTTagGamer) { String text2 = "current_win_streak"; if (tNTTagGamer.getWins() > 0) { text2 = "current_win_streak + 1"; @@ -120,9 +120,9 @@ public class TNTTagStatisticsRepository extends GameStatisticsRepository { text2 = "0"; } - String text3 = this.a() instanceof MysqlDatabase ? "GREATEST" : "MAX"; - this.a() - .a( + String text3 = this.getDatabase() instanceof MysqlDatabase ? "GREATEST" : "MAX"; + this.getDatabase() + .executeAsync( "UPDATE " + text + " SET wins = wins + ?, win_streak = " @@ -132,76 +132,76 @@ public class TNTTagStatisticsRepository extends GameStatisticsRepository { + "), current_win_streak = " + text2 + ", loses = loses + ?, kills = kills + ? WHERE id IN (SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ?);", preparedStatement -> { preparedStatement.setInt(1, tNTTagGamer.getWins()); preparedStatement.setInt(2, tNTTagGamer.getLoses()); - preparedStatement.setInt(3, tNTTagGamer.m()); + preparedStatement.setInt(3, tNTTagGamer.getKills()); preparedStatement.setString(4, tNTTagGamer.getUUID().toString()); preparedStatement.executeUpdate(); } ); } - private void c(String text, TNTTagGamer tNTTagGamer) { - this.a().a("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.a().b() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { + private void insertPeriodicStatistics(String text, TNTTagGamer tNTTagGamer) { + this.getDatabase().executeAsync("INSERT INTO " + text + " VALUES ((SELECT id FROM " + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement -> { preparedStatement.setString(1, tNTTagGamer.getUUID().toString()); preparedStatement.setInt(2, tNTTagGamer.getWins()); preparedStatement.setInt(3, tNTTagGamer.getWins()); preparedStatement.setInt(4, tNTTagGamer.getWins()); preparedStatement.setInt(5, tNTTagGamer.getLoses()); - preparedStatement.setInt(6, tNTTagGamer.m()); + preparedStatement.setInt(6, tNTTagGamer.getKills()); preparedStatement.executeUpdate(); }); } - private void e() { - this.a() - .b( + private void createMigrationTables() { + this.getDatabase() + .executeSync( "CREATE TABLE IF NOT EXISTS " - + this.b + + this.tableName + "_new (id INT UNIQUE, options TEXT, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);" ); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); - this.a() - .b("CREATE TABLE IF NOT EXISTS " + this.b + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_weekly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); + this.getDatabase() + .executeSync("CREATE TABLE IF NOT EXISTS " + this.tableName + "_monthly_new (id INT UNIQUE, wins INT, win_streak INT, current_win_streak INT, loses INT, kills INT);"); } - private void f() { - this.a().b("DROP TABLE IF EXISTS " + this.b + ";"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_weekly;"); - this.a().b("DROP TABLE IF EXISTS " + this.b + "_monthly;"); - if (this.a() instanceof MysqlDatabase) { - this.a().b("RENAME TABLE " + this.b + "_new TO " + this.b + ";"); - this.a().b("RENAME TABLE " + this.b + "_weekly_new TO " + this.b + "_weekly;"); - this.a().b("RENAME TABLE " + this.b + "_monthly_new TO " + this.b + "_monthly;"); + private void swapMigrationTables() { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + ";"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_monthly;"); + if (this.getDatabase() instanceof MysqlDatabase) { + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_new TO " + this.tableName + ";"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_weekly_new TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("RENAME TABLE " + this.tableName + "_monthly_new TO " + this.tableName + "_monthly;"); } else { - this.a().b("ALTER TABLE " + this.b + "_new RENAME TO " + this.b + ";"); - this.a().b("ALTER TABLE " + this.b + "_weekly_new RENAME TO " + this.b + "_weekly;"); - this.a().b("ALTER TABLE " + this.b + "_monthly_new RENAME TO " + this.b + "_monthly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_new RENAME TO " + this.tableName + ";"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_weekly_new RENAME TO " + this.tableName + "_weekly;"); + this.getDatabase().executeSync("ALTER TABLE " + this.tableName + "_monthly_new RENAME TO " + this.tableName + "_monthly;"); } } - private void g() { - if (this.a().a(this.b, "wins") && !this.a().a(this.b, "current_win_streak")) { - this.engine.getLogger().sendWarn("Upgrading " + this.b + " to the newer format. Please don't stop the server!"); - this.e(); - this.a(this.b, true); - this.a(this.b + "_weekly", false); - this.a(this.b + "_monthly", false); - if (!this.b.equals(this.a().b())) { - this.a().b("DROP TABLE IF EXISTS " + this.b + "_time;"); + private void migrateLegacyTables() { + if (this.getDatabase().hasColumn(this.tableName, "wins") && !this.getDatabase().hasColumn(this.tableName, "current_win_streak")) { + this.engine.getLogger().sendWarn("Upgrading " + this.tableName + " to the newer format. Please don't stop the server!"); + this.createMigrationTables(); + this.migrateTableData(this.tableName, true); + this.migrateTableData(this.tableName + "_weekly", false); + this.migrateTableData(this.tableName + "_monthly", false); + if (!this.tableName.equals(this.getDatabase().getTablePrefix())) { + this.getDatabase().executeSync("DROP TABLE IF EXISTS " + this.tableName + "_time;"); } - this.f(); + this.swapMigrationTables(); } } - private void a(String text, boolean flag) { - this.a() - .b( + private void migrateTableData(String text, boolean flag) { + this.getDatabase() + .executeSync( "SELECT * from " + text + ";", preparedStatement -> { try (ResultSet var4 = preparedStatement.executeQuery()) { @@ -211,22 +211,22 @@ public class TNTTagStatisticsRepository extends GameStatisticsRepository { int index = var4.getInt("wins"); int index2 = var4.getInt("loses"); int index3 = var4.getInt("kills"); - String text4 = this.a() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; - this.a().b("INSERT " + text4 + " INTO " + this.a().b() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { + String text4 = this.getDatabase() instanceof MysqlDatabase ? "IGNORE" : "OR IGNORE"; + this.getDatabase().executeSync("INSERT " + text4 + " INTO " + this.getDatabase().getTablePrefix() + "_id(uuid, name) VALUES (?, ?);", var2xx -> { var2xx.setString(1, text2); var2xx.setString(2, text3); var2xx.executeUpdate(); }); if (flag) { String text5 = var4.getString("options"); - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?, ?);", preparedStatement2 -> { preparedStatement2.setString(1, text2); @@ -240,14 +240,14 @@ public class TNTTagStatisticsRepository extends GameStatisticsRepository { } ); } else { - this.a() - .b( + this.getDatabase() + .executeSync( "INSERT " + text4 + " INTO " + text + "_new VALUES ((SELECT id FROM " - + this.a().b() + + this.getDatabase().getTablePrefix() + "_id WHERE uuid = ? LIMIT 1), ?, ?, ?, ?, ?);", preparedStatement3 -> { preparedStatement3.setString(1, text2); diff --git a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/storage/TNTTagStorage.java b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/storage/TNTTagStorage.java index e8fd8ae..532d35b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/game/tnttag/storage/TNTTagStorage.java +++ b/common/src/main/java/ro/fr33styler/arcade/game/tnttag/storage/TNTTagStorage.java @@ -12,20 +12,20 @@ import ro.fr33styler.arcade.game.tnttag.statistics.storage.TNTTagStatisticsRepos public class TNTTagStorage extends GameStorage { private final GameMapStorage storage; - private final NpcStorage storage2; - private final SignStorage storage3; + private final NpcStorage npcStorage; + private final SignStorage signStorage; private final TNTTagStatisticsRepository tNTTagStatisticsRepository; - private final LeaderboardStorage storage4; - private final GameTemplateStorage storage5; + private final LeaderboardStorage leaderboardStorage; + private final GameTemplateStorage templateStorage; public TNTTagStorage(TNTTagManager tNTTagManager) { super(tNTTagManager); this.storage = new GameMapStorage(tNTTagManager.getConfigManager(), this.file, TNTTagMap::new); - this.storage2 = new NpcStorage(tNTTagManager.getConfigManager(), this.file); - this.storage3 = new SignStorage(tNTTagManager.getConfigManager(), this.file); + this.npcStorage = new NpcStorage(tNTTagManager.getConfigManager(), this.file); + this.signStorage = new SignStorage(tNTTagManager.getConfigManager(), this.file); this.tNTTagStatisticsRepository = new TNTTagStatisticsRepository(tNTTagManager.getEngine()); - this.storage4 = new LeaderboardStorage(tNTTagManager.getConfigManager(), this.file); - this.storage5 = new GameTemplateStorage(tNTTagManager.getConfigManager(), this.file, TNTTagMap::new); + this.leaderboardStorage = new LeaderboardStorage(tNTTagManager.getConfigManager(), this.file); + this.templateStorage = new GameTemplateStorage(tNTTagManager.getConfigManager(), this.file, TNTTagMap::new); } @Override @@ -34,26 +34,26 @@ public class TNTTagStorage extends GameStorage { } @Override - public NpcStorage getStorage2() { - return this.storage2; + public NpcStorage getNpcStorage() { + return this.npcStorage; } @Override - public SignStorage getStorage3() { - return this.storage3; + public SignStorage getSignStorage() { + return this.signStorage; } - public TNTTagStatisticsRepository e() { + public TNTTagStatisticsRepository getStatisticsRepository() { return this.tNTTagStatisticsRepository; } @Override - public LeaderboardStorage getStorage4() { - return this.storage4; + public LeaderboardStorage getLeaderboardStorage() { + return this.leaderboardStorage; } @Override - public GameTemplateStorage getStorage5() { - return this.storage5; + public GameTemplateStorage getTemplateStorage() { + return this.templateStorage; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/IntegrationManager.java b/common/src/main/java/ro/fr33styler/arcade/integration/IntegrationManager.java index 558ea4a..29f3d20 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/IntegrationManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/IntegrationManager.java @@ -4,21 +4,21 @@ import java.util.ArrayList; import java.util.List; public class IntegrationManager { - private final List list = new ArrayList<>(); + private final List integrations = new ArrayList<>(); - public void a(PluginIntegration pluginIntegration) { - this.list.add(pluginIntegration); - if (pluginIntegration.a()) { - pluginIntegration.b(); - pluginIntegration.a(true); + public void register(PluginIntegration pluginIntegration) { + this.integrations.add(pluginIntegration); + if (pluginIntegration.canEnable()) { + pluginIntegration.onEnable(); + pluginIntegration.setEnabled(true); } } - public void a() { - for (PluginIntegration pluginIntegration : this.list) { - if (pluginIntegration.d()) { - pluginIntegration.c(); - pluginIntegration.a(false); + public void disableAll() { + for (PluginIntegration pluginIntegration : this.integrations) { + if (pluginIntegration.isEnabled()) { + pluginIntegration.onDisable(); + pluginIntegration.setEnabled(false); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/PluginIntegration.java b/common/src/main/java/ro/fr33styler/arcade/integration/PluginIntegration.java index b652b92..7239796 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/PluginIntegration.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/PluginIntegration.java @@ -1,19 +1,19 @@ package ro.fr33styler.arcade.integration; public abstract class PluginIntegration { - private boolean a; + private boolean enabled; - public abstract boolean a(); + public abstract boolean canEnable(); - public boolean d() { - return this.a; + public boolean isEnabled() { + return this.enabled; } - void a(boolean flag) { - this.a = flag; + void setEnabled(boolean flag) { + this.enabled = flag; } - public abstract void b(); + public abstract void onEnable(); - public abstract void c(); + public abstract void onDisable(); } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/party/PartyManagerFactory.java b/common/src/main/java/ro/fr33styler/arcade/integration/party/PartyManagerFactory.java index f08432b..29c5415 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/party/PartyManagerFactory.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/party/PartyManagerFactory.java @@ -13,36 +13,36 @@ import ro.fr33styler.arcade.api.engine.party.PartyManager; public class PartyManagerFactory { private final DefaultEngine engine; - private PartyManager b = NoPartyManager.a; + private PartyManager partyManager = NoPartyManager.INSTANCE; private final PartySettings settings = new PartySettings(); public PartyManagerFactory(DefaultEngine engine2) { this.engine = engine2; } - public void a() { - this.b = (PartyManager)(switch (this.settings.getMode()) { + public void load() { + this.partyManager = (PartyManager)(switch (this.settings.getMode()) { case "Internal" -> new InternalPartyManager(this.engine, this.settings.getInternal()); case "PartyAndFriends" -> new PafSpigotPartyManager(); case "PartyAndFriendsSpigot" -> new PartyAndFriendsManager(); case "Parties" -> new PartiesManager(); case "Voxy" -> new VoxyPartyManager(); - default -> NoPartyManager.a; + default -> NoPartyManager.INSTANCE; }); - if (!this.b.hasDependency()) { - this.b = NoPartyManager.a; + if (!this.partyManager.hasDependency()) { + this.partyManager = NoPartyManager.INSTANCE; this.engine.getLogger().sendError(this.settings.getMode() + " dependency not found!"); } - this.b.load(); + this.partyManager.load(); } - public void b() { - this.b.unload(); + public void unload() { + this.partyManager.unload(); } - public PartyManager c() { - return this.b; + public PartyManager getPartyManager() { + return this.partyManager; } public PartySettings getSettings() { diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/party/none/NoPartyManager.java b/common/src/main/java/ro/fr33styler/arcade/integration/party/none/NoPartyManager.java index 8f322f4..255c645 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/party/none/NoPartyManager.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/party/none/NoPartyManager.java @@ -5,7 +5,7 @@ import ro.fr33styler.arcade.api.engine.party.Party; import ro.fr33styler.arcade.api.engine.party.PartyManager; public class NoPartyManager implements PartyManager { - public static final PartyManager a = new NoPartyManager(); + public static final PartyManager INSTANCE = new NoPartyManager(); private NoPartyManager() { } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/party/pafspigot/PafSpigotParty.java b/common/src/main/java/ro/fr33styler/arcade/integration/party/pafspigot/PafSpigotParty.java index 3ad0aff..99bb7d3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/party/pafspigot/PafSpigotParty.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/party/pafspigot/PafSpigotParty.java @@ -8,20 +8,20 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.party.Party; public class PafSpigotParty implements Party { - private final PlayerParty a; + private final PlayerParty handle; public PafSpigotParty(PlayerParty playerParty) { - this.a = playerParty; + this.handle = playerParty; } public UUID getLeader() { - return this.a.getLeader().getUniqueId(); + return this.handle.getLeader().getUniqueId(); } public Collection getMembers() { HashSet set = new HashSet(); - for (PAFPlayer pAFPlayer : this.a.getPlayers()) { + for (PAFPlayer pAFPlayer : this.handle.getPlayers()) { set.add(pAFPlayer.getUniqueId()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/party/partyandfriends/PartyAndFriendsParty.java b/common/src/main/java/ro/fr33styler/arcade/integration/party/partyandfriends/PartyAndFriendsParty.java index dcf043b..07df6e0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/party/partyandfriends/PartyAndFriendsParty.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/party/partyandfriends/PartyAndFriendsParty.java @@ -8,20 +8,20 @@ import java.util.UUID; import ro.fr33styler.arcade.api.engine.party.Party; public class PartyAndFriendsParty implements Party { - private final PlayerParty a; + private final PlayerParty handle; public PartyAndFriendsParty(PlayerParty playerParty) { - this.a = playerParty; + this.handle = playerParty; } public UUID getLeader() { - return this.a.getLeader().getUniqueId(); + return this.handle.getLeader().getUniqueId(); } public Collection getMembers() { HashSet set = new HashSet(); - for (OnlinePAFPlayer onlinePAFPlayer : this.a.getPlayers()) { + for (OnlinePAFPlayer onlinePAFPlayer : this.handle.getPlayers()) { set.add(onlinePAFPlayer.getUniqueId()); } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderExpansion.java b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderExpansion.java index b9ee8c1..6f800fd 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderExpansion.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderExpansion.java @@ -37,17 +37,17 @@ public class GamePlaceholderExpansion extends PlaceholderExpansion { return this.manager.getVersion(); } - private String a(OfflinePlayer offlinePlayer, String text) { + private String resolvePlayerPlaceholder(OfflinePlayer offlinePlayer, String text) { if (offlinePlayer == null) { return null; } BaseGameStatistics baseGameStatistics = this.manager.getData(offlinePlayer.getUniqueId()); - return baseGameStatistics != null ? baseGameStatistics.a(text) : null; + return baseGameStatistics != null ? baseGameStatistics.resolvePlaceholder(text) : null; } @Override public String onRequest(OfflinePlayer offlinePlayer, String text) { - return (String)EngineUtils.a((Object)this.a(offlinePlayer, text), this.manager.resolvePlaceholder(text)); + return (String)EngineUtils.orElse((Object)this.resolvePlayerPlaceholder(offlinePlayer, text), this.manager.resolvePlaceholder(text)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderIntegration.java b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderIntegration.java index d31adb7..fe8ef53 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderIntegration.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/GamePlaceholderIntegration.java @@ -7,25 +7,25 @@ import org.bukkit.Bukkit; public class GamePlaceholderIntegration extends PluginIntegration { private GamePlaceholderExpansion gamePlaceholderExpansion; - private final AbstractGameManager b; + private final AbstractGameManager manager; public GamePlaceholderIntegration(AbstractGameManager abstractGameManager) { - this.b = abstractGameManager; + this.manager = abstractGameManager; } @Override - public boolean a() { + public boolean canEnable() { return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null; } @Override - public void b() { - this.gamePlaceholderExpansion = new GamePlaceholderExpansion(this.b); + public void onEnable() { + this.gamePlaceholderExpansion = new GamePlaceholderExpansion(this.manager); this.gamePlaceholderExpansion.register(); } @Override - public void c() { + public void onDisable() { this.gamePlaceholderExpansion.unregister(); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiIntegration.java b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiIntegration.java index 283c807..6269757 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiIntegration.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiIntegration.java @@ -13,17 +13,17 @@ public class PlaceholderApiIntegration extends PluginIntegration { } @Override - public boolean a() { + public boolean canEnable() { return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null; } @Override - public void b() { + public void onEnable() { this.engine.setPlaceholderResolver(new PlaceholderApiResolver()); } @Override - public void c() { + public void onDisable() { this.engine.setPlaceholderResolver((ro.fr33styler.arcade.integration.placeholderapi.PlaceholderApiResolver)null); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiResolver.java b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiResolver.java index 854c26e..da84599 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiResolver.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/placeholderapi/PlaceholderApiResolver.java @@ -6,7 +6,7 @@ import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.OfflinePlayer; public class PlaceholderApiResolver { - public String a(OfflinePlayer offlinePlayer, String text) { - return Strings.a(PlaceholderAPI.setPlaceholders(offlinePlayer, text)); + public String resolve(OfflinePlayer offlinePlayer, String text) { + return Strings.colorize(PlaceholderAPI.setPlaceholders(offlinePlayer, text)); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeTemplateLoader.java b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeTemplateLoader.java index 8d6064f..31598c5 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeTemplateLoader.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeTemplateLoader.java @@ -10,38 +10,38 @@ import java.io.IOException; import java.util.List; public class SlimeTemplateLoader implements SlimeLoader { - private final AbstractGameManager a; + private final AbstractGameManager manager; public SlimeTemplateLoader(AbstractGameManager abstractGameManager) { - this.a = abstractGameManager; + this.manager = abstractGameManager; } public byte[] loadWorld(String text, boolean flag) { - GameTemplate gameTemplate = this.a.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new UnknownWorldException(text)); } else { - return gameTemplate.c(); + return gameTemplate.getWorldData(); } } public boolean worldExists(String text) { - GameTemplate gameTemplate = this.a.getSessions().e(text); - return gameTemplate != null && gameTemplate.c() != null; + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); + return gameTemplate != null && gameTemplate.getWorldData() != null; } public List listWorlds() { - return this.a.getSessions().h(); + return this.manager.getSessions().getTemplateNames(); } public void saveWorld(String text, byte[] byteVals, boolean flag) { - GameTemplate gameTemplate = this.a.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new IOException("Template not found!")); } - gameTemplate.a(byteVals); - this.a.getStorage().getStorage5().a(gameTemplate); + gameTemplate.setWorldData(byteVals); + this.manager.getStorage().getTemplateStorage().save(gameTemplate); } public void unlockWorld(String text) { @@ -52,11 +52,11 @@ public class SlimeTemplateLoader implements SlimeLoader { } public void deleteWorld(String text) { - GameTemplate gameTemplate = this.a.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new UnknownWorldException(text)); } - this.a.getSessions().f(gameTemplate.a()); + this.manager.getSessions().unregisterTemplate(gameTemplate.getId()); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldManagerIntegration.java b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldManagerIntegration.java index ed494fe..93eface 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldManagerIntegration.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldManagerIntegration.java @@ -7,24 +7,24 @@ import ro.fr33styler.arcade.integration.PluginIntegration; import org.bukkit.Bukkit; public class SlimeWorldManagerIntegration extends PluginIntegration { - private final AbstractGameManager a; + private final AbstractGameManager manager; public SlimeWorldManagerIntegration(AbstractGameManager abstractGameManager) { - this.a = abstractGameManager; + this.manager = abstractGameManager; } @Override - public boolean a() { + public boolean canEnable() { return Bukkit.getPluginManager().getPlugin("SlimeWorldManager") != null; } @Override - public void b() { - this.a.setWorldProvider(new SlimeWorldProvider(this.a)); + public void onEnable() { + this.manager.setWorldProvider(new SlimeWorldProvider(this.manager)); } @Override - public void c() { - this.a.setWorldProvider((ro.fr33styler.arcade.engine.world.spi.WorldProvider)null); + public void onDisable() { + this.manager.setWorldProvider((ro.fr33styler.arcade.engine.world.spi.WorldProvider)null); } } diff --git a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldProvider.java b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldProvider.java index 0ce6e52..ad05fb9 100644 --- a/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldProvider.java +++ b/common/src/main/java/ro/fr33styler/arcade/integration/world/slimeworldmanager/SlimeWorldProvider.java @@ -17,53 +17,53 @@ import org.bukkit.World; public class SlimeWorldProvider implements WorldProvider { private final SlimeTemplateLoader slimeTemplateLoader; - private final AbstractGameManager b; - private final SlimePlugin c; + private final AbstractGameManager manager; + private final SlimePlugin slimePlugin; public SlimeWorldProvider(AbstractGameManager abstractGameManager) { - this.b = abstractGameManager; + this.manager = abstractGameManager; this.slimeTemplateLoader = new SlimeTemplateLoader(abstractGameManager); - this.c = (SlimePlugin)Bukkit.getPluginManager().getPlugin("SlimeWorldManager"); + this.slimePlugin = (SlimePlugin)Bukkit.getPluginManager().getPlugin("SlimeWorldManager"); } - public World a(GameTemplate gameTemplate, String text) { - if (gameTemplate.c() == null) { + public World createWorld(GameTemplate gameTemplate, String text) { + if (gameTemplate.getWorldData() == null) { return null; } try { - SlimeWorld slimeWorld = this.c.loadWorld(this.slimeTemplateLoader, gameTemplate.a(), true, new SlimePropertyMap()); - this.c.generateWorld(slimeWorld.clone(text)); + SlimeWorld slimeWorld = this.slimePlugin.loadWorld(this.slimeTemplateLoader, gameTemplate.getId(), true, new SlimePropertyMap()); + this.slimePlugin.generateWorld(slimeWorld.clone(text)); return Bukkit.getWorld(text); } catch (Exception ex) { - this.b.getLogger().sendWarn("Failed assigning template: " + gameTemplate.a()); + this.manager.getLogger().sendWarn("Failed assigning template: " + gameTemplate.getId()); return null; } } - public void a(GameTemplate gameTemplate) { + public void saveTemplate(GameTemplate gameTemplate) { World world = gameTemplate.getMap().getLobby().getWorld(); if (world != null) { CompletableFuture.runAsync(() -> { - File file = new File(this.b.getEngine().getDataFolder(), "temp"); + File file = new File(this.manager.getEngine().getDataFolder(), "temp"); file.mkdirs(); try { File file2 = new File(Bukkit.getWorldContainer(), world.getName()); File file3 = new File(file2, "region"); if (file3.exists() && file3.isDirectory()) { - Files.a(file3, new File(file, "region")); + Files.copyDirectory(file3, new File(file, "region")); } else { Path path = Path.of("dimensions", "minecraft", "overworld", "region"); - Files.a(new File(file2, path.toString()), new File(file, "region")); + Files.copyDirectory(new File(file2, path.toString()), new File(file, "region")); } - this.c.importWorld(file, gameTemplate.a(), this.slimeTemplateLoader); + this.slimePlugin.importWorld(file, gameTemplate.getId(), this.slimeTemplateLoader); } catch (Exception ex) { - this.b.getSessions().f(gameTemplate.a()); - this.b.getLogger().sendWarn("Failed saving the template: " + ex.getMessage(), ex); + this.manager.getSessions().unregisterTemplate(gameTemplate.getId()); + this.manager.getLogger().sendWarn("Failed saving the template: " + ex.getMessage(), ex); } finally { - Files.a(file); + Files.deleteDirectory(file); } }); } diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/codec/SharedCompression.java b/common/src/main/java/ro/fr33styler/arcade/internal/codec/SharedCompression.java index 60d73d6..a7e674d 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/codec/SharedCompression.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/codec/SharedCompression.java @@ -20,7 +20,7 @@ public final class SharedCompression { private SharedCompression() { } - public static byte[] a(String text) { + public static byte[] compressString(String text) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (GZIPOutputStream var2 = new GZIPOutputStream(byteArrayOutputStream)) { var2.write(text.getBytes(StandardCharsets.UTF_8)); @@ -29,7 +29,7 @@ public final class SharedCompression { return byteArrayOutputStream.toByteArray(); } - public static String a(byte[] byteVals) { + public static String decompressString(byte[] byteVals) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals); try (GZIPInputStream var2 = new GZIPInputStream(byteArrayInputStream)) { StringBuilder stringBuilder = new StringBuilder(); @@ -47,7 +47,7 @@ public final class SharedCompression { } } - public static T a(Gson gson, byte[] byteVals, Class clazz) { + public static T decompressJson(Gson gson, byte[] byteVals, Class clazz) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals); try (GZIPInputStream var4 = new GZIPInputStream(byteArrayInputStream)) { return (T) gson.fromJson(new InputStreamReader(var4, StandardCharsets.UTF_8), clazz); @@ -56,30 +56,30 @@ public final class SharedCompression { } } - public static byte[] a(ConfigManager configManager, GameTemplate gameTemplate) throws IOException { + public static byte[] serializeTemplate(ConfigManager configManager, GameTemplate gameTemplate) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { - byte[] byteVals = a(re$saveToString(configManager, gameTemplate.getMap())); + byte[] byteVals = compressString(re$saveToString(configManager, gameTemplate.getMap())); byteArrayOutputStream.write(ByteBuffer.allocate(4).putInt(byteVals.length).array()); byteArrayOutputStream.write(byteVals); } catch (InvalidConfigException ex) { throw new IOException("Error saving template: " + ex.getMessage(), ex); } - byteArrayOutputStream.write(ByteBuffer.allocate(4).putInt(gameTemplate.c().length).array()); - byteArrayOutputStream.write(gameTemplate.c()); + byteArrayOutputStream.write(ByteBuffer.allocate(4).putInt(gameTemplate.getWorldData().length).array()); + byteArrayOutputStream.write(gameTemplate.getWorldData()); return byteArrayOutputStream.toByteArray(); } - public static void a(ConfigManager configManager, byte[] byteVals, GameTemplate gameTemplate) throws IOException { + public static void deserializeTemplate(ConfigManager configManager, byte[] byteVals, GameTemplate gameTemplate) throws IOException { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteVals); try { int index = ByteBuffer.wrap(byteArrayInputStream.readNBytes(4)).getInt(); - re$loadFromString(configManager, gameTemplate.getMap(), a(byteArrayInputStream.readNBytes(index))); + re$loadFromString(configManager, gameTemplate.getMap(), decompressString(byteArrayInputStream.readNBytes(index))); } catch (InvalidConfigException ex) { throw new IOException("Error loading template: " + ex.getMessage(), ex); } int index2 = ByteBuffer.wrap(byteArrayInputStream.readNBytes(4)).getInt(); - gameTemplate.a(byteArrayInputStream.readNBytes(index2)); + gameTemplate.setWorldData(byteArrayInputStream.readNBytes(index2)); } private static String re$saveToString(ConfigManager configManager, ro.fr33styler.arcade.api.engine.config.serialize.Configuration configuration) throws InvalidConfigException { diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassPatternMatcher.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassPatternMatcher.java index 4f9b320..82100e8 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassPatternMatcher.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassPatternMatcher.java @@ -6,7 +6,7 @@ import java.lang.reflect.Method; import java.util.function.Predicate; public class ClassPatternMatcher { - public static boolean a(Class clazz, Predicate predicate) { + public static boolean hasMatchingMethod(Class clazz, Predicate predicate) { for (Method method : clazz.getDeclaredMethods()) { if (predicate.test(method)) { return true; @@ -16,7 +16,7 @@ public class ClassPatternMatcher { return false; } - public static boolean a(InputStream inputStream, int[] indexs) { + public static boolean containsByteSequence(InputStream inputStream, int[] indexs) { try { int index = 0; diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassResourceReader.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassResourceReader.java index 8aabf75..d9b5a78 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassResourceReader.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/classfile/ClassResourceReader.java @@ -4,20 +4,20 @@ import java.io.IOException; import java.io.InputStream; public class ClassResourceReader { - public static String a(Class clazz) { + public static String getClassResourcePath(Class clazz) { return clazz.getCanonicalName().replace('.', '/') + ".class"; } - public static int a(InputStream inputStream) { + public static int readLeadingIntSafe(InputStream inputStream) { try { - return b(inputStream); + return readLeadingInt(inputStream); } catch (IOException ex) { ex.printStackTrace(); return -1; } } - private static int b(InputStream inputStream) throws IOException { + private static int readLeadingInt(InputStream inputStream) throws IOException { int index = 0; boolean flag = false; diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/LeakMarkerProbe.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/LeakMarkerProbe.java index bb65452..54e4eff 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/LeakMarkerProbe.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/LeakMarkerProbe.java @@ -3,11 +3,11 @@ package ro.fr33styler.arcade.internal.compatibility.marker; import org.bukkit.plugin.Plugin; public class LeakMarkerProbe { - private static boolean a; - private static boolean b; - private static final int[] c = new int[]{76, 101, 97, 107}; + private static boolean detected; + private static boolean checked; + private static final int[] MARKER_BYTES = new int[]{76, 101, 97, 107}; - public static boolean a(Plugin plugin) { + public static boolean probe(Plugin plugin) { return true; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/MethodSuffixProbe.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/MethodSuffixProbe.java index 64f9773..7cba64b 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/MethodSuffixProbe.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/MethodSuffixProbe.java @@ -3,15 +3,15 @@ package ro.fr33styler.arcade.internal.compatibility.marker; import ro.fr33styler.arcade.internal.compatibility.classfile.ClassPatternMatcher; public class MethodSuffixProbe { - private static boolean a; - private static boolean b; + private static boolean detected; + private static boolean checked; - public static boolean a(Class clazz) { - if (!b) { - b = true; - a = ClassPatternMatcher.a(clazz, method -> method.getName().endsWith("g0")); + public static boolean hasTargetMethodSuffix(Class clazz) { + if (!checked) { + checked = true; + detected = ClassPatternMatcher.hasMatchingMethod(clazz, method -> method.getName().endsWith("g0")); } - return a; + return detected; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/RemoteMarkerRegistry.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/RemoteMarkerRegistry.java index df5aa8b..57ccdc3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/RemoteMarkerRegistry.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/RemoteMarkerRegistry.java @@ -9,14 +9,14 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; public class RemoteMarkerRegistry { - private static boolean a; - private static Set set; + private static boolean initialized; + private static Set markers; - public static Set getSet() { - return set; + public static Set getMarkers() { + return markers; } - private static Set a(InputStream inputStream) { + private static Set readLines(InputStream inputStream) { HashSet set2 = new HashSet(); Scanner scanner = new Scanner(inputStream); @@ -28,17 +28,17 @@ public class RemoteMarkerRegistry { return set2; } - private static void b(String text, String text2, String text3) { - InputStream inputStream = EngineUtils.a(text, text2, text3, 5000); + private static void fetchMarkers(String text, String text2, String text3) { + InputStream inputStream = EngineUtils.openStream(text, text2, text3, 5000); if (inputStream != null) { - set = a(inputStream); + markers = readLines(inputStream); } } - public static void a(String text, String text2, String text3) { - if (!a) { - a = true; - CompletableFuture.runAsync(() -> b(text, text2, text3)); + public static void initAsync(String text, String text2, String text3) { + if (!initialized) { + initialized = true; + CompletableFuture.runAsync(() -> fetchMarkers(text, text2, text3)); } } } diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/UserNonceMarkerProbe.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/UserNonceMarkerProbe.java index c8c81c2..23200d0 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/UserNonceMarkerProbe.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/UserNonceMarkerProbe.java @@ -3,12 +3,12 @@ package ro.fr33styler.arcade.internal.compatibility.marker; import org.bukkit.plugin.Plugin; public class UserNonceMarkerProbe { - private static boolean a; - private static boolean b; - private static final int[] c = new int[]{117, 115, 101, 114, 95, 105, 100, 61}; - private static final int[] d = new int[]{110, 111, 110, 99, 101, 61}; + private static boolean detected; + private static boolean checked; + private static final int[] USER_ID_BYTES = new int[]{117, 115, 101, 114, 95, 105, 100, 61}; + private static final int[] NONCE_BYTES = new int[]{110, 111, 110, 99, 101, 61}; - public static boolean a(Plugin plugin) { + public static boolean probe(Plugin plugin) { return true; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/VendorMarkerProbe.java b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/VendorMarkerProbe.java index b3a1c99..430acb3 100644 --- a/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/VendorMarkerProbe.java +++ b/common/src/main/java/ro/fr33styler/arcade/internal/compatibility/marker/VendorMarkerProbe.java @@ -3,14 +3,14 @@ package ro.fr33styler.arcade.internal.compatibility.marker; import org.bukkit.plugin.Plugin; public class VendorMarkerProbe { - private static boolean a; - private static boolean b; - private static final int[] c = new int[]{115, 112, 105, 103, 111, 116, 109, 99, 46}; - private static final int[] d = new int[]{118, 111, 120, 101, 108, 46, 115, 104, 111, 112}; - private static final int[] e = new int[]{117, 115, 101, 114, 95, 105, 100, 61}; - private static final int[] f = new int[]{110, 111, 110, 99, 101, 61}; + private static boolean detected; + private static boolean checked; + private static final int[] SPIGOT_BYTES = new int[]{115, 112, 105, 103, 111, 116, 109, 99, 46}; + private static final int[] VOXEL_BYTES = new int[]{118, 111, 120, 101, 108, 46, 115, 104, 111, 112}; + private static final int[] USER_ID_BYTES = new int[]{117, 115, 101, 114, 95, 105, 100, 61}; + private static final int[] NONCE_BYTES = new int[]{110, 111, 110, 99, 101, 61}; - public static boolean a(Plugin plugin) { + public static boolean probe(Plugin plugin) { return true; } } diff --git a/common/src/main/java/ro/fr33styler/arcade/support/compression/Compression.java b/common/src/main/java/ro/fr33styler/arcade/support/compression/Compression.java index 14bdf36..d1bf5da 100644 --- a/common/src/main/java/ro/fr33styler/arcade/support/compression/Compression.java +++ b/common/src/main/java/ro/fr33styler/arcade/support/compression/Compression.java @@ -19,15 +19,15 @@ import ro.fr33styler.arcade.platform.compat.VersionAdapters; public final class Compression { - public static byte[] a(String text) { - return SharedCompression.a(text); + public static byte[] compressString(String text) { + return SharedCompression.compressString(text); } - public static String a(byte[] byteVals) { - return SharedCompression.a(byteVals); + public static String decompressString(byte[] byteVals) { + return SharedCompression.decompressString(byteVals); } - public static byte[] a(Gson gson, Object obj) { + public static byte[] compressJson(Gson gson, Object obj) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (GZIPOutputStream var3 = new GZIPOutputStream(byteArrayOutputStream)) { JsonWriter jsonWriter = VersionAdapters.get().createJsonWriter(gson, new OutputStreamWriter(var3, StandardCharsets.UTF_8)); @@ -38,16 +38,16 @@ public final class Compression { return byteArrayOutputStream.toByteArray(); } - public static T a(Gson gson, byte[] byteVals, Class clazz) { - return SharedCompression.a(gson, byteVals, clazz); + public static T decompressJson(Gson gson, byte[] byteVals, Class clazz) { + return SharedCompression.decompressJson(gson, byteVals, clazz); } - public static byte[] a(ConfigManager configManager, GameTemplate gameTemplate) throws IOException { - return SharedCompression.a(configManager, gameTemplate); + public static byte[] serializeTemplate(ConfigManager configManager, GameTemplate gameTemplate) throws IOException { + return SharedCompression.serializeTemplate(configManager, gameTemplate); } - public static void a(ConfigManager configManager, byte[] byteVals, GameTemplate gameTemplate) throws IOException { - SharedCompression.a(configManager, byteVals, gameTemplate); + public static void deserializeTemplate(ConfigManager configManager, byte[] byteVals, GameTemplate gameTemplate) throws IOException { + SharedCompression.deserializeTemplate(configManager, byteVals, gameTemplate); } private static String re$saveToString(ConfigManager configManager, ro.fr33styler.arcade.api.engine.config.serialize.Configuration configuration) throws InvalidConfigException { diff --git a/common/src/main/java/ro/fr33styler/arcade/support/io/Files.java b/common/src/main/java/ro/fr33styler/arcade/support/io/Files.java index 9354182..f82fb95 100644 --- a/common/src/main/java/ro/fr33styler/arcade/support/io/Files.java +++ b/common/src/main/java/ro/fr33styler/arcade/support/io/Files.java @@ -9,7 +9,7 @@ import java.util.function.Consumer; import java.util.stream.Stream; public final class Files { - public static void a(File file, Consumer consumer) { + public static void forEachChild(File file, Consumer consumer) { File[] files = file.listFiles(); if (files != null) { for (File file2 : files) { @@ -18,7 +18,7 @@ public final class Files { } } - public static void a(File file, File file2) { + public static void copyDirectory(File file, File file2) { String text = file2.getPath(); String text2 = file.getPath(); @@ -33,7 +33,7 @@ public final class Files { } } - public static void a(File file) { + public static void deleteDirectory(File file) { try (Stream var1 = java.nio.file.Files.walk(file.toPath())) { var1.sorted(Comparator.reverseOrder()).forEach(path -> path.toFile().delete()); } catch (IOException ex) { diff --git a/common/src/main/java/ro/fr33styler/arcade/support/random/Randoms.java b/common/src/main/java/ro/fr33styler/arcade/support/random/Randoms.java index 7c5791e..fc72141 100644 --- a/common/src/main/java/ro/fr33styler/arcade/support/random/Randoms.java +++ b/common/src/main/java/ro/fr33styler/arcade/support/random/Randoms.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.concurrent.ThreadLocalRandom; public final class Randoms { - private static final char[] a = new char[]{ + private static final char[] ALPHANUMERIC_CHARS = new char[]{ 'A', 'B', 'C', @@ -71,29 +71,29 @@ public final class Randoms { '0' }; - public static ThreadLocalRandom a() { + public static ThreadLocalRandom current() { return ThreadLocalRandom.current(); } - public static T a(T[] objs) { - return (T)(objs.length == 0 ? null : objs[a().nextInt(objs.length)]); + public static T pickRandom(T[] objs) { + return (T)(objs.length == 0 ? null : objs[current().nextInt(objs.length)]); } - public static T a(List list) { - return (T)(list.isEmpty() ? null : list.get(a().nextInt(list.size()))); + public static T pickRandom(List list) { + return (T)(list.isEmpty() ? null : list.get(current().nextInt(list.size()))); } - public static void b(Object[] objs) { + public static void shuffle(Object[] objs) { for (int index = objs.length; index > 1; index--) { - EngineUtils.a(objs, index - 1, a().nextInt(index)); + EngineUtils.swap(objs, index - 1, current().nextInt(index)); } } - public static String a(int index) { + public static String randomAlphanumeric(int index) { char[] chs = new char[index]; for (int index2 = 0; index2 < chs.length; index2++) { - chs[index2] = a[a().nextInt(a.length)]; + chs[index2] = ALPHANUMERIC_CHARS[current().nextInt(ALPHANUMERIC_CHARS.length)]; } return new String(chs); diff --git a/common/src/main/java/ro/fr33styler/arcade/support/text/Strings.java b/common/src/main/java/ro/fr33styler/arcade/support/text/Strings.java index a455c1f..80c8c24 100644 --- a/common/src/main/java/ro/fr33styler/arcade/support/text/Strings.java +++ b/common/src/main/java/ro/fr33styler/arcade/support/text/Strings.java @@ -14,8 +14,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; public final class Strings { - public static final String a = "▬".repeat(70); - private static final NavigableMap b = new TreeMap<>( + public static final String SEPARATOR_LINE = "▬".repeat(70); + private static final NavigableMap ROMAN_NUMERALS = new TreeMap<>( Map.ofEntries( Map.entry(1000, "M"), Map.entry(900, "CM"), @@ -33,42 +33,42 @@ public final class Strings { ) ); - public static String a(String text) { - return text.isEmpty() ? text : d(ChatColor.translateAlternateColorCodes('&', text)); + public static String colorize(String text) { + return text.isEmpty() ? text : translateHexColors(ChatColor.translateAlternateColorCodes('&', text)); } - public static List a(String... texts) { + public static List colorizeLines(String... texts) { ArrayList list = new ArrayList(texts.length); for (String text : texts) { - list.add(a(text)); + list.add(colorize(text)); } return list; } - public static String b(String text) { + public static String decodeBase64(String text) { return new String(Base64.getDecoder().decode(text.getBytes())); } - public static boolean a(String text, String text2, boolean flag) { + public static boolean startsWith(String text, String text2, boolean flag) { return text.regionMatches(flag, 0, text2, 0, text2.length()); } - public static String a(int index, int index2) { + public static String formatProgressColor(int index, int index2) { String text = String.valueOf(index); char[] chs = new char[text.length() + 2]; chs[0] = 167; - chs[1] = a((double)index / index2); + chs[1] = getRatioColorCode((double)index / index2); text.getChars(0, text.length(), chs, 2); return new String(chs); } - public static char a(double doubleVal) { + public static char getRatioColorCode(double doubleVal) { return (char)(doubleVal > 0.66 ? 'a' : (doubleVal > 0.33 ? 'e' : 'c')); } - public static String b(int index, int index2) { + public static String groupDigits(int index, int index2) { String text = Integer.toString(index); int index3 = index < 0 ? 1 : 0; int index4 = (text.length() - index3 - 1) / index2; @@ -84,7 +84,7 @@ public final class Strings { return new String(chs); } - public static String a(double doubleVal, int index) { + public static String formatFixedDecimal(double doubleVal, int index) { Validate.isTrue(index > 0, "The precision must be 1 or higher!"); int index2 = (int)doubleVal; int index3 = IntMath.pow(10, index); @@ -92,11 +92,11 @@ public final class Strings { return index2 + "." + index4; } - public static String a(char ch, int index, double doubleVal) { - return a(ch, 'a', 'c', index, doubleVal); + public static String formatProgressBar(char ch, int index, double doubleVal) { + return formatProgressBar(ch, 'a', 'c', index, doubleVal); } - public static String a(char ch, char ch2, char ch3, int index, double doubleVal) { + public static String formatProgressBar(char ch, char ch2, char ch3, int index, double doubleVal) { Validate.isTrue(index > 1, "The barLength must be 2 or higher!"); Validate.isTrue(doubleVal >= 0.0 && doubleVal <= 1.0, "The percentage must be between 0.0 and 1.0"); char[] chs = new char[index + 4]; @@ -109,22 +109,22 @@ public final class Strings { return new String(chs); } - public static String a(int index) { + public static String formatDuration(int index) { int index2 = index / 3600; int index3 = index % 3600 / 60; index %= 60; char[] chs = new char[]{'0', '0', ':', '0', '0', ':', '0', '0'}; - a(chs, 3, index3); - a(chs, 6, index); + writeTwoDigits(chs, 3, index3); + writeTwoDigits(chs, 6, index); if (index2 > 0) { - a(chs, 0, index2 % 24); + writeTwoDigits(chs, 0, index2 % 24); return new String(chs, 0, 8); } else { return new String(chs, 3, 5); } } - private static void a(char[] chs, int index, int index2) { + private static void writeTwoDigits(char[] chs, int index, int index2) { if (index2 > 9) { chs[index] = Character.forDigit(index2 / 10, 10); } @@ -132,7 +132,7 @@ public final class Strings { chs[index + 1] = Character.forDigit(index2 % 10, 10); } - public static String c(String text) { + public static String stripHexColors(String text) { if (text.isEmpty()) { return text; } @@ -167,7 +167,7 @@ public final class Strings { return stringBuilder.toString(); } - public static String d(String text) { + public static String translateHexColors(String text) { if (text.isEmpty()) { return text; } @@ -211,11 +211,11 @@ public final class Strings { return stringBuilder.toString(); } - public static String a(CharSequence charSequence, Iterable iterable, Function function) { - return a(charSequence, charSequence, iterable, function); + public static String join(CharSequence charSequence, Iterable iterable, Function function) { + return join(charSequence, charSequence, iterable, function); } - public static String a(CharSequence charSequence, CharSequence charSequence2, Iterable iterable, Function function) { + public static String join(CharSequence charSequence, CharSequence charSequence2, Iterable iterable, Function function) { StringBuilder stringBuilder = new StringBuilder(); Iterator iterator = iterable.iterator(); diff --git a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimePaperIntegration.java b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimePaperIntegration.java index 69124c2..352d110 100644 --- a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimePaperIntegration.java +++ b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimePaperIntegration.java @@ -14,17 +14,17 @@ public class AdvancedSlimePaperIntegration extends PluginIntegration { } @Override - public boolean a() { + public boolean canEnable() { return Bukkit.getPluginManager().getPlugin("ASPaperPlugin") != null; } @Override - public void b() { + public void onEnable() { this.manager.setWorldProvider(new AdvancedSlimeWorldProvider(this.manager)); } @Override - public void c() { + public void onDisable() { this.manager.setWorldProvider((ro.fr33styler.arcade.engine.world.spi.WorldProvider)null); } } diff --git a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeTemplateLoader.java b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeTemplateLoader.java index 1e20e24..0bd9215 100644 --- a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeTemplateLoader.java +++ b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeTemplateLoader.java @@ -17,39 +17,39 @@ public class AdvancedSlimeTemplateLoader implements SlimeLoader { } public byte[] readWorld(String text) { - GameTemplate gameTemplate = this.manager.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new UnknownWorldException(text)); } else { - return gameTemplate.c(); + return gameTemplate.getWorldData(); } } public boolean worldExists(String text) { - GameTemplate gameTemplate = this.manager.getSessions().e(text); - return gameTemplate != null && gameTemplate.c() != null; + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); + return gameTemplate != null && gameTemplate.getWorldData() != null; } public List listWorlds() { - return this.manager.getSessions().h(); + return this.manager.getSessions().getTemplateNames(); } public void saveWorld(String text, byte[] byteVals) { - GameTemplate gameTemplate = this.manager.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new IOException("Template not found!")); } - gameTemplate.a(byteVals); - this.manager.getStorage().getStorage5().a(gameTemplate); + gameTemplate.setWorldData(byteVals); + this.manager.getStorage().getTemplateStorage().save(gameTemplate); } public void deleteWorld(String text) { - GameTemplate gameTemplate = this.manager.getSessions().e(text); + GameTemplate gameTemplate = this.manager.getSessions().getTemplate(text); if (gameTemplate == null) { throw GenericTypeValidation.re$propagate(new UnknownWorldException(text)); } - this.manager.getSessions().f(gameTemplate.a()); + this.manager.getSessions().unregisterTemplate(gameTemplate.getId()); } } diff --git a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeWorldProvider.java b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeWorldProvider.java index a7a1047..0b57ab6 100644 --- a/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeWorldProvider.java +++ b/latest/src/main/java/ro/fr33styler/arcade/integration/world/advancedslimepaper/AdvancedSlimeWorldProvider.java @@ -20,23 +20,23 @@ import org.bukkit.World; public class AdvancedSlimeWorldProvider implements WorldProvider { private final AdvancedSlimeTemplateLoader advancedSlimeTemplateLoader; private final AbstractGameManager manager; - private final AdvancedSlimePaperAPI c = AdvancedSlimePaperAPI.instance(); + private final AdvancedSlimePaperAPI slimeApi = AdvancedSlimePaperAPI.instance(); public AdvancedSlimeWorldProvider(AbstractGameManager manager2) { this.manager = manager2; this.advancedSlimeTemplateLoader = new AdvancedSlimeTemplateLoader(manager2); } - public World a(GameTemplate gameTemplate, String text) { - if (gameTemplate.c() == null) { + public World createWorld(GameTemplate gameTemplate, String text) { + if (gameTemplate.getWorldData() == null) { return null; } try { - SlimeWorld slimeWorld = re$readWorld(this.c, this.advancedSlimeTemplateLoader, gameTemplate.a(), true, new SlimePropertyMap()); - return this.c.loadWorld(slimeWorld.clone(text), true).getBukkitWorld(); + SlimeWorld slimeWorld = re$readWorld(this.slimeApi, this.advancedSlimeTemplateLoader, gameTemplate.getId(), true, new SlimePropertyMap()); + return this.slimeApi.loadWorld(slimeWorld.clone(text), true).getBukkitWorld(); } catch (IOException | SlimeException ex) { - this.manager.getLogger().sendWarn("Failed assigning template: " + gameTemplate.a()); + this.manager.getLogger().sendWarn("Failed assigning template: " + gameTemplate.getId()); return null; } } @@ -51,7 +51,7 @@ public class AdvancedSlimeWorldProvider implements WorldProvider { return advancedSlimePaperAPI.readWorld(slimeLoader, text, flag, slimePropertyMap); } - public void a(GameTemplate gameTemplate) { + public void saveTemplate(GameTemplate gameTemplate) { World world = gameTemplate.getMap().getLobby().getWorld(); if (world != null) { CompletableFuture.runAsync(() -> { @@ -62,18 +62,18 @@ public class AdvancedSlimeWorldProvider implements WorldProvider { File file2 = new File(Bukkit.getWorldContainer(), world.getName()); File file3 = new File(file2, "region"); if (file3.exists() && file3.isDirectory()) { - Files.a(file3, new File(file, "region")); + Files.copyDirectory(file3, new File(file, "region")); } else { Path path = Path.of("dimensions", "minecraft", "overworld", "region"); - Files.a(new File(file2, path.toString()), new File(file, "region")); + Files.copyDirectory(new File(file2, path.toString()), new File(file, "region")); } - this.c.saveWorld(this.c.readVanillaWorld(file, gameTemplate.a(), this.advancedSlimeTemplateLoader)); + this.slimeApi.saveWorld(this.slimeApi.readVanillaWorld(file, gameTemplate.getId(), this.advancedSlimeTemplateLoader)); } catch (Exception ex) { - this.manager.getSessions().f(gameTemplate.a()); + this.manager.getSessions().unregisterTemplate(gameTemplate.getId()); this.manager.getLogger().sendWarn("Failed saving the template: " + ex.getMessage(), ex); } finally { - Files.a(file); + Files.deleteDirectory(file); } }); } diff --git a/latest/src/main/java/ro/fr33styler/arcade/platform/compat/LatestVersionAdapter.java b/latest/src/main/java/ro/fr33styler/arcade/platform/compat/LatestVersionAdapter.java index c933475..b364b6b 100644 --- a/latest/src/main/java/ro/fr33styler/arcade/platform/compat/LatestVersionAdapter.java +++ b/latest/src/main/java/ro/fr33styler/arcade/platform/compat/LatestVersionAdapter.java @@ -345,7 +345,7 @@ public class LatestVersionAdapter implements VersionAdapter { @Override public void registerVariantGameIntegrations(Object integrationRegistry, Object gameManager) { if (integrationRegistry instanceof IntegrationManager manager && gameManager instanceof AbstractGameManager gm) { - manager.a(new AdvancedSlimePaperIntegration(gm)); + manager.register(new AdvancedSlimePaperIntegration(gm)); } }