Fixed some more 1.18.1 NMS issues

This commit is contained in:
SBDeveloper 2022-07-30 13:07:03 +02:00
parent 4ba1633893
commit eec76559f3
3 changed files with 14 additions and 2 deletions

View file

@ -111,7 +111,7 @@ public class MapReflectionAPI extends JavaPlugin {
}
}
}
getLogger().info("Found " + occupiedIDs + " occupied Map IDs. These will not be used.");
getLogger().info("Found " + occupiedIDs + " occupied Map IDs." + (occupiedIDs > 0 ? " These will not be used." : ""));
}
getLogger().info("Registering the listeners...");

View file

@ -159,7 +159,18 @@ public class MapWrapper {
}
Object playerHandle = ReflectionUtil.getHandle(player);
Object inventoryMenu = ReflectionUtil.getField(playerHandle, ReflectionUtil.supports(19) ? "bT" : ReflectionUtil.supports(17) ? "bU" : "defaultContainer");
String inventoryMenuName;
if (ReflectionUtil.supports(19)) { //1.19
inventoryMenuName = "bT";
} else if (ReflectionUtil.supports(18)) { //1.18
inventoryMenuName = ReflectionUtil.VER_MINOR == 1 ? "bV" : "bU"; //1.18.1 = ap, 1.18(.2) = ao
} else if (ReflectionUtil.supports(17)) { //1.17, same as 1.18(.2)
inventoryMenuName = "bU";
} else { //1.12-1.16
inventoryMenuName = "defaultContainer";
}
Object inventoryMenu = ReflectionUtil.getField(playerHandle, inventoryMenuName);
int windowId = (int) ReflectionUtil.getField(inventoryMenu, ReflectionUtil.supports(17) ? "j" : "windowId");
ItemStack stack = new ItemStack(ReflectionUtil.supports(13) ? Material.FILLED_MAP : Material.MAP, 1);

View file

@ -38,6 +38,7 @@ public class Configuration {
private Configuration(JavaPlugin plugin) {
this.file = new YamlFile(plugin, "config");
this.file.loadDefaults();
reload();
}