From cd5c18157cfea7d916b94a8f59ba927bb11b3c41 Mon Sep 17 00:00:00 2001 From: Zelytra Date: Thu, 26 Aug 2021 19:11:34 +0200 Subject: [PATCH] Fix spectator ejected by guardian --- src/main/java/fr/zelytra/daedalus/commands/test.java | 5 +++-- .../java/fr/zelytra/daedalus/managers/guardian/Guardian.java | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/zelytra/daedalus/commands/test.java b/src/main/java/fr/zelytra/daedalus/commands/test.java index 1e27f76..83031fb 100644 --- a/src/main/java/fr/zelytra/daedalus/commands/test.java +++ b/src/main/java/fr/zelytra/daedalus/commands/test.java @@ -1,5 +1,6 @@ package fr.zelytra.daedalus.commands; +import fr.zelytra.daedalus.Daedalus; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -10,10 +11,10 @@ public class test implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if(!(sender instanceof Player)){ + if (!(sender instanceof Player)) { return false; } - + Daedalus.getInstance().getGameManager().getTimeManager().episode = Integer.parseInt(args[0]); return true; } } diff --git a/src/main/java/fr/zelytra/daedalus/managers/guardian/Guardian.java b/src/main/java/fr/zelytra/daedalus/managers/guardian/Guardian.java index 5e8b984..0c5953a 100644 --- a/src/main/java/fr/zelytra/daedalus/managers/guardian/Guardian.java +++ b/src/main/java/fr/zelytra/daedalus/managers/guardian/Guardian.java @@ -255,6 +255,10 @@ private void ejection() { if (isPlayer) { for (Entity e : nearbyEntities) { + + if (e instanceof Player && ((Player) e).getGameMode() != GameMode.SURVIVAL) + continue; + Vector delta = new Vector(e.getLocation().getX() - entity.getLocation().getX(), 0, e.getLocation().getZ() - entity.getLocation().getZ()); double norme = Math.sqrt(Math.pow(delta.getX() + 0.01, 2) + Math.pow(delta.getY() + 0.01, 2) + Math.pow(delta.getZ() + 0.01, 2)); final int coef = 2;