ScriptCraft

ScriptCraft

14.6k Downloads

How can i make ClickEvents/HoverEvents in Scriptcraft?

leumasme opened this issue · 3 comments

commented

I want to send Json messages like i would with /tellraw.

Spigot 1.8.8

commented

Ok, i found out that it is only possible with packets by creating a new PacketPlayOutChat from the Json Data and sending it with player.getHandle().playerConnection.sendPacket(packet)
But i cant create a new Packet from net.minecraft.server.v1_8_R3.PacketPlayOutChat because net,
unlike org(.bukkit....) is not defined. send help pls <3

commented

You can access any Java class by doing either Packages.net.minecraft.server.v1_8_R3.PacketPlayOutChat or Java.type('net.minecraft.server.v1_8_R3.PacketPlayOutChat'). Though if you need a class under net.minecraft.server it's safer to do something like Java.type(server.handle.class.package.name + '.PacketPlayOutChat') so that things don't break when you upgrade from Minecraft 1.8.

But it this case there's no need to craft your own PacketPlayOutChat. Here's one way do it:

var player = self; // or someone else
var rawMessage = ["",{"text":"Hello","italic":true},{"text":", "},{"text":"World","color":"red"}];
var ComponentSerializer = Packages.net.md_5.bungee.chat.ComponentSerializer;
player.spigot().sendMessage(ComponentSerializer.parse(JSON.stringify(rawMessage)));
commented

@walterhiggins Save Me xd (sry for ping <3 )