From 9ab0e405310fa4bc8e922380af259886155113ca Mon Sep 17 00:00:00 2001 From: 4drian3d Date: Sat, 9 Oct 2021 14:57:10 -0500 Subject: [PATCH] some changes --- .../common/utils/BossBarUtils.java | 32 +++++----- .../common/utils/ConfigUtils.java | 58 +++++++++---------- .../common/utils/GeneralUtils.java | 4 +- .../common/utils/TitleUtil.java | 2 +- .../paper/commands/AnnouncerCommand.java | 24 ++++---- .../actionbar/AnnouncerActionbarCommand.java | 13 ++--- .../actionbar/SelfActionbarCommand.java | 11 ++-- .../actionbar/SendActionbarCommand.java | 13 ++--- .../actionbar/WorldActionbarCommand.java | 11 ++-- .../bossbar/AnnouncerBossbarCommand.java | 27 +++++---- .../commands/bossbar/SelfBossbarCommand.java | 23 +++++--- .../commands/bossbar/SendBossbarCommand.java | 13 ++--- .../commands/bossbar/WorldBossbarCommand.java | 13 ++--- .../commands/title/AnnouncerTitleCommand.java | 21 ++++--- .../commands/title/SelfTitleCommand.java | 15 +++-- .../commands/title/SendTitleCommand.java | 17 +++--- .../commands/title/WorldTitleCommand.java | 15 +++-- .../paper/utils/RegisterCommands.java | 5 +- .../velocity/commands/AnnouncerCommand.java | 9 ++- .../actionbar/AnnouncerActionbarCommand.java | 7 +-- .../actionbar/SelfActionbarCommand.java | 9 ++- .../actionbar/SendActionbarCommand.java | 11 ++-- .../actionbar/ServerActionbarCommand.java | 11 ++-- .../bossbar/AnnouncerBossbarCommand.java | 11 ++-- .../commands/bossbar/SelfBossbarCommand.java | 11 ++-- .../commands/bossbar/SendBossbarCommand.java | 11 ++-- .../bossbar/ServerBossbarCommand.java | 11 ++-- .../commands/title/AnnouncerTitleCommand.java | 13 ++--- .../commands/title/SelfTitleCommand.java | 11 ++-- .../commands/title/SendTitleCommand.java | 13 ++--- .../commands/title/ServerTitleCommand.java | 13 ++--- .../velocity/utils/SoundUtils.java | 25 ++++---- 32 files changed, 236 insertions(+), 247 deletions(-) diff --git a/src/main/java/net/dreamerzero/titleannouncer/common/utils/BossBarUtils.java b/src/main/java/net/dreamerzero/titleannouncer/common/utils/BossBarUtils.java index 892b867..de98693 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/common/utils/BossBarUtils.java +++ b/src/main/java/net/dreamerzero/titleannouncer/common/utils/BossBarUtils.java @@ -4,7 +4,7 @@ import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.text.minimessage.MiniMessage; -public record BossBarUtils(ConfigUtils config, MiniMessage mm) { +public record BossBarUtils(MiniMessage mm) { /** * Based on the argument given in the command, * it will return the color of the specified bossbar. @@ -48,7 +48,7 @@ public boolean regularBossbarArgs(int length, Audience sender) { return switch (length) { case 0 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-argument", "You need to enter the time, color and message arguments.")))); @@ -56,7 +56,7 @@ public boolean regularBossbarArgs(int length, Audience sender) { } case 1 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.only-time", "You must enter the color and the message arguments.")))); @@ -64,7 +64,7 @@ public boolean regularBossbarArgs(int length, Audience sender) { } case 2 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.overlay-missing", "You must enter the overlay and the message arguments.")))); @@ -72,7 +72,7 @@ public boolean regularBossbarArgs(int length, Audience sender) { } case 3 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-message", "You need to enter the message to announce.")))); @@ -87,7 +87,7 @@ public boolean sendBossbarArgs(int length, Audience sender) { return switch (length) { case 0 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-argument", "You need to enter the time, color and message arguments.")))); @@ -95,7 +95,7 @@ public boolean sendBossbarArgs(int length, Audience sender) { } case 1 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.only-player", "You must enter the message to be sent after the player's name.")))); @@ -103,7 +103,7 @@ public boolean sendBossbarArgs(int length, Audience sender) { } case 2 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.only-time", "You must enter the color, overlay and the message arguments.")))); @@ -111,7 +111,7 @@ public boolean sendBossbarArgs(int length, Audience sender) { } case 3 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.overlay-missing", "You must enter the overlay and the message arguments.")))); @@ -119,7 +119,7 @@ public boolean sendBossbarArgs(int length, Audience sender) { } case 4 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-message", "You need to enter the message to announce.")))); @@ -134,7 +134,7 @@ public boolean proxyBossbarArgs(int length, Audience sender) { return switch (length) { case 0 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-argument", "You need to enter the time, color and message arguments.")))); @@ -142,7 +142,7 @@ public boolean proxyBossbarArgs(int length, Audience sender) { } case 1 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.general.no-server-provided", "No server provided to send the message")))); @@ -150,7 +150,7 @@ public boolean proxyBossbarArgs(int length, Audience sender) { } case 2 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.only-time", "You must enter the color, overlay and the message arguments.")))); @@ -158,7 +158,7 @@ public boolean proxyBossbarArgs(int length, Audience sender) { } case 3 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.overlay-missing", "You must enter the overlay and the message arguments.")))); @@ -166,7 +166,7 @@ public boolean proxyBossbarArgs(int length, Audience sender) { } case 4 -> { sender.sendMessage( - config.getPrefix().append(mm.parse( + ConfigUtils.getPrefix().append(mm.parse( cManager.getConfig().getOrDefault( "messages.bossbar.without-message", "You need to enter the message to announce.")))); @@ -180,7 +180,7 @@ public float validBossbarNumber(String number, Audience sender){ try { return Integer.parseInt(number); } catch (Exception e){ - sender.sendMessage(config.getPrefix().append( + sender.sendMessage(ConfigUtils.getPrefix().append( mm.parse("This is not a valid number"))); return 0.1f; } diff --git a/src/main/java/net/dreamerzero/titleannouncer/common/utils/ConfigUtils.java b/src/main/java/net/dreamerzero/titleannouncer/common/utils/ConfigUtils.java index f1c8750..3915822 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/common/utils/ConfigUtils.java +++ b/src/main/java/net/dreamerzero/titleannouncer/common/utils/ConfigUtils.java @@ -6,10 +6,10 @@ import net.kyori.adventure.text.minimessage.MiniMessage; public class ConfigUtils { - private Yaml config = new ConfigManager().getConfig(); - private MiniMessage mm = MiniMessage.miniMessage(); + private static Yaml config = new ConfigManager().getConfig(); + private static MiniMessage mm = MiniMessage.miniMessage(); - public Component getPrefix(){ + public static Component getPrefix(){ if (config.getOrDefault("messages.prefix.enabled", true)) { return mm.parse(config.getOrDefault( "messages.prefix.line", @@ -23,42 +23,42 @@ public Component getPrefix(){ TITLE CONFIGURATION -----------------------------*/ - public void sendTitleError(Audience sender){ + public static void sendTitleError(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.title.error", "An error occurred while sending the title. Be sure to use the ';' to separate the title and the subtitle.")))); } - public void sendNoArgumentMessage(Audience sender) { + public static void sendNoArgumentMessage(Audience sender) { sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.title.without-argument", "You need to enter the title and subtitle arguments.")))); } - public void noTitlePlayerArgumentProvided(Audience sender){ + public static void noTitlePlayerArgumentProvided(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.title.only-player", "You must enter the title and subtitle after the player's name to send the message correctly.")))); } - public String getTitleSound(){ + public static String getTitleSound(){ return config.getOrDefault( "sounds.title.sound-id", "entity.experience_orb.pickup"); } - public boolean isTitleSoundEnabled(){ + public static boolean isTitleSoundEnabled(){ return config.getOrDefault("sounds.title.enabled", true); } - public float getTitleSoundVolume(){ + public static float getTitleSoundVolume(){ return config.getOrDefault("sounds.title.volume", 10); } - public float getTitleSoundPitch(){ + public static float getTitleSoundPitch(){ return config.getOrDefault("sounds.title.pitch", 2); } @@ -66,7 +66,7 @@ public float getTitleSoundPitch(){ ACTIONBAR CONFIGURATION -----------------------------*/ - public void noActionbarArgumentProvided(Audience sender){ + public static void noActionbarArgumentProvided(Audience sender){ sender.sendMessage( getPrefix().append(mm.parse( config.getOrDefault( @@ -74,7 +74,7 @@ public void noActionbarArgumentProvided(Audience sender){ "You need to enter the message to announce.")))); } - public void noActionbarPlayerArgumentProvided(Audience sender){ + public static void noActionbarPlayerArgumentProvided(Audience sender){ sender.sendMessage( getPrefix().append(mm.parse( config.getOrDefault( @@ -82,21 +82,21 @@ public void noActionbarPlayerArgumentProvided(Audience sender){ "You must enter the message to be sent after the player's name.")))); } - public String getActionbarSound(){ + public static String getActionbarSound(){ return config.getOrDefault( "sounds.actionbar.sound-id", "entity.experience_orb.pickup"); } - public boolean isActionbarSoundEnabled(){ + public static boolean isActionbarSoundEnabled(){ return config.getOrDefault("sounds.actionbar.enabled", true); } - public float getActionbarSoundVolume(){ + public static float getActionbarSoundVolume(){ return config.getOrDefault("sounds.actionbar.volume", 10); } - public float getActionbarSoundPitch(){ + public static float getActionbarSoundPitch(){ return config.getOrDefault("sounds.actionbar.pitch", 2); } @@ -104,28 +104,28 @@ public float getActionbarSoundPitch(){ BOSSBAR CONFIGURATION -----------------------------*/ - public String getBossbarSound(){ + public static String getBossbarSound(){ return config.getOrDefault( "sounds.bossbar.sound-id", "entity.experience_orb.pickup"); } - public boolean isBossbarSoundEnabled(){ + public static boolean isBossbarSoundEnabled(){ return config.getOrDefault("sounds.bossbar.enabled", true); } - public float getBossbarSoundVolume(){ + public static float getBossbarSoundVolume(){ return config.getOrDefault("sounds.bossbar.volume", 10); } - public float getBossbarSoundPitch(){ + public static float getBossbarSoundPitch(){ return config.getOrDefault("sounds.bossbar.pitch", 2); } /* GENERAL CONFIGURATION */ - public void sendConfirmation(ComponentType type, Audience sender){ + public static void sendConfirmation(ComponentType type, Audience sender){ sender.sendMessage(getPrefix().append(mm.parse(switch(type){ case BOSSBAR -> config.getOrDefault( "messages.bossbar.successfully", @@ -139,7 +139,7 @@ public void sendConfirmation(ComponentType type, Audience sender){ }))); } - public void playPaperSound(ComponentType type, Audience audience){ + public static void playPaperSound(ComponentType type, Audience audience){ SoundUtil sUtils = new SoundUtil(); switch(type){ case TITLE -> { @@ -172,35 +172,35 @@ public void playPaperSound(ComponentType type, Audience audience){ } } - public void reloadMessage(Audience sender){ + public static void reloadMessage(Audience sender){ sender.sendMessage(mm.parse( config.getOrDefault( "messages.general.reload-config", "Config Reloaded"))); } - public void invalidCommand(Audience sender){ + public static void invalidCommand(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.general.invalid-command", "Unknown Command")))); } - public void helpPrefix(Audience sender){ + public static void helpPrefix(Audience sender){ sender.sendMessage(mm.parse( config.getOrDefault( "messages.general.help-message", "Available Commands:"))); } - public void playerNotFoundMessage(Audience sender){ + public static void playerNotFoundMessage(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.general.player-not-found", "Player not found")))); } - public void onlyPlayerExecute(Audience sender){ + public static void onlyPlayerExecute(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.general.no-console", @@ -208,7 +208,7 @@ public void onlyPlayerExecute(Audience sender){ ))); } - public void noServerArgumentProvided(Audience sender){ + public static void noServerArgumentProvided(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.general.no-server-provided", @@ -216,7 +216,7 @@ public void noServerArgumentProvided(Audience sender){ ))); } - public void noServerFound(Audience sender){ + public static void noServerFound(Audience sender){ sender.sendMessage(getPrefix().append(mm.parse( config.getOrDefault( "messages.general.server-not-found", diff --git a/src/main/java/net/dreamerzero/titleannouncer/common/utils/GeneralUtils.java b/src/main/java/net/dreamerzero/titleannouncer/common/utils/GeneralUtils.java index e698c98..2a7f63b 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/common/utils/GeneralUtils.java +++ b/src/main/java/net/dreamerzero/titleannouncer/common/utils/GeneralUtils.java @@ -6,7 +6,7 @@ public class GeneralUtils { * @param args Arguments of the command * @return The arguments of a command in string form */ - public String getCommandString(String[] args){ + public static String getCommandString(String[] args){ // Concatenate the arguments provided by the command sent. StringBuilder commandString = new StringBuilder(); for (String argument : args) { @@ -22,7 +22,7 @@ public String getCommandString(String[] args){ * @param since Specific position from which the string is to be formed * @return The command arguments from a specified position converted to String */ - public String getCommandString(String[] args, int since){ + public static String getCommandString(String[] args, int since){ // Concatenate the arguments provided by the command sent. StringBuilder commandString = new StringBuilder(); for (int i = since; i < args.length; i++) { diff --git a/src/main/java/net/dreamerzero/titleannouncer/common/utils/TitleUtil.java b/src/main/java/net/dreamerzero/titleannouncer/common/utils/TitleUtil.java index ab3b75d..20d95bc 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/common/utils/TitleUtil.java +++ b/src/main/java/net/dreamerzero/titleannouncer/common/utils/TitleUtil.java @@ -92,7 +92,7 @@ public String[] getTitleAndSubtitle(String string, Audience sender) { // it will catch the error in the console and send an error message to the sender. } catch (Exception e) { // Send an error message to the sender using the command - new ConfigUtils().sendTitleError(sender); + ConfigUtils.sendTitleError(sender); return null; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/AnnouncerCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/AnnouncerCommand.java index e924b41..483c9a6 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/AnnouncerCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/AnnouncerCommand.java @@ -10,7 +10,14 @@ import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.util.TriState; -public record AnnouncerCommand(MiniMessage mm) implements CommandExecutor { +public class AnnouncerCommand implements CommandExecutor { + private MiniMessage mm; + private PaperHelpMessages paperMessages; + + public AnnouncerCommand(MiniMessage mm){ + this.mm = mm; + paperMessages = new PaperHelpMessages(); + } // Main Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { @@ -19,12 +26,11 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String "TitleAnnouncer by 4drian3d")); return true; } - ConfigUtils config = new ConfigUtils(); - PaperHelpMessages paperMessages = new PaperHelpMessages(); + if (args.length == 0) { sender.sendMessage(mm.parse( "TitleAnnouncer by 4drian3d")); - config.helpPrefix(sender); + ConfigUtils.helpPrefix(sender); sender.sendMessage(paperMessages.titleHelpMessage); sender.sendMessage(paperMessages.actionbarHelpMessage); sender.sendMessage(paperMessages.bossbarHelpMessage); @@ -34,14 +40,13 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String switch (args[0].toLowerCase()) { case "reload" -> { new ConfigManager().getConfig().forceReload(); - config.reloadMessage(sender); + ConfigUtils.reloadMessage(sender); return true; } case "help" -> { - sender.sendMessage( - mm.parse( + sender.sendMessage(mm.parse( "TitleAnnouncer by 4drian3d")); - config.helpPrefix(sender); + ConfigUtils.helpPrefix(sender); if(args.length == 2){ switch (args[1].toLowerCase()) { case "title" -> { @@ -76,10 +81,9 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String } } default -> { - config.invalidCommand(sender); + ConfigUtils.invalidCommand(sender); return false; } } } - } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/AnnouncerActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/AnnouncerActionbarCommand.java index 97b4fcf..94a07ec 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/AnnouncerActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/AnnouncerActionbarCommand.java @@ -20,16 +20,15 @@ public record AnnouncerActionbarCommand(MiniMessage mm) implements CommandExecut // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return false; } boolean placeholderAPISupport = Announcer.placeholderAPIHook(); // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args); + String actionbartext = GeneralUtils.getCommandString(args); // The audience that will receive the actionbar will be all the players on the server. Audience audience = Bukkit.getServer(); @@ -39,16 +38,16 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String MiniMessageUtil.replaceLegacy( placeholderAPISupport ? PlaceholderAPI.setPlaceholders(player, actionbartext) : actionbartext), PPlaceholders.replacePlaceholders(player))); - config.playPaperSound(ComponentType.ACTIONBAR, audience); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.playPaperSound(ComponentType.ACTIONBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); return true; } else { audience.sendActionBar(mm.parse( MiniMessageUtil.replaceLegacy( placeholderAPISupport ? PlaceholderAPI.setPlaceholders(null, actionbartext) : actionbartext), PPlaceholders.replacePlaceholders())); - config.playPaperSound(ComponentType.ACTIONBAR, audience); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.playPaperSound(ComponentType.ACTIONBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SelfActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SelfActionbarCommand.java index 01554d3..1187d6d 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SelfActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SelfActionbarCommand.java @@ -18,29 +18,28 @@ public record SelfActionbarCommand(MiniMessage mm) implements CommandExecutor { //Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an actionbar to the one who executes the command, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return false; } // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args); + String actionbartext = GeneralUtils.getCommandString(args); // Send to sender sender.sendActionBar(mm.parse( MiniMessageUtil.replaceLegacy( Announcer.placeholderAPIHook() ? PlaceholderAPI.setPlaceholders(player, actionbartext) : actionbartext), PPlaceholders.replacePlaceholders(player))); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); - config.playPaperSound(ComponentType.ACTIONBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.playPaperSound(ComponentType.ACTIONBAR, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SendActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SendActionbarCommand.java index 4d4aa7a..46cb763 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SendActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/SendActionbarCommand.java @@ -19,12 +19,11 @@ public record SendActionbarCommand(MiniMessage mm) implements CommandExecutor { // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return false; } else if (args.length < 2) { - config.noActionbarPlayerArgumentProvided(sender); + ConfigUtils.noActionbarPlayerArgumentProvided(sender); return false; } @@ -36,20 +35,20 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (!serverplayers.contains(playerObjetive)) { // Send an error message to the sender using the command. - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return false; } // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args, 1); + String actionbartext = GeneralUtils.getCommandString(args, 1); playerObjetive.sendActionBar( mm.parse( MiniMessageUtil.replaceLegacy( Announcer.placeholderAPIHook() ? PlaceholderAPI.setPlaceholders(playerObjetive, actionbartext) : actionbartext), PPlaceholders.replacePlaceholders(playerObjetive))); - config.playPaperSound(ComponentType.ACTIONBAR, playerObjetive); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.playPaperSound(ComponentType.ACTIONBAR, playerObjetive); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/WorldActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/WorldActionbarCommand.java index af11ef8..567dbf7 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/WorldActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/actionbar/WorldActionbarCommand.java @@ -23,16 +23,15 @@ public WorldActionbarCommand(MiniMessage mm) { // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an actionbar to the world in which the command is executed, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return false; } @@ -40,14 +39,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String Audience audience = player.getWorld(); // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args); + String actionbartext = GeneralUtils.getCommandString(args); audience.sendActionBar( mm.parse(MiniMessageUtil.replaceLegacy( Announcer.placeholderAPIHook() ? PlaceholderAPI.setPlaceholders(player, actionbartext) : actionbartext), PPlaceholders.replacePlaceholders(player))); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); - config.playPaperSound(ComponentType.ACTIONBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.playPaperSound(ComponentType.ACTIONBAR, audience); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/AnnouncerBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/AnnouncerBossbarCommand.java index 01f0bef..cfb2629 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/AnnouncerBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/AnnouncerBossbarCommand.java @@ -21,21 +21,26 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; -public record AnnouncerBossbarCommand(Announcer plugin, MiniMessage mm) implements CommandExecutor { +public class AnnouncerBossbarCommand implements CommandExecutor { + private Announcer plugin; + private MiniMessage mm; + private Audience audience; + public AnnouncerBossbarCommand(Announcer plugin, MiniMessage mm){ + this.plugin = plugin; + this.mm = mm; + audience = Bukkit.getServer(); + } // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { // The command requires arguments to work - ConfigUtils config = new ConfigUtils(); - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); if (!bUtils.regularBossbarArgs(args.length, sender)) { return false; } - // The audience that will receive the bossbar will be all the players on the server. - Audience audience = Bukkit.getServer(); // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 3); + String bossbartext = GeneralUtils.getCommandString(args, 3); float time = bUtils.validBossbarNumber(args[0], sender); if(time == 0.1f) return false; @@ -46,7 +51,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PaperBossBar pBossBar = new PaperBossBar(plugin); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); + sender.sendMessage(ConfigUtils.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); return false; } @@ -62,8 +67,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PPlaceholders.replacePlaceholders(player)), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); - config.playPaperSound(ComponentType.BOSSBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.playPaperSound(ComponentType.BOSSBAR, audience); return true; } else { pBossBar.sendBukkitBossBar( @@ -75,8 +80,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PPlaceholders.replacePlaceholders()), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); - config.playPaperSound(ComponentType.BOSSBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.playPaperSound(ComponentType.BOSSBAR, audience); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SelfBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SelfBossbarCommand.java index a655213..5f47acc 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SelfBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SelfBossbarCommand.java @@ -19,19 +19,24 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; -public record SelfBossbarCommand(Announcer plugin, MiniMessage mm) implements CommandExecutor { - +public class SelfBossbarCommand implements CommandExecutor { + private MiniMessage mm; + private Announcer plugin; + private BossBarUtils bUtils; + public SelfBossbarCommand(Announcer plugin, MiniMessage mm){ + this.mm = mm; + this.plugin = plugin; + bUtils = new BossBarUtils(mm); + } // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an actionbar to the one who executes the command, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } - BossBarUtils bUtils = new BossBarUtils(config, mm); PaperBossBar pBossBar = new PaperBossBar(plugin); // The command requires arguments to work @@ -46,12 +51,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String BossBar.Overlay overlay = bUtils.bossbarOverlay(args[2]); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); + sender.sendMessage(ConfigUtils.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); return false; } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 4); + String bossbartext = GeneralUtils.getCommandString(args, 4); pBossBar.sendBukkitBossBar( player, @@ -61,8 +66,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PPlaceholders.replacePlaceholders(player)), color, overlay); - config.playPaperSound(ComponentType.BOSSBAR, sender); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.playPaperSound(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SendBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SendBossbarCommand.java index 4eab3bc..f9e64f2 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SendBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/SendBossbarCommand.java @@ -24,8 +24,7 @@ public record SendBossbarCommand(Announcer plugin, MiniMessage mm) implements Co // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); // The command requires arguments to work if (!bUtils.sendBossbarArgs(args.length, sender)) { @@ -39,7 +38,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String if (!serverplayers.contains(playerObjetive)) { // Send an error message to the sender using the command. - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return false; } @@ -50,12 +49,12 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String BossBar.Overlay overlay = bUtils.bossbarOverlay(args[3]); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); + sender.sendMessage(ConfigUtils.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); return false; } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 5); + String bossbartext = GeneralUtils.getCommandString(args, 5); new PaperBossBar(plugin).sendBukkitBossBar( playerObjetive, @@ -65,8 +64,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PPlaceholders.replacePlaceholders(playerObjetive)), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); - config.playPaperSound(ComponentType.BOSSBAR, playerObjetive); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.playPaperSound(ComponentType.BOSSBAR, playerObjetive); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/WorldBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/WorldBossbarCommand.java index fddf8c4..e5134f0 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/WorldBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/bossbar/WorldBossbarCommand.java @@ -24,15 +24,14 @@ public record WorldBossbarCommand(Announcer plugin, MiniMessage mm) implements C // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an actionbar to the world in which the command is executed, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } - BossBarUtils bUtils = new BossBarUtils(config,mm); + BossBarUtils bUtils = new BossBarUtils(mm); // The command requires arguments to work if (!bUtils.regularBossbarArgs(args.length, sender)) { @@ -40,7 +39,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 3); + String bossbartext = GeneralUtils.getCommandString(args, 3); float time = bUtils.validBossbarNumber(args[0], sender); if(time == 0.1f) return false; @@ -49,7 +48,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String BossBar.Overlay overlay = bUtils.bossbarOverlay(args[2]); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); + sender.sendMessage(ConfigUtils.getPrefix().append(Component.text("Invalid Argument", NamedTextColor.DARK_RED))); return false; } @@ -65,8 +64,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PPlaceholders.replacePlaceholders()), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); - config.playPaperSound(ComponentType.BOSSBAR, audience); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.playPaperSound(ComponentType.BOSSBAR, audience); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/AnnouncerTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/AnnouncerTitleCommand.java index 0936d8f..2cea8db 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/AnnouncerTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/AnnouncerTitleCommand.java @@ -28,16 +28,15 @@ public AnnouncerTitleCommand(MiniMessage mm) { // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); if(args.length == 0) { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return true; } boolean placeholderAPISupport = Announcer.placeholderAPIHook(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args); + String titleandsubtitle = GeneralUtils.getCommandString(args); TitleUtil tUtil = new TitleUtil(); if(!tUtil.containsComma(args)){ @@ -47,8 +46,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String placeholderAPISupport ? PlaceholderAPI.setPlaceholders(player, titleandsubtitle) : titleandsubtitle), PPlaceholders.replacePlaceholders(player)), audience, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); return true; } else { tUtil.sendOnlySubtitle( @@ -56,8 +55,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String placeholderAPISupport ? PlaceholderAPI.setPlaceholders(null, titleandsubtitle) : titleandsubtitle), PPlaceholders.replacePlaceholders()), audience, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); return true; } } @@ -79,8 +78,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String 1000, 3000, 1000); - config.playPaperSound(ComponentType.TITLE, audience); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); return true; } else { // Send the title @@ -95,8 +94,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String 1000, 3000, 1000); - config.playPaperSound(ComponentType.TITLE, audience); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SelfTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SelfTitleCommand.java index eef38e6..46089e3 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SelfTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SelfTitleCommand.java @@ -23,24 +23,23 @@ public SelfTitleCommand(MiniMessage mm) { // Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an title to the one who executes the command, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } // The command requires arguments to work if(args.length == 0){ - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return true; } boolean placeholderAPISupport = Announcer.placeholderAPIHook(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args); + String titleandsubtitle = GeneralUtils.getCommandString(args); TitleUtil tUtil = new TitleUtil(); @@ -50,8 +49,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String placeholderAPISupport ? PlaceholderAPI.setPlaceholders(player, titleandsubtitle) : titleandsubtitle), PPlaceholders.replacePlaceholders(player)), sender, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, sender); return true; } @@ -71,8 +70,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SendTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SendTitleCommand.java index 56c3c8d..a998534 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SendTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/SendTitleCommand.java @@ -24,15 +24,14 @@ public SendTitleCommand(MiniMessage mm) { //Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // The command requires arguments to work switch (args.length) { case 0 -> { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return true; } case 1 -> { - config.noTitlePlayerArgumentProvided(sender); + ConfigUtils.noTitlePlayerArgumentProvided(sender); return true; } } @@ -40,14 +39,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String boolean placeholderAPISupport = Announcer.placeholderAPIHook(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args, 1); + String titleandsubtitle = GeneralUtils.getCommandString(args, 1); var serverplayers = Bukkit.getOnlinePlayers(); Player playerObjetive = Bukkit.getPlayer(args[0]); if (!serverplayers.contains(playerObjetive)) { // Send an error message to the sender using the command. - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return false; } @@ -59,8 +58,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String placeholderAPISupport ? PlaceholderAPI.setPlaceholders(playerObjetive, titleandsubtitle) : titleandsubtitle), PPlaceholders.replacePlaceholders(playerObjetive)), playerObjetive, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, playerObjetive); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, playerObjetive); return true; } @@ -77,8 +76,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PlaceholderAPI.setPlaceholders(playerObjetive, titleandsubtitlefinal[1])) : titleandsubtitlefinal[1], PPlaceholders.replacePlaceholders(playerObjetive)), playerObjetive, 1000, 3000, 1000); - config.playPaperSound(ComponentType.TITLE, playerObjetive); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, playerObjetive); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/WorldTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/WorldTitleCommand.java index 732c6f3..c53532b 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/WorldTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/commands/title/WorldTitleCommand.java @@ -24,11 +24,10 @@ public WorldTitleCommand(MiniMessage mm) { //Command public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - ConfigUtils config = new ConfigUtils(); // It will send an title to the one who executes the command, // it makes no sense for the console to execute it. if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return false; } @@ -37,14 +36,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String // The command requires arguments to work if(args.length == 0){ - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return false; } boolean placeholderAPISupport = Announcer.placeholderAPIHook(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args); + String titleandsubtitle = GeneralUtils.getCommandString(args); TitleUtil tUtil = new TitleUtil(); @@ -55,8 +54,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PlaceholderAPI.setPlaceholders(player, titleandsubtitle) : titleandsubtitle), PPlaceholders.replacePlaceholders(player)), sender, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); - config.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); return true; } @@ -75,8 +74,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String 1000, 3000, 1000); - config.playPaperSound(ComponentType.TITLE, audience); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.playPaperSound(ComponentType.TITLE, audience); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); return true; } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/paper/utils/RegisterCommands.java b/src/main/java/net/dreamerzero/titleannouncer/paper/utils/RegisterCommands.java index fb934c4..0020f9c 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/paper/utils/RegisterCommands.java +++ b/src/main/java/net/dreamerzero/titleannouncer/paper/utils/RegisterCommands.java @@ -59,9 +59,8 @@ private void initCommand(CommandFactory ...factories) { PluginCommand command = this.plugin.getCommand(factory.command()); command.setExecutor(factory.executor()); command.permissionMessage( - new ConfigUtils().getPrefix().append( - mm.parse( - config.getString("messages.general.no-permission")))); + ConfigUtils.getPrefix().append( + mm.parse(config.getString("messages.general.no-permission")))); } } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/AnnouncerCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/AnnouncerCommand.java index ec166c2..9d9dbc3 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/AnnouncerCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/AnnouncerCommand.java @@ -15,12 +15,11 @@ public record AnnouncerCommand(MiniMessage mm) implements SimpleCommand { public void execute(Invocation invocation) { CommandSource source = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); if (args.length == 0) { source.sendMessage(mm.parse( "TitleAnnouncer by 4drian3d")); - config.helpPrefix(source); + ConfigUtils.helpPrefix(source); source.sendMessage(VelocityHelpMessages.titleHelpMessage); source.sendMessage(VelocityHelpMessages.actionbarHelpMessage); source.sendMessage(VelocityHelpMessages.bossbarHelpMessage); @@ -31,13 +30,13 @@ public void execute(Invocation invocation) { switch (args[0].toLowerCase()) { case "reload" -> { new ConfigManager().getConfig().forceReload(); - config.reloadMessage(source); + ConfigUtils.reloadMessage(source); } case "help" -> { source.sendMessage( mm.parse( "TitleAnnouncer by 4drian3d")); - config.helpPrefix(source); + ConfigUtils.helpPrefix(source); if(args.length == 2){ switch (args[1].toLowerCase()) { case "title" -> { @@ -67,7 +66,7 @@ public void execute(Invocation invocation) { } } default -> { - config.invalidCommand(source); + ConfigUtils.invalidCommand(source); } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/AnnouncerActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/AnnouncerActionbarCommand.java index 238a64f..bba4b1b 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/AnnouncerActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/AnnouncerActionbarCommand.java @@ -22,12 +22,11 @@ public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args); - ConfigUtils config = new ConfigUtils(); + String actionbartext = GeneralUtils.getCommandString(args); VPlaceholders vPlaceholders = new VPlaceholders(server); if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return; } @@ -39,7 +38,7 @@ public void execute(Invocation invocation) { vPlaceholders.replaceProxyPlaceholders(player) : vPlaceholders.replaceProxyPlaceholders())); new SoundUtils(server).playProxySound(ComponentType.ACTIONBAR); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SelfActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SelfActionbarCommand.java index f80cf54..f929cb6 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SelfActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SelfActionbarCommand.java @@ -20,25 +20,24 @@ public record SelfActionbarCommand(ProxyServer server, MiniMessage mm) implement public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); if(!(sender instanceof Player player)){ - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return; } if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return; } // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args); + String actionbartext = GeneralUtils.getCommandString(args); sender.sendActionBar(mm.parse( MiniMessageUtil.replaceLegacy(actionbartext), vPlaceholders.replaceProxyPlaceholders(player))); new SoundUtils(server).playProxySound(player, ComponentType.ACTIONBAR); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SendActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SendActionbarCommand.java index 3a2f76e..faa18c4 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SendActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/SendActionbarCommand.java @@ -23,26 +23,25 @@ public record SendActionbarCommand(ProxyServer server, MiniMessage mm) implement public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return; }else if (args.length < 2) { - config.noActionbarPlayerArgumentProvided(sender); + ConfigUtils.noActionbarPlayerArgumentProvided(sender); return; } Optional optionalPlayerObjetive = server.getPlayer(args[0]); if(!optionalPlayerObjetive.isPresent()) { - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return; } Player playerObjetive = optionalPlayerObjetive.get(); // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args, 1); + String actionbartext = GeneralUtils.getCommandString(args, 1); playerObjetive.sendActionBar( mm.parse( @@ -50,7 +49,7 @@ public void execute(Invocation invocation) { actionbartext), vPlaceholders.replaceProxyPlaceholders(playerObjetive))); new SoundUtils(server).playProxySound(playerObjetive, ComponentType.ACTIONBAR); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/ServerActionbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/ServerActionbarCommand.java index 4588e7b..3c3db57 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/ServerActionbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/actionbar/ServerActionbarCommand.java @@ -23,26 +23,25 @@ public record ServerActionbarCommand(ProxyServer server, MiniMessage mm) impleme public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); if(args.length == 0) { - config.noActionbarArgumentProvided(sender); + ConfigUtils.noActionbarArgumentProvided(sender); return; }else if (args.length < 2) { - config.noServerArgumentProvided(sender); + ConfigUtils.noServerArgumentProvided(sender); return; } Optional optionalServerObjetive = server.getServer(args[0]); if(!optionalServerObjetive.isPresent()) { - config.noServerFound(sender); + ConfigUtils.noServerFound(sender); return; } RegisteredServer serverObjetive = optionalServerObjetive.get(); // Concatenate the arguments provided by the command sent. - String actionbartext = new GeneralUtils().getCommandString(args, 1); + String actionbartext = GeneralUtils.getCommandString(args, 1); serverObjetive.sendActionBar( mm.parse( @@ -50,7 +49,7 @@ public void execute(Invocation invocation) { actionbartext), vPlaceholders.replaceProxyPlaceholders())); new SoundUtils(server).playProxySound(serverObjetive, ComponentType.ACTIONBAR); - config.sendConfirmation(ComponentType.ACTIONBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.ACTIONBAR, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/AnnouncerBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/AnnouncerBossbarCommand.java index 204813d..066fa46 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/AnnouncerBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/AnnouncerBossbarCommand.java @@ -25,8 +25,7 @@ public record AnnouncerBossbarCommand(ProxyServer server, Announcer plugin, Mini public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); VelocityBossbar vBossbar = new VelocityBossbar(plugin, server); VPlaceholders vPlaceholders = new VPlaceholders(server); @@ -36,7 +35,7 @@ public void execute(Invocation invocation) { } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 3); + String bossbartext = GeneralUtils.getCommandString(args, 3); float time = bUtils.validBossbarNumber(args[0], sender); if(time == 0.1f) return; @@ -46,7 +45,7 @@ public void execute(Invocation invocation) { if (color == null || overlay == null) { sender.sendMessage( - config.getPrefix().append( + ConfigUtils.getPrefix().append( mm.parse("Invalid Argument"))); return; } @@ -64,7 +63,7 @@ public void execute(Invocation invocation) { vPlaceholders.replaceProxyPlaceholders(player)), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); sUtils.playProxySound(ComponentType.BOSSBAR); return; } else { @@ -77,7 +76,7 @@ public void execute(Invocation invocation) { vPlaceholders.replaceProxyPlaceholders()), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); sUtils.playProxySound(ComponentType.BOSSBAR); } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SelfBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SelfBossbarCommand.java index 4cfa2c8..017f336 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SelfBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SelfBossbarCommand.java @@ -24,14 +24,13 @@ public record SelfBossbarCommand(Announcer plugin, ProxyServer server, MiniMessa public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return; } - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); // The command requires arguments to work if (!bUtils.regularBossbarArgs(args.length, sender)) { @@ -39,7 +38,7 @@ public void execute(Invocation invocation) { } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 3); + String bossbartext = GeneralUtils.getCommandString(args, 3); float time = bUtils.validBossbarNumber(args[0], sender); if(time == 0.1f) return; @@ -49,7 +48,7 @@ public void execute(Invocation invocation) { if (color == null || overlay == null) { sender.sendMessage( - config.getPrefix().append( + ConfigUtils.getPrefix().append( mm.parse("Invalid Argument"))); return; } @@ -63,7 +62,7 @@ public void execute(Invocation invocation) { new VPlaceholders(server).replaceProxyPlaceholders(player)), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); new SoundUtils(server).playProxySound(player, ComponentType.BOSSBAR); } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SendBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SendBossbarCommand.java index 09f3d0c..106a094 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SendBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/SendBossbarCommand.java @@ -27,8 +27,7 @@ public record SendBossbarCommand(ProxyServer server, Announcer plugin, MiniMessa public void execute(Invocation invocation){ CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); VelocityBossbar vBossbar = new VelocityBossbar(plugin, server); // The command requires arguments to work @@ -38,7 +37,7 @@ public void execute(Invocation invocation){ Optional optionalPlayerObjetive = server.getPlayer(args[0]); if(!optionalPlayerObjetive.isPresent()) { - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return; } Player playerObjetive = optionalPlayerObjetive.get(); @@ -50,12 +49,12 @@ public void execute(Invocation invocation){ BossBar.Overlay overlay = bUtils.bossbarOverlay(args[3]); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(mm.parse("Invalid Argument"))); + sender.sendMessage(ConfigUtils.getPrefix().append(mm.parse("Invalid Argument"))); return; } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 5); + String bossbartext = GeneralUtils.getCommandString(args, 5); vBossbar.sendVelocityBossbar( playerObjetive, @@ -66,7 +65,7 @@ public void execute(Invocation invocation){ new VPlaceholders(server).replaceProxyPlaceholders(playerObjetive)), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); new SoundUtils(server).playProxySound(playerObjetive, ComponentType.BOSSBAR); } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/ServerBossbarCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/ServerBossbarCommand.java index 9c9c02b..fe9c6f8 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/ServerBossbarCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/bossbar/ServerBossbarCommand.java @@ -27,8 +27,7 @@ public record ServerBossbarCommand(ProxyServer server, Announcer plugin, MiniMes public void execute(Invocation invocation){ CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); - BossBarUtils bUtils = new BossBarUtils(config, mm); + BossBarUtils bUtils = new BossBarUtils(mm); // The command requires arguments to work if (!bUtils.proxyBossbarArgs(args.length, sender)) { @@ -37,7 +36,7 @@ public void execute(Invocation invocation){ Optional optionalServerObjetive = server.getServer(args[0]); if(!optionalServerObjetive.isPresent()) { - config.noServerFound(sender); + ConfigUtils.noServerFound(sender); return; } RegisteredServer serverObjetive = optionalServerObjetive.get(); @@ -49,12 +48,12 @@ public void execute(Invocation invocation){ BossBar.Overlay overlay = bUtils.bossbarOverlay(args[3]); if (color == null || overlay == null) { - sender.sendMessage(config.getPrefix().append(mm.parse("Invalid Argument"))); + sender.sendMessage(ConfigUtils.getPrefix().append(mm.parse("Invalid Argument"))); return; } // Concatenate the arguments provided by the command sent. - String bossbartext = new GeneralUtils().getCommandString(args, 5); + String bossbartext = GeneralUtils.getCommandString(args, 5); new VelocityBossbar(plugin, server).sendVelocityBossbar( serverObjetive, @@ -65,7 +64,7 @@ public void execute(Invocation invocation){ new VPlaceholders(server).replaceProxyPlaceholders()), color, overlay); - config.sendConfirmation(ComponentType.BOSSBAR, sender); + ConfigUtils.sendConfirmation(ComponentType.BOSSBAR, sender); new SoundUtils(server).playProxySound(serverObjetive, ComponentType.BOSSBAR); } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/AnnouncerTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/AnnouncerTitleCommand.java index e6a3f16..9aad78a 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/AnnouncerTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/AnnouncerTitleCommand.java @@ -22,16 +22,15 @@ public record AnnouncerTitleCommand(ProxyServer server, MiniMessage mm) implemen public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); if(args.length == 0) { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return; } // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args); + String titleandsubtitle = GeneralUtils.getCommandString(args); SoundUtils sUtils = new SoundUtils(server); TitleUtil tUtil = new TitleUtil(); @@ -43,7 +42,7 @@ public void execute(Invocation invocation) { MiniMessageUtil.replaceLegacy(titleandsubtitle), vPlaceholders.replaceProxyPlaceholders(player)), server, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); sUtils.playProxySound(ComponentType.TITLE); return; } else { @@ -52,7 +51,7 @@ public void execute(Invocation invocation) { MiniMessageUtil.replaceLegacy(titleandsubtitle), vPlaceholders.replaceProxyPlaceholders()), server, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); sUtils.playProxySound(ComponentType.TITLE); return; } @@ -77,7 +76,7 @@ public void execute(Invocation invocation) { 3000, 1000); sUtils.playProxySound(ComponentType.TITLE); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); } else { // Send the title tUtil.sendTitle( @@ -92,7 +91,7 @@ public void execute(Invocation invocation) { 3000, 1000); sUtils.playProxySound(ComponentType.TITLE); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); } } diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SelfTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SelfTitleCommand.java index be275a8..3fb8466 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SelfTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SelfTitleCommand.java @@ -22,21 +22,20 @@ public record SelfTitleCommand(ProxyServer server, MiniMessage mm) implements Si public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); if (!(sender instanceof Player player)) { - config.onlyPlayerExecute(sender); + ConfigUtils.onlyPlayerExecute(sender); return; } if(args.length == 0) { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return; } // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args); + String titleandsubtitle = GeneralUtils.getCommandString(args); SoundUtils sUtils = new SoundUtils(server); TitleUtil tUtil = new TitleUtil(); @@ -46,7 +45,7 @@ public void execute(Invocation invocation) { mm.parse(MiniMessageUtil.replaceLegacy(titleandsubtitle), vPlaceholders.replaceProxyPlaceholders(player)), sender, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); sUtils.playProxySound(player, ComponentType.TITLE); return; } @@ -68,7 +67,7 @@ public void execute(Invocation invocation) { 3000, 1000); sUtils.playProxySound(player, ComponentType.TITLE); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SendTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SendTitleCommand.java index 36663ff..516b170 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SendTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/SendTitleCommand.java @@ -24,29 +24,28 @@ public record SendTitleCommand(ProxyServer server, MiniMessage mm) implements Si public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); switch (args.length) { case 0 -> { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return; } case 1 -> { - config.noTitlePlayerArgumentProvided(sender); + ConfigUtils.noTitlePlayerArgumentProvided(sender); return; } } Optional optionalPlayerObjetive = server.getPlayer(args[0]); if(!optionalPlayerObjetive.isPresent()) { - config.playerNotFoundMessage(sender); + ConfigUtils.playerNotFoundMessage(sender); return; } Player playerObjetive = optionalPlayerObjetive.get(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args, 1); + String titleandsubtitle = GeneralUtils.getCommandString(args, 1); SoundUtils sUtils = new SoundUtils(server); TitleUtil tUtil = new TitleUtil(); @@ -56,7 +55,7 @@ public void execute(Invocation invocation) { mm.parse(MiniMessageUtil.replaceLegacy(titleandsubtitle), vPlaceholders.replaceProxyPlaceholders(playerObjetive)), playerObjetive, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); sUtils.playProxySound(playerObjetive, ComponentType.TITLE); return; } @@ -78,7 +77,7 @@ public void execute(Invocation invocation) { 3000, 1000); sUtils.playProxySound(playerObjetive, ComponentType.TITLE); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/ServerTitleCommand.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/ServerTitleCommand.java index 4a0adb2..8a7369b 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/ServerTitleCommand.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/commands/title/ServerTitleCommand.java @@ -24,29 +24,28 @@ public record ServerTitleCommand(ProxyServer server, MiniMessage mm) implements public void execute(Invocation invocation) { CommandSource sender = invocation.source(); String[] args = invocation.arguments(); - ConfigUtils config = new ConfigUtils(); VPlaceholders vPlaceholders = new VPlaceholders(server); switch (args.length) { case 0 -> { - config.sendNoArgumentMessage(sender); + ConfigUtils.sendNoArgumentMessage(sender); return; } case 1 -> { - config.noServerArgumentProvided(sender); + ConfigUtils.noServerArgumentProvided(sender); return; } } Optional optionalServerObjetive = server.getServer(args[0]); if(!optionalServerObjetive.isPresent()) { - config.noServerFound(sender); + ConfigUtils.noServerFound(sender); return; } RegisteredServer serverObjetive = optionalServerObjetive.get(); // Concatenate the arguments provided by the command sent. - String titleandsubtitle = new GeneralUtils().getCommandString(args, 1); + String titleandsubtitle = GeneralUtils.getCommandString(args, 1); SoundUtils sUtils = new SoundUtils(server); TitleUtil tUtil = new TitleUtil(); @@ -56,7 +55,7 @@ public void execute(Invocation invocation) { mm.parse(MiniMessageUtil.replaceLegacy(titleandsubtitle), vPlaceholders.replaceProxyPlaceholders()), serverObjetive, 1000, 3000, 1000); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); sUtils.playProxySound(serverObjetive, ComponentType.TITLE); return; } @@ -78,7 +77,7 @@ public void execute(Invocation invocation) { 3000, 1000); sUtils.playProxySound(serverObjetive, ComponentType.TITLE); - config.sendConfirmation(ComponentType.TITLE, sender); + ConfigUtils.sendConfirmation(ComponentType.TITLE, sender); } @Override diff --git a/src/main/java/net/dreamerzero/titleannouncer/velocity/utils/SoundUtils.java b/src/main/java/net/dreamerzero/titleannouncer/velocity/utils/SoundUtils.java index 6d6141c..c34baae 100644 --- a/src/main/java/net/dreamerzero/titleannouncer/velocity/utils/SoundUtils.java +++ b/src/main/java/net/dreamerzero/titleannouncer/velocity/utils/SoundUtils.java @@ -17,7 +17,6 @@ public class SoundUtils { private static Sound titleSound; private static Sound actionbarSound; private static Sound bossbarSound; - private ConfigUtils config = new ConfigUtils(); private ProxyServer proxy; public SoundUtils(ProxyServer server){ @@ -25,15 +24,15 @@ public SoundUtils(ProxyServer server){ } public void setTitleSound(){ - titleSound = SoundTransformer.getSoundFromString(config.getTitleSound()); + titleSound = SoundTransformer.getSoundFromString(ConfigUtils.getTitleSound()); } public void setBossBarSound(){ - bossbarSound = SoundTransformer.getSoundFromString(config.getBossbarSound()); + bossbarSound = SoundTransformer.getSoundFromString(ConfigUtils.getBossbarSound()); } public void setActionBarSound(){ - actionbarSound = SoundTransformer.getSoundFromString(config.getActionbarSound()); + actionbarSound = SoundTransformer.getSoundFromString(ConfigUtils.getActionbarSound()); } public Sound getTitleSound(){ @@ -54,9 +53,9 @@ public void playProxySound(Player player, ComponentType type){ UUID playeruuid = player.getUniqueId(); ProtocolizePlayer protocolizePlayer = Protocolize.playerProvider().player(playeruuid); switch(type) { - case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, config.getTitleSoundVolume(), config.getTitleSoundPitch()); - case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, config.getBossbarSoundVolume(), config.getBossbarSoundPitch()); - case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, config.getActionbarSoundVolume(), config.getActionbarSoundPitch()); + case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, ConfigUtils.getTitleSoundVolume(), ConfigUtils.getTitleSoundPitch()); + case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, ConfigUtils.getBossbarSoundVolume(), ConfigUtils.getBossbarSoundPitch()); + case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, ConfigUtils.getActionbarSoundVolume(), ConfigUtils.getActionbarSoundPitch()); }; } @@ -69,9 +68,9 @@ public void playProxySound(ComponentType type){ ProtocolizePlayer protocolizePlayer = Protocolize.playerProvider().player(playeruuid); switch(type) { - case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, config.getTitleSoundVolume(), config.getTitleSoundPitch()); - case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, config.getBossbarSoundVolume(), config.getBossbarSoundPitch()); - case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, config.getActionbarSoundVolume(), config.getActionbarSoundPitch()); + case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, ConfigUtils.getTitleSoundVolume(), ConfigUtils.getTitleSoundPitch()); + case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, ConfigUtils.getBossbarSoundVolume(), ConfigUtils.getBossbarSoundPitch()); + case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, ConfigUtils.getActionbarSoundVolume(), ConfigUtils.getActionbarSoundPitch()); }; } } @@ -84,9 +83,9 @@ public void playProxySound(RegisteredServer server, ComponentType type){ ProtocolizePlayer protocolizePlayer = Protocolize.playerProvider().player(playeruuid); switch(type) { - case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, config.getTitleSoundVolume(), config.getTitleSoundPitch()); - case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, config.getBossbarSoundVolume(), config.getBossbarSoundPitch()); - case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, config.getActionbarSoundVolume(), config.getActionbarSoundPitch()); + case TITLE -> protocolizePlayer.playSound(getTitleSound(), SoundCategory.MASTER, ConfigUtils.getTitleSoundVolume(), ConfigUtils.getTitleSoundPitch()); + case BOSSBAR -> protocolizePlayer.playSound(getBossBarSound(), SoundCategory.MASTER, ConfigUtils.getBossbarSoundVolume(), ConfigUtils.getBossbarSoundPitch()); + case ACTIONBAR -> protocolizePlayer.playSound(getActionBarSound(), SoundCategory.MASTER, ConfigUtils.getActionbarSoundVolume(), ConfigUtils.getActionbarSoundPitch()); }; } }