Add "local" chat channels with proximity-based messaging

Introduced a "local" channel type to restrict chat visibility based on player proximity, configurable via `LOCAL_DISTANCE`. Added channel spy functionality to monitor "local" messages. Updated constructors and configuration to support this new feature.
This commit is contained in:
2025-03-22 18:19:25 +01:00
parent 769859a617
commit e74361a7b7
5 changed files with 45 additions and 10 deletions
@@ -368,6 +368,8 @@ public final class Config {
public static String CUSTOM_CHANNEL_TOGGLED = "<yellow>Toggled <channel> <status>.</yellow>";
public static Component TOGGLED_ON = null;
public static Component TOGGLED_OFF = null;
public static double LOCAL_DISTANCE;
public static String CHANNEL_SPY = "<i><gray>SPY:</gray> <dark_gray>(<dark_gray><sender> → <channel>) <message></dark_gray>";
private static void chatChannels() {
ConfigurationNode node = getNode("chat-channels");
if (node.empty()) {
@@ -383,12 +385,16 @@ public final class Config {
new CustomChannel(channelName,
getString(key + "format", ""),
getList(key + "servers", Collections.EMPTY_LIST),
getBoolean(key + "proxy", false));
getBoolean(key + "proxy", false),
getBoolean(key + "local", false)
);
}
CUSTOM_CHANNEL_TOGGLED = getString("chat-channels-messages.channel-toggled", CUSTOM_CHANNEL_TOGGLED);
TOGGLED_ON = Utility.parseMiniMessage(getString("chat-channels-messages.channel-on", "<green>on</green><gray>"));
TOGGLED_OFF = Utility.parseMiniMessage(getString("chat-channels-messages.channel-off", "<red>off</red><gray>"));
LOCAL_DISTANCE = getDouble("chat-channels-messages.local-distance", 200.0);
CHANNEL_SPY = getString("chat-channels-messages.spy", CHANNEL_SPY);
}
public static String SERVERMUTEPERMISSION = "chat.command.mute-server";
@@ -10,12 +10,14 @@ public class Channel {
protected String channelName;
protected String format;
protected boolean proxy;
protected boolean local;
public Channel(String channelName, String format, boolean proxy) {
public Channel(String channelName, String format, boolean proxy, boolean local) {
this.permission = "chat.channel." + channelName.toLowerCase();
this.channelName = channelName;
this.format = format;
this.proxy = proxy;
this.local = local;
channels.put(channelName.toLowerCase(), this);
}
@@ -39,6 +41,10 @@ public class Channel {
return proxy;
}
public boolean isLocal() {
return local;
}
public static Channel getChatChannel(String channelName) {
return channels.get(channelName.toLowerCase());
}
@@ -5,8 +5,8 @@ import java.util.*;
public class CustomChannel extends Channel {
private final List<String> servers;
public CustomChannel(String channelName, String format, List<String> servers, boolean proxy) {
super(channelName, format, proxy);
public CustomChannel(String channelName, String format, List<String> servers, boolean proxy, boolean local) {
super(channelName, format, proxy, local);
this.permission = "chat.channel." + channelName.toLowerCase();
this.channelName = channelName;
this.format = format;
@@ -2,6 +2,6 @@ package com.alttd.chat.objects.channels;
public abstract class DefaultChannel extends Channel{
public DefaultChannel(String channelName, String format, boolean proxy) {
super(channelName, format, proxy);
super(channelName, format, proxy, false);
}
}