From 1c2d00ea47f0e7eea8f8f2bb0a855e08f48882df Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 1 Oct 2025 22:18:45 +0200 Subject: [PATCH 01/16] 3.3.1 --- build.gradle.kts | 2 +- src/main/java/me/calrl/hubbly/Hubbly.java | 12 +++++++ .../hubbly/commands/debug/DebugCommand.java | 2 +- .../hubbly/commands/debug/ItemsCommand.java | 31 +++++++++++++++++++ .../calrl/hubbly/managers/ItemsManager.java | 29 +++++++++++++++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/calrl/hubbly/commands/debug/ItemsCommand.java diff --git a/build.gradle.kts b/build.gradle.kts index dd20dc6..b8e3a07 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ dependencies { } group = "me.calrl" -version = "3.3.0" +version = "3.3.1" description = "Hubbly" java.sourceCompatibility = JavaVersion.VERSION_21 diff --git a/src/main/java/me/calrl/hubbly/Hubbly.java b/src/main/java/me/calrl/hubbly/Hubbly.java index fed5cee..aaaf8e8 100644 --- a/src/main/java/me/calrl/hubbly/Hubbly.java +++ b/src/main/java/me/calrl/hubbly/Hubbly.java @@ -22,11 +22,19 @@ import me.calrl.hubbly.functions.BossBarManager; import me.calrl.hubbly.hooks.HookManager; import me.calrl.hubbly.inventory.InventoryListener; +import me.calrl.hubbly.items.AoteItem; +import me.calrl.hubbly.items.EnderbowItem; +import me.calrl.hubbly.items.RodItem; +import me.calrl.hubbly.items.TridentItem; import me.calrl.hubbly.listeners.ServerLoadListener; import me.calrl.hubbly.listeners.chat.ChatListener; import me.calrl.hubbly.listeners.chat.CommandBlockerListener; import me.calrl.hubbly.listeners.items.ConfigItemListener; import me.calrl.hubbly.listeners.items.PlayerVisibilityListener; +import me.calrl.hubbly.listeners.items.movement.AoteListener; +import me.calrl.hubbly.listeners.items.movement.EnderbowListener; +import me.calrl.hubbly.listeners.items.movement.RodListener; +import me.calrl.hubbly.listeners.items.movement.TridentListener; import me.calrl.hubbly.listeners.player.*; import me.calrl.hubbly.listeners.world.AntiWDL; import me.calrl.hubbly.listeners.world.LaunchpadListener; @@ -150,6 +158,10 @@ private void loadListeners() { registerListener(new InventoryListener(this)); registerListener(new XPListener(this), "player.experience.enabled"); registerListener(new PlayerMoveListener(this)); + registerListener(new TridentListener(this)); + registerListener(new EnderbowListener(this)); + registerListener(new AoteListener(this)); + registerListener(new RodListener(this)); } @Override diff --git a/src/main/java/me/calrl/hubbly/commands/debug/DebugCommand.java b/src/main/java/me/calrl/hubbly/commands/debug/DebugCommand.java index 4030c51..063e2c8 100644 --- a/src/main/java/me/calrl/hubbly/commands/debug/DebugCommand.java +++ b/src/main/java/me/calrl/hubbly/commands/debug/DebugCommand.java @@ -41,7 +41,7 @@ public Result execute(CommandSender sender, String[] args, int depth) { } private void loadNodes() { - + addChild("items", new ItemsCommand(plugin)); } @Override diff --git a/src/main/java/me/calrl/hubbly/commands/debug/ItemsCommand.java b/src/main/java/me/calrl/hubbly/commands/debug/ItemsCommand.java new file mode 100644 index 0000000..e0349d0 --- /dev/null +++ b/src/main/java/me/calrl/hubbly/commands/debug/ItemsCommand.java @@ -0,0 +1,31 @@ +package me.calrl.hubbly.commands.debug; + +import me.calrl.hubbly.Hubbly; +import me.calrl.hubbly.enums.Permissions; +import me.calrl.hubbly.enums.Result; +import me.calrl.hubbly.managers.ItemsManager; +import me.calrl.hubbly.utils.CommandNode; +import org.bukkit.command.CommandSender; + +import java.util.Set; +import java.util.stream.Collectors; + +public class ItemsCommand extends CommandNode { + private final Hubbly plugin; + public ItemsCommand(Hubbly plugin) { + super("items"); + this.plugin = plugin; + } + + @Override + public Result execute(CommandSender sender, String[] args, int depth) { + ItemsManager manager = plugin.getItemsManager(); + if(!sender.hasPermission(Permissions.COMMAND_DEBUG.getPermission())) { + return Result.NO_PERMISSION; + } + Set set = manager.getItems().keySet(); + String message = String.join(",", set); + sender.sendMessage(message); + return Result.SUCCESS; + } +} diff --git a/src/main/java/me/calrl/hubbly/managers/ItemsManager.java b/src/main/java/me/calrl/hubbly/managers/ItemsManager.java index 577bc6d..efee9ea 100644 --- a/src/main/java/me/calrl/hubbly/managers/ItemsManager.java +++ b/src/main/java/me/calrl/hubbly/managers/ItemsManager.java @@ -1,7 +1,9 @@ package me.calrl.hubbly.managers; +import com.google.common.base.Supplier; import me.calrl.hubbly.Hubbly; import me.calrl.hubbly.action.ActionManager; +import me.calrl.hubbly.enums.Result; import me.calrl.hubbly.interfaces.CustomItem; import me.calrl.hubbly.items.*; import me.calrl.hubbly.listeners.items.movement.AoteListener; @@ -14,6 +16,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -31,6 +34,7 @@ public class ItemsManager { private FileConfiguration itemsConfig; private DebugMode debugMode; private final Map items = new HashMap<>(); + private final Map listeners; private File itemsFile; private final ActionManager actionManager; private Player player; @@ -38,9 +42,13 @@ public class ItemsManager { public ItemsManager(Hubbly plugin) { this.plugin = plugin; this.debugMode = plugin.getDebugMode(); + this.config = plugin.getConfig(); this.itemsFile = new File(plugin.getDataFolder(), "items.yml"); this.actionManager = plugin.getActionManager(); this.itemsConfig = plugin.getItemsConfig(); + + this.listeners = new HashMap<>(); + this.registerItems(); } @@ -87,6 +95,20 @@ private void register(String itemName, CustomItem item, Listener listener) { } Bukkit.getPluginManager().registerEvents(listener, plugin); + items.put(itemName, item); + listeners.put(itemName, listener); + debugMode.info("Registered item: " + itemName); + } + + private void register(String itemName, CustomItem item) { + this.config = plugin.getConfig(); + String enabledPath = "movementitems." + itemName + ".enabled"; + boolean isEnabled = config.getBoolean(enabledPath); + if(!isEnabled) { + debugMode.info("Item: " + itemName + " not registered."); + return; + } + items.put(itemName, item); debugMode.info("Registered item: " + itemName); } @@ -96,6 +118,13 @@ public void reload() { this.registerItems(); } + public void clean() { + Collection collection = this.listeners.values(); + for(Listener listener : collection) { + HandlerList.unregisterAll(listener); + } + } + public void clear() { items.clear(); } From 4c7bbedc9664aed8cda8d6a3d32ac75a0c524678 Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:37:12 +0200 Subject: [PATCH 02/16] Make build build the message, and send send it --- .../me/calrl/hubbly/utils/MessageBuilder.java | 44 ++++++++++++------- .../player/PlayerJoinListenerTests.java | 4 ++ 2 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 src/test/java/me/calrl/hubbly/listeners/player/PlayerJoinListenerTests.java diff --git a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java index c82029a..f48bf39 100644 --- a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java +++ b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java @@ -1,13 +1,14 @@ package me.calrl.hubbly.utils; import me.calrl.hubbly.Hubbly; -import me.calrl.hubbly.enums.LocaleKey; +import me.calrl.hubbly.enums.Result; import me.calrl.hubbly.managers.LocaleManager; -import net.minecraft.world.entity.ai.behavior.warden.TryToSniff; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Optional; + public class MessageBuilder { private Player player; @@ -104,21 +105,34 @@ public MessageBuilder usePrefix(boolean bool) { return this; } - public String build() { - return content; - } - - public void send() { - String toSend = ChatUtils.prefixMessage(plugin, player, content); - if(toSend.contains("nomessage")) { - return; + public Optional build() { + if(this.content.isEmpty() || this.content.isBlank()) { + return Optional.empty(); + } + String finalMsg = this.content; + if(this.usePrefix) { + finalMsg = ChatUtils.prefixMessage(plugin, player, finalMsg); } - if(player != null) { - ChatUtils.processMessage(player, toSend); - player.sendMessage(toSend); - } else { - Bukkit.getConsoleSender().sendMessage(toSend); + finalMsg = ChatUtils.processMessage(player, finalMsg); + if(finalMsg.contains("nomessage")) { + return Optional.empty(); } + return Optional.of(content); + } + + public Result send() { + return build() + .map(toSend -> { + if(player != null) { + ChatUtils.processMessage(player, toSend); + player.sendMessage(toSend); + } else { + Bukkit.getConsoleSender().sendMessage(toSend); + } + + return Result.SUCCESS; + }) + .orElse(Result.FAILURE); } } diff --git a/src/test/java/me/calrl/hubbly/listeners/player/PlayerJoinListenerTests.java b/src/test/java/me/calrl/hubbly/listeners/player/PlayerJoinListenerTests.java new file mode 100644 index 0000000..bd46644 --- /dev/null +++ b/src/test/java/me/calrl/hubbly/listeners/player/PlayerJoinListenerTests.java @@ -0,0 +1,4 @@ +package me.calrl.hubbly.listeners.player; + +public class PlayerJoinListenerTests { +} From 2f256f812e2d3855a591f63160bc9cc46a88cd3d Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:37:46 +0200 Subject: [PATCH 03/16] Add CANCELLED, DISABLED_WORLD and NOT_FOUND results --- src/main/java/me/calrl/hubbly/enums/Result.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/calrl/hubbly/enums/Result.java b/src/main/java/me/calrl/hubbly/enums/Result.java index 9edc3cd..be1b5ce 100644 --- a/src/main/java/me/calrl/hubbly/enums/Result.java +++ b/src/main/java/me/calrl/hubbly/enums/Result.java @@ -11,5 +11,10 @@ public enum Result { COOLDOWN, ALREADY_EXISTS, NOTHING_TO_DO, - NO_CHILD + NO_CHILD, + // in disabled world + DISABLED_WORLD, + // event cancelled + CANCELLED, + NOT_FOUND } From 8ad5539b03533ca25043886ec778881d28f52a53 Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:38:03 +0200 Subject: [PATCH 04/16] Add disabledworld bypass to executeAction --- .../me/calrl/hubbly/action/ActionManager.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/main/java/me/calrl/hubbly/action/ActionManager.java b/src/main/java/me/calrl/hubbly/action/ActionManager.java index 4cf5dca..9ee8515 100644 --- a/src/main/java/me/calrl/hubbly/action/ActionManager.java +++ b/src/main/java/me/calrl/hubbly/action/ActionManager.java @@ -19,6 +19,7 @@ import me.calrl.hubbly.Hubbly; import me.calrl.hubbly.action.actions.*; +import me.calrl.hubbly.enums.Result; import me.calrl.hubbly.events.ActionEvent; import me.calrl.hubbly.managers.DisabledWorlds; import me.calrl.hubbly.utils.MessageBuilder; @@ -93,6 +94,53 @@ public void executeAction(Player player, String actionData) { } } + /** + * @param player the player + * @param actionData e.g. "[PLAYER] spawn" + * @param bypass the disabled world check + * @return + */ + public Result executeAction(Player player, String actionData, boolean bypass) { + + if(!bypass) { + DisabledWorlds disabledWorldsManager = plugin.getDisabledWorldsManager(); + boolean inDisabledWorld = disabledWorldsManager.inDisabledWorld(player.getLocation()); + + if(inDisabledWorld) return Result.DISABLED_WORLD; + } + + + if(!actionData.startsWith("[") || !actionData.contains("]")) { + return Result.INVALID_ARGS; + } + + String identifier = this.getIdentifier(actionData); + String data = this.getData(actionData); + + Action action = actions.get(identifier); + ActionEvent event = new ActionEvent(player, action, data); + Bukkit.getPluginManager().callEvent(event); + + if (action == null) { + String errorMessage = new MessageBuilder(plugin) + .setKey("action.errors.null") + .setPlayer(Bukkit.getConsoleSender()) + .build(); + + plugin.getLogger().warning(errorMessage); + return Result.NOT_FOUND; + } + + plugin.getDebugMode().info("Checking if ActionEvent is cancelled..."); + if(event.isCancelled()) { + return Result.CANCELLED; + } + + plugin.getDebugMode().info("Executing action: " + identifier + " " + data); + action.execute(plugin, player, data); + return Result.SUCCESS; + } + public void executeActions(Player player, String actionData) { if(actionData == null) { new MessageBuilder(plugin).setKey("action.errors.null").setPlayer(Bukkit.getConsoleSender()).send(); From 3b683b386aa05091a52831fb3f8a96cf163297bd Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:38:13 +0200 Subject: [PATCH 05/16] add bypass for actions_on_join --- .../me/calrl/hubbly/listeners/player/PlayerJoinListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java index 99e98b2..ffc6a46 100644 --- a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java @@ -122,7 +122,7 @@ private void handleActionsOnJoin(Player player) { Bukkit.getScheduler().runTaskLater(plugin, () -> { for(String action : actions) { - actionManager.executeAction(player, action); + actionManager.executeAction(player, action, true); debugMode.info("Executed " + action); } From d979a959498ab9a54dbfef8b5ad774474c382e51 Mon Sep 17 00:00:00 2001 From: Cal Date: Sat, 4 Oct 2025 19:05:44 +0200 Subject: [PATCH 06/16] fix build to return a string instead of option --- .../me/calrl/hubbly/utils/MessageBuilder.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java index f48bf39..7d43ded 100644 --- a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java +++ b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java @@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.util.Objects; import java.util.Optional; public class MessageBuilder { @@ -105,9 +106,9 @@ public MessageBuilder usePrefix(boolean bool) { return this; } - public Optional build() { + public String build() { if(this.content.isEmpty() || this.content.isBlank()) { - return Optional.empty(); + return ""; } String finalMsg = this.content; if(this.usePrefix) { @@ -116,23 +117,15 @@ public Optional build() { finalMsg = ChatUtils.processMessage(player, finalMsg); if(finalMsg.contains("nomessage")) { - return Optional.empty(); + return ""; } - return Optional.of(content); + return content; } public Result send() { - return build() - .map(toSend -> { - if(player != null) { - ChatUtils.processMessage(player, toSend); - player.sendMessage(toSend); - } else { - Bukkit.getConsoleSender().sendMessage(toSend); - } - - return Result.SUCCESS; - }) - .orElse(Result.FAILURE); + String message = this.build(); + Objects.requireNonNullElseGet(this.player, Bukkit::getConsoleSender).sendMessage(message); + + return Result.SUCCESS; } } From 1cb189ced403a643ea14324e516d0fa2cfb36e4d Mon Sep 17 00:00:00 2001 From: Cal Date: Sat, 4 Oct 2025 19:06:02 +0200 Subject: [PATCH 07/16] make actions_on_join bypass disabledworlds check --- .../listeners/player/PlayerJoinListener.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java index ffc6a46..f395d0e 100644 --- a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java @@ -56,24 +56,27 @@ private void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); DisabledWorlds disabledWorlds = plugin.getDisabledWorldsManager(); - if(disabledWorlds.inDisabledWorld(player.getWorld())) return; + boolean inDisabledWorld = disabledWorlds.inDisabledWorld(player.getWorld()); + + if(!inDisabledWorld) { + this.sendUpdateMessage(player); + } - this.sendUpdateMessage(player); boolean doubleJump = config.getBoolean("double_jump.enabled"); - if(doubleJump) { + if(doubleJump && !inDisabledWorld) { plugin.setPlayerFlight(player, (byte) 0); player.setAllowFlight(true); } - if (config.getBoolean("player.join_message.enabled")) { + if (config.getBoolean("player.join_message.enabled") && !inDisabledWorld) { String joinMessage = config.getString("player.join_message.message"); joinMessage = ChatUtils.parsePlaceholders(player, joinMessage); event.setJoinMessage(ChatUtils.translateHexColorCodes(joinMessage)); } - if (config.getBoolean("player.bossbar.enabled")) { + if (config.getBoolean("player.bossbar.enabled") && !inDisabledWorld) { bossBarManager = plugin.getBossBarManager(); bossBarManager.createBossBar(player); } @@ -119,7 +122,7 @@ private void handleActionsOnJoin(Player player) { if(actions.isEmpty()) { return; } - + debugMode.info("Running actions..."); Bukkit.getScheduler().runTaskLater(plugin, () -> { for(String action : actions) { actionManager.executeAction(player, action, true); From f7f7007d95a0051239ad54ed5a641aad03ab55aa Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 8 Oct 2025 21:31:12 +0200 Subject: [PATCH 08/16] No longer sends spammy enderbow debug message --- .../calrl/hubbly/listeners/items/movement/EnderbowListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/me/calrl/hubbly/listeners/items/movement/EnderbowListener.java b/src/main/java/me/calrl/hubbly/listeners/items/movement/EnderbowListener.java index 0bdbae7..55560d8 100644 --- a/src/main/java/me/calrl/hubbly/listeners/items/movement/EnderbowListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/items/movement/EnderbowListener.java @@ -50,7 +50,6 @@ private void onPlayerJoin(PlayerJoinEvent event) { private void onInteract(PlayerInteractEvent event) { FileConfiguration config = plugin.getConfig(); if(!config.getBoolean("movementitems.enderbow.enabled")) { - plugin.getDebugMode().info("Ender Bow is disabled in config."); return; } From 5098b9e8959cfa570be8271a45231c99225081c5 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 8 Oct 2025 21:31:22 +0200 Subject: [PATCH 09/16] set player manually in message action --- .../java/me/calrl/hubbly/action/actions/MessageAction.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/calrl/hubbly/action/actions/MessageAction.java b/src/main/java/me/calrl/hubbly/action/actions/MessageAction.java index 26a5661..a04fc66 100644 --- a/src/main/java/me/calrl/hubbly/action/actions/MessageAction.java +++ b/src/main/java/me/calrl/hubbly/action/actions/MessageAction.java @@ -14,7 +14,8 @@ public String getIdentifier() { @Override public void execute(Hubbly plugin, Player player, String data) { - new MessageBuilder(plugin, player) + new MessageBuilder(plugin) + .setPlayer(player) .setMessage(data) .send(); } From ef176e16304ca798a29b1760cfba5bd0652efaa5 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 8 Oct 2025 21:31:29 +0200 Subject: [PATCH 10/16] fix MessageBuilder --- src/main/java/me/calrl/hubbly/utils/MessageBuilder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java index 7d43ded..a5abd76 100644 --- a/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java +++ b/src/main/java/me/calrl/hubbly/utils/MessageBuilder.java @@ -2,6 +2,7 @@ import me.calrl.hubbly.Hubbly; import me.calrl.hubbly.enums.Result; +import me.calrl.hubbly.managers.DebugMode; import me.calrl.hubbly.managers.LocaleManager; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -108,6 +109,7 @@ public MessageBuilder usePrefix(boolean bool) { public String build() { if(this.content.isEmpty() || this.content.isBlank()) { + new DebugMode(plugin).info("MessageBuilder > Content is empty... Returning."); return ""; } String finalMsg = this.content; @@ -117,9 +119,11 @@ public String build() { finalMsg = ChatUtils.processMessage(player, finalMsg); if(finalMsg.contains("nomessage")) { + new DebugMode(plugin).info("MessageBuilder > \"nomessage\" found"); return ""; } - return content; + new DebugMode(plugin).info(String.format("MessageBuilder > Content: %s", content)); + return finalMsg; } public Result send() { From 9f6aa1c7ef015ec98320fb048863cc22c58f08a5 Mon Sep 17 00:00:00 2001 From: Cal Date: Fri, 7 Nov 2025 17:32:50 +0100 Subject: [PATCH 11/16] add /hubbly pv command todo: add a tracker for players with /hubbly pv hide enabled, adding newly joined players to the hidden list. --- .../commands/visibility/HideCommand.java | 28 +++++++++++ .../commands/visibility/ShowCommand.java | 28 +++++++++++ .../visibility/VisibilityCommand.java | 46 +++++++++++++++++++ .../me/calrl/hubbly/enums/Permissions.java | 1 + .../hubbly/managers/SubCommandManager.java | 8 +++- 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java create mode 100644 src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java create mode 100644 src/main/java/me/calrl/hubbly/commands/visibility/VisibilityCommand.java diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java new file mode 100644 index 0000000..770d2e9 --- /dev/null +++ b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java @@ -0,0 +1,28 @@ +package me.calrl.hubbly.commands.visibility; + +import me.calrl.hubbly.Hubbly; +import me.calrl.hubbly.enums.Result; +import me.calrl.hubbly.utils.CommandNode; +import me.calrl.hubbly.utils.MessageBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class HideCommand extends CommandNode { + private final Hubbly plugin; + public HideCommand(Hubbly plugin) { + super("hide"); + this.plugin = plugin; + } + + @Override + public Result execute(CommandSender sender, String[] args, int depth) { + if(sender instanceof Player player) { + for(Player onlinePlayer : plugin.getServer().getOnlinePlayers()) { + player.hidePlayer(plugin, onlinePlayer); + } + new MessageBuilder(plugin).setPlayer(player).setMessage("Hiding players").send(); + return Result.SUCCESS; + } + return Result.PLAYER_ONLY; + } +} diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java new file mode 100644 index 0000000..5f6c46a --- /dev/null +++ b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java @@ -0,0 +1,28 @@ +package me.calrl.hubbly.commands.visibility; + +import me.calrl.hubbly.Hubbly; +import me.calrl.hubbly.enums.Result; +import me.calrl.hubbly.utils.CommandNode; +import me.calrl.hubbly.utils.MessageBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class ShowCommand extends CommandNode { + private final Hubbly plugin; + public ShowCommand(Hubbly plugin) { + super("show"); + this.plugin = plugin; + } + + @Override + public Result execute(CommandSender sender, String[] args, int depth) { + if(sender instanceof Player player) { + for(Player onlinePlayer : plugin.getServer().getOnlinePlayers()) { + player.showPlayer(plugin, onlinePlayer); + } + new MessageBuilder(plugin).setPlayer(player).setMessage("Showing players").send(); + return Result.SUCCESS; + } + return Result.PLAYER_ONLY; + } +} diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/VisibilityCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/VisibilityCommand.java new file mode 100644 index 0000000..fd831dc --- /dev/null +++ b/src/main/java/me/calrl/hubbly/commands/visibility/VisibilityCommand.java @@ -0,0 +1,46 @@ +package me.calrl.hubbly.commands.visibility; + +import me.calrl.hubbly.Hubbly; +import me.calrl.hubbly.enums.Permissions; +import me.calrl.hubbly.enums.Result; +import me.calrl.hubbly.utils.CommandNode; +import me.calrl.hubbly.utils.MessageBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class VisibilityCommand extends CommandNode { + private final Hubbly plugin; + public VisibilityCommand(Hubbly plugin) { + super("pv"); + this.plugin = plugin; + this.loadNodes(); + } + + private void loadNodes() { + this.addChild("show", new ShowCommand(plugin)); + this.addChild("hide", new HideCommand(plugin)); + } + + @Override + public Result execute(CommandSender sender, String[] args, int depth) { + if(!(sender instanceof Player player)) { + new MessageBuilder(plugin).setKey("no_console").setPlayer(sender).send(); + return Result.PLAYER_ONLY; + } + if(!player.hasPermission(Permissions.COMMAND_PLAYER_VISIBILITY.getPermission())) { + new MessageBuilder(plugin).setKey("no_permission_command").setPlayer(player).send(); + return Result.NO_PERMISSION; + } + + this.executeIfChildPresent(sender, args, depth); + + return Result.SUCCESS; + } + + @Override + public List tabComplete(CommandSender sender, String[] args, int depth) { + return super.tabComplete(sender, args, depth); + } +} diff --git a/src/main/java/me/calrl/hubbly/enums/Permissions.java b/src/main/java/me/calrl/hubbly/enums/Permissions.java index 482eba0..a48ee69 100644 --- a/src/main/java/me/calrl/hubbly/enums/Permissions.java +++ b/src/main/java/me/calrl/hubbly/enums/Permissions.java @@ -33,6 +33,7 @@ public enum Permissions { COMMAND_CONVERT("command.convert"), COMMAND_MENU("command.menu"), COMMAND_DEBUG("command.debug"), + COMMAND_PLAYER_VISIBILITY("command.playervisibility"), COMMAND_WORLDS("commands.worlds"), COMMAND_WORLDS_ADD("commands.worlds.add"), diff --git a/src/main/java/me/calrl/hubbly/managers/SubCommandManager.java b/src/main/java/me/calrl/hubbly/managers/SubCommandManager.java index 49da7bb..1bccc08 100644 --- a/src/main/java/me/calrl/hubbly/managers/SubCommandManager.java +++ b/src/main/java/me/calrl/hubbly/managers/SubCommandManager.java @@ -3,6 +3,7 @@ import me.calrl.hubbly.Hubbly; import me.calrl.hubbly.commands.debug.DebugCommand; import me.calrl.hubbly.commands.subcommands.*; +import me.calrl.hubbly.commands.visibility.VisibilityCommand; import me.calrl.hubbly.commands.worlds.WorldsCommand; import me.calrl.hubbly.interfaces.SubCommand; import me.calrl.hubbly.utils.CommandNode; @@ -55,9 +56,14 @@ public Map getSubCommands() { } public void loadNodes() { + DebugMode debug = new DebugMode(plugin); this.registerNode(new WorldsCommand(plugin)); this.registerNode(new DebugCommand(plugin)); - new DebugMode().info("Loaded all WorldsCommand nodes"); + debug.info("Loaded all WorldsCommand nodes"); + + this.registerNode(new VisibilityCommand(plugin)); + debug.info("Loaded Visibility command"); + } public void registerNode(CommandNode node) { this.nodes.put(node.getIdentifier(), node); From 716226421503147a0e254b3ceab1b6299c9277c9 Mon Sep 17 00:00:00 2001 From: Cal Date: Fri, 7 Nov 2025 17:32:56 +0100 Subject: [PATCH 12/16] fix spawn teleport task --- .../calrl/hubbly/tasks/spawn/SpawnTeleportTask.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/calrl/hubbly/tasks/spawn/SpawnTeleportTask.java b/src/main/java/me/calrl/hubbly/tasks/spawn/SpawnTeleportTask.java index a0f9a8c..e53a0bf 100644 --- a/src/main/java/me/calrl/hubbly/tasks/spawn/SpawnTeleportTask.java +++ b/src/main/java/me/calrl/hubbly/tasks/spawn/SpawnTeleportTask.java @@ -7,6 +7,8 @@ import me.calrl.hubbly.tasks.ITask; import me.calrl.hubbly.utils.MessageBuilder; import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -30,10 +32,12 @@ public SpawnTeleportTask(Hubbly plugin, Player player, long timer) { @Override public void run() { if(player.isOnline()) { - String soundString = plugin.getConfig().getString("spawn.sound"); + String soundString = plugin.getConfig().getString("spawn.sound", null); if(soundString != null) { - Sound sound = Sound.valueOf(soundString); - player.playSound(player, sound, 1L, 1L); + Sound sound = Registry.SOUNDS.get(NamespacedKey.minecraft(soundString)); + if(sound != null) { + player.playSound(player, sound, 1L, 1L); + } } player.teleport(spawn); cleanup(); @@ -41,8 +45,8 @@ public void run() { } }; this.timer = timer; - } + public Result start() { registry.register(this.player.getUniqueId(), this.startLocation, this); this.task.runTaskLater(this.plugin, 20L * this.timer); From 77bcda68a13aeba305410c6d530d4991a3d42613 Mon Sep 17 00:00:00 2001 From: Cal Date: Tue, 11 Nov 2025 00:05:04 +0100 Subject: [PATCH 13/16] Changes add Result::from add playervisibilitymanager make show/hide use PVM logic --- .../commands/visibility/HideCommand.java | 11 +- .../commands/visibility/ShowCommand.java | 11 +- .../java/me/calrl/hubbly/enums/Result.java | 10 +- .../listeners/player/PlayerJoinListener.java | 4 + .../calrl/hubbly/managers/ManagerFactory.java | 7 ++ .../managers/PlayerVisibilityManager.java | 103 ++++++++++++++++++ 6 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java index 770d2e9..4f25397 100644 --- a/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java +++ b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java @@ -16,11 +16,12 @@ public HideCommand(Hubbly plugin) { @Override public Result execute(CommandSender sender, String[] args, int depth) { - if(sender instanceof Player player) { - for(Player onlinePlayer : plugin.getServer().getOnlinePlayers()) { - player.hidePlayer(plugin, onlinePlayer); - } - new MessageBuilder(plugin).setPlayer(player).setMessage("Hiding players").send(); + if (sender instanceof Player player) { + plugin.getManagerFactory().getPlayerVisibilityManager().setHideMode(player, true); +// new MessageBuilder(plugin) +// .setPlayer(player) +// .setMessage("Hiding players") +// .send(); return Result.SUCCESS; } return Result.PLAYER_ONLY; diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java index 5f6c46a..5ede939 100644 --- a/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java +++ b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java @@ -16,11 +16,12 @@ public ShowCommand(Hubbly plugin) { @Override public Result execute(CommandSender sender, String[] args, int depth) { - if(sender instanceof Player player) { - for(Player onlinePlayer : plugin.getServer().getOnlinePlayers()) { - player.showPlayer(plugin, onlinePlayer); - } - new MessageBuilder(plugin).setPlayer(player).setMessage("Showing players").send(); + if (sender instanceof Player player) { + plugin.getManagerFactory().getPlayerVisibilityManager().setHideMode(player, false); +// new MessageBuilder(plugin) +// .setPlayer(player) +// .setMessage("Showing players") +// .send(); return Result.SUCCESS; } return Result.PLAYER_ONLY; diff --git a/src/main/java/me/calrl/hubbly/enums/Result.java b/src/main/java/me/calrl/hubbly/enums/Result.java index be1b5ce..cec2419 100644 --- a/src/main/java/me/calrl/hubbly/enums/Result.java +++ b/src/main/java/me/calrl/hubbly/enums/Result.java @@ -16,5 +16,13 @@ public enum Result { DISABLED_WORLD, // event cancelled CANCELLED, - NOT_FOUND + NOT_FOUND; + + public static Result from(boolean bool) { + if(bool) { + return Result.SUCCESS; + } else { + return Result.FAILURE; + } + } } diff --git a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java index f395d0e..e7e9ab1 100644 --- a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java @@ -23,6 +23,7 @@ import me.calrl.hubbly.functions.BossBarManager; import me.calrl.hubbly.managers.DebugMode; import me.calrl.hubbly.managers.DisabledWorlds; +import me.calrl.hubbly.managers.PlayerVisibilityManager; import me.calrl.hubbly.utils.ChatUtils; import me.calrl.hubbly.utils.MessageBuilder; import me.calrl.hubbly.utils.update.UpdateUtil; @@ -55,6 +56,9 @@ public PlayerJoinListener(Hubbly plugin) { private void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); + PlayerVisibilityManager manager = plugin.getManagerFactory().getPlayerVisibilityManager(); + manager.handleJoin(player); + DisabledWorlds disabledWorlds = plugin.getDisabledWorldsManager(); boolean inDisabledWorld = disabledWorlds.inDisabledWorld(player.getWorld()); diff --git a/src/main/java/me/calrl/hubbly/managers/ManagerFactory.java b/src/main/java/me/calrl/hubbly/managers/ManagerFactory.java index dc14f19..6ef03ee 100644 --- a/src/main/java/me/calrl/hubbly/managers/ManagerFactory.java +++ b/src/main/java/me/calrl/hubbly/managers/ManagerFactory.java @@ -7,14 +7,17 @@ public class ManagerFactory { private Hubbly plugin; private TridentDataManager tridentDataManager; private SpawnTaskManager spawnTaskManager; + private PlayerVisibilityManager playerVisibilityManager; public ManagerFactory(Hubbly plugin) { + this.plugin = plugin; this.start(); } public void start() { this.tridentDataManager = new TridentDataManager(); this.spawnTaskManager = new SpawnTaskManager(); + this.playerVisibilityManager = new PlayerVisibilityManager(this.plugin); } public TridentDataManager getTridentDataManager() { @@ -25,4 +28,8 @@ public SpawnTaskManager getSpawnTaskManager() { return this.spawnTaskManager; } + public PlayerVisibilityManager getPlayerVisibilityManager() { + return this.playerVisibilityManager; + } + } diff --git a/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java b/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java new file mode 100644 index 0000000..d3a7e3c --- /dev/null +++ b/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java @@ -0,0 +1,103 @@ +package me.calrl.hubbly.managers; + +import me.calrl.hubbly.Hubbly; +import me.calrl.hubbly.enums.Result; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataType; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class PlayerVisibilityManager{ + private final Set players = new HashSet<>(); + private final NamespacedKey hideKey; + private final Hubbly plugin; + + public PlayerVisibilityManager(Hubbly plugin) { + this.plugin = plugin; + this.hideKey = new NamespacedKey(plugin, "hide_mode"); + } + + public void reload() { + this.plugin.getServer().getOnlinePlayers().forEach(this::applyHideState); + } + + private void applyHideState(Player player) { + if (isHideMode(player)) { + for (Player other : this.plugin.getServer().getOnlinePlayers()) { + player.hidePlayer(this.plugin, other); + } + } + } + + public boolean isHideMode(Player player) { + return player.getPersistentDataContainer().has(hideKey, PersistentDataType.BYTE); + } + + private void hideAll(Player player) { + for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers()) { + player.hidePlayer(this.plugin, onlinePlayer); + } + } + + private void revealAll(Player player) { + for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers()) { + player.showPlayer(this.plugin, onlinePlayer); + } + } + + public void setHideMode(Player player, boolean hidden) { + if (hidden) { + player.getPersistentDataContainer().set(hideKey, PersistentDataType.BYTE, (byte) 1); + if(player.getPersistentDataContainer().has(hideKey)) { + this.hideAll(player); + } else { + new DebugMode(this.plugin).info(String.format("Failed to enable hide mode for player: %s", player)); + } + } else { + player.getPersistentDataContainer().remove(hideKey); + if(!player.getPersistentDataContainer().has(hideKey)) { + this.revealAll(player); + } else { + new DebugMode(this.plugin).info(String.format("Failed to disable hide mode for player: %s", player)); + } + } + } + + public void handleJoin(Player joined) { + for (Player viewer : Bukkit.getOnlinePlayers()) { + if (isHideMode(viewer)) { + new DebugMode(plugin).info(String.format("Player: %s is in hide mode?", viewer)); + viewer.hidePlayer(plugin, joined); + } + } + } + + private NamespacedKey getKey() { + return this.hideKey; + } + + public Set getHideModePlayers() { + return this.players; + } + + public Result add(Player player) { + return this.add(player.getUniqueId()); + } + + private Result add(UUID uuid) { + boolean success = this.players.add(uuid); + return Result.from(success); + } + + private Result remove(UUID uuid) { + return Result.from(this.players.remove(uuid)); + } + + public boolean contains(UUID uuid) { + return this.players.contains(uuid); + } +} From 71740b08214347e6d01c9bb48ad612624440e190 Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Wed, 12 Nov 2025 13:18:18 +0100 Subject: [PATCH 14/16] 3.4.0 work --- .../commands/visibility/HideCommand.java | 8 +- .../commands/visibility/ShowCommand.java | 8 +- .../items/PlayerVisibilityListener.java | 87 ++++++++++++++++++- .../listeners/player/PlayerJoinListener.java | 4 +- .../managers/PlayerVisibilityManager.java | 8 ++ .../hubbly/commands/HubblyCommandTest.java | 9 +- 6 files changed, 106 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java index 4f25397..ead7262 100644 --- a/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java +++ b/src/main/java/me/calrl/hubbly/commands/visibility/HideCommand.java @@ -18,10 +18,10 @@ public HideCommand(Hubbly plugin) { public Result execute(CommandSender sender, String[] args, int depth) { if (sender instanceof Player player) { plugin.getManagerFactory().getPlayerVisibilityManager().setHideMode(player, true); -// new MessageBuilder(plugin) -// .setPlayer(player) -// .setMessage("Hiding players") -// .send(); + new MessageBuilder(plugin) + .setPlayer(player) + .setKey("playervisibility.show") + .send(); return Result.SUCCESS; } return Result.PLAYER_ONLY; diff --git a/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java index 5ede939..ffd7b67 100644 --- a/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java +++ b/src/main/java/me/calrl/hubbly/commands/visibility/ShowCommand.java @@ -18,10 +18,10 @@ public ShowCommand(Hubbly plugin) { public Result execute(CommandSender sender, String[] args, int depth) { if (sender instanceof Player player) { plugin.getManagerFactory().getPlayerVisibilityManager().setHideMode(player, false); -// new MessageBuilder(plugin) -// .setPlayer(player) -// .setMessage("Showing players") -// .send(); + new MessageBuilder(plugin) + .setPlayer(player) + .setKey("playervisibility.hide") + .send(); return Result.SUCCESS; } return Result.PLAYER_ONLY; diff --git a/src/main/java/me/calrl/hubbly/listeners/items/PlayerVisibilityListener.java b/src/main/java/me/calrl/hubbly/listeners/items/PlayerVisibilityListener.java index d34a128..4c4328b 100644 --- a/src/main/java/me/calrl/hubbly/listeners/items/PlayerVisibilityListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/items/PlayerVisibilityListener.java @@ -17,7 +17,6 @@ package me.calrl.hubbly.listeners.items; import me.calrl.hubbly.Hubbly; -import me.calrl.hubbly.enums.LocaleKey; import me.calrl.hubbly.enums.Permissions; import me.calrl.hubbly.enums.PluginKeys; import me.calrl.hubbly.managers.DebugMode; @@ -73,12 +72,92 @@ public void onItemClick(PlayerInteractEvent event) { return; } - Bukkit.getScheduler().runTaskLater(plugin, () -> swapDye(player, itemInHand), 2L); + Bukkit.getScheduler().runTaskLater(plugin, () -> swapDye(player), 2L); event.setCancelled(true); - debugMode.info("Holding: " + player.getInventory().getItemInMainHand()); } + enum VisDye { + VISIBLE("visible"), + HIDDEN("hidden"), + ; + private final String key; + + VisDye(String key) { + this.key = key; + } + public final String getKey() { return this.key; } + + public final boolean asBool() { + return switch (this.key) { + case "visible" -> false; + case "hidden" -> true; + default -> throw new IllegalStateException("Unexpected value: " + key); + }; + } + + public static VisDye fromKey(String key) { + return switch (key) { + case "visible" -> VisDye.VISIBLE; + case "hidden" -> VisDye.HIDDEN; + default -> throw new IllegalStateException("Unexpected value: " + key); + }; + } + + public final VisDye getOpposite() { + return switch (this) { + case VISIBLE -> HIDDEN; + case HIDDEN -> VISIBLE; + }; + } + + private ItemStack buildDye(FileConfiguration config) { + String key = this.getKey(); + String format = "playervisibility.%s.%s"; + Material mat = Material.valueOf(config.getString(format.formatted(key, "item"))); + String displayName = ChatUtils.translateHexColorCodes( + config.getString(format.formatted(key, "text")) + ); + + ItemStack item = new ItemStack(mat); + ItemMeta meta = item.getItemMeta(); + if(meta != null) { + meta.setDisplayName(displayName); + PersistentDataContainer container = meta.getPersistentDataContainer(); + container.set( + PluginKeys.PLAYER_VISIBILITY.getKey(), + PersistentDataType.STRING, + this.getKey() + ); + item.setItemMeta(meta); + } + return item; + } + } + + + private void swapDye(Player player) { + ItemStack itemInHand = player.getInventory().getItemInMainHand(); + ItemMeta meta = itemInHand.getItemMeta(); + if(meta == null) { + new DebugMode().info("Failed to swap dyes, item meta is null?"); + return; + } + + PersistentDataContainer container = meta.getPersistentDataContainer(); + String key = container.get(PluginKeys.PLAYER_VISIBILITY.getKey(), PersistentDataType.STRING); + if(key == null) { + new DebugMode().info("PlaverVisibility key is null?"); + return; + } + VisDye dye = VisDye.fromKey(key); + VisDye oppositeDye = dye.getOpposite(); + + ItemStack newDye = oppositeDye.buildDye(config); + plugin.getManagerFactory().getPlayerVisibilityManager().setHideMode(player, oppositeDye.asBool()); + + player.getInventory().setItemInMainHand(newDye); + } private void swapDye(Player player, ItemStack itemInHand) { Material newMaterial; @@ -91,7 +170,9 @@ private void swapDye(Player player, ItemStack itemInHand) { .send(); return; } + PersistentDataContainer container = meta.getPersistentDataContainer(); + String finalString; if (Objects.equals(container.get(PluginKeys.PLAYER_VISIBILITY.getKey(), PersistentDataType.STRING), "visible")) { newMaterial = Material.valueOf(config.getString("playervisibility.hidden.item", "GRAY_DYE")); diff --git a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java index e7e9ab1..a880f19 100644 --- a/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java +++ b/src/main/java/me/calrl/hubbly/listeners/player/PlayerJoinListener.java @@ -56,8 +56,8 @@ public PlayerJoinListener(Hubbly plugin) { private void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - PlayerVisibilityManager manager = plugin.getManagerFactory().getPlayerVisibilityManager(); - manager.handleJoin(player); + PlayerVisibilityManager pvManager = plugin.getManagerFactory().getPlayerVisibilityManager(); + pvManager.handleJoin(player); DisabledWorlds disabledWorlds = plugin.getDisabledWorldsManager(); boolean inDisabledWorld = disabledWorlds.inDisabledWorld(player.getWorld()); diff --git a/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java b/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java index d3a7e3c..0ab7a47 100644 --- a/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java +++ b/src/main/java/me/calrl/hubbly/managers/PlayerVisibilityManager.java @@ -37,6 +37,14 @@ public boolean isHideMode(Player player) { return player.getPersistentDataContainer().has(hideKey, PersistentDataType.BYTE); } + public void sendMessageToVisiblePlayers(String message) { + for (Player player : Bukkit.getOnlinePlayers()) { + if (!isHideMode(player)) { + player.sendMessage(message); + } + } + } + private void hideAll(Player player) { for(Player onlinePlayer : this.plugin.getServer().getOnlinePlayers()) { player.hidePlayer(this.plugin, onlinePlayer); diff --git a/src/test/java/me/calrl/hubbly/commands/HubblyCommandTest.java b/src/test/java/me/calrl/hubbly/commands/HubblyCommandTest.java index 2b5ffa5..bf7fdb6 100644 --- a/src/test/java/me/calrl/hubbly/commands/HubblyCommandTest.java +++ b/src/test/java/me/calrl/hubbly/commands/HubblyCommandTest.java @@ -1,15 +1,14 @@ package me.calrl.hubbly.commands; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; import be.seeseemelk.mockbukkit.entity.PlayerMock; -import me.calrl.hubbly.Hubbly; import me.calrl.hubbly.PluginTestBase; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class HubblyCommandTest extends PluginTestBase { From 89e32ac75c8dd28a175fd05672ae2b10f21b484f Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Wed, 12 Nov 2025 13:18:27 +0100 Subject: [PATCH 15/16] changelog + build file --- CHANGELOG.md | 16 +++++++++++++++- build.gradle.kts | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ed34f..b73b2a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,4 +25,18 @@ - ArmorStands are no longer breakable and interactable - Fix: if `spawn.timer` is 0, it will no longer check for movement (could not /spawn during freefall) - DisabledWorlds no longer stops tracking if a world is reloaded -- Spawn timer no longer sends message if timer = 0 \ No newline at end of file +- Spawn timer no longer sends message if timer = 0 + +## [3.4.0] - 12-11-2025 +- /spawn task now correctly plays sounds on Paper/Purpur +- actions_on_join bypass disabledworlds +- EnderBow now longer sends spammy console message while in debug mode +- Added debug logging to messagebuilder +- Added hide mode + - Tracks to see if players join, if in hide mode, will automatically hide players + - PlayerVisibilityItem now uses this logic +- Added `/hubbly pv` command (for toggling hide mode) + - `/hubbly pv show` to disable hide mode + - `/hubbly pv hide` to enable hide mode +- Added `playervisibility.hide` and `playervisibility.show` keys in the messages file + (available on github in english and portuguese) \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index b8e3a07..c3b2ba9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,7 +48,7 @@ dependencies { } group = "me.calrl" -version = "3.3.1" +version = "3.4.0" description = "Hubbly" java.sourceCompatibility = JavaVersion.VERSION_21 From 092fd1a180725793c36f07a92d14c9fef9e84f90 Mon Sep 17 00:00:00 2001 From: Cal <43823915+CalRL@users.noreply.github.com> Date: Wed, 12 Nov 2025 13:20:28 +0100 Subject: [PATCH 16/16] Add playervisibility to languages --- src/main/resources/languages/en.yml | 4 ++++ src/main/resources/languages/pt.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/resources/languages/en.yml b/src/main/resources/languages/en.yml index 8b9dde9..bceaa35 100644 --- a/src/main/resources/languages/en.yml +++ b/src/main/resources/languages/en.yml @@ -24,6 +24,10 @@ teleport_cancelled: You moved, teleport cancelled. chat_locked: Chat has been locked by %player_name% chat_unlocked: Chat has been unlocked by %player_name% +playervisibility: + show: Showing players + hide: Hiding players + update: new_update: An update is available! Hubbly %new% can be downloaded on SpigotMC, diff --git a/src/main/resources/languages/pt.yml b/src/main/resources/languages/pt.yml index 45d0772..764b800 100644 --- a/src/main/resources/languages/pt.yml +++ b/src/main/resources/languages/pt.yml @@ -24,6 +24,10 @@ teleport_cancelled: Mexeu, teletransporte cancelado. chat_locked: Chat foi bloqueado por %player_name% chat_unlocked: Chat foi desbloqueado por %player_name% +playervisibility: + show: Mostrando jogadores + hide: Escondendo jogadores + update: new_update: Uma atualização está disponível! Hubbly %new% pode ser transferido em SpigotMC,