Started with 1.20.5 support
This commit is contained in:
parent
89d4234a8c
commit
ef49048ee1
4 changed files with 23 additions and 5 deletions
2
pom.xml
2
pom.xml
|
@ -161,7 +161,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
<version>1.20.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class MapReflectionAPI extends JavaPlugin {
|
||||||
getLogger().info("Made by © Copyright SBDevelopment 2023");
|
getLogger().info("Made by © Copyright SBDevelopment 2023");
|
||||||
|
|
||||||
if (!supports(12)) {
|
if (!supports(12)) {
|
||||||
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12 - 1.19.4!");
|
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12 - 1.20.5!");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,25 @@ public class MapSender {
|
||||||
|
|
||||||
final int id = -id0;
|
final int id = -id0;
|
||||||
Object packet;
|
Object packet;
|
||||||
if (supports(17)) { //1.17+
|
if (supports(20, 4)) { //1.20.5+
|
||||||
|
//TODO: Implement 1.20.5+ map sending
|
||||||
|
|
||||||
|
Object updateData = ReflectionUtil.callConstructor(worldMapData,
|
||||||
|
content.minX, //X pos
|
||||||
|
content.minY, //Y pos
|
||||||
|
content.maxX, //X size (2nd X pos)
|
||||||
|
content.maxY, //Y size (2nd Y pos)
|
||||||
|
content.array //Data
|
||||||
|
);
|
||||||
|
|
||||||
|
packet = ReflectionUtil.callConstructor(packetPlayOutMapClass,
|
||||||
|
id, //ID
|
||||||
|
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||||
|
false, //Show icons
|
||||||
|
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||||
|
updateData
|
||||||
|
);
|
||||||
|
} else if (supports(17)) { //1.17+
|
||||||
Object updateData = ReflectionUtil.callConstructor(worldMapData,
|
Object updateData = ReflectionUtil.callConstructor(worldMapData,
|
||||||
content.minX, //X pos
|
content.minX, //X pos
|
||||||
content.minY, //Y pos
|
content.minY, //Y pos
|
||||||
|
|
|
@ -140,8 +140,8 @@ public class PacketListener implements Listener {
|
||||||
} else if (packet.getClass().isAssignableFrom(packetPlayInSetCreativeSlotClass)) {
|
} else if (packet.getClass().isAssignableFrom(packetPlayInSetCreativeSlotClass)) {
|
||||||
Object packetPlayInSetCreativeSlot = packetPlayInSetCreativeSlotClass.cast(packet);
|
Object packetPlayInSetCreativeSlot = packetPlayInSetCreativeSlotClass.cast(packet);
|
||||||
|
|
||||||
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(19, 4) ? "a" : supports(13) ? "b" : "a"); //1.19.4 = a, 1.19.3 - 1.13 = b, 1.12 = a
|
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(20,4) ? "b" : supports(19, 4) ? "a" : supports(13) ? "b" : "a"); //1.20.4 - 1.19.4 = a, 1.19.3 - 1.13 and 1.20.5 = b, 1.12 = a
|
||||||
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(20, 2) ? "d" : supports(18) ? "c" : "getItemStack"); //1.20.2 = d, >= 1.18 = c, 1.17 = getItemStack
|
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(20,4) ? "e" : supports(20, 2) ? "d" : supports(18) ? "c" : "getItemStack"); //1.20.5 = e, 1.20.2-1.20.4 = d, >= 1.18 = c, 1.17 = getItemStack
|
||||||
ItemStack craftStack = (ItemStack) ReflectionUtil.callMethod(craftStackClass, "asBukkitCopy", nmsStack);
|
ItemStack craftStack = (ItemStack) ReflectionUtil.callMethod(craftStackClass, "asBukkitCopy", nmsStack);
|
||||||
|
|
||||||
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
|
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
|
||||||
|
|
Loading…
Add table
Reference in a new issue