protocolsupport.protocol.serializer.StringSerializer Java Examples

The following examples show how to use protocolsupport.protocol.serializer.StringSerializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpawnEntityPacket.java    From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void toData(ConnectionImpl connection, ByteBuf serializer) {
	VarNumberSerializer.writeSVarLong(serializer, entityId); // entity ID
	VarNumberSerializer.writeVarLong(serializer, entityId); // runtime ID
	VarNumberSerializer.writeVarInt(serializer, entityType); // boss bar entity id
	serializer.writeFloatLE(x); // x
	serializer.writeFloatLE(y); // y
	serializer.writeFloatLE(z); // z
	serializer.writeFloatLE(motionX); // motx
	serializer.writeFloatLE(motionY); // moty
	serializer.writeFloatLE(motionZ); // motz
	serializer.writeFloatLE(pitch); // pitch
	serializer.writeFloatLE(yaw); // yaw
	// We can't use SetAttributePackets#encodeAttributes because MCPE uses an different format in SpawnEntityPacket (why mojang?)
	VarNumberSerializer.writeVarInt(serializer, attributes.size());
	for (SetAttributesPacket.Attribute attribute : attributes) {
		StringSerializer.writeString(serializer, connection.getVersion(), attribute.getName());
		serializer.writeFloatLE(attribute.getMinimum());
		serializer.writeFloatLE(attribute.getValue());
		serializer.writeFloatLE(attribute.getMaximum());
	}
	//TODO: fix
	VarNumberSerializer.writeVarInt(serializer, 0);
	//EntityMetadata.encodeMeta(serializer, connection.getVersion(), I18NData.DEFAULT_LOCALE, metadata);
	VarNumberSerializer.writeVarInt(serializer, 0); //links, not used
}
 
Example #2
Source File: MiddleTitle.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	action = MiscSerializer.readVarIntEnum(serverdata, Action.CONSTANT_LOOKUP);
	switch (action) {
		case SET_TITLE:
		case SET_SUBTITLE:
		case SET_ACTION_BAR: {
			message = ChatAPI.fromJSON(StringSerializer.readVarIntUTF8String(serverdata), true);
			break;
		}
		case SET_TIMES: {
			fadeIn = serverdata.readInt();
			stay = serverdata.readInt();
			fadeOut = serverdata.readInt();
			break;
		}
		case HIDE:
		case RESET: {
			break;
		}
	}
}
 
Example #3
Source File: MiddleStartGame.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	player = NetworkEntity.createPlayer(serverdata.readInt());
	int gmdata = serverdata.readByte();
	gamemodeCurrent = GameMode.getById(gmdata & 0xFFFFFFF7);
	hardcore = (gmdata & 0x8) == 0x8;
	gamemodePrevious = GameMode.getById(serverdata.readByte());
	worlds = ArraySerializer.readVarIntVarIntUTF8StringArray(serverdata);
	dimensions = ItemStackSerializer.readDirectTag(serverdata);
	dimension = StringSerializer.readVarIntUTF8String(serverdata);
	world = StringSerializer.readVarIntUTF8String(serverdata);
	hashedSeed = serverdata.readLong();
	serverdata.readByte();
	maxplayers = TabAPI.getMaxTabSize();
	renderDistance = VarNumberSerializer.readVarInt(serverdata);
	reducedDebugInfo = serverdata.readBoolean();
	respawnScreenEnabled = serverdata.readBoolean();
	worldDebug = serverdata.readBoolean();
	worldFlat = serverdata.readBoolean();
}
 
Example #4
Source File: LegacyCustomPayloadData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void transformAndWriteAutoCommandBlockEdit(PacketDataCodec codec, ByteBuf data) {
	Position position = PositionSerializer.readLegacyPositionI(data);
	String command = StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE);
	int trackOutput = data.readByte();
	MiddleUpdateCommandBlock.Mode mode = null;
	switch (StringSerializer.readVarIntUTF8String(data, 16)) {
		case "SEQUENCE": {
			mode = MiddleUpdateCommandBlock.Mode.SEQUENCE;
			break;
		}
		case "AUTO": {
			mode = MiddleUpdateCommandBlock.Mode.AUTO;
			break;
		}
		case "REDSTONE": {
			mode = MiddleUpdateCommandBlock.Mode.REDSTONE;
			break;
		}
	}
	int conditional = data.readByte();
	int auto = data.readByte();
	codec.read(MiddleUpdateCommandBlock.create(
		position, command, mode,
		BitUtils.createIBitMaskFromBits(auto_command_block_bits, new int[] {trackOutput, conditional, auto})
	));
}
 
Example #5
Source File: Advancements.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
protected static void writeAdvanvement(ByteBuf to, ProtocolVersion version, String locale, Advancement advancement) {
	if (advancement.parentId != null) {
		to.writeBoolean(true);
		StringSerializer.writeVarIntUTF8String(to, advancement.parentId);
	} else {
		to.writeBoolean(false);
	}
	if (advancement.display != null) {
		to.writeBoolean(true);
		writeAdvancementDisplay(to, version, locale, advancement.display);
	} else {
		to.writeBoolean(false);
	}
	ArraySerializer.writeVarIntVarIntUTF8StringArray(to, advancement.criteria);
	ArraySerializer.writeVarIntTArray(to, advancement.requirements, ArraySerializer::writeVarIntVarIntUTF8StringArray);
}
 
Example #6
Source File: MiddleUpdateStructureBlock.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
public static ServerBoundPacketData create(Position position, Action action, Mode mode, String name,
	byte offsetX, byte offsetY, byte offsetZ, byte sizeX, byte sizeY, byte sizeZ,
	Mirror mirror, Rotation rotation, String metadata, float integrity, long seed, byte flags
) {
	ServerBoundPacketData creator = ServerBoundPacketData.create(PacketType.SERVERBOUND_PLAY_UPDATE_STRUCTURE_BLOCK);
	PositionSerializer.writePosition(creator, position);
	MiscSerializer.writeVarIntEnum(creator, action);
	MiscSerializer.writeVarIntEnum(creator, mode);
	StringSerializer.writeVarIntUTF8String(creator, name);
	creator.writeByte(offsetX);
	creator.writeByte(offsetY);
	creator.writeByte(offsetZ);
	creator.writeByte(sizeX);
	creator.writeByte(sizeY);
	creator.writeByte(sizeZ);
	MiscSerializer.writeVarIntEnum(creator, mirror);
	MiscSerializer.writeVarIntEnum(creator, rotation);
	StringSerializer.writeVarIntUTF8String(creator, metadata);
	creator.writeFloat(integrity);
	VarNumberSerializer.writeVarLong(creator, seed);
	creator.writeByte(flags);
	return creator;
}
 
Example #7
Source File: CombatEvent.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData combatevent = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_COMBAT_EVENT);
	MiscSerializer.writeVarIntEnum(combatevent, type);
	switch (type) {
		case ENTER_COMBAT: {
			break;
		}
		case END_COMBAT: {
			VarNumberSerializer.writeVarInt(combatevent, duration);
			combatevent.writeInt(entityId);
			break;
		}
		case ENTITY_DEAD: {
			VarNumberSerializer.writeVarInt(combatevent, playerId);
			combatevent.writeInt(entityId);
			StringSerializer.writeVarIntUTF8String(combatevent, message);
			break;
		}
	}
}
 
Example #8
Source File: LegacyCustomPayloadData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void transformAndWriteStructureBlock(PacketDataCodec codec, ByteBuf data) {
	Position position = PositionSerializer.readLegacyPositionI(data);
	MiddleUpdateStructureBlock.Action action = MiddleUpdateStructureBlock.Action.CONSTANT_LOOKUP.getByOrdinal(data.readByte() - 1);
	MiddleUpdateStructureBlock.Mode mode = MiddleUpdateStructureBlock.Mode.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	String name = StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE);
	byte offsetX = (byte) data.readInt();
	byte offsetY = (byte) data.readInt();
	byte offsetZ = (byte) data.readInt();
	byte sizeX = (byte) data.readInt();
	byte sizeY = (byte) data.readInt();
	byte sizeZ = (byte) data.readInt();
	MiddleUpdateStructureBlock.Mirror mirror = MiddleUpdateStructureBlock.Mirror.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	MiddleUpdateStructureBlock.Rotation rotation = MiddleUpdateStructureBlock.Rotation.valueOf(StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE));
	String metadata = StringSerializer.readVarIntUTF8String(data, Short.MAX_VALUE);
	int ignoreEntities = data.readBoolean() ? 0x01 : 0;
	int showAir = data.readBoolean() ? 0x02 : 0;
	int showBoundingBox = data.readBoolean() ? 0x04 : 0;
	float integrity = data.readFloat();
	long seed = VarNumberSerializer.readVarLong(data);
	byte flags = (byte) (ignoreEntities | showAir | showBoundingBox);
	codec.read(MiddleUpdateStructureBlock.create(
		position, action, mode, name,
		offsetX, offsetY, offsetZ, sizeX, sizeY, sizeZ,
		mirror, rotation, metadata, integrity, seed, flags
	));
}
 
Example #9
Source File: MiddleRecipeBookData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData recipebookdata = ServerBoundPacketData.create(PacketType.SERVERBOUND_PLAY_RECIPE_BOOK_DATA);
	MiscSerializer.writeVarIntEnum(recipebookdata, type);
	switch (type) {
		case DISPLAYED_RECIPE: {
			StringSerializer.writeVarIntUTF8String(recipebookdata, recipeId);
			break;
		}
		case RECIPE_BOOK_STATUS: {
			recipebookdata.writeBoolean(craftRecipeBookOpen);
			recipebookdata.writeBoolean(craftRecipeBookFiltering);
			recipebookdata.writeBoolean(smeltingRecipeBookOpen);
			recipebookdata.writeBoolean(smeltingRecipeBookFiltering);
			recipebookdata.writeBoolean(blastingRecipeBookOpen);
			recipebookdata.writeBoolean(blastingRecipeBookFiltering);
			recipebookdata.writeBoolean(smokingRecipeBookOpen);
			recipebookdata.writeBoolean(smokingRecipeBookFiltering);
			break;
		}
	}
	codec.read(recipebookdata);
}
 
Example #10
Source File: MiddleBossBar.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	uuid = UUIDSerializer.readUUID2L(serverdata);
	action = MiscSerializer.readVarIntEnum(serverdata, Action.CONSTANT_LOOKUP);
	switch (action) {
		case ADD: {
			title = ChatAPI.fromJSON(StringSerializer.readVarIntUTF8String(serverdata), true);
			percent = serverdata.readFloat();
			color = VarNumberSerializer.readVarInt(serverdata);
			divider = VarNumberSerializer.readVarInt(serverdata);
			flags = serverdata.readUnsignedByte();
			break;
		}
		case REMOVE: {
			break;
		}
		case UPDATE_PERCENT: {
			percent = serverdata.readFloat();
			break;
		}
		case UPDATE_TITLE: {
			title = ChatAPI.fromJSON(StringSerializer.readVarIntUTF8String(serverdata), true);
			break;
		}
		case UPDATE_STYLE: {
			color = VarNumberSerializer.readVarInt(serverdata);
			divider = VarNumberSerializer.readVarInt(serverdata);
			break;
		}
		case UPDATE_FLAGS: {
			flags = serverdata.readUnsignedByte();
			break;
		}
	}
}
 
Example #11
Source File: ClientLogin.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	clientdata.readUnsignedByte();
	username = StringSerializer.readShortUTF16BEString(clientdata, 16);
	hostname = StringSerializer.readShortUTF16BEString(clientdata, Short.MAX_VALUE);
	port = clientdata.readInt();
}
 
Example #12
Source File: UpdateMap.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData updatemap = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_MAP);
	VarNumberSerializer.writeVarInt(updatemap, id);
	updatemap.writeByte(scale);
	updatemap.writeBoolean(showIcons);
	ArraySerializer.writeVarIntTArray(updatemap, icons, (to, icon) -> {
		VarNumberSerializer.writeVarInt(to, icon.type);
		to.writeByte(icon.x);
		to.writeByte(icon.z);
		to.writeByte(icon.direction);
		to.writeBoolean(icon.displayName != null);
		if (icon.displayName != null) {
			StringSerializer.writeVarIntUTF8String(to, icon.displayName);
		}
	});
	updatemap.writeByte(columns);
	if (columns > 0) {
		ArrayBasedIdRemappingTable colorRemapper = MapColorRemapper.REMAPPER.getTable(version);
		for (int i = 0; i < colors.length; i++) {
			colors[i] = (byte) colorRemapper.getRemap(colors[i] & 0xFF);
		}
		updatemap.writeByte(rows);
		updatemap.writeByte(xstart);
		updatemap.writeByte(zstart);
		ArraySerializer.writeVarIntByteArray(updatemap, colors);
	}
	codec.write(updatemap);
}
 
Example #13
Source File: ScoreboardObjective.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData scoreboardobjective = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_OBJECTIVE);
	StringSerializer.writeVarIntUTF8String(scoreboardobjective, name);
	MiscSerializer.writeByteEnum(scoreboardobjective, mode);
	if (mode != Mode.REMOVE) {
		StringSerializer.writeVarIntUTF8String(scoreboardobjective, LegacyChat.clampLegacyText(value.toLegacyText(cache.getClientCache().getLocale()), 32));
		StringSerializer.writeVarIntUTF8String(scoreboardobjective, getTypeString(type));
	}
	codec.write(scoreboardobjective);
}
 
Example #14
Source File: ResourcePack.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData resourcepack = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CUSTOM_PAYLOAD);
	StringSerializer.writeVarIntUTF8String(resourcepack, "MC|RPack");
	ArraySerializer.writeShortByteArray(resourcepack, to -> ByteBufUtil.writeUtf8(to, url));
	codec.write(resourcepack);
}
 
Example #15
Source File: ClientSettingsPacket.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void read0(ByteBuf from) {
	locale = StringSerializer.readShortUTF16BEString(from);
	viewDistance = from.readByte();
	byte chatState = from.readByte();
	chatFlags = (byte) (chatState & 7);
	chatColours = ((chatState & 8) == 8);
	difficulty = from.readByte();
	from.readBoolean();
}
 
Example #16
Source File: ClientLogin.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	String[] data = StringSerializer.readShortUTF16BEString(clientdata, Short.MAX_VALUE).split("[;]");
	String[] addrdata = data[1].split("[:]");
	username = data[0];
	hostname = addrdata[0];
	port = Integer.parseInt(addrdata[1]);
}
 
Example #17
Source File: UpdateSign.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	PositionSerializer.readPositionTo(clientdata, position);
	for (int i = 0; i < lines.length; i++) {
		String rawline = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
		lines[i] = version.isAfter(ProtocolVersion.MINECRAFT_1_8) ? rawline : ChatAPI.fromJSON(rawline).toLegacyText(cache.getClientCache().getLocale());
	}
}
 
Example #18
Source File: AdvancementsTab.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData advanvementstab = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_ADVANCEMENTS_TAB);
	if (identifier != null) {
		advanvementstab.writeBoolean(true);
		StringSerializer.writeVarIntUTF8String(advanvementstab, identifier);
	} else {
		advanvementstab.writeBoolean(false);
	}
	codec.write(advanvementstab);
}
 
Example #19
Source File: Ping.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData setprotocol = ServerBoundPacketData.create(PacketType.SERVERBOUND_HANDSHAKE_START);
	VarNumberSerializer.writeVarInt(setprotocol, ProtocolVersionsHelper.LATEST_PC.getId());
	StringSerializer.writeVarIntUTF8String(setprotocol, hostname);
	setprotocol.writeShort(port);
	VarNumberSerializer.writeVarInt(setprotocol, 1);
	codec.read(setprotocol);

	codec.read(ServerBoundPacketData.create(PacketType.SERVERBOUND_STATUS_REQUEST));
}
 
Example #20
Source File: MiddleScoreboardObjective.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readServerData(ByteBuf serverdata) {
	name = StringSerializer.readVarIntUTF8String(serverdata);
	mode = MiscSerializer.readByteEnum(serverdata, Mode.CONSTANT_LOOKUP);
	if (mode != Mode.REMOVE) {
		value = ChatAPI.fromJSON(StringSerializer.readVarIntUTF8String(serverdata), true);
		type = MiscSerializer.readVarIntEnum(serverdata, Type.CONSTANT_LOOKUP);
	}

	switch (mode) {
		case CREATE: {
			if (!objectives.add(name)) {
				throw CancelMiddlePacketException.INSTANCE;
			}
			break;
		}
		case REMOVE: {
			if (!objectives.remove(name)) {
				throw CancelMiddlePacketException.INSTANCE;
			}
			break;
		}
		default: {
			if (!objectives.contains(name)) {
				throw CancelMiddlePacketException.INSTANCE;
			}
			break;
		}
	}
}
 
Example #21
Source File: SetProtocol.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	VarNumberSerializer.readVarInt(clientdata);
	hostname = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE);
	port = clientdata.readUnsignedShort();
	nextState = VarNumberSerializer.readVarInt(clientdata);
}
 
Example #22
Source File: MiddleClientSettings.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
public static ServerBoundPacketData create(String locale, int viewDist, ChatMode chatMode, boolean chatColors, int skinFlags, MainHand mainHand) {
	ServerBoundPacketData creator = ServerBoundPacketData.create(PacketType.SERVERBOUND_PLAY_SETTINGS);
	StringSerializer.writeVarIntUTF8String(creator, locale);
	creator.writeByte(viewDist);
	MiscSerializer.writeVarIntEnum(creator, chatMode);
	creator.writeBoolean(chatColors);
	creator.writeByte(skinFlags);
	MiscSerializer.writeVarIntEnum(creator, mainHand);
	return creator;
}
 
Example #23
Source File: MiddleCraftRecipeRequest.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData craftreciperequest = ServerBoundPacketData.create(PacketType.SERVERBOUND_PLAY_CRAFT_RECIPE_REQUEST);
	craftreciperequest.writeByte(windowId);
	StringSerializer.writeVarIntUTF8String(craftreciperequest, recipeId);
	craftreciperequest.writeBoolean(all);
	codec.read(craftreciperequest);
}
 
Example #24
Source File: LoginCustomPayload.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData logincustompayload = ClientBoundPacketData.create(PacketType.CLIENTBOUND_LOGIN_CUSTOM_PAYLOAD);
	VarNumberSerializer.writeVarInt(logincustompayload, id);
	StringSerializer.writeVarIntUTF8String(logincustompayload, tag);
	logincustompayload.writeBytes(data);
	codec.write(logincustompayload);
}
 
Example #25
Source File: MiddleJigsawUpdate.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToServer() {
	ServerBoundPacketData jigsawupdate = ServerBoundPacketData.create(PacketType.SERVERBOUND_PLAY_JIGSAW_UPDATE);
	PositionSerializer.writePosition(jigsawupdate, position);
	StringSerializer.writeVarIntUTF8String(jigsawupdate, name);
	StringSerializer.writeVarIntUTF8String(jigsawupdate, target);
	StringSerializer.writeVarIntUTF8String(jigsawupdate, pool);
	StringSerializer.writeVarIntUTF8String(jigsawupdate, finalState);
	StringSerializer.writeVarIntUTF8String(jigsawupdate, jointType);
	codec.read(jigsawupdate);
}
 
Example #26
Source File: StartGamePacket.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void write(ByteBuf data, Login packet) {
	data.writeInt(packet.getEntityId());
	StringSerializer.writeShortUTF16BEString(data, packet.getLevelType());
	data.writeByte(packet.getGameMode());
	data.writeByte(packet.getDimension());
	data.writeByte(packet.getDifficulty());
	data.writeByte(0);
	data.writeByte(packet.getMaxPlayers());
}
 
Example #27
Source File: SmeltingRecipe.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
public SmeltingRecipe(String id, RecipeType type, ByteBuf data) {
	super(id, type);

	group = StringSerializer.readVarIntUTF8String(data);
	ingredient = new RecipeIngredient(data);
	result = ItemStackSerializer.readItemStack(data);
	exp = data.readFloat();
	time = VarNumberSerializer.readVarInt(data);
}
 
Example #28
Source File: EncryptionRequest.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData encryptionrequest = ClientBoundPacketData.create(PacketType.CLIENTBOUND_LOGIN_ENCRYPTION_BEGIN);
	StringSerializer.writeString(encryptionrequest, version, serverId);
	ArraySerializer.writeShortByteArray(encryptionrequest, publicKey);
	ArraySerializer.writeShortByteArray(encryptionrequest, verifyToken);
	codec.write(encryptionrequest);
}
 
Example #29
Source File: ServerInfo.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void writeToClient() {
	ClientBoundPacketData serverinfo = ClientBoundPacketData.create(PacketType.CLIENTBOUND_STATUS_SERVER_INFO);
	String response = new StringJoiner("§")
	.add(ChatColor.stripColor(ping.getMotd().toLegacyText(cache.getClientCache().getLocale())).replace("§", ""))
	.add(String.valueOf(ping.getPlayers().getOnline()))
	.add(String.valueOf(ping.getPlayers().getMax()))
	.toString();
	StringSerializer.writeShortUTF16BEString(serverinfo, response);
	codec.write(serverinfo);
}
 
Example #30
Source File: Advancements.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void wrtieAdvancementProgress(ByteBuf to, AdvancementProgress obj2) {
	ArraySerializer.writeVarIntTArray(to, obj2.criterionsProgress, (lTo, element) -> {
		StringSerializer.writeVarIntUTF8String(lTo, element.getObj1());
		if (element.getObj2() != null) {
			lTo.writeBoolean(true);
			lTo.writeLong(element.getObj2());
		} else {
			lTo.writeBoolean(false);
		}
	});
}