package in.twizmwaz.cardinal.module.modules.appliedRegion.type;

import in.twizmwaz.cardinal.module.modules.appliedRegion.AppliedRegion;
import in.twizmwaz.cardinal.module.modules.filter.FilterModule;
import in.twizmwaz.cardinal.module.modules.filter.FilterState;
import in.twizmwaz.cardinal.module.modules.kit.Kit;
import in.twizmwaz.cardinal.module.modules.regions.RegionModule;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerMoveEvent;

public class KitRegion extends AppliedRegion {
    
    private final Kit kit;
    
    public KitRegion(RegionModule region, FilterModule filter, String message, Kit kit) {
        super(region, filter, message);
        this.kit = kit;
    }
    
    @EventHandler(priority = EventPriority.HIGH)
    public void onPlayerMove(PlayerMoveEvent event) {
        if (event.isCancelled()) return;
        if (region.contains(event.getTo().toVector()) && !region.contains(event.getFrom().toVector()) && (filter == null || filter.evaluate(event.getPlayer(), event.getTo(), event).equals(FilterState.ALLOW))) {
            kit.apply(event.getPlayer());
        }
    }
}

@@ -370,24 +370,68 @@
 gionModule;%0A
+import in.twizmwaz.cardinal.util.TeamUtils;%0A
 import org.b
@@ -456,16 +456,16 @@
 andler;%0A
-
 import o
@@ -542,16 +542,68 @@
 veEvent;
+%0Aimport org.bukkit.event.player.PlayerTeleportEvent;
 %0A%0Apublic
@@ -944,24 +944,24 @@
 nt event) %7B%0A
-
         if (
@@ -979,16 +979,556 @@
 celled()
+ %7C%7C TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver()) return;%0A        if (region.contains(event.getTo().toVector()) && !region.contains(event.getFrom().toVector()) && (filter == null %7C%7C filter.evaluate(event.getPlayer(), event.getTo(), event).equals(FilterState.ALLOW))) %7B%0A            kit.apply(event.getPlayer());%0A        %7D%0A    %7D%0A%0A    @EventHandler(priority = EventPriority.HIGH)%0A    public void onPlayerMove(PlayerTeleportEvent event) %7B%0A        if (event.isCancelled() %7C%7C TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver()
 ) return

Apply kits when player teleport to a region and isn't an observer