Broadcast server brand

This commit is contained in:
LOOHP 2022-04-22 23:14:56 +01:00
parent d0cc0b05dc
commit 7ad2b19177
5 changed files with 18 additions and 4 deletions

View File

@ -24,7 +24,7 @@
<groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId>
<name>Limbo</name>
<version>0.6.12-ALPHA</version>
<version>0.6.13-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url>

View File

@ -88,6 +88,8 @@ import net.querz.nbt.tag.CompoundTag;
public class Limbo {
public static final String LIMBO_BRAND = "Limbo";
private static Limbo instance;
public static boolean noGui = false;

View File

@ -80,7 +80,7 @@ public class ServerProperties {
private Component tabHeader;
private Component tabFooter;
Optional<BufferedImage> favicon;
private Optional<BufferedImage> favicon;
public ServerProperties(File file) throws IOException {
this.file = file;
@ -189,6 +189,10 @@ public class ServerProperties {
return Limbo.getInstance().serverImplementationVersion;
}
public String getServerModName() {
return Limbo.LIMBO_BRAND;
}
public boolean isBungeecord() {
return bungeecord;
}

View File

@ -60,6 +60,7 @@ import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoAction;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPlayerInfo.PlayerInfoData.PlayerInfoDataAddPlayer.PlayerSkinProperty;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPluginMessaging;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutPositionAndLook;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutSpawnPosition;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutTabComplete;
@ -92,6 +93,7 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -117,6 +119,7 @@ import java.util.stream.Stream;
public class ClientConnection extends Thread {
private static final NamespacedKey DEFAULT_HANDLER_NAMESPACE = new NamespacedKey("default");
private static final NamespacedKey BRAND_ANNOUNCE_CHANNEL = new NamespacedKey("brand");
private final Random random = new Random();
private final Socket clientSocket;
@ -464,6 +467,11 @@ public class ClientConnection extends Thread {
sendPacket(join);
Limbo.getInstance().getUnsafe().setPlayerGameModeSilently(player, properties.getDefaultGamemode());
ByteArrayOutputStream brandOut = new ByteArrayOutputStream();
DataTypeIO.writeString(new DataOutputStream(brandOut), properties.getServerModName(), StandardCharsets.UTF_8);
PacketPlayOutPluginMessaging brand = new PacketPlayOutPluginMessaging(BRAND_ANNOUNCE_CHANNEL, brandOut.toByteArray());
sendPacket(brand);
SkinResponse skinresponce = (isVelocityModern || isBungeeGuard || isBungeecord) && forwardedSkin != null ? forwardedSkin : MojangAPIUtils.getSkinFromMojangServer(player.getName());
PlayerSkinProperty skin = skinresponce != null ? new PlayerSkinProperty(skinresponce.getSkin(), skinresponce.getSignature()) : null;
PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PlayerInfoAction.ADD_PLAYER, player.getUniqueId(), new PlayerInfoData.PlayerInfoDataAddPlayer(player.getName(), Optional.ofNullable(skin), properties.getDefaultGamemode(), 0, false, Optional.empty()));

View File

@ -32,7 +32,7 @@ public class NamespacedKey {
this.namespace = namespacedKey.substring(0, index);
this.key = namespacedKey.substring(index + 1);
} else {
this.namespace = "minecraft";
this.namespace = MINECRAFT_KEY;
this.key = namespacedKey;
}
}