Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Merge pull request #1432 from KennyTV/master
Fix hitbox listener on 1.8.0 servers
Dieser Commit ist enthalten in:
Commit
8ccba70788
@ -31,18 +31,24 @@ public class PlayerSneakListener extends ViaBukkitListener {
|
|||||||
private boolean is1_14Fix;
|
private boolean is1_14Fix;
|
||||||
private boolean useCache;
|
private boolean useCache;
|
||||||
|
|
||||||
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) {
|
public PlayerSneakListener(ViaVersionPlugin plugin, boolean is1_9Fix, boolean is1_14Fix) throws ReflectiveOperationException {
|
||||||
super(plugin, null);
|
super(plugin, null);
|
||||||
this.is1_9Fix = is1_9Fix;
|
this.is1_9Fix = is1_9Fix;
|
||||||
this.is1_14Fix = is1_14Fix;
|
this.is1_14Fix = is1_14Fix;
|
||||||
|
|
||||||
|
final String packageName = plugin.getServer().getClass().getPackage().getName();
|
||||||
|
getHandle = Class.forName(packageName + ".entity.CraftPlayer").getMethod("getHandle");
|
||||||
|
|
||||||
|
final Class<?> entityPlayerClass = Class.forName(packageName
|
||||||
|
.replace("org.bukkit.craftbukkit", "net.minecraft.server") + ".EntityPlayer");
|
||||||
try {
|
try {
|
||||||
getHandle = Class.forName(plugin.getServer().getClass().getPackage().getName() + ".entity.CraftPlayer").getMethod("getHandle");
|
setSize = entityPlayerClass.getMethod("setSize", Float.TYPE, Float.TYPE);
|
||||||
setSize = Class.forName(plugin.getServer().getClass().getPackage().getName()
|
} catch (NoSuchMethodException e) {
|
||||||
.replace("org.bukkit.craftbukkit", "net.minecraft.server") + ".EntityPlayer").getMethod("setSize", Float.TYPE, Float.TYPE);
|
// Don't catch this one
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
setSize = entityPlayerClass.getMethod("a", Float.TYPE, Float.TYPE);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// From 1.9 upwards the server hitbox is set in every entity tick, so we have to reset it everytime
|
// From 1.9 upwards the server hitbox is set in every entity tick, so we have to reset it everytime
|
||||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_9.getId()) {
|
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_9.getId()) {
|
||||||
sneaking = new WeakHashMap<>();
|
sneaking = new WeakHashMap<>();
|
||||||
|
@ -82,7 +82,12 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
|||||||
if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) {
|
if (ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_14.getId()) {
|
||||||
boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId();
|
boolean use1_9Fix = plugin.getConf().is1_9HitboxFix() && ProtocolRegistry.SERVER_PROTOCOL < ProtocolVersion.v1_9.getId();
|
||||||
if (use1_9Fix || plugin.getConf().is1_14HitboxFix()) {
|
if (use1_9Fix || plugin.getConf().is1_14HitboxFix()) {
|
||||||
|
try {
|
||||||
storeListener(new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix())).register();
|
storeListener(new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix())).register();
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
Via.getPlatform().getLogger().warning("Could not load hitbox fix - please report this on our GitHub");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren