SteamWar/SpigotCore
Archiviert
13
0

untested rework of dependent scoreboard source

Dieser Commit ist enthalten in:
BuildTools 2019-12-05 19:33:34 +01:00
Ursprung 82cec029ec
Commit 473d78ce75
3 geänderte Dateien mit 47 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -1,23 +1,25 @@
package de.steamwar.scoreboard; package de.steamwar.scoreboard;
import org.bukkit.entity.Player;
public class SWScoreboard_12 { public class SWScoreboard_12 {
private SWScoreboard_12() {} private SWScoreboard_12() {}
static void sendRemovePacket() { static void sendRemovePacket(Player player) {
SWScoreboard_8.sendRemovePacket(); SWScoreboard_8.sendRemovePacket(player);
} }
static void sendCreatePacket(String title) { static void sendCreatePacket(String title, Player player) {
SWScoreboard_8.sendCreatePacket(title); SWScoreboard_8.sendCreatePacket(title, player);
} }
static void sendUpdatePacket(String content, Integer line) { static void sendUpdatePacket(String content, Integer line, Player player) {
SWScoreboard_8.sendUpdatePacket(content, line); SWScoreboard_8.sendUpdatePacket(content, line, player);
} }
static void sendDisplayPacket() { static void sendDisplayPacket(Player player) {
SWScoreboard_8.sendDisplayPacket(); SWScoreboard_8.sendDisplayPacket(player);
} }

Datei anzeigen

@ -3,38 +3,59 @@ package de.steamwar.scoreboard;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
public class SWScoreboard_8 { public class SWScoreboard_8 {
private SWScoreboard_8() {} private SWScoreboard_8() {}
static void sendRemovePacket() { static void sendRemovePacket(Player player) {
PacketContainer removePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE); PacketContainer removePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
removePacket.getStrings().write(0, "AAA"); removePacket.getStrings().write(0, "AAA");
removePacket.getIntegers().write(0, 1); removePacket.getIntegers().write(0, 1);
//TODO kann vlt entfernt werden -> remove.getStrings().write(1, "integer"); //TODO kann vlt entfernt werden -> remove.getStrings().write(1, "integer");
sendPacket(player, removePacket);
} }
static void sendCreatePacket(String title) { static void sendCreatePacket(String title, Player player) {
PacketContainer createPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE); PacketContainer createPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
createPacket.getStrings().write(0, "AAA"); createPacket.getStrings().write(0, "AAA");
createPacket.getIntegers().write(0, 0); createPacket.getIntegers().write(0, 0);
createPacket.getStrings().write(1, title); createPacket.getStrings().write(1, title);
createPacket.getStrings().write(2, "integer"); createPacket.getStrings().write(2, "integer");
sendPacket(player, createPacket);
} }
static void sendUpdatePacket(String content, Integer line) { static void sendUpdatePacket(String content, Integer line, Player player) {
PacketContainer updatePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_SCORE); PacketContainer updatePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_SCORE);
updatePacket.getStrings().write(0, content); updatePacket.getStrings().write(0, content);
updatePacket.getStrings().write(1, "AAA"); updatePacket.getStrings().write(1, "AAA");
updatePacket.getIntegers().write(0, line); updatePacket.getIntegers().write(0, line);
updatePacket.getBytes().write(0, (byte) 0); updatePacket.getBytes().write(0, (byte) 0);
sendPacket(player, updatePacket);
} }
static void sendDisplayPacket() { static void sendDisplayPacket(Player player) {
PacketContainer displayPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE); PacketContainer displayPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);
displayPacket.getIntegers().write(0, 1); displayPacket.getIntegers().write(0, 1);
displayPacket.getStrings().write(0, "AAA"); displayPacket.getStrings().write(0, "AAA");
sendPacket(player, displayPacket);
}
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);
}
} }

Datei anzeigen

@ -1,15 +1,11 @@
package de.steamwar.scoreboard; package de.steamwar.scoreboard;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
public class SWScoreboard { public class SWScoreboard {
@ -22,72 +18,47 @@ public class SWScoreboard {
} }
private void sendScoreboard(Player player) { private void sendScoreboard(Player player) {
PacketContainer remove;
PacketContainer createpacket;
switch (Core.getVersion()) { switch (Core.getVersion()) {
case 8: case 8:
remove = SWScoreboard_8.getRemovePacket(); SWScoreboard_8.sendRemovePacket(player);
createpacket = SWScoreboard_8.getCreatePacket(this.callback.getTitle()); SWScoreboard_8.sendCreatePacket(this.callback.getTitle(), player);
break; break;
case 14: case 14:
remove = SWScoreboard_14.getRemovePacket(); //Todo remove = SWScoreboard_14.getRemovePacket();
createpacket = SWScoreboard_14.getCreatePacket(this.callback.getTitle()); //Todo createpacket = SWScoreboard_14.getCreatePacket(this.callback.getTitle());
break; break;
default: default:
remove = SWScoreboard_12.getRemovePacket(); SWScoreboard_12.sendRemovePacket(player);
createpacket = SWScoreboard_12.getCreatePacket(this.callback.getTitle()); SWScoreboard_12.sendCreatePacket(this.callback.getTitle(), player);
}
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, remove);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, createpacket);
} catch (InvocationTargetException ex) {
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
} }
for(Map.Entry<String, Integer> entry : this.callback.getData().entrySet()) { for(Map.Entry<String, Integer> entry : this.callback.getData().entrySet()) {
PacketContainer update;
switch (Core.getVersion()) { switch (Core.getVersion()) {
case 8: case 8:
update = SWScoreboard_8.getUpdatePacket(entry.getKey(), entry.getValue()); SWScoreboard_8.sendUpdatePacket(entry.getKey(), entry.getValue(), player);
break; break;
case 14: case 14:
update = SWScoreboard_14.getUpdatePacket(entry.getKey(), entry.getValue()); //Todo update = SWScoreboard_14.getUpdatePacket(entry.getKey(), entry.getValue());
break; break;
default: default:
update = SWScoreboard_12.getUpdatePacket(entry.getKey(), entry.getValue()); SWScoreboard_12.sendUpdatePacket(entry.getKey(), entry.getValue(), player);
}
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, update);
} catch (InvocationTargetException ex) {
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
} }
} }
} }
private void display(Player player) { private void display(Player player) {
PacketContainer display;
switch (Core.getVersion()) { switch (Core.getVersion()) {
case 8: case 8:
display = SWScoreboard_8.getDisplayPacket(this.callback.getTitle()); SWScoreboard_8.sendDisplayPacket(player);
break; break;
case 14: case 14:
display = SWScoreboard_14.getDisplayPacket(this.callback.getTitle()); //Todo display = SWScoreboard_14.getDisplayPacket(this.callback.getTitle());
break; break;
default: default:
display = SWScoreboard_12.getDisplayPacket(this.callback.getTitle()); SWScoreboard_12.sendDisplayPacket(player);
} }
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, display);
} catch (InvocationTargetException ex) {
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
}
} }
static { static {