mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-08 09:27:34 +01:00
allow setting if chat preview is enabled in WrappedServerPing (#1623)
This commit is contained in:
parent
aed98abac6
commit
e202503c09
@ -51,6 +51,7 @@ public class WrappedServerPing extends AbstractWrapper implements ClonableWrappe
|
||||
private static FieldAccessor PLAYERS = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingPlayerSampleClass(), true);
|
||||
private static FieldAccessor VERSION = Accessors.getFieldAccessor(SERVER_PING, MinecraftReflection.getServerPingServerDataClass(), true);
|
||||
private static FieldAccessor FAVICON = Accessors.getFieldAccessor(SERVER_PING, String.class, true);
|
||||
private static FieldAccessor PREVIEWS_CHAT = Accessors.getFieldAccessor(SERVER_PING, boolean.class, true);
|
||||
|
||||
// For converting to the underlying array
|
||||
private static EquivalentConverter<Iterable<? extends WrappedGameProfile>> PROFILE_CONVERT =
|
||||
@ -181,6 +182,24 @@ public class WrappedServerPing extends AbstractWrapper implements ClonableWrappe
|
||||
FAVICON.set(handle, (image != null) ? image.toEncodedText() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve whether chat preview is enabled on the server.
|
||||
* @return whether chat preview is enabled on the server.
|
||||
* @since 1.19
|
||||
*/
|
||||
public boolean isChatPreviewEnabled() {
|
||||
return (Boolean) PREVIEWS_CHAT.get(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether chat preview is enabled on the server.
|
||||
* @param chatPreviewEnabled true if enabled, false otherwise.
|
||||
* @since 1.19
|
||||
*/
|
||||
public void setChatPreviewEnabled(boolean chatPreviewEnabled) {
|
||||
PREVIEWS_CHAT.set(handle, chatPreviewEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the displayed number of online players.
|
||||
* @return The displayed number.
|
||||
|
@ -2,6 +2,7 @@ package com.comphenix.protocol.wrappers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
@ -31,11 +32,13 @@ public class WrappedServerPingTest {
|
||||
serverPing.setVersionName("Minecraft 123");
|
||||
serverPing.setVersionProtocol(4);
|
||||
serverPing.setFavicon(tux);
|
||||
serverPing.setChatPreviewEnabled(true);
|
||||
|
||||
assertEquals(5, serverPing.getPlayersOnline());
|
||||
assertEquals(10, serverPing.getPlayersMaximum());
|
||||
assertEquals("Minecraft 123", serverPing.getVersionName());
|
||||
assertEquals(4, serverPing.getVersionProtocol());
|
||||
assertTrue(serverPing.isChatPreviewEnabled());
|
||||
|
||||
assertArrayEquals(original, serverPing.getFavicon().getData());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user