forked from Nan1t/NanoLimbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Optimize imports and delete command declaration packet"
This reverts commit 6d2ff1a.
- Loading branch information
Showing
8 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/ru/nanit/limbo/protocol/packets/play/PacketDeclareCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ru.nanit.limbo.protocol.packets.play; | ||
|
||
import ru.nanit.limbo.protocol.ByteMessage; | ||
import ru.nanit.limbo.protocol.PacketOut; | ||
import ru.nanit.limbo.protocol.registry.Version; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Packet for 1.13+ | ||
*/ | ||
public class PacketDeclareCommands implements PacketOut { | ||
|
||
private List<String> commands; | ||
|
||
public void setCommands(List<String> commands) { | ||
this.commands = commands; | ||
} | ||
|
||
@Override | ||
public void encode(ByteMessage msg, Version version) { | ||
msg.writeVarInt(commands.size() * 2 + 1); // +1 because declaring root node | ||
|
||
// Declare root node | ||
|
||
msg.writeByte(0); | ||
msg.writeVarInt(commands.size()); | ||
|
||
for (int i = 1; i <= commands.size() * 2; i++) { | ||
msg.writeVarInt(i++); | ||
} | ||
|
||
// Declare other commands | ||
|
||
int i = 1; | ||
for (String cmd : commands) { | ||
msg.writeByte(1 | 0x04); | ||
msg.writeVarInt(1); | ||
msg.writeVarInt(i + 1); | ||
msg.writeString(cmd); | ||
i++; | ||
|
||
msg.writeByte(2 | 0x04 | 0x10); | ||
msg.writeVarInt(1); | ||
msg.writeVarInt(i); | ||
msg.writeString("arg"); | ||
msg.writeString("brigadier:string"); | ||
msg.writeVarInt(0); | ||
msg.writeString("minecraft:ask_server"); | ||
i++; | ||
} | ||
|
||
msg.writeVarInt(0); | ||
} | ||
|
||
} |
3 changes: 1 addition & 2 deletions
3
src/main/java/ru/nanit/limbo/protocol/packets/status/PacketStatusRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/main/java/ru/nanit/limbo/protocol/packets/status/PacketStatusResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters