Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ChannelBuffer getData(boolean worldConfiguration, boolean worldStatus) {
- ChannelBuffer buffer = ChannelBuffers.buffer(1024);
- buffer.writeByte(worldConfiguration ? 1 : 0);
- buffer.writeByte(worldStatus ? 1 : 0);
- if (worldConfiguration) {
- populateConfiguration(buffer);
- }
- if (worldStatus) {
- populateStatus(buffer);
- }
- buffer.writeByte((byte) 0);
- buffer.writeShort((short) buffer.capacity());
- return buffer;
- }
- private static void populateConfiguration(ChannelBuffer buffer) {
- WorldData.putSmart(buffer, worldList.length);
- setCountry(buffer);
- WorldData.putSmart(buffer, 0);
- WorldData.putSmart(buffer, (worldList.length + 1));
- WorldData.putSmart(buffer, worldList.length );
- for (final RS2WorldList w : worldList) {
- WorldData.putSmart(buffer, w.getWorldId());
- buffer.writeByte(w.getLocation());
- buffer.writeInt(w.getFlag());
- WorldData.putJagString(buffer, w.getActivity());
- WorldData.putJagString(buffer, w.getIp());
- }
- buffer.writeInt(-626474014);
- }
- /**
- * Adds the world status on the packet.
- * @param buffer The current packet.
- */
- private static void populateStatus(ChannelBuffer buffer) {
- for (RS2WorldList w : worldList) {
- WorldData.putSmart(buffer, w.getWorldId());
- buffer.writeShort(5);// players
- }
- }
- /**
- * The country data being written.
- */
- private static void setCountry(ChannelBuffer buffer) {
- for (final RS2WorldList w : worldList) {
- WorldData.putSmart(buffer, w.getCountry());
- WorldData.putJagString(buffer, w.getRegion());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement