SteamWar/SpigotCore
Archiviert
13
0

Fix SWScoreboard <= 1.12, Remove todos

Dieser Commit ist enthalten in:
Lixfel 2021-09-11 18:24:28 +02:00
Ursprung ef2553e6ac
Commit 2b1e7c3322
5 geänderte Dateien mit 20 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -264,6 +264,15 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
scoreboardName.set(packet, chatComponentConstructor.invoke(title)); scoreboardName.set(packet, chatComponentConstructor.invoke(title));
} }
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms}.ScoreboardServer$Action");
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(SWScoreboard.scoreboardScore, scoreActionEnum, 0);
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
@Override
public void setScoreAction(Object packet) {
scoreAction.set(packet, scoreActionChange);
}
@Override @Override
public Material getMaterial(String material) { public Material getMaterial(String material) {
try{ try{

Datei anzeigen

@ -58,12 +58,20 @@ import java.util.stream.Collectors;
public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper { public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper {
private static final Reflection.FieldAccessor<String> scoreboardName = Reflection.getField(SWScoreboard.scoreboardObjective, String.class, 1); private static final Reflection.FieldAccessor<String> scoreboardName = Reflection.getField(SWScoreboard.scoreboardObjective, String.class, 1);
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms}.PacketPlayOutScoreboardScore$EnumScoreboardAction");
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(SWScoreboard.scoreboardScore, scoreActionEnum, 0);
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
@Override @Override
public void setScoreboardTitle(Object packet, String title) { public void setScoreboardTitle(Object packet, String title) {
scoreboardName.set(packet, title); scoreboardName.set(packet, title);
} }
@Override
public void setScoreAction(Object packet) {
scoreAction.set(packet, scoreActionChange);
}
@Override @Override
public Material getMaterial(String material) { public Material getMaterial(String material) {
try{ try{

Datei anzeigen

@ -34,6 +34,7 @@ public class FlatteningWrapper {
public interface IFlatteningWrapper { public interface IFlatteningWrapper {
void setScoreboardTitle(Object packet, String title); void setScoreboardTitle(Object packet, String title);
void setScoreAction(Object packet);
Material getMaterial(String material); Material getMaterial(String material);
Material getDye(int colorCode); Material getDye(int colorCode);

Datei anzeigen

@ -45,9 +45,6 @@ public class ChunkListener {
) )
return packet; return packet;
//TODO: Test ViaVersion prior or post
//TODO: Test if this can be done async?
//TODO: Nicer way: generate new and send new
CraftbukkitWrapper.impl.sendChunk(receiver, chunkX.get(packet), chunkZ.get(packet)); CraftbukkitWrapper.impl.sendChunk(receiver, chunkX.get(packet), chunkZ.get(packet));
return null; return null;
} }

Datei anzeigen

@ -39,13 +39,10 @@ public class SWScoreboard {
private static final Reflection.FieldAccessor<?> scoreboardDisplayType = Reflection.getField(scoreboardObjective, scoreboardDisplayEnum, 0); private static final Reflection.FieldAccessor<?> scoreboardDisplayType = Reflection.getField(scoreboardObjective, scoreboardDisplayEnum, 0);
private static final Object displayTypeIntegers = scoreboardDisplayEnum.getEnumConstants()[0]; private static final Object displayTypeIntegers = scoreboardDisplayEnum.getEnumConstants()[0];
private static final Class<?> scoreboardScore = Reflection.getClass("{nms}.PacketPlayOutScoreboardScore"); public static final Class<?> scoreboardScore = Reflection.getClass("{nms}.PacketPlayOutScoreboardScore");
private static final Reflection.FieldAccessor<String> scoreName = Reflection.getField(scoreboardScore, String.class, 0); private static final Reflection.FieldAccessor<String> scoreName = Reflection.getField(scoreboardScore, String.class, 0);
private static final Reflection.FieldAccessor<String> scoreScoreboardName = Reflection.getField(scoreboardScore, String.class, 1); private static final Reflection.FieldAccessor<String> scoreScoreboardName = Reflection.getField(scoreboardScore, String.class, 1);
private static final Reflection.FieldAccessor<Integer> scoreValue = Reflection.getField(scoreboardScore, int.class, 0); private static final Reflection.FieldAccessor<Integer> scoreValue = Reflection.getField(scoreboardScore, int.class, 0);
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms}.ScoreboardServer$Action");
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(scoreboardScore, scoreActionEnum, 0);
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
private static final HashMap<Player, ScoreboardCallback> playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map! private static final HashMap<Player, ScoreboardCallback> playerBoards = new HashMap<>(); //Object -> Scoreboard | Alle Versionen in der Map!
private static int toggle = 0; // Scoreboard 0 updates while scoreboard 1 is presenting. toggle marks the current active scoreboard private static int toggle = 0; // Scoreboard 0 updates while scoreboard 1 is presenting. toggle marks the current active scoreboard
@ -116,7 +113,7 @@ public class SWScoreboard {
scoreName.set(packet, name); scoreName.set(packet, name);
scoreScoreboardName.set(packet, SIDEBAR + toggle); scoreScoreboardName.set(packet, SIDEBAR + toggle);
scoreValue.set(packet, value); scoreValue.set(packet, value);
scoreAction.set(packet, scoreActionChange); FlatteningWrapper.impl.setScoreAction(packet);
return packet; return packet;
} }
} }