Skip to content

Commit

Permalink
v0.65:
Browse files Browse the repository at this point in the history
  - Altered behaviour:
    - Previously using the channel command for the channel you're
already speaking in would move you to the next default channel,
      or if non was found, the next global channel.
    - Ex: While being in townchat you use "/tc" you could find yourself
in globalchat.
    - Now you will be told you're already in the channel you just used
the command to enter into.
  • Loading branch information
LlmDl committed Dec 11, 2019
1 parent 802efbd commit 068b186
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.palmergames.bukkit</groupId>
<artifactId>TownyChat</artifactId>
<packaging>jar</packaging>
<version>0.64</version>
<version>0.65</version>

<licenses>
<license>
Expand Down
8 changes: 7 additions & 1 deletion resources/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,10 @@ v0.63:
- Defaults to ops.
- Bypasses spam check.
v0.64:
- Removed "[Towny] Modes set: " line seen when a player changes channels.
- Removed "[Towny] Modes set: " line seen when a player changes channels.
v0.65:
- Altered behaviour:
- Previously using the channel command for the channel you're already speaking in would move you to the next default channel,
or if non was found, the next global channel.
- Ex: While being in townchat you use "/tc" you could find yourself in globalchat.
- Now you will be told you're already in the channel you just used the command to enter into.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.palmergames.bukkit.TownyChat.Chat;
import com.palmergames.bukkit.TownyChat.channels.Channel;
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
import com.palmergames.bukkit.TownyChat.util.TownyUtil;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.TownyUniverse;
Expand All @@ -30,38 +28,13 @@ public boolean execute(CommandSender commandSender, String label, String[] args)
if (commandSender instanceof Player) { // So a player has ran some /g command or something
if (channel.getCommands().contains(this.getName())) { // Should in theory always be true.
final Player player = (Player) commandSender;
final Channel defaultChannel = plugin.getChannelsHandler().getDefaultChannel();
String message = "";
if (args.length > 0) {
message = StringMgmt.join(args, " ");
}
if (message.isEmpty()) {
if (plugin.getTowny().hasPlayerMode(player, channel.getName())) {
// Find what the next channel is if any
Channel nextChannel = null;
if (defaultChannel != null && defaultChannel.isPresent(player.getName())) {
nextChannel = defaultChannel;
if (!nextChannel.getName().equalsIgnoreCase(channel.getName())) {
TownyUtil.removeAndSetPlayerMode(plugin.getTowny(), player, channel.getName(), nextChannel.getName(), false);
} else {
// They're talking on default channel and want to leave but can't because they'll be put default again
// Their only option out is to leave the channel if they have permission to do so.
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("tc_err_you_are_already_talking_in_default_channel_help"));
return true;
}
} else {
TownyUtil.removePlayerMode(plugin.getTowny(), player, channel.getName(), false);
}

if (nextChannel == null) {
nextChannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.GLOBAL);
}

// If the new channel is not us, announce it
if (nextChannel != null && !channel.getName().equalsIgnoreCase(nextChannel.getName())) {
TownyMessaging.sendMsg(player, String.format(TownySettings.getLangString("tc_you_are_now_talking_in_channel"), nextChannel.getName()));
return true;
}
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("tc_you_are_already_in_channel"), channel.getName()));
return true;
} else {
// You can join a channel if:
Expand Down

0 comments on commit 068b186

Please sign in to comment.