From 2b0f64d86d56b6b3bf1c4a15c6d440f29b79fd4e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 5 Dec 2019 20:01:37 +0100 Subject: [PATCH] untested rework of dependent scoreboard source --- .../steamwar/scoreboard/SWScoreboard_12.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java b/SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java index 494d264..b318d05 100644 --- a/SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java +++ b/SpigotCore_12/src/de/steamwar/scoreboard/SWScoreboard_12.java @@ -1,7 +1,15 @@ package de.steamwar.scoreboard; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; +import net.minecraft.server.v1_12_R1.IScoreboardCriteria; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.lang.reflect.InvocationTargetException; +import java.util.logging.Level; + public class SWScoreboard_12 { private SWScoreboard_12() {} @@ -11,7 +19,13 @@ public class SWScoreboard_12 { } static void sendCreatePacket(String title, Player player) { - SWScoreboard_8.sendCreatePacket(title, player); + PacketContainer createPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE); + createPacket.getStrings().write(0, "AAA"); + createPacket.getIntegers().write(0, 0); + createPacket.getStrings().write(1, title); + createPacket.getEnumModifier(IScoreboardCriteria.EnumScoreboardHealthDisplay.class, 0).write(0, IScoreboardCriteria.EnumScoreboardHealthDisplay.INTEGER); + + sendPacket(player, createPacket); } static void sendUpdatePacket(String content, Integer line, Player player) { @@ -22,5 +36,13 @@ public class SWScoreboard_12 { SWScoreboard_8.sendDisplayPacket(player); } + private static void sendPacket(Player player, PacketContainer packetContainer) { + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(player, packetContainer); + } catch (InvocationTargetException ex) { + Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex); + } + } + }