Fixed some typos

This commit is contained in:
SBDeveloper 2022-09-27 21:07:21 +02:00
parent 0195f7edf6
commit df98877ebd
3 changed files with 24 additions and 22 deletions

View file

@ -121,7 +121,7 @@ public class MapReflectionAPI extends JavaPlugin {
if (Configuration.getInstance().isUpdaterCheck()) {
try {
UpdateManager updateManager = new UpdateManager(this, UpdateManager.CheckType.SPIGOT);
UpdateManager updateManager = new UpdateManager(this, 103011);
updateManager.handleResponse((versionResponse, version) -> {
switch (versionResponse) {

View file

@ -43,9 +43,9 @@ import static tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil.*;
public class PacketListener implements Listener {
private static final Class<?> packetPlayOutMapClass = getNMSClass("network.protocol.game", "PacketPlayOutMap");
private static final Class<?> packetPlayInUseEntityClass = getNMSClass("network.protocol.game", "PacketPlayInUseEntity");
private static final Class<?> packetPlayInSetCreativeSlotClass = getNMSClass("network.protocol.game", "packetPlayInSetCreativeSlot");
private static final Class<?> packetPlayInSetCreativeSlotClass = getNMSClass("network.protocol.game", "PacketPlayInSetCreativeSlot");
private static final Class<?> vec3DClass = getNMSClass("world.phys", "Vec3D");
private static final Class<?> craftStackClass = getCraftClass("CraftItemStack");
private static final Class<?> craftStackClass = getCraftClass("inventory.CraftItemStack");
@EventHandler
public void onJoin(PlayerJoinEvent e) {
@ -98,7 +98,7 @@ public class PacketListener implements Listener {
hand = hasField(action, "a") ? (Enum<?>) getDeclaredField(action, "a") : null;
pos = hasField(action, "b") ? getDeclaredField(action, "b") : null;
} else {
actionEnum = (Enum<?>) getDeclaredField(packetPlayInEntity, ReflectionUtil.supports(13) ? "b" : "a"); //1.13 = b, 1.12 = a
actionEnum = (Enum<?>) callDeclaredMethod(packetPlayInEntity, ReflectionUtil.supports(13) ? "b" : "a"); //1.13 = b, 1.12 = a
hand = (Enum<?>) callDeclaredMethod(packetPlayInEntity, ReflectionUtil.supports(13) ? "c" : "b"); //1.13 = c, 1.12 = b
pos = callDeclaredMethod(packetPlayInEntity, ReflectionUtil.supports(13) ? "d" : "c"); //1.13 = d, 1.12 = c
}
@ -117,7 +117,7 @@ public class PacketListener implements Listener {
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, ReflectionUtil.supports(13) ? "b" : "a"); //1.13 = b, 1.12 = a
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, ReflectionUtil.supports(18) ? "c" : "getItemStack"); //1.18 = c, 1.17 = getItemStack
ItemStack craftStack = (ItemStack) ReflectionUtil.callDeclaredMethod(craftStackClass, "asBukkitCopy", nmsStack);
ItemStack craftStack = (ItemStack) ReflectionUtil.callMethod(craftStackClass, "asBukkitCopy", nmsStack);
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
CreateInventoryMapUpdateEvent event = new CreateInventoryMapUpdateEvent(player, slot, craftStack, async);
@ -142,9 +142,9 @@ public class PacketListener implements Listener {
private Channel getChannel(Player player) {
Object playerHandle = getHandle(player);
Object connection = getDeclaredField(playerHandle, "b");
Object connection2 = getDeclaredField(connection, ReflectionUtil.supports(19) ? "b" : "a"); //1.19 = b, 1.18 = a
return (Channel) getDeclaredField(connection2, ReflectionUtil.supports(18) ? "m" : "k"); //1.18 = m, 1.17 = k
Object playerConnection = getDeclaredField(playerHandle, ReflectionUtil.supports(17) ? "b" : "playerConnection"); //1.17 = b, 1.16 = playerConnection
Object networkManager = getDeclaredField(playerConnection, ReflectionUtil.supports(19) ? "b" : ReflectionUtil.supports(17) ? "a" : "networkManager"); //1.19 = b, 1.18 = a, 1.16 = networkManager
return (Channel) getDeclaredField(networkManager, ReflectionUtil.supports(18) ? "m" : ReflectionUtil.supports(17) ? "k" : "channel"); //1.18 = m, 1.17 = k, 1.16 = channel
}
private Vector vec3DToVector(Object vec3d) {

View file

@ -35,7 +35,7 @@ import java.util.function.BiConsumer;
* Update checker class
*
* @author Stijn [SBDeveloper]
* @version 2.2 [17-04-2022] - Added Polymart support
* @version 2.3 [27-09-2022] - Added Polymart support ; fixed Spigot support
* @since 05-03-2020
*/
public class UpdateManager {
@ -68,22 +68,24 @@ public class UpdateManager {
*
* @param plugin The plugin instance
*/
public UpdateManager(Plugin plugin, CheckType type) {
if ("%%__RESOURCE__%%".equals("%%__" + "RES" + "OU" + "RCE" + "__%%"))
throw new IllegalStateException("Resource ID not set!");
public UpdateManager(Plugin plugin) {
this.plugin = plugin;
this.currentVersion = new Version(plugin.getDescription().getVersion());
this.type = type;
this.type = CheckType.POLYMART_PAID;
this.resourceID = Integer.parseInt("%%__RESOURCE__%%");
if (type == CheckType.POLYMART_PAID) {
this.injector_version = Integer.parseInt("%%__INJECT_VER__%%");
this.user_id = Integer.parseInt("%%__USER__%%");
this.nonce = Integer.parseInt("%%__NONCE__%%");
this.download_agent = Integer.parseInt("%%__AGENT__%%");
this.download_time = Integer.parseInt("%%__TIMESTAMP__%%");
this.download_token = "%%__VERIFY_TOKEN__%%";
}
this.injector_version = Integer.parseInt("%%__INJECT_VER__%%");
this.user_id = Integer.parseInt("%%__USER__%%");
this.nonce = Integer.parseInt("%%__NONCE__%%");
this.download_agent = Integer.parseInt("%%__AGENT__%%");
this.download_time = Integer.parseInt("%%__TIMESTAMP__%%");
this.download_token = "%%__VERIFY_TOKEN__%%";
}
public UpdateManager(Plugin plugin, int resourceID) {
this.plugin = plugin;
this.currentVersion = new Version(plugin.getDescription().getVersion());
this.type = CheckType.SPIGOT;
this.resourceID = resourceID;
}
/**