Replace towny modes usage with player channel map. (#35)

* Replace towny modes usage with player channel map.

Ends TownyChat's usage of Towny's Resident Modes to determine which
channel a player is actively chatting into.

Done as an attempt to fix
https://github.com/TownyAdvanced/Towny/issues/5451 but did not result in
solving the bug, in the end this is probably the correct thing to do
anyways.

* Add temporary debug messaging, make the directChat map store the channel
name instead of the channel command.

* Handle Spigot 1.18.1 config changes. Remove debug messaging.
This commit is contained in:
LlmDl authored and GitHub committed 2021-12-23 11:27:19 -06:00
1 parent 27f46966a6
commit f355807538
14 files changed
+65 -193

No files matched your search

+13 -1
View File
@@ -17,6 +17,7 @@ import com.palmergames.bukkit.util.Version;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -27,6 +28,9 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Chat plugin to manage all Towny chat
@@ -51,7 +55,7 @@ public class Chat extends JavaPlugin {
public static boolean usingEssentialsDiscord = false;
boolean chatConfigError = false;
boolean channelsConfigError = false;
private static ConcurrentMap<UUID, Channel> playerChannelMap = new ConcurrentHashMap<>();
@Override
public void onEnable() {
@@ -241,4 +245,12 @@ public class Chat extends JavaPlugin {
public TownyChatPlayerListener getTownyPlayerListener() {
return TownyPlayerListener;
}
public Channel getPlayerChannel(Player player) {
return playerChannelMap.get(player.getUniqueId());
}
public void setPlayerChannel(Player player, Channel channel) {
playerChannelMap.put(player.getUniqueId(), channel);
}
}