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'
|
group 'me.creepermaxcz.mc-bots'
|
||||||
version '1.2.4'
|
version '1.2.5'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
@@ -11,11 +11,13 @@ targetCompatibility = 1.8
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'https://jitpack.io' }
|
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 {
|
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 'commons-cli:commons-cli:1.5.0'
|
||||||
implementation 'com.diogonunes:JColor:5.2.0'
|
implementation 'com.diogonunes:JColor:5.2.0'
|
||||||
implementation 'dnsjava:dnsjava:3.4.3'
|
implementation 'dnsjava:dnsjava:3.4.3'
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.creepermaxcz.mcbots;
|
package me.creepermaxcz.mcbots;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
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.ClientboundLoginPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
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.net.InetSocketAddress;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -108,13 +110,14 @@ public class Bot extends Thread {
|
|||||||
|
|
||||||
//send command
|
//send command
|
||||||
if (text.startsWith("/")) {
|
if (text.startsWith("/")) {
|
||||||
|
|
||||||
client.send(new ServerboundChatCommandPacket(
|
client.send(new ServerboundChatCommandPacket(
|
||||||
text.substring(1), //remove slash on start
|
text.substring(1),
|
||||||
timeStamp,
|
timeStamp,
|
||||||
0,
|
0,
|
||||||
new HashMap<>(),
|
new ArrayList<>(),
|
||||||
true
|
true,
|
||||||
|
new ArrayList<>(),
|
||||||
|
new LastSeenMessage(null, null)
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
//send chat message
|
//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.
|
// tmpSignature will provide an empty byte array that can pretend it as signature.
|
||||||
byte[] tmpSignature = new byte[0]; // Set it empty byte array.
|
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.
|
// 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.
|
// 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.
|
// Instead, they use ClientboundPlayerChatPacket and ClientboundSystemChatPacket for taking care of chat packets.
|
||||||
Component message = null;
|
Component message = null;
|
||||||
|
|
||||||
if (packet instanceof ClientboundPlayerChatPacket) {
|
if (packet instanceof ClientboundPlayerChatPacket) {
|
||||||
// Since we are working on offline server, salt will be 0.
|
message = ((ClientboundPlayerChatPacket) packet).getMessageDecorated();
|
||||||
message = ((ClientboundPlayerChatPacket) packet).getSignedContent(); // getSignedContent
|
|
||||||
} else if (packet instanceof ClientboundSystemChatPacket) {
|
} else if (packet instanceof ClientboundSystemChatPacket) {
|
||||||
message = ((ClientboundSystemChatPacket) packet).getContent();
|
message = ((ClientboundSystemChatPacket) packet).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.chat(message.toString());
|
//Log.chat(message.toString());
|
||||||
if (message instanceof TextComponent) {
|
if (message instanceof TextComponent) {
|
||||||
TextComponent msg = (TextComponent) message;
|
TextComponent msg = (TextComponent) message;
|
||||||
|
|||||||
Reference in new issue
Block a user