Fix tellRaw for 1.16.4/1.16.5

This commit is contained in:
Norbi Peti 2021-01-18 17:18:35 +01:00
parent 9a10dcd1fc
commit 724858ac70
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 17 additions and 4 deletions

View file

@ -161,8 +161,7 @@
<!-- <dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<version>1.16.4-R0.1-SNAPSHOT</version>
</dependency> -->
<dependency>
<groupId>com.github.webbukkit</groupId>

View file

@ -7,6 +7,8 @@ import lombok.val;
import org.bukkit.entity.Player;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.UUID;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
@ -84,7 +86,16 @@ public class VanillaUtils {
val chatcompcl = Class.forName(nms + ".IChatBaseComponent");
//val chatcomarrcl = Class.forName("[L" + chatcompcl.getName() + ";");
val chatcomparr = Array.newInstance(chatcompcl, 1);
val sendmsg = handle.getClass().getMethod("sendMessage", chatcomparr.getClass());
final Method sendmsg;
{
Method sendmsg1;
try {
sendmsg1 = handle.getClass().getMethod("sendMessage", UUID.class, chatcomparr.getClass());
} catch (NoSuchMethodException e) {
sendmsg1 = handle.getClass().getMethod("sendMessage", chatcomparr.getClass());
}
sendmsg = sendmsg1;
}
/*val ccucl = Class.forName(nms + ".ChatComponentUtils");
val iclcl = Class.forName(nms + ".ICommandListener");
@ -101,7 +112,10 @@ public class VanillaUtils {
val deserialized = am.invoke(null, jsonStr);
//val filtered = ffdm.invoke(null, hhandle, deserialized, hhandle);
Array.set(chatcomparr, 0, deserialized);
sendmsg.invoke(hhandle, chatcomparr);
if (sendmsg.getParameterCount() == 2)
sendmsg.invoke(hhandle, null, chatcomparr); //
else
sendmsg.invoke(hhandle, chatcomparr);
return true;
} catch (Exception e) {
e.printStackTrace();