1 /*
2  * This file was automatically generated by sel-utils and
3  * released under the MIT License.
4  * 
5  * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE
6  * Repository: https://github.com/sel-project/sel-utils
7  * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/hncom1.xml
8  */
9 /**
10  * Node-related packets and updates.
11  */
12 module sul.protocol.hncom1.status;
13 
14 import std.bitmanip : write, peek;
15 static import std.conv;
16 import std.system : Endian;
17 import std.typetuple : TypeTuple;
18 import std.typecons : Tuple;
19 import std.uuid : UUID;
20 
21 import sul.utils.buffer;
22 import sul.utils.var;
23 
24 static import sul.protocol.hncom1.types;
25 
26 static if(__traits(compiles, { import sul.metadata.hncom1; })) import sul.metadata.hncom1;
27 
28 alias Packets = TypeTuple!(AddNode, RemoveNode, MessageServerbound, MessageClientbound, Players, ResourcesUsage, Log, RemoteCommand, UpdateList, Reload);
29 
30 /**
31  * Notifies the node that another node (that is not itself) has connected to the hub.
32  */
33 class AddNode : Buffer {
34 
35 	public enum ubyte ID = 5;
36 
37 	public enum bool CLIENTBOUND = true;
38 	public enum bool SERVERBOUND = false;
39 
40 	public enum string[] FIELDS = ["hubId", "name", "main", "acceptedGames"];
41 
42 	/**
43 	 * Identifier given by the hub to uniquey identify the node.
44 	 */
45 	public uint hubId;
46 
47 	/**
48 	 * Node's name used for displaying and identification purposes.
49 	 */
50 	public string name;
51 
52 	/**
53 	 * Whether the node is a main node (see ConnectionRequest.main).
54 	 */
55 	public bool main;
56 
57 	/**
58 	 * Indicates the game accepted by the node.
59 	 */
60 	public sul.protocol.hncom1.types.Game[] acceptedGames;
61 
62 	public pure nothrow @safe @nogc this() {}
63 
64 	public pure nothrow @safe @nogc this(uint hubId, string name=string.init, bool main=bool.init, sul.protocol.hncom1.types.Game[] acceptedGames=(sul.protocol.hncom1.types.Game[]).init) {
65 		this.hubId = hubId;
66 		this.name = name;
67 		this.main = main;
68 		this.acceptedGames = acceptedGames;
69 	}
70 
71 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
72 		_buffer.length = 0;
73 		static if(writeId){ writeBigEndianUbyte(ID); }
74 		writeBytes(varuint.encode(hubId));
75 		writeBytes(varuint.encode(cast(uint)name.length)); writeString(name);
76 		writeBigEndianBool(main);
77 		writeBytes(varuint.encode(cast(uint)acceptedGames.length)); foreach(ynzbzry1;acceptedGames){ ynzbzry1.encode(bufferInstance); }
78 		return _buffer;
79 	}
80 
81 	public pure nothrow @safe void decode(bool readId=true)() {
82 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
83 		hubId=varuint.decode(_buffer, &_index);
84 		uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz);
85 		main=readBigEndianBool();
86 		acceptedGames.length=varuint.decode(_buffer, &_index); foreach(ref ynzbzry1;acceptedGames){ ynzbzry1.decode(bufferInstance); }
87 	}
88 
89 	public static pure nothrow @safe AddNode fromBuffer(bool readId=true)(ubyte[] buffer) {
90 		AddNode ret = new AddNode();
91 		ret._buffer = buffer;
92 		ret.decode!readId();
93 		return ret;
94 	}
95 
96 	public override string toString() {
97 		return "AddNode(hubId: " ~ std.conv.to!string(this.hubId) ~ ", name: " ~ std.conv.to!string(this.name) ~ ", main: " ~ std.conv.to!string(this.main) ~ ", acceptedGames: " ~ std.conv.to!string(this.acceptedGames) ~ ")";
98 	}
99 
100 }
101 
102 /**
103  * Notifies the node that another node, previously added with AddNode has disconnected
104  * from the hub.
105  */
106 class RemoveNode : Buffer {
107 
108 	public enum ubyte ID = 6;
109 
110 	public enum bool CLIENTBOUND = true;
111 	public enum bool SERVERBOUND = false;
112 
113 	public enum string[] FIELDS = ["hubId"];
114 
115 	/**
116 	 * Node's id given by the hub.
117 	 */
118 	public uint hubId;
119 
120 	public pure nothrow @safe @nogc this() {}
121 
122 	public pure nothrow @safe @nogc this(uint hubId) {
123 		this.hubId = hubId;
124 	}
125 
126 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
127 		_buffer.length = 0;
128 		static if(writeId){ writeBigEndianUbyte(ID); }
129 		writeBytes(varuint.encode(hubId));
130 		return _buffer;
131 	}
132 
133 	public pure nothrow @safe void decode(bool readId=true)() {
134 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
135 		hubId=varuint.decode(_buffer, &_index);
136 	}
137 
138 	public static pure nothrow @safe RemoveNode fromBuffer(bool readId=true)(ubyte[] buffer) {
139 		RemoveNode ret = new RemoveNode();
140 		ret._buffer = buffer;
141 		ret.decode!readId();
142 		return ret;
143 	}
144 
145 	public override string toString() {
146 		return "RemoveNode(hubId: " ~ std.conv.to!string(this.hubId) ~ ")";
147 	}
148 
149 }
150 
151 /**
152  * Sends a binary message to some selected nodes or broadcast it.
153  */
154 class MessageServerbound : Buffer {
155 
156 	public enum ubyte ID = 7;
157 
158 	public enum bool CLIENTBOUND = false;
159 	public enum bool SERVERBOUND = true;
160 
161 	public enum string[] FIELDS = ["addressees", "payload"];
162 
163 	/**
164 	 * Addressees of the message. If the array is empty the message is broadcasted to every
165 	 * connected node.
166 	 */
167 	public uint[] addressees;
168 
169 	/**
170 	 * Bytes to be sent/broadcasted. It may be a serialised packet of a plugin-defined
171 	 * protocol.
172 	 */
173 	public ubyte[] payload;
174 
175 	public pure nothrow @safe @nogc this() {}
176 
177 	public pure nothrow @safe @nogc this(uint[] addressees, ubyte[] payload=(ubyte[]).init) {
178 		this.addressees = addressees;
179 		this.payload = payload;
180 	}
181 
182 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
183 		_buffer.length = 0;
184 		static if(writeId){ writeBigEndianUbyte(ID); }
185 		writeBytes(varuint.encode(cast(uint)addressees.length)); foreach(yrcvcvc;addressees){ writeBytes(varuint.encode(yrcvcvc)); }
186 		writeBytes(varuint.encode(cast(uint)payload.length)); writeBytes(payload);
187 		return _buffer;
188 	}
189 
190 	public pure nothrow @safe void decode(bool readId=true)() {
191 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
192 		addressees.length=varuint.decode(_buffer, &_index); foreach(ref yrcvcvc;addressees){ yrcvcvc=varuint.decode(_buffer, &_index); }
193 		payload.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+payload.length){ payload=_buffer[_index.._index+payload.length].dup; _index+=payload.length; }
194 	}
195 
196 	public static pure nothrow @safe MessageServerbound fromBuffer(bool readId=true)(ubyte[] buffer) {
197 		MessageServerbound ret = new MessageServerbound();
198 		ret._buffer = buffer;
199 		ret.decode!readId();
200 		return ret;
201 	}
202 
203 	public override string toString() {
204 		return "MessageServerbound(addressees: " ~ std.conv.to!string(this.addressees) ~ ", payload: " ~ std.conv.to!string(this.payload) ~ ")";
205 	}
206 
207 }
208 
209 /**
210  * Receives a binary message sent by another node using MessageServerbound.
211  */
212 class MessageClientbound : Buffer {
213 
214 	public enum ubyte ID = 8;
215 
216 	public enum bool CLIENTBOUND = true;
217 	public enum bool SERVERBOUND = false;
218 
219 	public enum string[] FIELDS = ["sender", "payload"];
220 
221 	/**
222 	 * Id of the node that has sent the message.
223 	 */
224 	public uint sender;
225 
226 	/**
227 	 * Bytes received. It could be a serialised packet of a plugin-defined packet.
228 	 */
229 	public ubyte[] payload;
230 
231 	public pure nothrow @safe @nogc this() {}
232 
233 	public pure nothrow @safe @nogc this(uint sender, ubyte[] payload=(ubyte[]).init) {
234 		this.sender = sender;
235 		this.payload = payload;
236 	}
237 
238 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
239 		_buffer.length = 0;
240 		static if(writeId){ writeBigEndianUbyte(ID); }
241 		writeBytes(varuint.encode(sender));
242 		writeBytes(varuint.encode(cast(uint)payload.length)); writeBytes(payload);
243 		return _buffer;
244 	}
245 
246 	public pure nothrow @safe void decode(bool readId=true)() {
247 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
248 		sender=varuint.decode(_buffer, &_index);
249 		payload.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+payload.length){ payload=_buffer[_index.._index+payload.length].dup; _index+=payload.length; }
250 	}
251 
252 	public static pure nothrow @safe MessageClientbound fromBuffer(bool readId=true)(ubyte[] buffer) {
253 		MessageClientbound ret = new MessageClientbound();
254 		ret._buffer = buffer;
255 		ret.decode!readId();
256 		return ret;
257 	}
258 
259 	public override string toString() {
260 		return "MessageClientbound(sender: " ~ std.conv.to!string(this.sender) ~ ", payload: " ~ std.conv.to!string(this.payload) ~ ")";
261 	}
262 
263 }
264 
265 /**
266  * Updates the number of players on the server.
267  */
268 class Players : Buffer {
269 
270 	public enum ubyte ID = 9;
271 
272 	public enum bool CLIENTBOUND = true;
273 	public enum bool SERVERBOUND = false;
274 
275 	// max
276 	public enum int UNLIMITED = -1;
277 
278 	public enum string[] FIELDS = ["online", "max"];
279 
280 	/**
281 	 * Players currently online in the whole server (connected to a node).
282 	 */
283 	public uint online;
284 
285 	/**
286 	 * Maximum number of players that can connect to server.
287 	 */
288 	public int max;
289 
290 	public pure nothrow @safe @nogc this() {}
291 
292 	public pure nothrow @safe @nogc this(uint online, int max=int.init) {
293 		this.online = online;
294 		this.max = max;
295 	}
296 
297 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
298 		_buffer.length = 0;
299 		static if(writeId){ writeBigEndianUbyte(ID); }
300 		writeBytes(varuint.encode(online));
301 		writeBytes(varint.encode(max));
302 		return _buffer;
303 	}
304 
305 	public pure nothrow @safe void decode(bool readId=true)() {
306 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
307 		online=varuint.decode(_buffer, &_index);
308 		max=varint.decode(_buffer, &_index);
309 	}
310 
311 	public static pure nothrow @safe Players fromBuffer(bool readId=true)(ubyte[] buffer) {
312 		Players ret = new Players();
313 		ret._buffer = buffer;
314 		ret.decode!readId();
315 		return ret;
316 	}
317 
318 	public override string toString() {
319 		return "Players(online: " ~ std.conv.to!string(this.online) ~ ", max: " ~ std.conv.to!string(this.max) ~ ")";
320 	}
321 
322 }
323 
324 /**
325  * Updates the usage of the system's resources of the node.
326  */
327 class ResourcesUsage : Buffer {
328 
329 	public enum ubyte ID = 10;
330 
331 	public enum bool CLIENTBOUND = false;
332 	public enum bool SERVERBOUND = true;
333 
334 	public enum string[] FIELDS = ["tps", "ram", "cpu"];
335 
336 	/**
337 	 * Ticks per second of the node, in a range from 0 to 20, where a number lower than
338 	 * 20 indicates lag.
339 	 */
340 	public float tps;
341 
342 	/**
343 	 * Bytes of RAM used by the node.
344 	 */
345 	public ulong ram;
346 
347 	/**
348 	 * Percentage of CPU used by the node. It may be higher than 100 if the node has more
349 	 * than 1 CPU.
350 	 */
351 	public float cpu;
352 
353 	public pure nothrow @safe @nogc this() {}
354 
355 	public pure nothrow @safe @nogc this(float tps, ulong ram=ulong.init, float cpu=float.init) {
356 		this.tps = tps;
357 		this.ram = ram;
358 		this.cpu = cpu;
359 	}
360 
361 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
362 		_buffer.length = 0;
363 		static if(writeId){ writeBigEndianUbyte(ID); }
364 		writeBigEndianFloat(tps);
365 		writeBytes(varulong.encode(ram));
366 		writeBigEndianFloat(cpu);
367 		return _buffer;
368 	}
369 
370 	public pure nothrow @safe void decode(bool readId=true)() {
371 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
372 		tps=readBigEndianFloat();
373 		ram=varulong.decode(_buffer, &_index);
374 		cpu=readBigEndianFloat();
375 	}
376 
377 	public static pure nothrow @safe ResourcesUsage fromBuffer(bool readId=true)(ubyte[] buffer) {
378 		ResourcesUsage ret = new ResourcesUsage();
379 		ret._buffer = buffer;
380 		ret.decode!readId();
381 		return ret;
382 	}
383 
384 	public override string toString() {
385 		return "ResourcesUsage(tps: " ~ std.conv.to!string(this.tps) ~ ", ram: " ~ std.conv.to!string(this.ram) ~ ", cpu: " ~ std.conv.to!string(this.cpu) ~ ")";
386 	}
387 
388 }
389 
390 /**
391  * Sends a log to the hub.
392  */
393 class Log : Buffer {
394 
395 	public enum ubyte ID = 11;
396 
397 	public enum bool CLIENTBOUND = false;
398 	public enum bool SERVERBOUND = true;
399 
400 	public enum string[] FIELDS = ["timestamp", "logger", "message", "commandId"];
401 
402 	/**
403 	 * Unix time (in milliseconds) that indicates the exact creation time of the log (for
404 	 * ordering purposes).
405 	 */
406 	public ulong timestamp;
407 
408 	/**
409 	 * Name of the logger (world, plugin or module/packet) thas has generated the log.
410 	 */
411 	public string logger;
412 
413 	/**
414 	 * Logged message. It may contain Minecraft formatting codes.
415 	 */
416 	public string message;
417 
418 	/**
419 	 * Identifier of the command that has generated the output or -1 if the log wasn't
420 	 * generated by a command.
421 	 */
422 	public int commandId;
423 
424 	public pure nothrow @safe @nogc this() {}
425 
426 	public pure nothrow @safe @nogc this(ulong timestamp, string logger=string.init, string message=string.init, int commandId=int.init) {
427 		this.timestamp = timestamp;
428 		this.logger = logger;
429 		this.message = message;
430 		this.commandId = commandId;
431 	}
432 
433 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
434 		_buffer.length = 0;
435 		static if(writeId){ writeBigEndianUbyte(ID); }
436 		writeBytes(varulong.encode(timestamp));
437 		writeBytes(varuint.encode(cast(uint)logger.length)); writeString(logger);
438 		writeBytes(varuint.encode(cast(uint)message.length)); writeString(message);
439 		writeBytes(varint.encode(commandId));
440 		return _buffer;
441 	}
442 
443 	public pure nothrow @safe void decode(bool readId=true)() {
444 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
445 		timestamp=varulong.decode(_buffer, &_index);
446 		uint b9zv=varuint.decode(_buffer, &_index); logger=readString(b9zv);
447 		uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz);
448 		commandId=varint.decode(_buffer, &_index);
449 	}
450 
451 	public static pure nothrow @safe Log fromBuffer(bool readId=true)(ubyte[] buffer) {
452 		Log ret = new Log();
453 		ret._buffer = buffer;
454 		ret.decode!readId();
455 		return ret;
456 	}
457 
458 	public override string toString() {
459 		return "Log(timestamp: " ~ std.conv.to!string(this.timestamp) ~ ", logger: " ~ std.conv.to!string(this.logger) ~ ", message: " ~ std.conv.to!string(this.message) ~ ", commandId: " ~ std.conv.to!string(this.commandId) ~ ")";
460 	}
461 
462 }
463 
464 /**
465  * Executes a command on the node.
466  */
467 class RemoteCommand : Buffer {
468 
469 	public enum ubyte ID = 12;
470 
471 	public enum bool CLIENTBOUND = true;
472 	public enum bool SERVERBOUND = false;
473 
474 	// origin
475 	public enum ubyte HUB = 0;
476 	public enum ubyte EXTERNAL_CONSOLE = 1;
477 	public enum ubyte RCON = 2;
478 
479 	public enum string[] FIELDS = ["origin", "sender", "command", "commandId"];
480 
481 	/**
482 	 * Origin of the command. It could be the hub itself or an external source.
483 	 */
484 	public ubyte origin;
485 
486 	/**
487 	 * Address of the sender if the command has been sent from an external source and not
488 	 * the hub.
489 	 */
490 	public sul.protocol.hncom1.types.Address sender;
491 
492 	/**
493 	 * Commands and arguments that should be executed on the node. For example `say hello
494 	 * world` or `transfer steve lobby12`.
495 	 */
496 	public string command;
497 
498 	/**
499 	 * Identifier of the command. It's sent in Log.commandId if the command generates an
500 	 * output.
501 	 */
502 	public int commandId;
503 
504 	public pure nothrow @safe @nogc this() {}
505 
506 	public pure nothrow @safe @nogc this(ubyte origin, sul.protocol.hncom1.types.Address sender=sul.protocol.hncom1.types.Address.init, string command=string.init, int commandId=int.init) {
507 		this.origin = origin;
508 		this.sender = sender;
509 		this.command = command;
510 		this.commandId = commandId;
511 	}
512 
513 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
514 		_buffer.length = 0;
515 		static if(writeId){ writeBigEndianUbyte(ID); }
516 		writeBigEndianUbyte(origin);
517 		if(origin!=0){ sender.encode(bufferInstance); }
518 		writeBytes(varuint.encode(cast(uint)command.length)); writeString(command);
519 		writeBytes(varint.encode(commandId));
520 		return _buffer;
521 	}
522 
523 	public pure nothrow @safe void decode(bool readId=true)() {
524 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
525 		origin=readBigEndianUbyte();
526 		if(origin!=0){ sender.decode(bufferInstance); }
527 		uint y9bfz=varuint.decode(_buffer, &_index); command=readString(y9bfz);
528 		commandId=varint.decode(_buffer, &_index);
529 	}
530 
531 	public static pure nothrow @safe RemoteCommand fromBuffer(bool readId=true)(ubyte[] buffer) {
532 		RemoteCommand ret = new RemoteCommand();
533 		ret._buffer = buffer;
534 		ret.decode!readId();
535 		return ret;
536 	}
537 
538 	public override string toString() {
539 		return "RemoteCommand(origin: " ~ std.conv.to!string(this.origin) ~ ", sender: " ~ std.conv.to!string(this.sender) ~ ", command: " ~ std.conv.to!string(this.command) ~ ", commandId: " ~ std.conv.to!string(this.commandId) ~ ")";
540 	}
541 
542 }
543 
544 /**
545  * Updates a list.
546  */
547 class UpdateList : Buffer {
548 
549 	public enum ubyte ID = 13;
550 
551 	public enum bool CLIENTBOUND = false;
552 	public enum bool SERVERBOUND = true;
553 
554 	// list
555 	public enum ubyte WHITELIST = 0;
556 	public enum ubyte BLACKLIST = 1;
557 
558 	// action
559 	public enum ubyte ADD = 0;
560 	public enum ubyte REMOVE = 1;
561 
562 	public enum string[] FIELDS = ["list", "action", "type"];
563 
564 	/**
565 	 * Type of the list to update.
566 	 */
567 	public ubyte list;
568 
569 	/**
570 	 * Whether to add or removed the player from the list.
571 	 */
572 	public ubyte action;
573 	public ubyte type;
574 
575 	public pure nothrow @safe @nogc this() {}
576 
577 	public pure nothrow @safe @nogc this(ubyte list, ubyte action=ubyte.init, ubyte type=ubyte.init) {
578 		this.list = list;
579 		this.action = action;
580 		this.type = type;
581 	}
582 
583 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
584 		_buffer.length = 0;
585 		static if(writeId){ writeBigEndianUbyte(ID); }
586 		writeBigEndianUbyte(list);
587 		writeBigEndianUbyte(action);
588 		writeBigEndianUbyte(type);
589 		return _buffer;
590 	}
591 
592 	public pure nothrow @safe void decode(bool readId=true)() {
593 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
594 		list=readBigEndianUbyte();
595 		action=readBigEndianUbyte();
596 		type=readBigEndianUbyte();
597 	}
598 
599 	public static pure nothrow @safe UpdateList fromBuffer(bool readId=true)(ubyte[] buffer) {
600 		UpdateList ret = new UpdateList();
601 		ret._buffer = buffer;
602 		ret.decode!readId();
603 		return ret;
604 	}
605 
606 	public override string toString() {
607 		return "UpdateList(list: " ~ std.conv.to!string(this.list) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", type: " ~ std.conv.to!string(this.type) ~ ")";
608 	}
609 
610 	alias _encode = encode;
611 
612 	enum string variantField = "type";
613 
614 	alias Variants = TypeTuple!(ByHubId, ByName, ByUuid);
615 
616 	public class ByHubId {
617 
618 		public enum typeof(type) TYPE = 0;
619 
620 		public enum string[] FIELDS = ["hubId"];
621 
622 		public uint hubId;
623 
624 		public pure nothrow @safe @nogc this() {}
625 
626 		public pure nothrow @safe @nogc this(uint hubId) {
627 			this.hubId = hubId;
628 		}
629 
630 		public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
631 			type = 0;
632 			_encode!writeId();
633 			writeBytes(varuint.encode(hubId));
634 			return _buffer;
635 		}
636 
637 		public pure nothrow @safe void decode() {
638 			hubId=varuint.decode(_buffer, &_index);
639 		}
640 
641 		public override string toString() {
642 			return "UpdateList.ByHubId(hubId: " ~ std.conv.to!string(this.hubId) ~ ")";
643 		}
644 
645 	}
646 
647 	public class ByName {
648 
649 		public enum typeof(type) TYPE = 1;
650 
651 		public enum string[] FIELDS = ["username"];
652 
653 		/**
654 		 * Case-insensitive player's username. Spaces may be replaced by dashes.
655 		 */
656 		public string username;
657 
658 		public pure nothrow @safe @nogc this() {}
659 
660 		public pure nothrow @safe @nogc this(string username) {
661 			this.username = username;
662 		}
663 
664 		public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
665 			type = 1;
666 			_encode!writeId();
667 			writeBytes(varuint.encode(cast(uint)username.length)); writeString(username);
668 			return _buffer;
669 		}
670 
671 		public pure nothrow @safe void decode() {
672 			uint dnc5bu=varuint.decode(_buffer, &_index); username=readString(dnc5bu);
673 		}
674 
675 		public override string toString() {
676 			return "UpdateList.ByName(username: " ~ std.conv.to!string(this.username) ~ ")";
677 		}
678 
679 	}
680 
681 	public class ByUuid {
682 
683 		public enum typeof(type) TYPE = 2;
684 
685 		// game
686 		public enum ubyte POCKET = 1;
687 		public enum ubyte MINECRAFT = 2;
688 		public enum ubyte CONSOLE = 3;
689 
690 		public enum string[] FIELDS = ["game", "uuid"];
691 
692 		public ubyte game;
693 		public UUID uuid;
694 
695 		public pure nothrow @safe @nogc this() {}
696 
697 		public pure nothrow @safe @nogc this(ubyte game, UUID uuid=UUID.init) {
698 			this.game = game;
699 			this.uuid = uuid;
700 		}
701 
702 		public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
703 			type = 2;
704 			_encode!writeId();
705 			writeBigEndianUbyte(game);
706 			writeBytes(uuid.data);
707 			return _buffer;
708 		}
709 
710 		public pure nothrow @safe void decode() {
711 			game=readBigEndianUbyte();
712 			if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); }
713 		}
714 
715 		public override string toString() {
716 			return "UpdateList.ByUuid(game: " ~ std.conv.to!string(this.game) ~ ", uuid: " ~ std.conv.to!string(this.uuid) ~ ")";
717 		}
718 
719 	}
720 
721 }
722 
723 /**
724  * Notifies the node that the hub's reloadeable settings have been reloaded and that
725  * the node should also reload its resources (for example plugin's settings).
726  */
727 class Reload : Buffer {
728 
729 	public enum ubyte ID = 14;
730 
731 	public enum bool CLIENTBOUND = true;
732 	public enum bool SERVERBOUND = false;
733 
734 	public enum string[] FIELDS = [];
735 
736 	public pure nothrow @safe ubyte[] encode(bool writeId=true)() {
737 		_buffer.length = 0;
738 		static if(writeId){ writeBigEndianUbyte(ID); }
739 		return _buffer;
740 	}
741 
742 	public pure nothrow @safe void decode(bool readId=true)() {
743 		static if(readId){ ubyte _id; _id=readBigEndianUbyte(); }
744 	}
745 
746 	public static pure nothrow @safe Reload fromBuffer(bool readId=true)(ubyte[] buffer) {
747 		Reload ret = new Reload();
748 		ret._buffer = buffer;
749 		ret.decode!readId();
750 		return ret;
751 	}
752 
753 	public override string toString() {
754 		return "Reload()";
755 	}
756 
757 }
758