|
7 | 7 | import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException;
|
8 | 8 | import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
9 | 9 | import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
10 |
| -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRespawnPacket; |
11 | 10 | import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerCombatKillPacket;
|
12 | 11 | import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
13 | 12 | import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
|
24 | 23 |
|
25 | 24 | import java.net.InetSocketAddress;
|
26 | 25 | import java.time.Instant;
|
27 |
| -import java.util.ArrayList; |
28 |
| -import java.util.Timer; |
29 |
| -import java.util.TimerTask; |
| 26 | +import java.util.*; |
30 | 27 | import java.util.regex.Matcher;
|
31 | 28 | import java.util.regex.Pattern;
|
32 | 29 |
|
@@ -126,11 +123,9 @@ public void disconnected(DisconnectedEvent event) {
|
126 | 123 |
|
127 | 124 | // Do not write disconnect reason if disconnected by command
|
128 | 125 | if (!manualDisconnecting) {
|
129 |
| - //Log.info(" -> " + event.getReason()); |
130 |
| - |
131 |
| - //fix broken reason string by finding the content with regex |
| 126 | + // Fix broken reason string by finding the content with regex |
132 | 127 | Pattern pattern = Pattern.compile("content=\"(.*?)\"");
|
133 |
| - Matcher matcher = pattern.matcher(event.getReason()); |
| 128 | + Matcher matcher = pattern.matcher(String.valueOf(event.getReason())); |
134 | 129 |
|
135 | 130 | StringBuilder reason = new StringBuilder();
|
136 | 131 | while (matcher.find()) {
|
@@ -169,24 +164,24 @@ public void sendChat(String text) {
|
169 | 164 | client.send(new ServerboundChatCommandPacket(
|
170 | 165 | text.substring(1),
|
171 | 166 | timeStamp,
|
| 167 | + 0L, |
| 168 | + Collections.emptyList(), |
172 | 169 | 0,
|
173 |
| - new ArrayList<>(), |
174 |
| - true, |
175 |
| - new ArrayList<>(), |
176 |
| - null |
| 170 | + new BitSet() |
177 | 171 | ));
|
178 | 172 | } else {
|
179 | 173 | // Send chat message
|
180 | 174 | // From 1.19.1 or 1.19, the ServerboundChatPacket needs timestamp, salt and signed signature to generate packet.
|
181 | 175 | // tmpSignature will provide an empty byte array that can pretend it as signature.
|
182 | 176 | // salt is set 0 since this is offline server and no body will check it.
|
183 |
| - client.send(new ServerboundChatPacket(text, |
184 |
| - timeStamp, |
| 177 | + |
| 178 | + client.send(new ServerboundChatPacket( |
| 179 | + text, |
| 180 | + Instant.now().toEpochMilli(), |
| 181 | + 0L, |
| 182 | + null, |
185 | 183 | 0,
|
186 |
| - new byte[0], |
187 |
| - true, |
188 |
| - new ArrayList<>(), |
189 |
| - null |
| 184 | + new BitSet() |
190 | 185 | ));
|
191 | 186 | }
|
192 | 187 | }
|
|
0 commit comments