blob: bf5b7cb886923b21827df46160b013c1391b62e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package cuchaz.enigma.network.packet;
import cuchaz.enigma.analysis.EntryReference;
import cuchaz.enigma.gui.GuiController;
import cuchaz.enigma.translation.representation.entry.Entry;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class ChangeDocsS2CPacket implements Packet<GuiController> {
private int syncId;
private Entry<?> entry;
private String newDocs;
ChangeDocsS2CPacket() {
}
public ChangeDocsS2CPacket(int syncId, Entry<?> entry, String newDocs) {
this.syncId = syncId;
this.entry = entry;
this.newDocs = newDocs;
}
@Override
public void read(DataInput input) throws IOException {
this.syncId = input.readUnsignedShort();
this.entry = PacketHelper.readEntry(input);
this.newDocs = PacketHelper.readString(input);
}
@Override
public void write(DataOutput output) throws IOException {
output.writeShort(syncId);
PacketHelper.writeEntry(output, entry);
PacketHelper.writeString(output, newDocs);
}
@Override
public void handle(GuiController controller) {
controller.changeDocs(new EntryReference<>(entry, entry.getName()), newDocs, false);
controller.sendPacket(new ConfirmChangeC2SPacket(syncId));
}
}
|