Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Fix inv provider not working on 1.8 servers
Dieser Commit ist enthalten in:
Ursprung
5a7626f280
Commit
d57ef2b303
@ -16,6 +16,7 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
import us.myles.ViaVersion.bukkit.protocol1_12to1_11_1.BukkitInvContainerUpdateTask;
|
import us.myles.ViaVersion.bukkit.protocol1_12to1_11_1.BukkitInvContainerUpdateTask;
|
||||||
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
import us.myles.ViaVersion.bukkit.util.NMSUtil;
|
||||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||||
@ -68,6 +69,9 @@ public class BukkitInvContainerItemProvider extends InvContainerItemProvider {
|
|||||||
}
|
}
|
||||||
InventoryView inv = p.getOpenInventory();
|
InventoryView inv = p.getOpenInventory();
|
||||||
short slotId = storage.getSlotId();
|
short slotId = storage.getSlotId();
|
||||||
|
if (slotId < 0) { // clicked out of inv slot
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (slotId > inv.countSlots()) {
|
if (slotId > inv.countSlots()) {
|
||||||
return null; // wrong container open?
|
return null; // wrong container open?
|
||||||
}
|
}
|
||||||
@ -85,9 +89,9 @@ public class BukkitInvContainerItemProvider extends InvContainerItemProvider {
|
|||||||
ReflectionUtil.set(cinstance, "d", storage.getActionNumber());
|
ReflectionUtil.set(cinstance, "d", storage.getActionNumber());
|
||||||
ReflectionUtil.set(cinstance, "item", nmsItem);
|
ReflectionUtil.set(cinstance, "item", nmsItem);
|
||||||
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
|
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
|
||||||
if (protocolId == 47) {
|
if (protocolId == ProtocolVersion.v1_8.getId()) {
|
||||||
ReflectionUtil.set(cinstance, "shift", 1);
|
ReflectionUtil.set(cinstance, "shift", 1);
|
||||||
} else if (protocolId >= 107) { // 1.9+
|
} else if (protocolId >= ProtocolVersion.v1_9.getId()) { // 1.9+
|
||||||
ReflectionUtil.set(cinstance, "shift", clickTypeEnum);
|
ReflectionUtil.set(cinstance, "shift", clickTypeEnum);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -128,14 +132,17 @@ public class BukkitInvContainerItemProvider extends InvContainerItemProvider {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.wclickPacketClass = NMSUtil.nms("PacketPlayInWindowClick");
|
this.wclickPacketClass = NMSUtil.nms("PacketPlayInWindowClick");
|
||||||
|
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
|
||||||
|
if (protocolId >= ProtocolVersion.v1_9.getId()) {
|
||||||
Class<?> eclassz = NMSUtil.nms("InventoryClickType");
|
Class<?> eclassz = NMSUtil.nms("InventoryClickType");
|
||||||
Object[] constants = eclassz.getEnumConstants();
|
Object[] constants = eclassz.getEnumConstants();
|
||||||
this.clickTypeEnum = constants[1]; // QUICK_MOVE
|
this.clickTypeEnum = constants[1]; // QUICK_MOVE
|
||||||
|
}
|
||||||
Class<?> citemStack = NMSUtil.obc("inventory.CraftItemStack");
|
Class<?> citemStack = NMSUtil.obc("inventory.CraftItemStack");
|
||||||
this.nmsItemMethod = citemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
|
this.nmsItemMethod = citemStack.getDeclaredMethod("asNMSCopy", ItemStack.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.supported = false;
|
this.supported = false;
|
||||||
return;
|
throw new RuntimeException("Couldn't find required inventory classes", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.ephandle = NMSUtil.obc("entity.CraftPlayer").getDeclaredMethod("getHandle");
|
this.ephandle = NMSUtil.obc("entity.CraftPlayer").getDeclaredMethod("getHandle");
|
||||||
@ -159,10 +166,10 @@ public class BukkitInvContainerItemProvider extends InvContainerItemProvider {
|
|||||||
|
|
||||||
private boolean isSupported() {
|
private boolean isSupported() {
|
||||||
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
|
int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
|
||||||
if (protocolId >= 47 && protocolId <= 316) {
|
if (protocolId >= ProtocolVersion.v1_8.getId() && protocolId <= ProtocolVersion.v1_11_1.getId()) {
|
||||||
return true; // 1.8
|
return true; // 1.8-1.11.2
|
||||||
}
|
}
|
||||||
// this is not needed on 1.12+
|
// this is not needed on 1.12+ servers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren