Improved new channel notification on leaving

This commit is contained in:
Marco Cunha committed 2012-08-25 19:53:22 +02:00
1 parent 94bea8a158
commit 0de0edee00
1 file changed
+11 -25
@@ -1,7 +1,5 @@
package com.palmergames.bukkit.TownyChat.Command; package com.palmergames.bukkit.TownyChat.Command;
import java.util.logging.Level;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -88,35 +86,23 @@ public class LeaveCommand implements CommandExecutor {
// Announce it // Announce it
TownyMessaging.sendMsg(sender, "[TownyChat] You left " + Colors.White + chan.getName()); TownyMessaging.sendMsg(sender, "[TownyChat] You left " + Colors.White + chan.getName());
// Remove this channel from player modes
if (TownyUtil.removePlayerMode(plugin.getTowny(), player, chan.getName(), false)) {
} Channel nextChannel = null;
if (plugin.getTowny().hasPlayerMode(player, chan.getName())) {
Channel newchannel = null; if (plugin.getChannelsHandler().getDefaultChannel() != null && plugin.getChannelsHandler().getDefaultChannel().isPresent(player.getName())) {
// Find us a new channel to speak on nextChannel = plugin.getChannelsHandler().getDefaultChannel();
newchannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.GLOBAL); if (TownyUtil.removePlayerMode(plugin.getTowny(), player, chan.getName(), false)) {
if (newchannel == null) { TownyUtil.addPlayerMode(plugin.getTowny(), player, nextChannel.getName(), true);
newchannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.NATION);
if (newchannel == null) {
newchannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.TOWN);
if (newchannel == null) {
newchannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.DEFAULT);
if (newchannel == null) {
newchannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.PRIVATE);
}
} }
} }
} }
if (nextChannel == null) {
if (newchannel != null) { nextChannel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.GLOBAL);
TownyUtil.addPlayerMode(plugin.getTowny(), player, newchannel.getName(), true); }
TownyMessaging.sendMsg(sender, "[TownyChat] You are now talking in " + Colors.White + newchannel.getName()); if (nextChannel != null) {
} else { TownyMessaging.sendMsg(sender, "[TownyChat] You are now talking in " + Colors.White + nextChannel.getName());
TownyMessaging.sendMsg(sender, "[TownyChat] You are now in blissful silence.");
} }
return true; return true;
} }
} }