Release of v1.4 #10
3 changed files with 24 additions and 22 deletions
|
@ -121,7 +121,7 @@ public class MapReflectionAPI extends JavaPlugin {
|
||||||
|
|
||||||
if (Configuration.getInstance().isUpdaterCheck()) {
|
if (Configuration.getInstance().isUpdaterCheck()) {
|
||||||
try {
|
try {
|
||||||
UpdateManager updateManager = new UpdateManager(this, UpdateManager.CheckType.SPIGOT);
|
UpdateManager updateManager = new UpdateManager(this, 103011);
|
||||||
|
|
||||||
updateManager.handleResponse((versionResponse, version) -> {
|
updateManager.handleResponse((versionResponse, version) -> {
|
||||||
switch (versionResponse) {
|
switch (versionResponse) {
|
||||||
|
|
|
@ -43,9 +43,9 @@ import static tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil.*;
|
||||||
public class PacketListener implements Listener {
|
public class PacketListener implements Listener {
|
||||||
private static final Class<?> packetPlayOutMapClass = getNMSClass("network.protocol.game", "PacketPlayOutMap");
|
private static final Class<?> packetPlayOutMapClass = getNMSClass("network.protocol.game", "PacketPlayOutMap");
|
||||||
private static final Class<?> packetPlayInUseEntityClass = getNMSClass("network.protocol.game", "PacketPlayInUseEntity");
|
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<?> vec3DClass = getNMSClass("world.phys", "Vec3D");
|
||||||
private static final Class<?> craftStackClass = getCraftClass("CraftItemStack");
|
private static final Class<?> craftStackClass = getCraftClass("inventory.CraftItemStack");
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
|
@ -98,7 +98,7 @@ public class PacketListener implements Listener {
|
||||||
hand = hasField(action, "a") ? (Enum<?>) getDeclaredField(action, "a") : null;
|
hand = hasField(action, "a") ? (Enum<?>) getDeclaredField(action, "a") : null;
|
||||||
pos = hasField(action, "b") ? getDeclaredField(action, "b") : null;
|
pos = hasField(action, "b") ? getDeclaredField(action, "b") : null;
|
||||||
} else {
|
} 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
|
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
|
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
|
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
|
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();
|
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
|
||||||
CreateInventoryMapUpdateEvent event = new CreateInventoryMapUpdateEvent(player, slot, craftStack, async);
|
CreateInventoryMapUpdateEvent event = new CreateInventoryMapUpdateEvent(player, slot, craftStack, async);
|
||||||
|
@ -142,9 +142,9 @@ public class PacketListener implements Listener {
|
||||||
|
|
||||||
private Channel getChannel(Player player) {
|
private Channel getChannel(Player player) {
|
||||||
Object playerHandle = getHandle(player);
|
Object playerHandle = getHandle(player);
|
||||||
Object connection = getDeclaredField(playerHandle, "b");
|
Object playerConnection = getDeclaredField(playerHandle, ReflectionUtil.supports(17) ? "b" : "playerConnection"); //1.17 = b, 1.16 = playerConnection
|
||||||
Object connection2 = getDeclaredField(connection, ReflectionUtil.supports(19) ? "b" : "a"); //1.19 = b, 1.18 = a
|
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(connection2, ReflectionUtil.supports(18) ? "m" : "k"); //1.18 = m, 1.17 = k
|
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) {
|
private Vector vec3DToVector(Object vec3d) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.util.function.BiConsumer;
|
||||||
* Update checker class
|
* Update checker class
|
||||||
*
|
*
|
||||||
* @author Stijn [SBDeveloper]
|
* @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
|
* @since 05-03-2020
|
||||||
*/
|
*/
|
||||||
public class UpdateManager {
|
public class UpdateManager {
|
||||||
|
@ -68,15 +68,11 @@ public class UpdateManager {
|
||||||
*
|
*
|
||||||
* @param plugin The plugin instance
|
* @param plugin The plugin instance
|
||||||
*/
|
*/
|
||||||
public UpdateManager(Plugin plugin, CheckType type) {
|
public UpdateManager(Plugin plugin) {
|
||||||
if ("%%__RESOURCE__%%".equals("%%__" + "RES" + "OU" + "RCE" + "__%%"))
|
|
||||||
throw new IllegalStateException("Resource ID not set!");
|
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.currentVersion = new Version(plugin.getDescription().getVersion());
|
this.currentVersion = new Version(plugin.getDescription().getVersion());
|
||||||
this.type = type;
|
this.type = CheckType.POLYMART_PAID;
|
||||||
this.resourceID = Integer.parseInt("%%__RESOURCE__%%");
|
this.resourceID = Integer.parseInt("%%__RESOURCE__%%");
|
||||||
if (type == CheckType.POLYMART_PAID) {
|
|
||||||
this.injector_version = Integer.parseInt("%%__INJECT_VER__%%");
|
this.injector_version = Integer.parseInt("%%__INJECT_VER__%%");
|
||||||
this.user_id = Integer.parseInt("%%__USER__%%");
|
this.user_id = Integer.parseInt("%%__USER__%%");
|
||||||
this.nonce = Integer.parseInt("%%__NONCE__%%");
|
this.nonce = Integer.parseInt("%%__NONCE__%%");
|
||||||
|
@ -84,6 +80,12 @@ public class UpdateManager {
|
||||||
this.download_time = Integer.parseInt("%%__TIMESTAMP__%%");
|
this.download_time = Integer.parseInt("%%__TIMESTAMP__%%");
|
||||||
this.download_token = "%%__VERIFY_TOKEN__%%";
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue