untested rework of dependent scoreboard source
Dieser Commit ist enthalten in:
Ursprung
82cec029ec
Commit
473d78ce75
@ -1,23 +1,25 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SWScoreboard_12 {
|
||||
|
||||
private SWScoreboard_12() {}
|
||||
|
||||
static void sendRemovePacket() {
|
||||
SWScoreboard_8.sendRemovePacket();
|
||||
static void sendRemovePacket(Player player) {
|
||||
SWScoreboard_8.sendRemovePacket(player);
|
||||
}
|
||||
|
||||
static void sendCreatePacket(String title) {
|
||||
SWScoreboard_8.sendCreatePacket(title);
|
||||
static void sendCreatePacket(String title, Player player) {
|
||||
SWScoreboard_8.sendCreatePacket(title, player);
|
||||
}
|
||||
|
||||
static void sendUpdatePacket(String content, Integer line) {
|
||||
SWScoreboard_8.sendUpdatePacket(content, line);
|
||||
static void sendUpdatePacket(String content, Integer line, Player player) {
|
||||
SWScoreboard_8.sendUpdatePacket(content, line, player);
|
||||
}
|
||||
|
||||
static void sendDisplayPacket() {
|
||||
SWScoreboard_8.sendDisplayPacket();
|
||||
static void sendDisplayPacket(Player player) {
|
||||
SWScoreboard_8.sendDisplayPacket(player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,38 +3,59 @@ package de.steamwar.scoreboard;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
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 {
|
||||
|
||||
private SWScoreboard_8() {}
|
||||
|
||||
static void sendRemovePacket() {
|
||||
static void sendRemovePacket(Player player) {
|
||||
PacketContainer removePacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_OBJECTIVE);
|
||||
removePacket.getStrings().write(0, "AAA");
|
||||
removePacket.getIntegers().write(0, 1);
|
||||
//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);
|
||||
createPacket.getStrings().write(0, "AAA");
|
||||
createPacket.getIntegers().write(0, 0);
|
||||
createPacket.getStrings().write(1, title);
|
||||
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);
|
||||
updatePacket.getStrings().write(0, content);
|
||||
updatePacket.getStrings().write(1, "AAA");
|
||||
updatePacket.getIntegers().write(0, line);
|
||||
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);
|
||||
displayPacket.getIntegers().write(0, 1);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +1,11 @@
|
||||
package de.steamwar.scoreboard;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SWScoreboard {
|
||||
|
||||
@ -22,72 +18,47 @@ public class SWScoreboard {
|
||||
}
|
||||
|
||||
private void sendScoreboard(Player player) {
|
||||
PacketContainer remove;
|
||||
PacketContainer createpacket;
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
remove = SWScoreboard_8.getRemovePacket();
|
||||
createpacket = SWScoreboard_8.getCreatePacket(this.callback.getTitle());
|
||||
SWScoreboard_8.sendRemovePacket(player);
|
||||
SWScoreboard_8.sendCreatePacket(this.callback.getTitle(), player);
|
||||
break;
|
||||
case 14:
|
||||
remove = SWScoreboard_14.getRemovePacket();
|
||||
createpacket = SWScoreboard_14.getCreatePacket(this.callback.getTitle());
|
||||
//Todo remove = SWScoreboard_14.getRemovePacket();
|
||||
//Todo createpacket = SWScoreboard_14.getCreatePacket(this.callback.getTitle());
|
||||
break;
|
||||
default:
|
||||
remove = SWScoreboard_12.getRemovePacket();
|
||||
createpacket = SWScoreboard_12.getCreatePacket(this.callback.getTitle());
|
||||
}
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, remove);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, createpacket);
|
||||
} catch (InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
|
||||
SWScoreboard_12.sendRemovePacket(player);
|
||||
SWScoreboard_12.sendCreatePacket(this.callback.getTitle(), player);
|
||||
}
|
||||
|
||||
for(Map.Entry<String, Integer> entry : this.callback.getData().entrySet()) {
|
||||
PacketContainer update;
|
||||
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
update = SWScoreboard_8.getUpdatePacket(entry.getKey(), entry.getValue());
|
||||
SWScoreboard_8.sendUpdatePacket(entry.getKey(), entry.getValue(), player);
|
||||
break;
|
||||
case 14:
|
||||
update = SWScoreboard_14.getUpdatePacket(entry.getKey(), entry.getValue());
|
||||
//Todo update = SWScoreboard_14.getUpdatePacket(entry.getKey(), entry.getValue());
|
||||
break;
|
||||
default:
|
||||
update = SWScoreboard_12.getUpdatePacket(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, update);
|
||||
} catch (InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "COULD NOT SEND PACKAGE", ex);
|
||||
SWScoreboard_12.sendUpdatePacket(entry.getKey(), entry.getValue(), player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void display(Player player) {
|
||||
PacketContainer display;
|
||||
|
||||
switch (Core.getVersion()) {
|
||||
case 8:
|
||||
display = SWScoreboard_8.getDisplayPacket(this.callback.getTitle());
|
||||
SWScoreboard_8.sendDisplayPacket(player);
|
||||
break;
|
||||
case 14:
|
||||
display = SWScoreboard_14.getDisplayPacket(this.callback.getTitle());
|
||||
//Todo display = SWScoreboard_14.getDisplayPacket(this.callback.getTitle());
|
||||
break;
|
||||
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 {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren