diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/DamageListener.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/DamageListener.java index eb917b0..cdbe987 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/DamageListener.java +++ b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/DamageListener.java @@ -26,20 +26,17 @@ package net.foxdenstudio.sponge.foxguard.plugin.listener; import com.flowpowered.math.vector.Vector3d; +import com.google.common.collect.ImmutableList; import net.foxdenstudio.sponge.foxguard.plugin.FGManager; import net.foxdenstudio.sponge.foxguard.plugin.FoxGuardMain; -import net.foxdenstudio.sponge.foxguard.plugin.flag.Flag; import net.foxdenstudio.sponge.foxguard.plugin.flag.FlagSet; import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler; -import net.foxdenstudio.sponge.foxguard.plugin.listener.util.FGListenerUtil; +import net.foxdenstudio.sponge.foxguard.plugin.listener.util.EntityFlagCalculator; import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject; import net.foxdenstudio.sponge.foxguard.plugin.util.ExtraContext; import org.spongepowered.api.entity.Entity; -import org.spongepowered.api.entity.hanging.Hanging; -import org.spongepowered.api.entity.living.*; +import org.spongepowered.api.entity.living.Living; import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.entity.vehicle.Boat; -import org.spongepowered.api.entity.vehicle.minecart.Minecart; import org.spongepowered.api.event.EventListener; import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.cause.entity.damage.DamageModifier; @@ -65,6 +62,7 @@ */ public class DamageListener implements EventListener { + private static final EntityFlagCalculator ENTITY_FLAG_CALCULATOR = EntityFlagCalculator.getInstance(); private static final boolean[] BASE_FLAGS_SOURCE = FlagSet.arrayFromFlags(ROOT, DEBUFF, DAMAGE, ENTITY); private static final boolean[] INVINCIBLE_FLAGS = FlagSet.arrayFromFlags(ROOT, BUFF, INVINCIBLE); private static final FlagSet INVINCIBLE_FLAG_SET = new FlagSet(INVINCIBLE_FLAGS); @@ -115,7 +113,9 @@ public void handle(DamageEntityEvent event) throws Exception { flags = BASE_FLAGS_SOURCE.clone(); - FGListenerUtil.applyEntityFlags(entity, flags); + //FGListenerUtil.applyEntityFlags(entity, flags); + ENTITY_FLAG_CALCULATOR.applyEntityFlags(ImmutableList.of(entity), flags); + flagSet = new FlagSet(flags); currPriority = handlerList.get(0).getPriority(); diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/InteractEntityListener.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/InteractEntityListener.java index be2d6d5..268877a 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/InteractEntityListener.java +++ b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/InteractEntityListener.java @@ -32,10 +32,8 @@ import net.foxdenstudio.sponge.foxguard.plugin.flag.FlagSet; import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler; import net.foxdenstudio.sponge.foxguard.plugin.listener.util.EntityFlagCalculator; -import net.foxdenstudio.sponge.foxguard.plugin.listener.util.FGListenerUtil; import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject; import net.foxdenstudio.sponge.foxguard.plugin.util.ExtraContext; -import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.User; import org.spongepowered.api.event.EventListener; diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/util/FGListenerUtil.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/util/FGListenerUtil.java deleted file mode 100644 index 88f5d16..0000000 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/util/FGListenerUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.foxdenstudio.sponge.foxguard.plugin.listener.util; - -import org.spongepowered.api.entity.Entity; -import org.spongepowered.api.entity.hanging.Hanging; -import org.spongepowered.api.entity.living.*; -import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.entity.vehicle.Boat; -import org.spongepowered.api.entity.vehicle.minecart.Minecart; - -import java.util.Collection; - -import static net.foxdenstudio.sponge.foxguard.plugin.flag.Flags.*; - -public class FGListenerUtil { - - public static void applyEntityFlags(Entity entity, boolean[] flags){ - if (entity instanceof Living) { - flags[LIVING.id] = true; - if (entity instanceof Agent) { - flags[AGENT.id] = true; - if (entity instanceof Hostile) { - flags[HOSTILE.id] = true; - } else if (entity instanceof Human) { - flags[HUMAN.id] = true; - } else { - flags[PASSIVE.id] = true; - } - } else if (entity instanceof Player) { - flags[PLAYER.id] = true; - } else if (entity instanceof ArmorStand) { - flags[ARMORSTAND.id] = true; - } - } else if (entity instanceof Hanging) { - flags[HANGING.id] = true; - } else if (entity instanceof Boat) { - flags[BOAT.id] = true; - } else if (entity instanceof Minecart) { - flags[MINECART.id] = true; - } - } -}