Requesting PR for 1.19.1 (and 1.19.2) #44
No files matched your search
+5
-3
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'me.creepermaxcz.mc-bots'
|
||||
version '1.2.4'
|
||||
version '1.2.5'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
@@ -11,11 +11,13 @@ targetCompatibility = 1.8
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://repo.opencollab.dev/maven-releases' }
|
||||
maven { url 'https://repo.opencollab.dev/maven-snapshots/' }
|
||||
maven { url 'https://repo.opencollab.dev/maven-releases/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.GeyserMC:MCProtocolLib:1.19-1'
|
||||
implementation 'com.github.steveice10:mcprotocollib:1.19.1-SNAPSHOT'
|
||||
//implementation 'com.github.steveice10:mcprotocollib:1.19-1'
|
||||
implementation 'commons-cli:commons-cli:1.5.0'
|
||||
implementation 'com.diogonunes:JColor:5.2.0'
|
||||
implementation 'dnsjava:dnsjava:3.4.3'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.creepermaxcz.mcbots;
|
||||
|
||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||
import com.github.steveice10.mc.protocol.data.game.LastSeenMessage;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
||||
@@ -16,6 +17,7 @@ import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -108,13 +110,14 @@ public class Bot extends Thread {
|
||||
|
||||
//send command
|
||||
if (text.startsWith("/")) {
|
||||
|
||||
client.send(new ServerboundChatCommandPacket(
|
||||
text.substring(1), //remove slash on start
|
||||
text.substring(1),
|
||||
timeStamp,
|
||||
0,
|
||||
new HashMap<>(),
|
||||
true
|
||||
new ArrayList<>(),
|
||||
true,
|
||||
new ArrayList<>(),
|
||||
new LastSeenMessage(null, null)
|
||||
));
|
||||
} else {
|
||||
//send chat message
|
||||
@@ -123,7 +126,13 @@ public class Bot extends Thread {
|
||||
// tmpSignature will provide an empty byte array that can pretend it as signature.
|
||||
byte[] tmpSignature = new byte[0]; // Set it empty byte array.
|
||||
// salt is set 0 since this is offline server and no body will check it.
|
||||
client.send(new ServerboundChatPacket(text, timeStamp, 0, tmpSignature, true));
|
||||
client.send(new ServerboundChatPacket(text,
|
||||
timeStamp,
|
||||
0,
|
||||
new byte[0],
|
||||
true,
|
||||
new ArrayList<>(),
|
||||
new LastSeenMessage(null, null)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ public class MainListener implements SessionListener {
|
||||
// From 1.19.1 (as well as 1.19), the class ClientboundChatPacket was removed.
|
||||
// Instead, they use ClientboundPlayerChatPacket and ClientboundSystemChatPacket for taking care of chat packets.
|
||||
Component message = null;
|
||||
if(packet instanceof ClientboundPlayerChatPacket) {
|
||||
// Since we are working on offline server, salt will be 0.
|
||||
message = ((ClientboundPlayerChatPacket) packet).getSignedContent(); // getSignedContent
|
||||
|
||||
if (packet instanceof ClientboundPlayerChatPacket) {
|
||||
message = ((ClientboundPlayerChatPacket) packet).getMessageDecorated();
|
||||
} else if (packet instanceof ClientboundSystemChatPacket) {
|
||||
message = ((ClientboundSystemChatPacket) packet).getContent();
|
||||
}
|
||||
|
||||
//Log.chat(message.toString());
|
||||
if (message instanceof TextComponent) {
|
||||
TextComponent msg = (TextComponent) message;
|
||||
|
||||
Reference in new issue
Block a user