This commit is contained in:
Matej Pacan 2025-01-17 23:45:57 +01:00
parent 05b2ae15bc
commit 210dc7e070
10 changed files with 37 additions and 22 deletions

View File

@ -11,7 +11,7 @@
<artifactId>chatcontrol-bukkit</artifactId>
<name>ChatControl</name>
<version>11.1.3</version>
<version>11.1.4</version>
<properties>
<main.class>org.mineacademy.chatcontrol.ChatControl</main.class>

View File

@ -390,15 +390,15 @@ public interface SharedChatControlCommandCore extends SharedBukkitCommandCore {
default void updateProxyData(@NonNull final PlayerCache cache, @NonNull SimpleComponent message) throws CommandException {
final Player messageTarget = cache.toPlayer();
if (messageTarget != null && !message.isEmpty()) {
Messenger.info(messageTarget, message);
if (Settings.Proxy.ENABLED) {
if (messageTarget != null && !message.isEmpty()) {
Messenger.info(messageTarget, message);
message = SimpleComponent.empty();
}
message = SimpleComponent.empty();
}
if (Settings.Proxy.ENABLED)
ProxyUtil.sendPluginMessage(ChatControlProxyMessage.DATABASE_UPDATE, Platform.getCustomServerName(), cache.getUniqueId(), cache.toDataSectionOfMap(), message);
}
}
/**

View File

@ -14,7 +14,6 @@ import org.bukkit.plugin.IllegalPluginAccessException;
import org.mineacademy.chatcontrol.model.Colors;
import org.mineacademy.chatcontrol.settings.Settings;
import org.mineacademy.fo.Common;
import org.mineacademy.fo.model.CompChatColor;
import org.mineacademy.fo.model.SimpleComponent;
import org.mineacademy.fo.platform.BukkitPlugin;
@ -90,11 +89,13 @@ public final class AdventureChatListener implements EventExecutor, Listener {
@Override
public void sendMessage(final Identity source, final Component message, final MessageType type) {
final String consoleFormat = this.state.getConsoleFormat();
final String console = this.state.getConsoleFormat();
if (consoleFormat != null) {
if (!SimpleComponent.fromMiniSection(consoleFormat).toPlain().trim().isEmpty() && !"none".equals(consoleFormat))
Bukkit.getConsoleSender().sendMessage(CompChatColor.convertMiniToLegacy(consoleFormat));
if (console != null) {
final SimpleComponent consoleComponent = SimpleComponent.fromMiniAmpersand(console);
if (!consoleComponent.toPlain().trim().isEmpty() && !"none".equals(console))
Bukkit.getConsoleSender().sendMessage(consoleComponent.toLegacySection());
} else
Bukkit.getConsoleSender().sendMessage("<" + this.state.getPlayer().getName() + "> " + PlainTextComponentSerializer.plainText().serialize(message));

View File

@ -9,7 +9,6 @@ import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.mineacademy.chatcontrol.settings.Settings;
import org.mineacademy.fo.Common;
import org.mineacademy.fo.model.CompChatColor;
import org.mineacademy.fo.model.SimpleComponent;
import org.mineacademy.fo.platform.BukkitPlugin;
@ -46,9 +45,10 @@ public final class LegacyChatListener implements EventExecutor, Listener {
final String console = state.getConsoleFormat();
if (console != null) {
chatEvent.setFormat(CompChatColor.convertMiniToLegacy(console).replace("%", "%%"));
final SimpleComponent consoleComponent = SimpleComponent.fromMiniAmpersand(console);
chatEvent.setFormat(consoleComponent.toLegacySection().replace("%", "%%"));
if (SimpleComponent.fromMiniSection(console).toPlain().trim().isEmpty() || "none".equals(console))
if (consoleComponent.toPlain().trim().isEmpty() || "none".equals(console))
chatEvent.setCancelled(true);
}

View File

@ -686,7 +686,7 @@ public final class Channel extends YamlConfig implements ConfigStringSerializabl
// Log manually if not handled in player chat event
if (!sender.isPlayer() && !"none".equals(consoleFormat))
Platform.log(consoleFormat);
Platform.log(SimpleComponent.fromMiniAmpersand(consoleFormat).toLegacySection());
return state;
}

View File

@ -330,6 +330,11 @@ public final class Placeholders extends SimpleExpansion {
return playerCache == null ? "false" : String.valueOf(playerCache.hasToggledPartOff(toggleType));
}
// TODO merge with SyncedCache variables and remove duplicated code
if (identifier.startsWith("player_is_ignoring_"))
return "Unknown '" + identifier + "' part. Available: " + Common.join(ToggleType.values());
return null;
}

View File

@ -131,6 +131,7 @@ public final class ProxyChat {
final WrappedSender wrapped = WrappedSender.fromPlayerCaches(online, PlayerCache.fromCached(online), senderCache);
loadAllSyncedData(wrapped);
onlinePlayerUniqueIds.add(wrapped.getUniqueId());
}
}

View File

@ -11,7 +11,7 @@
<artifactId>chatcontrol-bungeecord</artifactId>
<name>BungeeControl</name>
<version>4.1.3</version>
<version>4.1.4</version>
<properties>
<main.class>org.mineacademy.chatcontrol.bungee.BungeeControl</main.class>

View File

@ -699,7 +699,7 @@ public final class SyncedCache {
final String name = cache != null ? cache.getPlayerName() : fallbackName;
final String nick = cache != null ? cache.getNameOrNickColoredPrefixed() : fallbackName;
return CommonCore.newHashMap(
final Map<String, Object> variables = CommonCore.newHashMap(
prefix + "_name", name,
prefix + "_nick", nick,
prefix + "_group", cache != null ? cache.getGroup() : "",
@ -707,8 +707,16 @@ public final class SyncedCache {
prefix + "_suffix", cache != null ? cache.getSuffix() : "",
prefix + "_server", cache != null ? cache.getServerName() : "",
prefix + "_channels", cache == null || cache.getChannels().isEmpty() ? Lang.plain("part-none") : CommonCore.join(cache.getChannels().keySet()),
prefix + "_afk", cache != null && cache.isAfk() ? "true" : "false",
prefix + "_ignoring_pms", cache != null && cache.hasToggledPartOff(ToggleType.PRIVATE_MESSAGE) ? "true" : "false",
prefix + "_vanished", cache != null && cache.isVanished() ? "true" : "false");
prefix + "_is_afk", cache != null && cache.isAfk() ? "true" : "false",
prefix + "_is_vanished", cache != null && cache.isVanished() ? "true" : "false");
for (final ToggleType part : ToggleType.values()) {
final String value = cache != null && cache.hasToggledPartOff(part) ? "true" : "false";
variables.put(prefix + "_is_ignoring_" + part.name().toLowerCase(), value);
variables.put(prefix + "_is_ignoring_" + part.name().toLowerCase() + "s", value);
}
return variables;
}
}

View File

@ -11,7 +11,7 @@
<artifactId>chatcontrol-velocity</artifactId>
<name>VelocityControl</name>
<version>2.1.3</version>
<version>2.1.4</version>
<properties>
<main.class>org.mineacademy.chatcontrol.velocity.VelocityControl</main.class>