From 3b5212cb08e18927e138d985c782c9b92dba3a82 Mon Sep 17 00:00:00 2001 From: Quinten Date: Thu, 16 Jun 2022 19:20:46 +0200 Subject: [PATCH 1/2] fixes of the message /sm reload not affecting --- pom.xml | 9 +++++-- .../subcommands/GetFlagSubCommand.java | 3 +-- .../subcommands/ResetFlagSubCommand.java | 2 +- .../commands/subcommands/SetFlagCommand.java | 2 +- .../sleepmost/mappers/MessageMapper.java | 24 +++++++++---------- .../runnables/NightcycleAnimationTask.java | 1 + .../sleepmost/services/MessageService.java | 16 +++++++++---- .../sleepmost/statics/ServerVersion.java | 4 ++-- src/main/resources/config.yml | 4 ++-- 9 files changed, 37 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index fe066e1..eaf45db 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 me.mrgeneralq sleep-most - 5.0.2 + 5.0.3 SleepMost @@ -112,7 +112,7 @@ org.spigotmc spigot-api - 1.18-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT provided @@ -127,5 +127,10 @@ 2.10.9 provided + + org.apache.commons + commons-lang3 + 3.1 + \ No newline at end of file diff --git a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/GetFlagSubCommand.java b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/GetFlagSubCommand.java index 3bf51e0..8528715 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/GetFlagSubCommand.java +++ b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/GetFlagSubCommand.java @@ -1,8 +1,7 @@ package me.mrgeneralq.sleepmost.commands.subcommands; import me.mrgeneralq.sleepmost.enums.MessageKey; -import me.mrgeneralq.sleepmost.flags.types.TabCompletedFlag; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/ResetFlagSubCommand.java b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/ResetFlagSubCommand.java index 932ede7..8f7255c 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/ResetFlagSubCommand.java +++ b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/ResetFlagSubCommand.java @@ -1,7 +1,7 @@ package me.mrgeneralq.sleepmost.commands.subcommands; import me.mrgeneralq.sleepmost.enums.MessageKey; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/SetFlagCommand.java b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/SetFlagCommand.java index 7470157..f8054f7 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/SetFlagCommand.java +++ b/src/main/java/me/mrgeneralq/sleepmost/commands/subcommands/SetFlagCommand.java @@ -5,7 +5,7 @@ import me.mrgeneralq.sleepmost.interfaces.*; import me.mrgeneralq.sleepmost.flags.ISleepFlag; import me.mrgeneralq.sleepmost.statics.CommandSenderUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/main/java/me/mrgeneralq/sleepmost/mappers/MessageMapper.java b/src/main/java/me/mrgeneralq/sleepmost/mappers/MessageMapper.java index 56350d0..2590a11 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/mappers/MessageMapper.java +++ b/src/main/java/me/mrgeneralq/sleepmost/mappers/MessageMapper.java @@ -32,30 +32,29 @@ public void loadMessages(){ this.messages.put(MessageKey.NO_PERMISSION_COMMAND, new ConfigMessage("admin.no-permission-command", "&cYou do not have permission to do this")); this.messages.put(MessageKey.UNKNOWN_COMMAND, new ConfigMessage("admin.unknown-command", "&cUnknown command")); this.messages.put(MessageKey.CONFIG_RELOADED, new ConfigMessage("admin.config-reloaded", "&aYou successfully reloaded Sleep-Most plugin")); - //this.messages.put(MessageKey.ONLY_PLAYERS_COMMAND, new ConfigMessage("", "default message")); - this.messages.put(MessageKey.ALREADY_ENABLED_FOR_WORLD, new ConfigMessage("admin.already-enabled-for-world", "&cSleep-Most is already enabled in %world%")); - this.messages.put(MessageKey.ALREADY_DISABLED_FOR_WORLD, new ConfigMessage("admin.already-disabled-for-world", "&cSleep-Most is already disabled in %world%")); - this.messages.put(MessageKey.ENABLED_FOR_WORLD, new ConfigMessage("admin.enabled-for-world", "&cSleep-Most is now enabled in %world%")); - this.messages.put(MessageKey.DISABLED_FOR_WORLD, new ConfigMessage("admin.disabled-for-world", "&cSleep-Most is now disabled in %world%")); - this.messages.put(MessageKey.NOT_ENABLED_FOR_WORLD, new ConfigMessage("admin.not-enabled-for-world", "&cSleep-Most is not enabled in %world%. Enable it with &a/sm enable")); + this.messages.put(MessageKey.ALREADY_ENABLED_FOR_WORLD, new ConfigMessage("admin.already-enabled-for-world", "&cSleep-Most is already enabled in &a%world%")); + this.messages.put(MessageKey.ALREADY_DISABLED_FOR_WORLD, new ConfigMessage("admin.already-disabled-for-world", "&cSleep-Most is already disabled in &a%world%")); + this.messages.put(MessageKey.ENABLED_FOR_WORLD, new ConfigMessage("admin.enabled-for-world", "&bSleep-Most is now enabled in &a%world%")); + this.messages.put(MessageKey.DISABLED_FOR_WORLD, new ConfigMessage("admin.disabled-for-world", "&cSleep-Most is now disabled in &a%world%")); + this.messages.put(MessageKey.NOT_ENABLED_FOR_WORLD, new ConfigMessage("admin.not-enabled-for-world", "&cSleep-Most is not enabled in &a%world%&c. Enable it with &a/sm enable")); this.messages.put(MessageKey.CURRENTLY_DISABLED, new ConfigMessage("admin.currently-disabled", "&bSleepmost is currently &cdisabled &bfor this world. Type &a/sm enable &bto enable sleepmost for this world")); this.messages.put(MessageKey.CANNOT_SLEEP_NOW, new ConfigMessage("user.cannot-sleep-now", "&cYou cannot sleep right now")); this.messages.put(MessageKey.ALL_FLAGS_RESET_SUCCESS, new ConfigMessage("flag.all-reset-success", "&cAll flags were successfully reset")); - this.messages.put(MessageKey.SLEEP_SUCCESS, new ConfigMessage("user.sleep-success", "&aYou are now asleep")); + this.messages.put(MessageKey.SLEEP_SUCCESS, new ConfigMessage("user.sleep-success", "&bYou are now asleep")); this.messages.put(MessageKey.NO_LONGER_SLEEPING, new ConfigMessage("user.no-longer-sleeping", "&cYou are no longer sleeping")); this.messages.put(MessageKey.NO_BED_LOCATION_SET, new ConfigMessage("user.no-bed-location-set", "&cThere is no bed location set")); - this.messages.put(MessageKey.TELEPORTED_TO_BED, new ConfigMessage("user.teleported-to-bed", "&cYou were teleported to your bed")); + this.messages.put(MessageKey.TELEPORTED_TO_BED, new ConfigMessage("user.teleported-to-bed", "&bYou were teleported to your bed")); this.messages.put(MessageKey.SLEEP_CMD_DISABLED, new ConfigMessage("user.sleep-command-disabled", "&cThe sleep-command is disabled")); - this.messages.put(MessageKey.ONE_PLAYER_SLEEP_SET, new ConfigMessage("admin.one-player-sleep-set", "&cOne player sleep has been configured")); + this.messages.put(MessageKey.ONE_PLAYER_SLEEP_SET, new ConfigMessage("admin.one-player-sleep-set", "&bOne player sleep has been configured")); this.messages.put(MessageKey.SPECIFY_PLAYER, new ConfigMessage("admin.specify-player", "&cPlease specify with the player username")); this.messages.put(MessageKey.TARGET_NOT_SLEEPING, new ConfigMessage("admin.target-not-sleeping", "&cThe player is not sleeping")); this.messages.put(MessageKey.TARGET_NOT_ONLINE, new ConfigMessage("admin.target-not-online", "&cThe player is not online")); - this.messages.put(MessageKey.INSOMNIA_NOT_SLEEPY, new ConfigMessage("user.insomnia-not-sleepy", "&cYou don't feel sleepy at the moment")); + this.messages.put(MessageKey.INSOMNIA_NOT_SLEEPY, new ConfigMessage("user.insomnia-not-sleepy", "&cYou don`t feel sleepy at the moment")); this.messages.put(MessageKey.INSOMNIA_ALREADY_ENABLED, new ConfigMessage("admin.insomnia-already-enabled", "&cInsomnia is already enabled in this world")); - this.messages.put(MessageKey.INSOMNIA_ENABLED, new ConfigMessage("admin.insomnia-enabled", "&cInsomnia is enabled")); + this.messages.put(MessageKey.INSOMNIA_ENABLED, new ConfigMessage("admin.insomnia-enabled", "&bInsomnia is enabled")); this.messages.put(MessageKey.CMD_ONLY_DURING_NIGHT, new ConfigMessage("admin.only-during-night-command", "&cThis command can only be used during the night")); this.messages.put(MessageKey.KICK_OUT_BED, new ConfigMessage("admin.kick-out-bed", "&c&l[kick out]")); - this.messages.put(MessageKey.KICKED_PLAYER_FROM_BED, new ConfigMessage("user.kicked-player-from-bed", "&cYou kicked %target-player% out from their bed")); + this.messages.put(MessageKey.KICKED_PLAYER_FROM_BED, new ConfigMessage("user.kicked-player-from-bed", "&bYou kicked &a%player% &bout of their bed")); this.messages.put(MessageKey.YOU_ARE_KICKED_FROM_BED, new ConfigMessage("user.kicked-from-bed", "&cYou were kicked out from your bed")); this.messages.put(MessageKey.KICKING_NOT_ALLOWED, new ConfigMessage("user.kicking-not-allowed", "&cYou do not have permission to kick this player out of their bed")); this.messages.put(MessageKey.FLAG_SET_IN_WORLD, new ConfigMessage("flag.set-in-world", "&bThe &e%flag% &bflag value in your world is &e%value%&b.")); @@ -67,7 +66,6 @@ public void loadMessages(){ this.messages.put(MessageKey.STORM_SKIPPED_TITLE, new ConfigMessage("user.storm-skipped.title", "&eStorm skipped")); this.messages.put(MessageKey.STORM_SKIPPED_SUBTITLE, new ConfigMessage("user.storm-skipped.subtitle", "&bWhat a weather...")); - } public ConfigMessage getMessage(MessageKey message){ diff --git a/src/main/java/me/mrgeneralq/sleepmost/runnables/NightcycleAnimationTask.java b/src/main/java/me/mrgeneralq/sleepmost/runnables/NightcycleAnimationTask.java index 9b6c551..2a40e57 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/runnables/NightcycleAnimationTask.java +++ b/src/main/java/me/mrgeneralq/sleepmost/runnables/NightcycleAnimationTask.java @@ -26,6 +26,7 @@ public class NightcycleAnimationTask extends BukkitRunnable { private final String lastSLeeperDisplayName; private final SleepSkipCause skipCause; private final List peopleWhoSlept; + private int iterationCount = 1; public NightcycleAnimationTask(ISleepService sleepService, IFlagsRepository flagsRepository, World world, Player lastSleeper, List peopleWhoSlept, SleepSkipCause sleepSkipCause) { this.sleepService = sleepService; diff --git a/src/main/java/me/mrgeneralq/sleepmost/services/MessageService.java b/src/main/java/me/mrgeneralq/sleepmost/services/MessageService.java index 0ca0cdc..a56d553 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/services/MessageService.java +++ b/src/main/java/me/mrgeneralq/sleepmost/services/MessageService.java @@ -132,12 +132,17 @@ public void sendPlayerLeftMessage(Player player, SleepSkipCause cause, int sleep public void sendNightSkippedMessage(World world, String lastSleeperName, String lastSleeperDisplayName, SleepSkipCause cause) { MessageKey message = (cause == SleepSkipCause.STORM ? MessageKey.STORM_SKIPPED : MessageKey.NIGHT_SKIPPED); - String skipMessage = this.getMessage(message) - .setPlayer(lastSleeperName) - .setWorld(world) - .build(); + for(Player p: world.getPlayers()){ + + String skipMessage = this.getMessage(message) + .setPlayer(lastSleeperName) + .setWorld(world) + .build(); + + this.sendMessage(p , skipMessage); + + } - sendWorldMessage(world, skipMessage); } @Override @@ -194,6 +199,7 @@ public void reloadConfig(){ this.messageRepository.loadConfig(); loadPrefix(); + this.createMissingMessages(); } diff --git a/src/main/java/me/mrgeneralq/sleepmost/statics/ServerVersion.java b/src/main/java/me/mrgeneralq/sleepmost/statics/ServerVersion.java index f133269..6eb594a 100644 --- a/src/main/java/me/mrgeneralq/sleepmost/statics/ServerVersion.java +++ b/src/main/java/me/mrgeneralq/sleepmost/statics/ServerVersion.java @@ -1,6 +1,6 @@ package me.mrgeneralq.sleepmost.statics; -import org.apache.commons.lang.WordUtils; +import org.apache.commons.lang3.text.WordUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -10,7 +10,7 @@ public enum ServerVersion { - UNKNOWN, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18; + UNKNOWN, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19; private final String name; private MaxHPHealer maxHPHealer; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 82f5ca3..9e65151 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,6 +1,6 @@ # WELCOME TO THE OFFICIAL SLEEP-MOST PLUGIN -# AUTHORS: MrGeneralQ, HorrendousEntity -# CONTRIBUTORS: Nozemi, Malin +# AUTHORS: MrGeneralQ +# CONTRIBUTORS: Malin, Nozemi, HorrendousEntity # VERSION: ${project.version} # SUPPORT NEEDED? Join our discord at --> https://discord.pseudonova.com/ WE ARE HAPPY TO HELP YOU FURTHER! # YOU CAN FIND THE DOCS FOR THIS PLUGIN HERE --> https://mrgeneralq.gitbook.io/sleepmost/ From 3fb75fcc5f2eb1ceff2f5f2cb3a87448a4f0870c Mon Sep 17 00:00:00 2001 From: Quinten Date: Sun, 19 Jun 2022 00:18:20 +0200 Subject: [PATCH 2/2] improved comments improved comments --- src/main/resources/messages.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 4087957..646bdd9 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -1,7 +1,8 @@ # CUSTOMIZE MESSAGES FOR SLEEP-MOST. # To disable messages set the message to '' # Placeholders are available here --> https://sleepmost.pseudonova.com/placeholders/sleepmost-config -# You need support? Join our Discord server --> https://discord.com/invite/KJ3kYX9 +# You need support? Join our Discord server --> https://discord.pseudonova.com/ +# # Add multiple messages to randomly select by doing the following: # messagetype: # - 'message1'