Merge remote-tracking branch 'origin/development' into development
# Conflicts: # .idea/misc.xml # pom.xml # src/main/java/tech/sbdevelopment/mapreflectionapi/api/MapWrapper.java # src/main/java/tech/sbdevelopment/mapreflectionapi/listeners/PacketListener.java # src/main/java/tech/sbdevelopment/mapreflectionapi/utils/XMaterial.java
This commit is contained in:
commit
603f144d26
6 changed files with 34 additions and 18 deletions
4
.github/workflows/maven.yml
vendored
4
.github/workflows/maven.yml
vendored
|
@ -10,10 +10,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 21
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
java-version: 11
|
java-version: 21
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B package --file pom.xml
|
run: mvn -B package --file pom.xml
|
||||||
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -30,7 +30,7 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
Object packet;
|
Object packet;
|
||||||
if (supports(17)) { //1.17+
|
if (supports(20, 4)) { //1.20.5+
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
Object mapId = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), id);
|
||||||
|
|
||||||
|
packet = ReflectionUtil.callConstructor(packetPlayOutMapClass,
|
||||||
|
mapId, //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
|
||||||
|
|
|
@ -170,8 +170,8 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
//1.21 = cc
|
//1.21 = cc
|
||||||
inventoryMenuName = "cc";
|
inventoryMenuName = "cc";
|
||||||
} else if (supports(20)) {
|
} else if (supports(20)) {
|
||||||
//>= 1.20.2 = bR, 1.20(.1) = bQ
|
//1.20.5 = cb, 1.20.2 - 1.20.4 = bR, 1.20(.1) = bQ
|
||||||
inventoryMenuName = supports(20, 2) ? "bR" : "bQ";
|
inventoryMenuName = supports(20, 4) ? "cb" : supports(20, 2) ? "bR" : "bQ";
|
||||||
} else if (supports(19)) {
|
} else if (supports(19)) {
|
||||||
//1.19.4 = bO, >= 1.19.3 = bT
|
//1.19.4 = bO, >= 1.19.3 = bT
|
||||||
inventoryMenuName = supports(19, 3) ? "bO" : "bT";
|
inventoryMenuName = supports(19, 3) ? "bO" : "bT";
|
||||||
|
@ -291,14 +291,12 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
|
|
||||||
Object nmsStack = ReflectionUtil.callMethod(craftStackClass, "asNMSCopy", stack);
|
Object nmsStack = ReflectionUtil.callMethod(craftStackClass, "asNMSCopy", stack);
|
||||||
|
|
||||||
if (supports(21)) { //1.21 method
|
//1.20.5 uses new NBT compound system
|
||||||
Object minecraftKey = ReflectionUtil.callDeclaredMethod(minecraftKeyClass, "a", "minecraft:map_id");
|
if (supports(20, 4)) {
|
||||||
Object dataComponentTypeRegistery = ReflectionUtil.getDeclaredField(builtInRegistriesClass, "aq");
|
Object mapIdComponent = ReflectionUtil.getDeclaredField(getNMSClass("core.component", "DataComponents"), "B");
|
||||||
Object dataComponentType = ReflectionUtil.callMethod(dataComponentTypeRegistery, "a", minecraftKey);
|
Object mapId1 = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), mapId);
|
||||||
|
ReflectionUtil.callMethod(nmsStack, "b", mapIdComponent, mapId1);
|
||||||
Object dataComponentMap = ReflectionUtil.callMethod(nmsStack, "a");
|
} else if (supports(13)) {
|
||||||
ReflectionUtil.callMethod(dataComponentMap, "a", dataComponentType, mapId);
|
|
||||||
} else if (supports(13)) { //1.13 - 1.20 method
|
|
||||||
String nbtObjectName;
|
String nbtObjectName;
|
||||||
if (supports(20)) { //1.20
|
if (supports(20)) { //1.20
|
||||||
nbtObjectName = "w";
|
nbtObjectName = "w";
|
||||||
|
@ -342,7 +340,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
|
|
||||||
Object packet;
|
Object packet;
|
||||||
if (supports(19, 3)) { //1.19.3
|
if (supports(19, 3)) { //1.19.3
|
||||||
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", "DataWatcher$" + (supports(21) ? "c" : "b"));
|
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", "DataWatcher$" + (supports(20, 4) ? "c" : "b"));
|
||||||
// Sadly not possible to use ReflectionUtil (in its current state), because of the Object parameter
|
// Sadly not possible to use ReflectionUtil (in its current state), because of the Object parameter
|
||||||
Object dataWatcherItem;
|
Object dataWatcherItem;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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(21) ? "b" : supports(19, 4) ? "a" : supports(13) ? "b" : "a"); //1.21 = b, 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(21) ? "e" : supports(20, 2) ? "d" : supports(18) ? "c" : "getItemStack"); //1.21 = e, 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