mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 14:38:57 +00:00
Merge pull request #41 from TownyAdvanced/fix/town_chat_limbo
Fix a player who has lost their town being stuck in /tc or /nc.
This commit is contained in:
7 files changed
+16
-17
No files matched your search
@@ -432,4 +432,5 @@ v0.99:
|
||||
- Update min. Towny version to 0.98.4.0.
|
||||
v0.100:
|
||||
- Use internal Essentials object instead of the one found in Towny.
|
||||
- Fix incorrect lang string called in /ch mutelist {channelname}
|
||||
- Fix incorrect lang string called in /ch mutelist {channelname}
|
||||
- Fix a player who has lost their town being stuck in /tc or /nc.
|
||||
@@ -119,7 +119,7 @@ public class ChannelCommand extends BaseCommand implements CommandExecutor {
|
||||
TownyMessaging.sendMessage(player, ChatTools.formatTitle("Channels"));
|
||||
TownyMessaging.sendMessage(player, Colors.Gold + "Channel" + Colors.Gray + " - " + Colors.LightBlue + translator.of("tc_channel_list_status"));
|
||||
for (Map.Entry<String, Channel> channel : chanList.entrySet()) {
|
||||
if (player.hasPermission(channel.getValue().getPermission()))
|
||||
if (channel.getValue().hasPermission(player))
|
||||
if (channel.getValue().isPresent(player.getName()))
|
||||
TownyMessaging.sendMessage(player, Colors.Gold + channel.getKey() + Colors.Gray + " - " + Colors.LightBlue + translator.of("tc_channel_list_in"));
|
||||
else
|
||||
@@ -372,8 +372,7 @@ public class ChannelCommand extends BaseCommand implements CommandExecutor {
|
||||
// - channel has no permission set OR [by default they don't]
|
||||
// - channel has permission set AND:
|
||||
// - player has channel permission
|
||||
String joinPerm = chan.getPermission();
|
||||
if ((joinPerm != null && (!TownyUniverse.getInstance().getPermissionSource().has(player, joinPerm)))) {
|
||||
if (chan.hasPermission(player)) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_you_cannot_join_channel", chan.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-5
@@ -4,7 +4,6 @@ import com.palmergames.bukkit.TownyChat.Chat;
|
||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||
import com.palmergames.bukkit.towny.object.Translatable;
|
||||
import com.palmergames.bukkit.util.Colors;
|
||||
import com.palmergames.util.StringMgmt;
|
||||
@@ -46,8 +45,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
||||
// - channel has no permission set [by default they don't] OR
|
||||
// - channel has permission set AND:
|
||||
// - player has channel permission
|
||||
String joinPerm = channel.getPermission();
|
||||
if ((joinPerm != null && !TownyUniverse.getInstance().getPermissionSource().has(player, joinPerm))) {
|
||||
if (!channel.hasPermission(player)) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_you_cannot_join_channel", channel.getName()));
|
||||
return true;
|
||||
}
|
||||
@@ -67,8 +65,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
||||
// - channel has no permission set [by default they don't] OR
|
||||
// - channel has permission set AND:
|
||||
// - player has channel permission
|
||||
String joinPerm = channel.getPermission();
|
||||
if ((joinPerm != null && !TownyUniverse.getInstance().getPermissionSource().has(player, joinPerm))) {
|
||||
if (!channel.hasPermission(player)) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_you_cannot_join_channel", channel.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public abstract class Channel {
|
||||
public void forgetPlayer(Player player) {
|
||||
|
||||
if (playerIgnoringThisChannel(player)
|
||||
|| !player.hasPermission(getPermission())
|
||||
|| !hasPermission(player)
|
||||
|| !autojoin)
|
||||
leave(player);
|
||||
else
|
||||
@@ -145,7 +145,7 @@ public abstract class Channel {
|
||||
|
||||
// If the player could see this channel if they wanted to,
|
||||
// we know they are ignoring the channel by choice.
|
||||
if (player.hasPermission(getPermission()) && !playerIgnoringThisChannel(player))
|
||||
if (hasPermission(player) && !playerIgnoringThisChannel(player))
|
||||
playerAddIgnoreMeta(player);
|
||||
|
||||
return (res == null || res == 0);
|
||||
@@ -434,4 +434,7 @@ public abstract class Channel {
|
||||
public boolean isGovernmentChannel() {
|
||||
return type.equals(channelTypes.TOWN) || type.equals(channelTypes.NATION) || type.equals(channelTypes.ALLIANCE);
|
||||
}
|
||||
public boolean hasPermission(Player player) {
|
||||
return getPermission() != null && TownyUniverse.getInstance().getPermissionSource().has(player, getPermission());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.palmergames.bukkit.TownyChat.channels;
|
||||
|
||||
import com.palmergames.bukkit.TownyChat.Chat;
|
||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -110,7 +109,7 @@ public class ChannelsHolder {
|
||||
for (Channel channel: channels.values()) {
|
||||
if (!channel.isPresent(name)) continue;
|
||||
if (!channel.getType().equals(type)) continue;
|
||||
if (TownyUniverse.getInstance().getPermissionSource().has(player, channel.getPermission()) || (channel.getPermission().isEmpty())) {
|
||||
if (channel.hasPermission(player)) {
|
||||
if (channel.getRange() == -1) {
|
||||
global = channel;
|
||||
} else if (channel.getRange() == 0) {
|
||||
@@ -148,7 +147,7 @@ public class ChannelsHolder {
|
||||
|
||||
for (Channel channel: channels.values()) {
|
||||
if (!channel.getType().equals(type)) continue;
|
||||
if (TownyUniverse.getInstance().getPermissionSource().has(player, channel.getPermission()) || (channel.getPermission().isEmpty())){
|
||||
if (channel.hasPermission(player)){
|
||||
if (channel.getRange() == -1) {
|
||||
global = channel;
|
||||
} else if (channel.getRange() == 0) {
|
||||
|
||||
@@ -151,7 +151,7 @@ public class StandardChannel extends Channel {
|
||||
// Refresh the potential channels a player can see, if they are not currently in the channel.
|
||||
playerList.stream().forEach(p -> refreshPlayer(this, p));
|
||||
return playerList.stream()
|
||||
.filter(p -> TownyUniverse.getInstance().getPermissionSource().has(p, getPermission())) // Check permission.
|
||||
.filter(p -> hasPermission(p)) // Check permission.
|
||||
.filter(p -> testDistance(sender, p, getRange())) // Within range.
|
||||
.filter(p -> !plugin.isIgnoredByEssentials(sender, p)) // Check essentials ignore.
|
||||
.filter(p -> !isAbsent(p.getName())) // Check if player is purposefully absent.
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TownyChatPlayerListener implements Listener {
|
||||
refreshPlayerChannels(player);
|
||||
|
||||
Channel channel = plugin.getChannelsHandler().getDefaultChannel();
|
||||
if (channel != null && player.hasPermission(channel.getPermission())) {
|
||||
if (channel != null && channel.hasPermission(player)) {
|
||||
plugin.setPlayerChannel(player, channel);
|
||||
if (ChatSettings.getShowChannelMessageOnServerJoin())
|
||||
TownyMessaging.sendMessage(player, Translatable.of("tc_you_are_now_talking_in_channel", channel.getName()));
|
||||
@@ -97,7 +97,7 @@ public class TownyChatPlayerListener implements Listener {
|
||||
* Check the player for any channel modes.
|
||||
*/
|
||||
Channel channel = plugin.getPlayerChannel(player);
|
||||
if (!forceGlobal && channel != null) {
|
||||
if (!forceGlobal && channel != null && channel.hasPermission(player)) {
|
||||
if (isMutedOrSpam(event, channel, player))
|
||||
return;
|
||||
channel.chatProcess(event);
|
||||
|
||||
Reference in new issue
Block a user