begin pre 1.17 support
This commit is contained in:
1 parent
2c84532f79
commit
33144908eb
7 files changed
+149
-70
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
allprojects {
|
||||
version = "2.5.0"
|
||||
version = "2.6.0-SNAPSHOT"
|
||||
group = "net.megavex"
|
||||
description = "Powerful packet-level scoreboard library for Paper/Spigot servers"
|
||||
}
|
||||
+17
@@ -68,6 +68,23 @@ public final class PacketAdapterLoader {
|
||||
case "1.12.1":
|
||||
case "1.12.2":
|
||||
return tryLoadImplementationClass(LEGACY);
|
||||
case "1.13":
|
||||
case "1.13.1":
|
||||
case "1.13.2":
|
||||
case "1.14":
|
||||
case "1.14.1":
|
||||
case "1.14.2":
|
||||
case "1.14.3":
|
||||
case "1.14.4":
|
||||
case "1.15":
|
||||
case "1.15.1":
|
||||
case "1.15.2":
|
||||
case "1.16":
|
||||
case "1.16.1":
|
||||
case "1.16.2":
|
||||
case "1.16.3":
|
||||
case "1.16.4":
|
||||
case "1.16.5":
|
||||
case "1.17":
|
||||
case "1.17.1":
|
||||
case "1.18":
|
||||
|
||||
+41
-19
@@ -1,51 +1,73 @@
|
||||
# test-servers
|
||||
# test-env
|
||||
|
||||
## Target server versions
|
||||
## TODO
|
||||
|
||||
- [ ] 1.7.10
|
||||
- [ ] 1.8.8
|
||||
- [ ] 1.9.4
|
||||
- [ ] 1.10.2
|
||||
- [ ] 1.11.2
|
||||
- [ ] 1.12.2
|
||||
- [x] 1.13
|
||||
- [ ] 1.14.4
|
||||
- [ ] 1.15.2
|
||||
- [ ] 1.16.5
|
||||
- [x] 1.17
|
||||
- [ ] 1.18.2
|
||||
- [ ] 1.19.4
|
||||
- [x] 1.20.2
|
||||
- [x] 1.20.4
|
||||
- [x] 1.20.5
|
||||
- [x] 1.21.3
|
||||
- [x] 1.21.5
|
||||
- [x] 1.21.6
|
||||
- [x] 1.21.9
|
||||
- [x] 1.21.11
|
||||
|
||||
## Legacy server versions
|
||||
|
||||
- [?] 1.8
|
||||
- [?] 1.8.3
|
||||
- [?] 1.8.4
|
||||
- [?] 1.8.5
|
||||
- [?] 1.8.6
|
||||
- [?] 1.8.7
|
||||
- [ ] 1.8.8
|
||||
- [?] 1.9
|
||||
- [?] 1.9.2
|
||||
- [?] 1.9.4
|
||||
- [?] 1.10.2
|
||||
- [?] 1.11
|
||||
- [?] 1.11.2
|
||||
- [?] 1.12
|
||||
- [?] 1.12.1
|
||||
- [ ] 1.12.2
|
||||
- [ ] 1.17
|
||||
|
||||
## Modern server versions
|
||||
|
||||
- [?] 1.13.1
|
||||
- [?] 1.13.2
|
||||
- [?] 1.14
|
||||
- [?] 1.14.1
|
||||
- [?] 1.14.2
|
||||
- [?] 1.14.3
|
||||
- [?] 1.15
|
||||
- [?] 1.15.1
|
||||
- [?] 1.16
|
||||
- [?] 1.16.1
|
||||
- [?] 1.16.2
|
||||
- [?] 1.16.3
|
||||
- [?] 1.16.4
|
||||
- [?] 1.17.1
|
||||
- [?] 1.18
|
||||
- [?] 1.18.1
|
||||
- [?] 1.18.2
|
||||
- [?] 1.19
|
||||
- [?] 1.19.1
|
||||
- [?] 1.19.2
|
||||
- [?] 1.19.3
|
||||
- [?] 1.19.4
|
||||
- [?] 1.20
|
||||
- [?] 1.20.1
|
||||
- [ ] 1.20.2
|
||||
- [-] 1.20.3
|
||||
- [ ] 1.20.4
|
||||
- [ ] 1.20.5
|
||||
- [-] 1.20.6
|
||||
- [-] 1.21
|
||||
- [-] 1.21.1
|
||||
- [-] 1.21.2
|
||||
- [ ] 1.21.3
|
||||
- [-] 1.21.4
|
||||
- [ ] 1.21.5
|
||||
- [ ] 1.21.6
|
||||
- [-] 1.21.7
|
||||
- [-] 1.21.8
|
||||
- [ ] 1.21.9
|
||||
- [-] 1.21.10
|
||||
- [ ] 1.21.11
|
||||
|
||||
@@ -145,3 +145,15 @@ download_file "paper-1.17.jar" "https://fill-data.papermc.io/v1/objects/760a93b9
|
||||
create_server "paper-1.17" "25571" "jdk25"
|
||||
|
||||
create_spigot_server "1.17" "25570" "jdk17"
|
||||
|
||||
# --- 1.16.5 ---
|
||||
download_file "paper-1.16.5.jar" "https://fill-data.papermc.io/v1/objects/e67da4851d08cde378ab2b89be58849238c303351ed2482181a99c2c2b489276/paper-1.16.5-794.jar" "e67da4851d08cde378ab2b89be58849238c303351ed2482181a99c2c2b489276"
|
||||
create_server "paper-1.16.5" "25569" "jdk8"
|
||||
|
||||
#create_spigot_server "1.13" "25568" "jdk8"
|
||||
|
||||
# --- 1.13 ---
|
||||
download_file "paper-1.13.jar" "https://fill-data.papermc.io/v1/objects/00db82d214242c9345266d44ff8d11a8e857a1a02edf7cb5fcc2d1d973283129/paper-1.13-173.jar" "00db82d214242c9345266d44ff8d11a8e857a1a02edf7cb5fcc2d1d973283129"
|
||||
create_server "paper-1.13" "25567" "jdk8"
|
||||
|
||||
create_spigot_server "1.13" "25566" "jdk8"
|
||||
+7
-3
@@ -48,10 +48,14 @@ public final class ScoreboardPlugin extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
for (final Module module : this.modules) {
|
||||
module.onDisable();
|
||||
if (this.modules != null){
|
||||
for (final Module module : this.modules) {
|
||||
module.onDisable();
|
||||
}
|
||||
}
|
||||
if (this.lib != null) {
|
||||
this.lib.close();
|
||||
}
|
||||
this.lib.close();
|
||||
GlobalTranslator.get().removeSource(this.translator);
|
||||
}
|
||||
|
||||
|
||||
+70
-47
@@ -2,12 +2,73 @@ package net.megavex.scoreboardlibrary.implementation.packetAdapter.modern;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.megavex.scoreboardlibrary.implementation.packetAdapter.util.reflect.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.*;
|
||||
|
||||
public final class PacketAccessors {
|
||||
public static final boolean IS_1_17_OR_ABOVE, IS_1_20_2_OR_ABOVE, IS_1_20_3_OR_ABOVE, IS_1_20_5_OR_ABOVE, IS_1_21_5_OR_ABOVE, IS_1_21_6_OR_ABOVE;
|
||||
private static final String OLD_NMS_VERSION_STRING;
|
||||
|
||||
static {
|
||||
boolean is1_17OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.world.item.BundleItem");
|
||||
is1_17OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_17_OR_ABOVE = is1_17OrAbove;
|
||||
|
||||
if (!is1_17OrAbove) {
|
||||
OLD_NMS_VERSION_STRING = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
} else {
|
||||
OLD_NMS_VERSION_STRING = null;
|
||||
}
|
||||
|
||||
boolean is1_20_2OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.world.scores.DisplaySlot");
|
||||
is1_20_2OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_2_OR_ABOVE = is1_20_2OrAbove;
|
||||
|
||||
boolean is1_20_3OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.network.chat.numbers.NumberFormat");
|
||||
is1_20_3OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_3_OR_ABOVE = is1_20_3OrAbove;
|
||||
|
||||
boolean is1_20_5OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.network.protocol.common.ClientboundTransferPacket");
|
||||
is1_20_5OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_5_OR_ABOVE = is1_20_5OrAbove;
|
||||
|
||||
boolean is1_21_5OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.world.item.component.BlocksAttacks");
|
||||
is1_21_5OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_21_5_OR_ABOVE = is1_21_5OrAbove;
|
||||
|
||||
boolean is1_21_6OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.server.dialog.Dialog");
|
||||
is1_21_6OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_21_6_OR_ABOVE = is1_21_6OrAbove;
|
||||
}
|
||||
|
||||
public static final Class<?> PKT_CLASS,
|
||||
SET_OBJECTIVE_PKT_CLASS,
|
||||
SET_DISPLAY_OBJECTIVE_PKT_CLASS,
|
||||
@@ -36,8 +97,7 @@ public final class PacketAccessors {
|
||||
ADVENTURE_COMPONENT_CLASS;
|
||||
|
||||
static {
|
||||
// TODO: spigot mapping names
|
||||
PKT_CLASS = ReflectUtil.getClassOrThrow("net.minecraft.network.protocol.Packet");
|
||||
PKT_CLASS = ReflectUtil.getClassOrThrow("net.minecraft.network.protocol.Packet", oldSpigotClassName("Packet"));
|
||||
SET_OBJECTIVE_PKT_CLASS = ReflectUtil.getClassOrThrow("net.minecraft.network.protocol.game.ClientboundSetObjectivePacket", "net.minecraft.network.protocol.game.PacketPlayOutScoreboardObjective");
|
||||
SET_DISPLAY_OBJECTIVE_PKT_CLASS = ReflectUtil.getClassOrThrow("net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket", "net.minecraft.network.protocol.game.PacketPlayOutScoreboardDisplayObjective");
|
||||
SET_SCORE_PKT_CLASS = ReflectUtil.getClassOrThrow("net.minecraft.network.protocol.game.ClientboundSetScorePacket", "net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore");
|
||||
@@ -65,50 +125,8 @@ public final class PacketAccessors {
|
||||
ADVENTURE_COMPONENT_CLASS = ReflectUtil.getOptionalClass("io.papermc.paper.adventure.AdventureComponent");
|
||||
}
|
||||
|
||||
public static final boolean IS_1_20_2_OR_ABOVE, IS_1_20_3_OR_ABOVE, IS_1_20_5_OR_ABOVE, IS_1_21_5_OR_ABOVE, IS_1_21_6_OR_ABOVE;
|
||||
|
||||
static {
|
||||
boolean is1_20_2OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.world.scores.DisplaySlot");
|
||||
is1_20_2OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_2_OR_ABOVE = is1_20_2OrAbove;
|
||||
|
||||
boolean is1_20_3OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.network.chat.numbers.NumberFormat");
|
||||
is1_20_3OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_3_OR_ABOVE = is1_20_3OrAbove;
|
||||
|
||||
boolean is1_20_5OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.network.protocol.common.ClientboundTransferPacket"); // Random 1.20.5 class
|
||||
is1_20_5OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_20_5_OR_ABOVE = is1_20_5OrAbove;
|
||||
|
||||
boolean is1_21_5OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.world.item.component.BlocksAttacks"); // Random 1.21.5 class
|
||||
is1_21_5OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_21_5_OR_ABOVE = is1_21_5OrAbove;
|
||||
|
||||
boolean is1_21_6OrAbove = false;
|
||||
try {
|
||||
Class.forName("net.minecraft.server.dialog.Dialog"); // Random 1.21.6 class
|
||||
is1_21_6OrAbove = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
IS_1_21_6_OR_ABOVE = is1_21_6OrAbove;
|
||||
|
||||
if (is1_21_5OrAbove) {
|
||||
if (IS_1_21_5_OR_ABOVE) {
|
||||
NAME_TAG_VISIBILITY_FIELD_1_21_5 = ReflectUtil.findFieldUnchecked(TEAM_PARAMETERS_PKT_CLASS, 0, TEAM_VISIBILITY_CLASS);
|
||||
COLLISION_RULE_FIELD_1_21_5 = ReflectUtil.findFieldUnchecked(TEAM_PARAMETERS_PKT_CLASS, 0, TEAM_COLLISION_RULE_CLASS);
|
||||
NAME_TAG_VISIBILITY_FIELD_1_21_4 = null;
|
||||
@@ -119,9 +137,7 @@ public final class PacketAccessors {
|
||||
NAME_TAG_VISIBILITY_FIELD_1_21_5 = null;
|
||||
COLLISION_RULE_FIELD_1_21_5 = null;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
if (IS_1_20_3_OR_ABOVE) {
|
||||
RESET_SCORE_CONSTRUCTOR = ReflectUtil.findConstructor(Objects.requireNonNull(RESET_SCORE_PKT_CLASS), String.class, String.class);
|
||||
} else {
|
||||
@@ -242,4 +258,11 @@ public final class PacketAccessors {
|
||||
public static @NotNull Object fromAdventureComponent(@NotNull Component component) {
|
||||
return Objects.requireNonNull(PacketAccessors.ADVENTURE_COMPONENT_CONSTRUCTOR).invoke(component);
|
||||
}
|
||||
|
||||
public static @Nullable String oldSpigotClassName(String clazz) {
|
||||
if (OLD_NMS_VERSION_STRING != null) {
|
||||
return "net.minecraft.server." + OLD_NMS_VERSION_STRING + "." + clazz;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
@@ -64,6 +64,7 @@ public class ReflectUtil {
|
||||
|
||||
public static @Nullable Class<?> getOptionalClass(String... names) {
|
||||
for (String name : names) {
|
||||
if (name == null) continue;
|
||||
try {
|
||||
return Class.forName(name);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
|
||||
Reference in new issue
Block a user