Fix sulk sensors detecting vanished players (#5262)

This commit is contained in:
Josh Roy 2023-04-02 18:29:29 -04:00 committed by GitHub
parent 11e6d3ca7b
commit e7c56b32a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,6 +121,15 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
} }
} }
private static boolean isGameEventEvent() {
try {
Class.forName("org.bukkit.event.block.BlockReceiveGameEvent");
return true;
} catch (final ClassNotFoundException ignored) {
return false;
}
}
public void registerEvents() { public void registerEvents() {
ess.getServer().getPluginManager().registerEvents(this, ess); ess.getServer().getPluginManager().registerEvents(this, ess);
@ -128,6 +137,10 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
ess.getServer().getPluginManager().registerEvents(new ArrowPickupListener(), ess); ess.getServer().getPluginManager().registerEvents(new ArrowPickupListener(), ess);
} }
if (isGameEventEvent()) {
ess.getServer().getPluginManager().registerEvents(new SculkListener1_17(), ess);
}
if (isEntityPickupEvent()) { if (isEntityPickupEvent()) {
ess.getServer().getPluginManager().registerEvents(new PickupListener1_12(), ess); ess.getServer().getPluginManager().registerEvents(new PickupListener1_12(), ess);
} else { } else {
@ -1001,6 +1014,15 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
} }
} }
private final class SculkListener1_17 implements Listener {
@EventHandler
public void onGameEvent(final org.bukkit.event.block.BlockReceiveGameEvent event) {
if (event.getEntity() instanceof Player && ess.getUser((Player) event.getEntity()).isVanished()) {
event.setCancelled(true);
}
}
}
private final class CommandSendFilter implements CommandSendListenerProvider.Filter { private final class CommandSendFilter implements CommandSendListenerProvider.Filter {
@Override @Override
public Predicate<String> apply(Player player) { public Predicate<String> apply(Player player) {