mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2026-02-11 03:16:14 +01:00
Changed config format. Added serializers. Removed static fields from registry classes
This commit is contained in:
@@ -2,36 +2,22 @@ package ru.nanit.limbo.protocol.packets.play;
|
||||
|
||||
import ru.nanit.limbo.protocol.ByteMessage;
|
||||
import ru.nanit.limbo.protocol.PacketOut;
|
||||
import ru.nanit.limbo.server.data.BossBar;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketBossBar implements PacketOut {
|
||||
|
||||
private UUID uuid;
|
||||
private String title;
|
||||
private float health;
|
||||
private Color color;
|
||||
private Division division;
|
||||
private BossBar bossBar;
|
||||
private int flags;
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setDivision(Division division) {
|
||||
this.division = division;
|
||||
public void setBossBar(BossBar bossBar) {
|
||||
this.bossBar = bossBar;
|
||||
}
|
||||
|
||||
public void setFlags(int flags) {
|
||||
@@ -42,43 +28,11 @@ public class PacketBossBar implements PacketOut {
|
||||
public void encode(ByteMessage msg) {
|
||||
msg.writeUuid(uuid);
|
||||
msg.writeVarInt(0); // Create bossbar
|
||||
msg.writeString(title);
|
||||
msg.writeFloat(health);
|
||||
msg.writeVarInt(color.index);
|
||||
msg.writeVarInt(division.index);
|
||||
msg.writeString(bossBar.getText());
|
||||
msg.writeFloat(bossBar.getHealth());
|
||||
msg.writeVarInt(bossBar.getColor().getIndex());
|
||||
msg.writeVarInt(bossBar.getDivision().getIndex());
|
||||
msg.writeByte(flags);
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
||||
PINK(0),
|
||||
BLUE(1),
|
||||
RED(2),
|
||||
GREEN(3),
|
||||
YELLOW(4),
|
||||
PURPLE(5),
|
||||
WHITE(6);
|
||||
|
||||
private final int index;
|
||||
|
||||
Color(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Division {
|
||||
|
||||
SOLID(0),
|
||||
DASHES_6(1),
|
||||
DASHES_10(2),
|
||||
DASHES_12(3),
|
||||
DASHES_20(4);
|
||||
|
||||
private final int index;
|
||||
|
||||
Division(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
package ru.nanit.limbo.protocol.packets.status;
|
||||
|
||||
import ru.nanit.limbo.LimboConfig;
|
||||
import ru.nanit.limbo.protocol.*;
|
||||
import ru.nanit.limbo.protocol.registry.Version;
|
||||
import ru.nanit.limbo.server.LimboServer;
|
||||
|
||||
public class PacketStatusResponse implements PacketOut {
|
||||
|
||||
private static final String TEMPLATE = "{ \"version\": { \"name\": \"%s\", \"protocol\": %d }, \"players\": { \"max\": %d, \"online\": %d, \"sample\": [] }, \"description\": %s }";
|
||||
|
||||
private int online;
|
||||
private LimboServer server;
|
||||
|
||||
public PacketStatusResponse(){ }
|
||||
|
||||
public PacketStatusResponse(int online){
|
||||
this.online = online;
|
||||
public PacketStatusResponse(LimboServer server){
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteMessage msg) {
|
||||
String ver = LimboConfig.getPingData().getVersion();
|
||||
String desc = LimboConfig.getPingData().getDescription();
|
||||
String ver = server.getConfig().getPingData().getVersion();
|
||||
String desc = server.getConfig().getPingData().getDescription();
|
||||
String json = getResponseJson(ver, Version.getCurrentSupported().getProtocolNumber(),
|
||||
LimboConfig.getMaxPlayers(), online, desc);
|
||||
server.getConfig().getMaxPlayers(), server.getConnections().getCount(), desc);
|
||||
|
||||
msg.writeString(json);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user