Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2eeb609
feat: ChatPlayerList
vakiliner Jan 9, 2026
3a4e326
fix: Бел новой строки
vakiliner Jan 9, 2026
10b7210
perf: Заменить ChatMessageType на boolean
vakiliner Jan 9, 2026
1c413fa
Merge branch 'main' into feat/chat-player-list
vakiliner Jan 10, 2026
656e374
refactor: Объединить BukkitChatServer с BukkitChatPlayerList
vakiliner Jan 10, 2026
b1bd523
Merge branch 'feat/chat-player-list' of https://github.com/vakiliner/…
vakiliner Jan 10, 2026
5e1bdb6
fix: Spigot удалить лишнюю строку
vakiliner Jan 10, 2026
72955dc
feat: Функции для ChatPlayerList
vakiliner Jan 10, 2026
abe899e
Merge branch 'main' into feat/chat-player-list
vakiliner Jan 16, 2026
398b7b6
Merge branch 'main' into feat/chat-player-list
vakiliner Jan 20, 2026
c14e50d
fix: Console message for Fabric & Forge
vakiliner Jan 21, 2026
613308c
Merge branch 'main' into feat/chat-player-list
vakiliner Jan 25, 2026
c71f0b1
feat: ParseIterator & ParseCollection
vakiliner Jan 25, 2026
586973a
perf: Use ParseCollection for ChatPlayerList.getPlayers()
vakiliner Jan 25, 2026
8516896
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 1, 2026
9655c57
feat: ChatPlayerList.broadcastMessage(ChatComponent)
vakiliner Feb 5, 2026
e0c0821
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 6, 2026
3361025
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 7, 2026
8af15c7
refactor: Override method equals
vakiliner Feb 7, 2026
56a0261
refactor: Make fields ChatServer & ChatPlayerList as protected
vakiliner Feb 7, 2026
9066c4d
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 7, 2026
b07450f
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 7, 2026
a5eb568
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 9, 2026
5f3d9c1
feat: ChatPlayerList.getPlayer(String)
vakiliner Feb 9, 2026
c22469a
feat: ChatBanList
vakiliner Feb 10, 2026
2bc913b
feat: ChatStoredUserList.remove(K)
vakiliner Feb 10, 2026
7ca8923
refactor: Change param names
vakiliner Feb 10, 2026
d74c489
feat: ChatStoredUserList.add(Key)
vakiliner Feb 10, 2026
0246dea
feat: ChatBanList<Key>
vakiliner Feb 10, 2026
483861a
Merge branch 'main' into feat/chat-player-list
vakiliner Feb 11, 2026
4100748
fix: broadcastMessage null uuid for Fabric & Forge
vakiliner Feb 11, 2026
dc2b2d6
Merge branch 'main' into feat/chat-player-list
vakiliner Mar 26, 2026
e8045f9
revert: feat: ForgeChatStoredUserList
vakiliner Apr 27, 2026
bead98b
revert: Spigot import net.md_5.bungee.api.ChatMessageType
vakiliner Apr 27, 2026
7f19116
revert: ChatPlayerList.getViewDistance()
vakiliner Apr 27, 2026
39dc9f0
refactor: ParseCollection & ParseIterator rename impl field
vakiliner Apr 27, 2026
c985fdd
refactor: Rename var in sendMessage to system
vakiliner Apr 27, 2026
84017f8
Merge branch 'main' into feat/chat-player-list
vakiliner Apr 27, 2026
29cbfab
refactor: Paper Identity.nil()
vakiliner Apr 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package vakiliner.chatcomponentapi.base;

import java.util.Collection;
import java.util.UUID;
import vakiliner.chatcomponentapi.common.ChatMessageType;
import vakiliner.chatcomponentapi.component.ChatComponent;

public interface ChatPlayerList {
ChatServer getServer();

int getPlayerCount();

int getMaxPlayers();

Collection<ChatPlayer> getPlayers();

ChatPlayer getPlayer(UUID uuid);

ChatPlayer getPlayer(String name);

default void broadcastMessage(ChatComponent component) {
this.broadcastMessage(component, ChatMessageType.SYSTEM, null);
}

void broadcastMessage(ChatComponent component, ChatMessageType type, UUID uuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.authlib.GameProfile;

public interface ChatServer {
ChatPlayerList getPlayerList();

boolean isDedicatedServer();

String getSingleplayerName();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package vakiliner.chatcomponentapi.util;

import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.function.Function;

public class ParseCollection<Output, Input> extends AbstractCollection<Output> {
protected final Collection<? extends Input> impl;
protected final Function<Input, Output> i2o;

public ParseCollection(Collection<? extends Input> impl, Function<Input, Output> i2o) {
this.impl = impl;
this.i2o = i2o;
}

public Collection<? extends Input> getImpl() {
return impl;
}

public Iterator<Output> iterator() {
return new ParseIterator<>(this.impl.iterator(), this.i2o);
}

public int size() {
return this.impl.size();
}

public boolean isEmpty() {
return this.impl.isEmpty();
}

public boolean add(Output e) {
throw new UnsupportedOperationException();
}

public void clear() {
this.impl.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package vakiliner.chatcomponentapi.util;

import java.util.Iterator;
import java.util.function.Function;

public class ParseIterator<Output, Input> implements Iterator<Output> {
protected final Iterator<? extends Input> impl;
protected final Function<Input, Output> i2o;

public ParseIterator(Iterator<? extends Input> impl, Function<Input, Output> i2o) {
this.impl = impl;
this.i2o = i2o;
}

public Iterator<? extends Input> getImpl() {
return this.impl;
}

public boolean hasNext() {
return this.impl.hasNext();
}

public Output next() {
return this.i2o.apply(this.impl.next());
}

public void remove() {
this.impl.remove();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package vakiliner.chatcomponentapi.craftbukkit;

import java.util.Collection;
import java.util.Objects;
import java.util.UUID;
import org.bukkit.Server;
import com.mojang.authlib.GameProfile;
import vakiliner.chatcomponentapi.base.ChatPlayer;
import vakiliner.chatcomponentapi.base.ChatPlayerList;
import vakiliner.chatcomponentapi.base.ChatServer;
import vakiliner.chatcomponentapi.base.IChatPlugin;
import vakiliner.chatcomponentapi.common.ChatMessageType;
import vakiliner.chatcomponentapi.component.ChatComponent;
import vakiliner.chatcomponentapi.util.ParseCollection;

public class BukkitChatServer implements ChatServer {
public class BukkitChatServer implements ChatServer, ChatPlayerList {
protected final BukkitParser parser;
protected final Server server;

Expand All @@ -19,6 +26,14 @@ public Server getImpl() {
return this.server;
}

public ChatServer getServer() {
return this;
}

public ChatPlayerList getPlayerList() {
return this;
}

public boolean isDedicatedServer() {
return true;
}
Expand All @@ -36,10 +51,34 @@ public boolean isSingleplayerOwner(GameProfile gameProfile) {
return false;
}

public int getPlayerCount() {
return this.server.getOnlinePlayers().size();
}

public int getMaxPlayers() {
return this.server.getMaxPlayers();
}

public Collection<ChatPlayer> getPlayers() {
return new ParseCollection<>(this.server.getOnlinePlayers(), this.parser::toChatPlayer);
}

public ChatPlayer getPlayer(UUID uuid) {
return this.parser.toChatPlayer(this.server.getPlayer(uuid));
}

public ChatPlayer getPlayer(String name) {
return this.parser.toChatPlayer(this.server.getPlayerExact(name));
}

public void execute(IChatPlugin plugin, Runnable runnable) {
this.parser.execute(this.server.getScheduler(), plugin, runnable);
}

public void broadcastMessage(ChatComponent component, ChatMessageType type, UUID uuid) {
this.parser.broadcastMessage(this.server, component, type, uuid);
}

public boolean equals(Object obj) {
if (obj == this) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package vakiliner.chatcomponentapi.craftbukkit;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.Team;
import vakiliner.chatcomponentapi.base.BaseParser;
import vakiliner.chatcomponentapi.base.ChatCommandSender;
import vakiliner.chatcomponentapi.base.ChatOfflinePlayer;
import vakiliner.chatcomponentapi.base.ChatPlayer;
import vakiliner.chatcomponentapi.base.ChatPlayerList;
import vakiliner.chatcomponentapi.base.ChatServer;
import vakiliner.chatcomponentapi.base.ChatTeam;
import vakiliner.chatcomponentapi.base.IChatPlugin;
Expand All @@ -30,10 +34,33 @@ public boolean supportsFontInStyle() {
}

public void sendMessage(CommandSender sender, ChatComponent component, ChatMessageType type, UUID uuid) {
if (type == ChatMessageType.CHAT) {
sender.sendMessage(uuid, component.toLegacyText());
this.sendMessage(sender, component.toLegacyText(), type == ChatMessageType.SYSTEM, uuid);
}

private void sendMessage(CommandSender sender, String message, boolean system, UUID uuid) {
if (!system) {
sender.sendMessage(uuid, message);
} else {
sender.sendMessage(component.toLegacyText());
sender.sendMessage(message);
}
}

public void broadcastMessage(Server server, ChatComponent component, ChatMessageType type, UUID uuid) {
Set<CommandSender> recipients = new HashSet<>();
Set<Permissible> permissibles = server.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_USERS);
for (Permissible permissible : permissibles) {
if (permissible instanceof CommandSender && permissible.hasPermission(Server.BROADCAST_CHANNEL_USERS)) {
recipients.add((CommandSender) permissible);
}
}
this.broadcast(recipients, component, type, uuid);
}

public void broadcast(Iterable<CommandSender> recipients, ChatComponent chatComponent, ChatMessageType chatMessageType, UUID uuid) {
String message = chatComponent.toLegacyText();
boolean system = chatMessageType == ChatMessageType.SYSTEM;
for (CommandSender recipient : recipients) {
this.sendMessage(recipient, message, system, uuid);
}
}

Expand Down Expand Up @@ -86,4 +113,8 @@ public ChatTeam toChatTeam(Team team) {
public ChatServer toChatServer(Server server) {
return server != null ? new BukkitChatServer(this, server) : null;
}

public ChatPlayerList toChatPlayerList(Server server) {
return server != null ? new BukkitChatServer(this, server) : null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package vakiliner.chatcomponentapi.fabric;

import java.util.Collection;
import java.util.Objects;
import java.util.UUID;
import net.minecraft.server.players.PlayerList;
import vakiliner.chatcomponentapi.base.ChatPlayer;
import vakiliner.chatcomponentapi.base.ChatPlayerList;
import vakiliner.chatcomponentapi.base.ChatServer;
import vakiliner.chatcomponentapi.common.ChatMessageType;
import vakiliner.chatcomponentapi.component.ChatComponent;
import vakiliner.chatcomponentapi.util.ParseCollection;

public class FabricChatPlayerList implements ChatPlayerList {
protected final FabricParser parser;
protected final PlayerList playerList;

public FabricChatPlayerList(FabricParser parser, PlayerList playerList) {
this.parser = Objects.requireNonNull(parser);
this.playerList = Objects.requireNonNull(playerList);
}

public PlayerList getPlayerList() {
return this.playerList;
}

public ChatServer getServer() {
return this.parser.toChatServer(this.playerList.getServer());
}

public int getPlayerCount() {
return this.playerList.getPlayerCount();
}

public int getMaxPlayers() {
return this.playerList.getMaxPlayers();
}

public Collection<ChatPlayer> getPlayers() {
return new ParseCollection<>(this.playerList.getPlayers(), this.parser::toChatPlayer);
}

public ChatPlayer getPlayer(UUID uuid) {
return this.parser.toChatPlayer(this.playerList.getPlayer(uuid));
}

public ChatPlayer getPlayer(String name) {
return this.parser.toChatPlayer(this.playerList.getPlayerByName(name));
}

public void broadcastMessage(ChatComponent component, ChatMessageType type, UUID uuid) {
this.parser.broadcastMessage(this.playerList, component, type, uuid);
}

public boolean equals(Object obj) {
if (obj == this) {
return true;
} else if (obj != null && this.getClass() == obj.getClass()) {
FabricChatPlayerList other = (FabricChatPlayerList) obj;
return this.parser.equals(other.parser) && this.playerList.equals(other.playerList);
} else {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Objects;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.MinecraftServer;
import vakiliner.chatcomponentapi.base.ChatPlayerList;
import vakiliner.chatcomponentapi.base.ChatServer;
import vakiliner.chatcomponentapi.base.IChatPlugin;

Expand All @@ -19,6 +20,10 @@ public MinecraftServer getImpl() {
return this.server;
}

public ChatPlayerList getPlayerList() {
return this.parser.toChatPlayerList(this.server.getPlayerList());
}

public boolean isDedicatedServer() {
return this.server.isDedicatedServer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.protocol.game.ClientboundChatPacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -29,6 +30,7 @@
import vakiliner.chatcomponentapi.base.ChatCommandSender;
import vakiliner.chatcomponentapi.base.ChatOfflinePlayer;
import vakiliner.chatcomponentapi.base.ChatPlayer;
import vakiliner.chatcomponentapi.base.ChatPlayerList;
import vakiliner.chatcomponentapi.base.ChatServer;
import vakiliner.chatcomponentapi.base.ChatTeam;
import vakiliner.chatcomponentapi.base.IChatPlugin;
Expand Down Expand Up @@ -66,9 +68,10 @@ public void sendMessage(CommandSource commandSource, ChatComponent component, Ch
}
}

@Deprecated
public void broadcastMessage(PlayerList playerList, ChatComponent component, ChatMessageType type, UUID uuid) {
playerList.broadcastMessage(fabric(component), fabric(type), uuid);
if (uuid == null) uuid = Util.NIL_UUID;
this.sendMessage(playerList.getServer(), component, type, uuid);
playerList.broadcastAll(new ClientboundChatPacket(fabric(component), fabric(type), uuid));
}

public void execute(MinecraftServer server, IChatPlugin plugin, Runnable runnable) {
Expand Down Expand Up @@ -271,4 +274,8 @@ public ChatTeam toChatTeam(PlayerTeam team) {
public ChatServer toChatServer(MinecraftServer server) {
return server != null ? new FabricChatServer(this, server) : null;
}

public ChatPlayerList toChatPlayerList(PlayerList playerList) {
return playerList != null ? new FabricChatPlayerList(this, playerList) : null;
}
}
Loading
Loading