Skip to content

Commit 2c04112

Browse files
committed
patches
1 parent c9b4b69 commit 2c04112

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/io/github/divinerealms/core/commands/ChannelCommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
9090
Player switchingPlayer = (Player) sender;
9191
String channelToSwitchTo = args[1];
9292
if (!channelManager.getChannels().containsKey(channelToSwitchTo.toLowerCase())) { logger.send(sender, Lang.CHANNEL_NOT_FOUND.replace(new String[]{channelToSwitchTo})); return true; }
93-
94-
boolean switchedStatus = channelManager.switchChannel(switchingPlayer.getUniqueId(), channelToSwitchTo.toLowerCase());
95-
logger.send(switchingPlayer, Lang.CHANNEL_TOGGLE.replace(new String[]{channelToSwitchTo.toUpperCase(), switchedStatus ? Lang.ON.replace(null) : Lang.OFF.replace(null)}));
93+
if (channelManager.isChannelDisabled(channelToSwitchTo)) { logger.send(sender, Lang.CHANNEL_DISABLED.replace(new String[]{channelToSwitchTo.toUpperCase()})); return true; }
94+
if (!channelManager.getChannels(switchingPlayer.getUniqueId()).contains(channelToSwitchTo.toLowerCase())) { logger.send(sender, Lang.CHANNEL_NOT_SUBSCRIBED.replace(new String[]{channelToSwitchTo.toUpperCase()})); return true; }
95+
channelManager.setLastChannelUsed(switchingPlayer.getUniqueId(), channelToSwitchTo.toLowerCase());
96+
String currentChannel = channelManager.getActiveChannel(switchingPlayer);
97+
boolean alreadyActive = channelToSwitchTo.equalsIgnoreCase(currentChannel);
98+
99+
channelManager.setLastActiveChannel(switchingPlayer.getUniqueId(), alreadyActive ? channelManager.getDefaultChannel() : channelToSwitchTo.toLowerCase());
100+
logger.send(switchingPlayer, Lang.CHANNEL_TOGGLE.replace(new String[]{channelToSwitchTo.toUpperCase(), alreadyActive ? Lang.OFF.replace(null) : Lang.ON.replace(null)}));
96101
break;
97102

98103
case "status":
@@ -101,6 +106,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
101106
if (args.length < 2) { logger.send(sender, Lang.CHANNEL_HELP.replace(null)); return true; }
102107

103108
Player statusPlayer = Bukkit.getPlayer(args[1]);
109+
if (statusPlayer == null || !statusPlayer.isOnline()) { logger.send(sender, Lang.PLAYER_NOT_FOUND.replace(new String[]{args[1]})); return true; }
104110
Set<String> subscribedChannels = channelManager.getChannels(statusPlayer.getUniqueId());
105111
String activeChannel = channelManager.getActiveChannel(statusPlayer);
106112
String subsList = subscribedChannels.stream()

version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#Sat Oct 11 15:09:00 CEST 2025
33
patch=2
44
major=1
5-
minor=10
5+
minor=11

0 commit comments

Comments
 (0)