mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-09 15:29:20 -04:00
locales, packet client settings and client support for plugin messages
This commit is contained in:
parent
9b360bc500
commit
1702c8ac14
26
src/main/java/de/bixilon/minosoft/game/datatypes/Locale.java
Normal file
26
src/main/java/de/bixilon/minosoft/game/datatypes/Locale.java
Normal file
@ -0,0 +1,26 @@
|
||||
package de.bixilon.minosoft.game.datatypes;
|
||||
|
||||
public enum Locale {
|
||||
EN_US("en_US"),
|
||||
EN_GB("en_gb"),
|
||||
DE_DE("de_DE");
|
||||
|
||||
String name;
|
||||
|
||||
Locale(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Locale byId(String name) {
|
||||
for (Locale g : values()) {
|
||||
if (g.getName().equals(name)) {
|
||||
return g;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.Difficulty;
|
||||
import de.bixilon.minosoft.game.datatypes.Locale;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketClientSettings implements ServerboundPacket {
|
||||
|
||||
public final Locale locale;
|
||||
public final byte renderDistance;
|
||||
|
||||
public PacketClientSettings(Locale locale, int renderDistance) {
|
||||
this.locale = locale;
|
||||
this.renderDistance = (byte) renderDistance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OutPacketBuffer write(ProtocolVersion v) {
|
||||
log();
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_CLIENT_SETTINGS));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeString(locale.getName()); // locale
|
||||
buffer.writeByte(renderDistance); // render Distance
|
||||
buffer.writeByte((byte) 0x00); // chat settings (nobody uses them)
|
||||
buffer.writeBoolean(true); // chat colors
|
||||
buffer.writeByte((byte) Difficulty.NORMAL.getId()); // difficulty
|
||||
buffer.writeBoolean(true); // cape
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Sending settings (%s, render distance: %s)", locale.getName(), renderDistance));
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package de.bixilon.minosoft.protocol.packets.serverbound.play;
|
||||
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketPluginMessageSended implements ServerboundPacket {
|
||||
|
||||
public final String channel;
|
||||
public final byte[] data;
|
||||
|
||||
public PacketPluginMessageSended(String channel, byte[] data) {
|
||||
this.channel = channel;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public OutPacketBuffer write(ProtocolVersion v) {
|
||||
log();
|
||||
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_PLUGIN_MESSAGE));
|
||||
switch (v) {
|
||||
case VERSION_1_7_10:
|
||||
buffer.writeString(channel); // name
|
||||
buffer.writeShort((short) data.length); // length
|
||||
buffer.writeBytes(data); // data
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Sending data in plugin channel %s with a length of %s bytes", channel, data.length));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user