Compare commits

..
15 Commits
Author SHA1 Message Date
NEZNAMY db2110b11e 5.3.2 2025-10-08 18:33:02 +02:00
NEZNAMY be1122ce50 Update to 1.21.10 2025-10-08 17:08:59 +02:00
NEZNAMY cf265987db [Bukkit] Remove override for %player_ping%, since people have probably updated their expansion by now. 2025-10-07 17:54:05 +02:00
NEZNAMY cd82e75514 [Teams] Improve anti-override message to contain source of blocked team and how to fix it. 2025-10-07 17:13:38 +02:00
NEZNAMY 74d36f1ab5 [MySQL] Fix error on upload command and message saying success despite operation not being successful 2025-10-06 20:38:05 +02:00
NEZNAMY 67da0ff32b [GitHub] Add an item to CONTRIBUTING.md 2025-10-06 18:42:03 +02:00
NEZNAMY aabad04e28 [MySQL] Delete data in database on upload first, instead of just overwriting / adding new content 2025-10-05 15:05:20 +02:00
NEZNAMY 9236da40dd [Spectator fix] Rewrite packets to avoid the same packet identity from being sent to all players, causing wrong result from modifying it for another player 2025-10-05 14:51:29 +02:00
NEZNAMY 88ff78b7e3 [Commands] Fix debug command not displaying server name correctly 2025-10-05 11:44:25 +02:00
NEZNAMY 21ebd68607 [API] Restore TabPlayer#getWorld and TabPlayer#getServer 2025-10-05 11:39:31 +02:00
NEZNAMY 9adad40aa9 [Pipeline injection] Change return type of onPacketSend to Object to allow changing the packet 2025-10-05 11:17:46 +02:00
NEZNAMY f63b3de63a [Bukkit] Add Header/Footer sending on 1.7.10 if the method is available (modded server) (#1557) 2025-10-04 19:03:21 +02:00
NEZNAMY 767933e522 [Bukkit] Add craftbukkit package version into debug command output 2025-10-04 18:49:20 +02:00
NEZNAMY 0fb86ddf6c 5.3.2-SNAPSHOT 2025-10-04 17:36:02 +02:00
NEZNAMY d52969597f [Description] Update badges 2025-10-04 17:31:03 +02:00
112 changed files with 1400 additions and 616 deletions

No files matched your search

+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="92" height="20" role="img" aria-label="Release: 5.3.0"><title>Release: 5.3.0</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="92" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="53" height="20" fill="#555"/><rect x="53" width="39" height="20" fill="#007ec6"/><rect width="92" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="275" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">Release</text><text x="275" y="140" transform="scale(.1)" fill="#fff" textLength="430">Release</text><text aria-hidden="true" x="715" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="290">5.3.0</text><text x="715" y="140" transform="scale(.1)" fill="#fff" textLength="290">5.3.0</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="92" height="20" role="img" aria-label="Release: 5.3.1"><title>Release: 5.3.1</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="92" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="53" height="20" fill="#555"/><rect x="53" width="39" height="20" fill="#007ec6"/><rect width="92" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="275" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">Release</text><text x="275" y="140" transform="scale(.1)" fill="#fff" textLength="430">Release</text><text aria-hidden="true" x="715" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="290">5.3.1</text><text x="715" y="140" transform="scale(.1)" fill="#fff" textLength="290">5.3.1</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

+1 -1
View File
@@ -274,7 +274,7 @@ if __name__ == "__main__":
]
)
release = "5.3.0"
release = "5.3.1"
download_image(f"https://img.shields.io/badge/Release-{release}-blue.svg", "Badge_Release.svg")
minecraft = "1.7.x - 1.21.9".replace(" ", "%20").replace("-", "--")
+4 -1
View File
@@ -6,4 +6,7 @@ is in quality of the report (typically providing correct steps to reproduce that
* Test **experimental builds**, which can be found in [GitHub Actions](https://github.com/NEZNAMY/TAB/actions) for problems of any kind including bugs.
This way you will help make the actual releases more stable / help get stable releases sooner.
* Help improve the wiki by opening a [Wiki change issue](https://github.com/NEZNAMY/TAB/issues/new?assignees=&labels=Wiki&template=wiki_change.yml),
where you can improve existing descriptions, add information you found missing, fix typos / grammar mistakes or add more examples.
where you can improve existing descriptions, add information you found missing, fix typos / grammar mistakes or add more examples.
* Create spark reports and then send them to me. I will analyze them and try to find optimizations to make the plugin run faster. Commands:
* `/spark profiler start --timeout 300 --thread * --interval 0.1`
* `/spark profiler start --timeout 300 --thread * --interval 0.1 --alloc`
@@ -96,6 +96,26 @@ public interface TabPlayer {
@NotNull
String getExpectedProfileName();
/**
* Returns name of the server the player is connected to.
* This requires TAB on proxy.
* On backend installation, this method returns {@code "N/A"}.
*
* @return Player's server on proxy or {@code "N/A"} on backend installation
*/
@NotNull
String getServer();
/**
* Returns name of the world the player is in.
* On proxy installation, TAB-Bridge must be installed to forward this info to the proxy.
* Otherwise, it will return {@code "N/A"}.
*
* @return Player's world or {@code "N/A"} on proxy installation without TAB-Bridge installed
*/
@NotNull
String getWorld();
/**
* Returns {@code true} if this player is a bedrock player, {@code false} if not.
*
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
allprojects {
group = "me.neznamy"
version = "5.3.1"
version = "5.3.2"
description = "An all-in-one solution that works"
ext.set("id", "tab")
@@ -133,7 +133,8 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -142,9 +143,11 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
if (action != TeamAction.UPDATE) {
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -3,13 +3,11 @@ package me.neznamy.tab.platforms.paper_1_20_5;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import lombok.NonNull;
import lombok.SneakyThrows;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
@@ -20,7 +18,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.*;
/**
@@ -34,8 +31,6 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateGameMode = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateListed = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -107,8 +102,8 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -146,8 +141,9 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) return new ClientboundPlayerInfoUpdatePacket(actions, updatedList);
}
return packet;
}
private void sendPacket(@NonNull EnumSet<ClientboundPlayerInfoUpdatePacket.Action> action, @NonNull UUID id, @NonNull String name, @Nullable Skin skin,
@@ -133,7 +133,8 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -142,9 +143,11 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
if (action != TeamAction.UPDATE) {
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
}
}
return packet;
}
private static int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -3,13 +3,11 @@ package me.neznamy.tab.platforms.paper_1_21_2;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import lombok.NonNull;
import lombok.SneakyThrows;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
@@ -20,7 +18,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.*;
/**
@@ -35,8 +32,6 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateListed = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateListOrder = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -108,8 +103,8 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -147,8 +142,9 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.listOrder(), nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) return new ClientboundPlayerInfoUpdatePacket(actions, updatedList);
}
return packet;
}
private void sendPacket(@NonNull EnumSet<ClientboundPlayerInfoUpdatePacket.Action> action, @NonNull UUID id, @NonNull String name, @Nullable Skin skin,
@@ -133,7 +133,8 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -142,9 +143,11 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
if (action != TeamAction.UPDATE) {
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -3,13 +3,11 @@ package me.neznamy.tab.platforms.paper_1_21_4;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import lombok.NonNull;
import lombok.SneakyThrows;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
@@ -20,7 +18,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.*;
/**
@@ -36,8 +33,6 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateListOrder = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateHat = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -109,8 +104,8 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -148,8 +143,9 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.showHat(), nmsData.listOrder(), nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) return new ClientboundPlayerInfoUpdatePacket(actions, updatedList);
}
return packet;
}
private void sendPacket(@NonNull EnumSet<ClientboundPlayerInfoUpdatePacket.Action> action, @NonNull UUID id, @NonNull String name, @Nullable Skin skin,
@@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
/**
* Implementation provider using direct Mojang-mapped NMS code for version 1.21.9.
* Implementation provider using direct Mojang-mapped NMS code for versions 1.21.9 - 1.21.10.
*/
@Getter
public class PaperImplementationProvider implements ImplementationProvider {
@@ -133,7 +133,8 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -142,9 +143,11 @@ public class PaperPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
if (action != TeamAction.UPDATE) {
players.set(team, onTeamPacket(action, team.getName(), team.getPlayers() == null ? Collections.emptyList() : team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -5,13 +5,11 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import lombok.NonNull;
import lombok.SneakyThrows;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
@@ -22,7 +20,6 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.*;
/**
@@ -38,8 +35,6 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateListOrder = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.Action> updateHat = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -111,8 +106,8 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -150,8 +145,9 @@ public class PaperPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.showHat(), nmsData.listOrder(), nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) return new ClientboundPlayerInfoUpdatePacket(actions, updatedList);
}
return packet;
}
private void sendPacket(@NonNull EnumSet<ClientboundPlayerInfoUpdatePacket.Action> action, @NonNull UUID id, @NonNull String name, @Nullable Skin skin,
@@ -20,7 +20,7 @@ public class BukkitTAB extends JavaPlugin {
} catch (UnsupportedOperationException e) {
Bukkit.getConsoleSender().sendMessage("§c[TAB] ================================================================================");
Bukkit.getConsoleSender().sendMessage("§c[TAB] Your server version (" + Bukkit.getBukkitVersion().split("-")[0] + ") is not supported. " +
"This jar only supports 1.7 - 1.21.9. If you just updated to a new Minecraft version, check for TAB updates.");
"This jar only supports 1.7 - 1.21.10. If you just updated to a new Minecraft version, check for TAB updates.");
Bukkit.getConsoleSender().sendMessage("§c[TAB] ================================================================================");
}
}
@@ -39,7 +39,6 @@ import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.TabPlayer;
import me.neznamy.tab.shared.platform.impl.AdventureBossBar;
import me.neznamy.tab.shared.platform.impl.DummyBossBar;
import me.neznamy.tab.shared.util.PerformanceUtil;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.kyori.adventure.audience.Audience;
import net.milkbowl.vault.chat.Chat;
@@ -84,10 +83,14 @@ public class BukkitPlatform implements BackendPlatform {
/** Detection for presence of Paper's MSPT getter */
private final boolean paperMspt = ReflectionUtils.methodExists(Bukkit.class, "getAverageTickTime");
/** Package name of the server implementation, null on Paper 1.20.5+ */
@Nullable
private final String serverPackage;
/** Implementation for creating new instances using content available on the server */
@NotNull
@Setter
private ImplementationProvider implementationProvider = findImplementationProvider();
private ImplementationProvider implementationProvider;
private final boolean modernOnlinePlayers;
@@ -101,6 +104,10 @@ public class BukkitPlatform implements BackendPlatform {
public BukkitPlatform(@NotNull JavaPlugin plugin) {
this.plugin = plugin;
modernOnlinePlayers = Bukkit.class.getMethod("getOnlinePlayers").getReturnType() == Collection.class;
String CRAFTBUKKIT_PACKAGE = Bukkit.getServer().getClass().getPackage().getName();
String[] array = CRAFTBUKKIT_PACKAGE.split("\\.");
serverPackage = array.length > 3 ? array[3] : null;
implementationProvider = findImplementationProvider();
try {
Object server = Bukkit.getServer().getClass().getMethod("getServer").invoke(Bukkit.getServer());
recentTps = ((double[]) server.getClass().getField("recentTps").get(server));
@@ -115,10 +122,6 @@ public class BukkitPlatform implements BackendPlatform {
@NotNull
@SneakyThrows
private ImplementationProvider findImplementationProvider() {
String CRAFTBUKKIT_PACKAGE = Bukkit.getServer().getClass().getPackage().getName();
String[] array = CRAFTBUKKIT_PACKAGE.split("\\.");
String serverPackage = array.length > 3 ? array[3] : null;
if (serverPackage == null) {
// Paper 1.20.5+, check for available module
String paperModule = getPaperModule();
@@ -131,10 +134,8 @@ public class BukkitPlatform implements BackendPlatform {
// Does not actually support flat 1.19, but whatever, no one is using it anyway
return (ImplementationProvider) Class.forName("me.neznamy.tab.platforms.bukkit." + serverPackage + ".NMSImplementationProvider").getConstructor().newInstance();
} catch (ClassNotFoundException ignored) {
}
}
throw new UnsupportedOperationException();
}
@@ -164,6 +165,7 @@ public class BukkitPlatform implements BackendPlatform {
case V1_21_8:
return "1_21_4";
case V1_21_9:
case V1_21_10:
return "1_21_9";
default:
return null;
@@ -190,8 +192,6 @@ public class BukkitPlatform implements BackendPlatform {
manager.registerInternalPlayerPlaceholder("%vault-suffix%", 1000, p -> chat.getPlayerSuffix((Player) p.getPlayer()));
}
}
// Override for the PAPI placeholder to prevent console errors on unsupported server versions when ping field changes
manager.registerPlayerPlaceholder("%player_ping%", p -> PerformanceUtil.toString(((TabPlayer) p).getPing()));
BackendPlatform.super.registerPlaceholders();
}
@@ -273,7 +273,7 @@ public class BukkitPlatform implements BackendPlatform {
@Override
@NotNull
public String getServerVersionInfo() {
return "[Bukkit] " + Bukkit.getName() + " - " + Bukkit.getBukkitVersion().split("-")[0];
return "[Bukkit] " + Bukkit.getName() + " - " + Bukkit.getBukkitVersion().split("-")[0] + " (" + serverPackage + ")";
}
@Override
@@ -121,7 +121,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -132,11 +133,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -115,37 +115,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -155,6 +183,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -121,7 +121,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -132,11 +133,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -118,37 +115,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -158,6 +183,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -121,7 +121,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -132,11 +133,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -120,37 +117,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -160,6 +185,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -147,11 +148,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -18,10 +18,7 @@ import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -117,37 +114,65 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
@@ -157,6 +182,13 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -138,7 +138,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -155,11 +156,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -34,10 +31,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, EnumGamemode.class);
private static final EnumPlayerInfoAction ADD_PLAYER = EnumPlayerInfoAction.a;
private static final EnumPlayerInfoAction UPDATE_GAME_MODE = EnumPlayerInfoAction.b;
private static final EnumPlayerInfoAction UPDATE_LATENCY = EnumPlayerInfoAction.c;
@@ -117,29 +110,56 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = ((PacketPlayOutPlayerInfo)packet).c();
for (PlayerInfoData nmsData : ((PacketPlayOutPlayerInfo)packet).b()) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = info.c();
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : info.b()) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().getId();
if (action == UPDATE_DISPLAY_NAME || action == ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_GAME_MODE || action == ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_LATENCY || action == ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -34,10 +31,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, EnumGamemode.class);
private static final EnumPlayerInfoAction ADD_PLAYER = EnumPlayerInfoAction.a;
private static final EnumPlayerInfoAction UPDATE_GAME_MODE = EnumPlayerInfoAction.b;
private static final EnumPlayerInfoAction UPDATE_LATENCY = EnumPlayerInfoAction.c;
@@ -117,29 +110,56 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = ((PacketPlayOutPlayerInfo)packet).c();
for (PlayerInfoData nmsData : ((PacketPlayOutPlayerInfo)packet).b()) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = info.c();
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : info.b()) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().a();
if (action == UPDATE_DISPLAY_NAME || action == ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_GAME_MODE || action == ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.a(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_LATENCY || action == ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -34,10 +31,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, EnumGamemode.class);
private static final EnumPlayerInfoAction ADD_PLAYER = EnumPlayerInfoAction.a;
private static final EnumPlayerInfoAction UPDATE_GAME_MODE = EnumPlayerInfoAction.b;
private static final EnumPlayerInfoAction UPDATE_LATENCY = EnumPlayerInfoAction.c;
@@ -117,29 +110,56 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = ((PacketPlayOutPlayerInfo)packet).c();
for (PlayerInfoData nmsData : ((PacketPlayOutPlayerInfo)packet).b()) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = info.c();
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : info.b()) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().a();
if (action == UPDATE_DISPLAY_NAME || action == ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_GAME_MODE || action == ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.a(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_LATENCY || action == ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -16,16 +16,14 @@ import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerListHeaderFooter;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.EnumGamemode;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -34,10 +32,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, EnumGamemode.class);
private static final EnumPlayerInfoAction ADD_PLAYER = EnumPlayerInfoAction.a;
private static final EnumPlayerInfoAction UPDATE_GAME_MODE = EnumPlayerInfoAction.b;
private static final EnumPlayerInfoAction UPDATE_LATENCY = EnumPlayerInfoAction.c;
@@ -117,29 +111,58 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = ((PacketPlayOutPlayerInfo)packet).c();
for (PlayerInfoData nmsData : ((PacketPlayOutPlayerInfo)packet).b()) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = info.c();
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : info.b()) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().a();
ProfilePublicKey.a publicKey = nmsData.e();
if (action == UPDATE_DISPLAY_NAME || action == ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_GAME_MODE || action == ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.a(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == UPDATE_LATENCY || action == ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName,
publicKey
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -42,8 +42,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -118,8 +116,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return packet;
ClientboundPlayerInfoUpdatePacket info = (ClientboundPlayerInfoUpdatePacket) packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
@@ -158,7 +157,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -42,8 +42,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -118,8 +116,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return packet;
ClientboundPlayerInfoUpdatePacket info = (ClientboundPlayerInfoUpdatePacket) packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.a();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
@@ -158,7 +157,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -139,7 +139,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(
player,
@@ -156,11 +157,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = getMethod((PacketPlayOutScoreboardTeam) packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = ((PacketPlayOutScoreboardTeam) packet).e();
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, ((PacketPlayOutScoreboardTeam)packet).d(), players));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -42,8 +42,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -118,8 +116,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket)) return packet;
ClientboundPlayerInfoUpdatePacket info = (ClientboundPlayerInfoUpdatePacket) packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.a();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
@@ -158,7 +157,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.a().ordinal(), display.d());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.e(), team.f() == null ? Collections.emptyList() : team.f()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.e(), team.f() == null ? Collections.emptyList() : team.f()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -42,8 +42,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -118,8 +116,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.a();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -157,7 +156,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -134,7 +134,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.a().ordinal(), display.d());
}
@@ -143,9 +144,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.e(), team.f() == null ? Collections.emptyList() : team.f()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.e(), team.f() == null ? Collections.emptyList() : team.f()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -42,8 +42,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -118,8 +116,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.a();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -157,7 +156,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -43,8 +43,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -119,8 +117,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -158,7 +157,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -43,8 +43,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LATENCY_SET = EnumSet.of(UPDATE_LATENCY);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -119,8 +117,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -158,7 +157,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -45,8 +45,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LISTED_SET = EnumSet.of(UPDATE_LISTED);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LIST_ORDER_SET = EnumSet.of(UPDATE_LIST_ORDER);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -121,8 +119,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -160,7 +159,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g(), nmsData.h()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -47,8 +47,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LIST_ORDER_SET = EnumSet.of(UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_HAT_SET = EnumSet.of(UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -123,8 +121,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -162,7 +161,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g(), nmsData.h(), nmsData.i()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -47,8 +47,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LIST_ORDER_SET = EnumSet.of(UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_HAT_SET = EnumSet.of(UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -123,8 +121,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -162,7 +161,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g(), nmsData.h(), nmsData.i()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -47,8 +47,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LIST_ORDER_SET = EnumSet.of(UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_HAT_SET = EnumSet.of(UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -123,8 +121,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -162,7 +161,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g(), nmsData.h(), nmsData.i()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
/**
* Implementation provider using direct NMS code for 1.21.9.
* Implementation provider using direct NMS code for 1.21.9 - 1.21.10.
*/
@Getter
public class NMSImplementationProvider implements ImplementationProvider {
@@ -136,7 +136,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.b().ordinal(), display.e());
}
@@ -145,9 +146,11 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam team) {
int action = getMethod(team);
if (action == TeamAction.UPDATE) return;
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
if (action != TeamAction.UPDATE) {
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, team.f(), team.g() == null ? Collections.emptyList() : team.g()));
}
}
return packet;
}
private int getMethod(@NonNull PacketPlayOutScoreboardTeam team) {
@@ -49,8 +49,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_LIST_ORDER_SET = EnumSet.of(UPDATE_LIST_ORDER);
private static final EnumSet<ClientboundPlayerInfoUpdatePacket.a> UPDATE_HAT_SET = EnumSet.of(UPDATE_HAT);
private static final Field entries = ReflectionUtils.getOnlyField(ClientboundPlayerInfoUpdatePacket.class, List.class);
/**
* Constructs new instance.
*
@@ -125,8 +123,9 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@SneakyThrows
@Override
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return;
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof ClientboundPlayerInfoUpdatePacket info)) return packet;
EnumSet<ClientboundPlayerInfoUpdatePacket.a> actions = info.b();
List<ClientboundPlayerInfoUpdatePacket.b> updatedList = new ArrayList<>();
boolean rewritePacket = false;
@@ -164,7 +163,12 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
nmsData.g(), nmsData.h(), nmsData.i()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -97,8 +97,10 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -83,8 +83,10 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -98,8 +98,10 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -83,8 +83,10 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -97,8 +97,10 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -83,8 +83,10 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
+1
View File
@@ -1,4 +1,5 @@
dependencies {
implementation(projects.bukkit)
compileOnly("org.purpurmc.purpur:purpur-api:1.16.5-R0.1-SNAPSHOT") // To expose header/footer method
compileOnly("org.bukkit:craftbukkit:1.7.10-R0.1-SNAPSHOT")
}
@@ -98,8 +98,10 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -4,8 +4,10 @@ import lombok.NonNull;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -16,6 +18,9 @@ import java.util.UUID;
*/
public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
/** Some Bukkit + Forge hybrids added this feature to 1.7.10 (#1557) */
private static final boolean HEADER_FOOTER_AVAILABLE = ReflectionUtils.methodExists(Player.class, "setPlayerListHeaderFooter", String.class, String.class);
/**
* Constructs new instance.
*
@@ -67,8 +72,14 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
@SuppressWarnings("deprecation")
public void setPlayerListHeaderFooter0(@NonNull TabComponent header, @NonNull TabComponent footer) {
// Added in 1.8
if (HEADER_FOOTER_AVAILABLE) {
player.getPlayer().setPlayerListHeaderFooter(
player.getPlatform().toBukkitFormat(header),
player.getPlatform().toBukkitFormat(footer)
);
}
}
@Override
@@ -83,8 +94,10 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
// Pipeline injection is not available (netty is relocated)
return packet;
}
/**
@@ -120,7 +120,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -131,11 +132,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -16,10 +16,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -28,11 +25,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field ACTION = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, EnumPlayerInfoAction.class);
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, EnumGamemode.class);
private static final Field FOOTER = ReflectionUtils.getFields(PacketPlayOutPlayerListHeaderFooter.class, IChatBaseComponent.class).get(1);
/**
@@ -111,30 +103,58 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? new PlayerInfoData(
info,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -119,7 +119,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -130,11 +131,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -13,15 +13,13 @@ import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.server.v1_8_R2.*;
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_8_R2.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.server.v1_8_R2.WorldSettings.EnumGamemode;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -30,11 +28,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field ACTION = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, EnumPlayerInfoAction.class);
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, WorldSettings.EnumGamemode.class);
private static final Field FOOTER = ReflectionUtils.getFields(PacketPlayOutPlayerListHeaderFooter.class, IChatBaseComponent.class).get(1);
/**
@@ -113,30 +106,57 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, WorldSettings.EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? info.new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -146,7 +166,7 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
PLAYERS.set(packet, Collections.singletonList(packet.new PlayerInfoData(
createProfile(id, name, skin),
latency,
WorldSettings.EnumGamemode.values()[gameMode],
EnumGamemode.values()[gameMode],
displayName == null ? null : displayName.convert())
));
sendPacket(packet);
@@ -119,7 +119,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -130,11 +131,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -4,24 +4,22 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import lombok.NonNull;
import lombok.SneakyThrows;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.platforms.bukkit.BukkitTabPlayer;
import me.neznamy.tab.shared.TAB;
import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.TabList;
import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -30,11 +28,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field ACTION = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, EnumPlayerInfoAction.class);
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, WorldSettings.EnumGamemode.class);
private static final Field FOOTER = ReflectionUtils.getFields(PacketPlayOutPlayerListHeaderFooter.class, IChatBaseComponent.class).get(1);
/**
@@ -113,30 +106,57 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, WorldSettings.EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? info.new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -146,7 +166,7 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
PLAYERS.set(packet, Collections.singletonList(packet.new PlayerInfoData(
createProfile(id, name, skin),
latency,
WorldSettings.EnumGamemode.values()[gameMode],
EnumGamemode.values()[gameMode],
displayName == null ? null : displayName.convert())
));
sendPacket(packet);
@@ -121,7 +121,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -132,11 +133,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -13,15 +13,13 @@ import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.server.v1_9_R1.*;
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.server.v1_9_R1.WorldSettings.EnumGamemode;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* TabList implementation using direct NMS code.
@@ -30,12 +28,6 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field ACTION = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, EnumPlayerInfoAction.class);
private static final Field PLAYERS = ReflectionUtils.getOnlyField(PacketPlayOutPlayerInfo.class, List.class);
private static final Field PlayerInfoData_Profile = ReflectionUtils.getOnlyField(PlayerInfoData.class, GameProfile.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData.class, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData.class, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData.class, WorldSettings.EnumGamemode.class);
private static final Field FOOTER = ReflectionUtils.getFields(PacketPlayOutPlayerListHeaderFooter.class, IChatBaseComponent.class).get(1);
/**
@@ -114,30 +106,57 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<PlayerInfoData> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (PlayerInfoData nmsData : (List<PlayerInfoData>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = nmsData.a();
UUID id = profile.getId();
IChatBaseComponent displayName = nmsData.d();
int latency = nmsData.b();
int gameMode = nmsData.c().getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, WorldSettings.EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? info.new PlayerInfoData(
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
@@ -147,7 +166,7 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
PLAYERS.set(packet, Collections.singletonList(packet.new PlayerInfoData(
createProfile(id, name, skin),
latency,
WorldSettings.EnumGamemode.values()[gameMode],
EnumGamemode.values()[gameMode],
displayName == null ? null : displayName.convert())
));
sendPacket(packet);
@@ -121,7 +121,8 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
@Override
@SneakyThrows
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PacketPlayOutScoreboardDisplayObjective) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, DisplayObjective_POSITION.getInt(packet),
(String) DisplayObjective_OBJECTIVE_NAME.get(packet));
@@ -132,11 +133,13 @@ public class NMSPacketScoreboard extends SafeScoreboard<BukkitTabPlayer> {
}
if (packet instanceof PacketPlayOutScoreboardTeam) {
int action = TeamPacket_ACTION.getInt(packet);
if (action == TeamAction.UPDATE) return;
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
if (action != TeamAction.UPDATE) {
Collection<String> players = (Collection<String>) TeamPacket_PLAYERS.get(packet);
if (players == null) players = Collections.emptyList();
TeamPacket_PLAYERS.set(packet, onTeamPacket(action, (String) TeamPacket_NAME.get(packet), players));
}
}
return packet;
}
/**
@@ -12,6 +12,7 @@ import me.neznamy.tab.shared.platform.decorators.TrackedTabList;
import me.neznamy.tab.shared.util.ReflectionUtils;
import net.minecraft.server.v1_9_R2.*;
import net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.v1_9_R2.WorldSettings.EnumGamemode;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -35,7 +36,7 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
private static final Field PlayerInfoData_Profile = ReflectionUtils.getOnlyField(PlayerInfoData, GameProfile.class);
private static final Field PlayerInfoData_Latency = ReflectionUtils.getFields(PlayerInfoData, int.class).get(0);
private static final Field PlayerInfoData_DisplayName = ReflectionUtils.getOnlyField(PlayerInfoData, IChatBaseComponent.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData, WorldSettings.EnumGamemode.class);
private static final Field PlayerInfoData_GameMode = ReflectionUtils.getOnlyField(PlayerInfoData, EnumGamemode.class);
private static final Field FOOTER = ReflectionUtils.getFields(PacketPlayOutPlayerListHeaderFooter.class, IChatBaseComponent.class).get(1);
@@ -115,46 +116,81 @@ public class NMSPacketTabList extends TrackedTabList<BukkitTabPlayer> {
@Override
@SneakyThrows
@NotNull
@SuppressWarnings("unchecked")
public void onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(packet);
for (Object nmsData : (List<Object>) PLAYERS.get(packet)) {
public Object onPacketSend(@NonNull Object packet) {
if (!(packet instanceof PacketPlayOutPlayerInfo)) return packet;
PacketPlayOutPlayerInfo info = (PacketPlayOutPlayerInfo) packet;
EnumPlayerInfoAction action = (EnumPlayerInfoAction) ACTION.get(info);
List<Object> updatedList = new ArrayList<>();
boolean rewritePacket = false;
for (Object nmsData : (List<Object>) PLAYERS.get(info)) {
boolean rewriteEntry = false;
GameProfile profile = (GameProfile) PlayerInfoData_Profile.get(nmsData);
UUID id = profile.getId();
IChatBaseComponent displayName = (IChatBaseComponent) PlayerInfoData_DisplayName.get(nmsData);
int latency = PlayerInfoData_Latency.getInt(nmsData);
int gameMode = ((EnumGamemode)PlayerInfoData_GameMode.get(nmsData)).getId();
if (action == EnumPlayerInfoAction.UPDATE_DISPLAY_NAME || action == EnumPlayerInfoAction.ADD_PLAYER) {
TabComponent expectedName = getForcedDisplayNames().get(id);
if (expectedName != null) PlayerInfoData_DisplayName.set(nmsData, expectedName.convert());
TabComponent forcedDisplayName = getForcedDisplayNames().get(id);
if (forcedDisplayName != null && forcedDisplayName.convert() != displayName) {
displayName = forcedDisplayName.convert();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_GAME_MODE || action == EnumPlayerInfoAction.ADD_PLAYER) {
Integer forcedGameMode = getForcedGameModes().get(id);
if (forcedGameMode != null) PlayerInfoData_GameMode.set(nmsData, WorldSettings.EnumGamemode.getById(forcedGameMode));
if (forcedGameMode != null && forcedGameMode != gameMode) {
gameMode = forcedGameMode;
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.UPDATE_LATENCY || action == EnumPlayerInfoAction.ADD_PLAYER) {
if (getForcedLatency() != null) {
PlayerInfoData_Latency.set(nmsData, getForcedLatency());
latency = getForcedLatency();
rewriteEntry = rewritePacket = true;
}
}
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
TAB.getInstance().getFeatureManager().onEntryAdd(player, id, profile.getName());
}
updatedList.add(rewriteEntry ? newPlayerInfoData(
(PacketPlayOutPlayerInfo) packet,
profile,
latency,
EnumGamemode.values()[gameMode],
displayName
) : nmsData);
}
if (rewritePacket) {
PacketPlayOutPlayerInfo newPacket = new PacketPlayOutPlayerInfo(action, Collections.emptyList());
PLAYERS.set(newPacket, updatedList);
return newPacket;
}
return packet;
}
@SneakyThrows
private void sendPacket(@NonNull EnumPlayerInfoAction action, @NonNull UUID id, @NonNull String name,
@Nullable Skin skin, int latency, int gameMode, @Nullable TabComponent displayName) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(action);
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData.newInstance(
PLAYERS.set(packet, Collections.singletonList(newPlayerInfoData(
packet,
createProfile(id, name, skin),
latency,
WorldSettings.EnumGamemode.values()[gameMode],
EnumGamemode.values()[gameMode],
displayName == null ? null : displayName.convert())
));
sendPacket(packet);
}
@NotNull
@SneakyThrows
private Object newPlayerInfoData(@NonNull PacketPlayOutPlayerInfo packet, @NonNull GameProfile profile,
int latency, @NonNull EnumGamemode gameMode, @Nullable IChatBaseComponent displayName) {
return newPlayerInfoData.newInstance(packet, profile, latency, gameMode, displayName);
}
/**
* Creates GameProfile from given parameters.
*
@@ -147,7 +147,8 @@ public class BungeeScoreboard extends SafeScoreboard<BungeeTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ScoreboardDisplay) {
ScoreboardDisplay display = (ScoreboardDisplay) packet;
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getPosition(), display.getName());
@@ -158,10 +159,12 @@ public class BungeeScoreboard extends SafeScoreboard<BungeeTabPlayer> {
}
if (packet instanceof net.md_5.bungee.protocol.packet.Team) {
net.md_5.bungee.protocol.packet.Team team = (net.md_5.bungee.protocol.packet.Team) packet;
if (team.getMode() == TeamAction.UPDATE) return;
List<String> players = team.getPlayers() == null ? Collections.emptyList() : Lists.newArrayList(team.getPlayers());
team.setPlayers(onTeamPacket(team.getMode(), team.getName(), players).toArray(new String[0]));
if (team.getMode() != TeamAction.UPDATE) {
List<String> players = team.getPlayers() == null ? Collections.emptyList() : Lists.newArrayList(team.getPlayers());
team.setPlayers(onTeamPacket(team.getMode(), team.getName(), players).toArray(new String[0]));
}
}
return packet;
}
@NotNull
@@ -109,7 +109,8 @@ public abstract class BungeeTabList extends TrackedTabList<BungeeTabPlayer> {
}
@Override
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof PlayerListItem) {
PlayerListItem listItem = (PlayerListItem) packet;
for (PlayerListItem.Item item : listItem.getItems()) {
@@ -151,6 +152,7 @@ public abstract class BungeeTabList extends TrackedTabList<BungeeTabPlayer> {
}
}
}
return packet;
}
@Override
+4 -3
View File
@@ -12,13 +12,14 @@ repositories {
maven("https://repo.papermc.io/repository/maven-public/") // Adventure
}
val minecraftVersion = "1.21.9"
val minecraftVersion = "1.21.10"
// Fabric API versions for each Minecraft version for easier backporting
// Official website (for updating in the future): https://fabricmc.net/develop/
val fabricApiVersions = mapOf(
"1.21.9" to "0.133.14+1.21.9",
"1.21.8" to "0.133.4+1.21.8",
"1.21.10" to "0.134.1+1.21.10",
"1.21.9" to "0.134.0+1.21.9",
"1.21.8" to "0.134.0+1.21.8",
"1.21.7" to "0.129.0+1.21.7",
"1.21.6" to "0.128.2+1.21.6",
"1.21.5" to "0.128.2+1.21.5",
@@ -127,7 +127,8 @@ public class FabricScoreboard extends SafeScoreboard<FabricTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -136,10 +137,11 @@ public class FabricScoreboard extends SafeScoreboard<FabricTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int method = getMethod(team);
if (method == TeamAction.UPDATE) return;
team.getPlayers();
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
if (method != TeamAction.UPDATE) {
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -110,7 +110,8 @@ public class FabricTabList extends TrackedTabList<FabricTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -148,8 +149,13 @@ public class FabricTabList extends TrackedTabList<FabricTabPlayer> {
nmsData.showHat(), nmsData.listOrder(), nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
entries.set(newPacket, updatedList);
return newPacket;
}
}
return packet;
}
@SneakyThrows
+2 -1
View File
@@ -14,7 +14,8 @@
"fabric-api-base": "*",
"java": ">=17",
"minecraft": [
"1.21.9"
"1.21.9",
"1.21.10"
]
},
"recommends": {
+2 -1
View File
@@ -13,11 +13,12 @@ repositories {
maven("https://repo.papermc.io/repository/maven-public/") // Adventure
}
val minecraftVersion = "1.21.9"
val minecraftVersion = "1.21.10"
// Forge API versions for each Minecraft version for easier backporting
// Official website (for updating in the future): https://files.minecraftforge.net/net/minecraftforge/forge/
val forgeApiVersions = mapOf(
"1.21.10" to "1.21.10-60.0.0",
"1.21.9" to "1.21.9-59.0.0",
"1.21.8" to "1.21.8-58.1.6",
"1.21.7" to "1.21.7-57.0.3",
@@ -127,7 +127,8 @@ public class ForgeScoreboard extends SafeScoreboard<ForgeTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -136,9 +137,11 @@ public class ForgeScoreboard extends SafeScoreboard<ForgeTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int method = getMethod(team);
if (method == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
if (method != TeamAction.UPDATE) {
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
@@ -110,7 +110,8 @@ public class ForgeTabList extends TrackedTabList<ForgeTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundPlayerInfoUpdatePacket info) {
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = info.actions();
List<ClientboundPlayerInfoUpdatePacket.Entry> updatedList = new ArrayList<>();
@@ -148,8 +149,13 @@ public class ForgeTabList extends TrackedTabList<ForgeTabPlayer> {
nmsData.showHat(), nmsData.listOrder(), nmsData.chatSession()
) : nmsData);
}
if (rewritePacket) entries.set(info, updatedList);
if (rewritePacket) {
ClientboundPlayerInfoUpdatePacket newPacket = new ClientboundPlayerInfoUpdatePacket(actions, Collections.emptyList());
entries.set(newPacket, updatedList);
return newPacket;
}
}
return packet;
}
@SneakyThrows
+1 -1
View File
@@ -22,6 +22,6 @@ side = "SERVER"
[[dependencies.tab]]
modId = "minecraft"
mandatory = true
versionRange = "[1.21.9]"
versionRange = "[1.21.9],[1.21.10]"
ordering = "NONE"
side = "SERVER"
+3 -2
View File
@@ -13,12 +13,13 @@ repositories {
maven("https://repo.papermc.io/repository/maven-public/") // Adventure
}
val minecraftVersion = "1.21.9"
val minecraftVersion = "1.21.10"
// NeoForge API versions for each Minecraft version for easier backporting
// Official website (for updating in the future): https://projects.neoforged.net/neoforged/neoforge
val neoforgeApiVersions = mapOf(
"1.21.9" to "21.9.2-beta",
"1.21.10" to "21.10.0-beta",
"1.21.9" to "21.9.16-beta",
"1.21.8" to "21.8.47",
"1.21.7" to "21.7.25-beta",
"1.21.6" to "21.6.20-beta",
@@ -127,7 +127,8 @@ public class NeoForgeScoreboard extends SafeScoreboard<NeoForgeTabPlayer> {
@Override
@SneakyThrows
public void onPacketSend(@NonNull Object packet) {
@NotNull
public Object onPacketSend(@NonNull Object packet) {
if (packet instanceof ClientboundSetDisplayObjectivePacket display) {
TAB.getInstance().getFeatureManager().onDisplayObjective(player, display.getSlot().ordinal(), display.getObjectiveName());
}
@@ -136,9 +137,11 @@ public class NeoForgeScoreboard extends SafeScoreboard<NeoForgeTabPlayer> {
}
if (packet instanceof ClientboundSetPlayerTeamPacket team) {
int method = getMethod(team);
if (method == TeamAction.UPDATE) return;
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
if (method != TeamAction.UPDATE) {
players.set(team, onTeamPacket(method, team.getName(), team.getPlayers()));
}
}
return packet;
}
private int getMethod(@NonNull ClientboundSetPlayerTeamPacket team) {
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more