forked from Upstream/Velocitab
Updated papiproxybridge version
Added a check to correctly remove old entries after a player left a server Fixed problem where PlayerChannelHandler couldn't be able to handle tablist entries before the creation of TabPlayer object.
This commit is contained in:
parent
4f2fe1ef3f
commit
cc548b19fa
@ -40,7 +40,7 @@ dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.34'
|
||||
compileOnly 'net.luckperms:api:5.4'
|
||||
compileOnly 'io.github.miniplaceholders:miniplaceholders-api:2.2.3'
|
||||
compileOnly 'net.william278:PAPIProxyBridge:1.5'
|
||||
compileOnly 'net.william278:PAPIProxyBridge:1.6.2'
|
||||
compileOnly 'it.unimi.dsi:fastutil:8.5.14'
|
||||
compileOnly 'net.kyori:adventure-nbt:4.17.0'
|
||||
|
||||
|
@ -189,14 +189,14 @@ public enum Placeholder {
|
||||
|
||||
final Matcher testMatcher = TEST.matcher(format);
|
||||
while (testMatcher.find()) {
|
||||
if(testMatcher.group().startsWith("<velocitab_rel")) {
|
||||
if (testMatcher.group().startsWith("<velocitab_rel")) {
|
||||
final Matcher second = TEST.matcher(testMatcher.group().substring(1));
|
||||
while (second.find()) {
|
||||
String s = second.group();
|
||||
for (Map.Entry<String, String> entry : SYMBOL_SUBSTITUTES.entrySet()) {
|
||||
s = s.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
format = format.replace(second.group(), s);
|
||||
format = format.replace(second.group(), s);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -20,12 +20,15 @@
|
||||
package net.william278.velocitab.packet;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.william278.velocitab.Velocitab;
|
||||
import net.william278.velocitab.config.Group;
|
||||
import net.william278.velocitab.player.TabPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -83,7 +86,7 @@ public class PlayerChannelHandler extends ChannelDuplexHandler {
|
||||
|
||||
try {
|
||||
final Optional<TabPlayer> tabPlayer = plugin.getTabList().getTabPlayer(player);
|
||||
if (tabPlayer.isEmpty()) {
|
||||
if (tabPlayer.isEmpty() && !isFutureTabPlayer()) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
@ -121,4 +124,14 @@ public class PlayerChannelHandler extends ChannelDuplexHandler {
|
||||
.filter(entry -> entry.getProfileId() != null && entry.getGameMode() == 3 && !entry.getProfileId().equals(player.getUniqueId()))
|
||||
.forEach(entry -> entry.setGameMode(0));
|
||||
}
|
||||
|
||||
private boolean isFutureTabPlayer() {
|
||||
final String serverName = player.getCurrentServer()
|
||||
.map(ServerConnection::getServerInfo)
|
||||
.map(ServerInfo::getName)
|
||||
.orElse("");
|
||||
|
||||
final Optional<Group> groupOptional = plugin.getTabList().getGroup(serverName);
|
||||
return groupOptional.isPresent();
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,10 @@ public class Protocol404Adapter extends TeamsPacketAdapter {
|
||||
private final GsonComponentSerializer serializer;
|
||||
|
||||
public Protocol404Adapter(@NotNull Velocitab plugin) {
|
||||
super(plugin, Set.of(ProtocolVersion.MINECRAFT_1_13_2,
|
||||
super(plugin, Set.of(
|
||||
ProtocolVersion.MINECRAFT_1_13,
|
||||
ProtocolVersion.MINECRAFT_1_13_1,
|
||||
ProtocolVersion.MINECRAFT_1_13_2,
|
||||
ProtocolVersion.MINECRAFT_1_14,
|
||||
ProtocolVersion.MINECRAFT_1_14_1,
|
||||
ProtocolVersion.MINECRAFT_1_14_2,
|
||||
|
@ -519,6 +519,10 @@ public class PlayerTabList {
|
||||
return plugin.getTabGroups().getGroupFromServer(serverName, plugin);
|
||||
}
|
||||
|
||||
public void removeOldEntry(@NotNull Group group, @NotNull UUID uuid) {
|
||||
final Set<TabPlayer> players = group.getTabPlayers(plugin);
|
||||
players.forEach(player -> player.getPlayer().getTabList().removeEntry(uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an offline player from the list of tracked TAB players
|
||||
|
@ -91,6 +91,9 @@ public class TabListListener {
|
||||
.map(ServerInfo::getName)
|
||||
.orElse("");
|
||||
|
||||
final Optional<Group> previousGroup = tabList.getTabPlayer(joined)
|
||||
.map(TabPlayer::getGroup);
|
||||
|
||||
// Get the group the player should now be in
|
||||
final @NotNull Optional<Group> groupOptional = tabList.getGroup(serverName);
|
||||
final boolean isDefault = groupOptional.map(g -> g.isDefault(plugin)).orElse(true);
|
||||
@ -98,6 +101,12 @@ public class TabListListener {
|
||||
// Removes cached relational data of the joined player from all other players
|
||||
plugin.getTabList().clearCachedData(joined);
|
||||
|
||||
if (!plugin.getSettings().isShowAllPlayersFromAllGroups() && previousGroup.isPresent()
|
||||
&& (groupOptional.isPresent() && !previousGroup.get().equals(groupOptional.get())
|
||||
|| groupOptional.isEmpty())) {
|
||||
tabList.removeOldEntry(previousGroup.get(), joined.getUniqueId());
|
||||
}
|
||||
|
||||
// If the server is not in a group, use fallback.
|
||||
// If fallback is disabled, permit the player to switch excluded servers without a header or footer override
|
||||
if (isDefault && !plugin.getSettings().isFallbackEnabled() && !groupOptional.map(g -> g.containsServer(plugin, serverName)).orElse(false)) {
|
||||
|
Loading…
Reference in New Issue
Block a user