package io.github.aquerr.eaglefactions.listeners;

import io.github.aquerr.eaglefactions.EagleFactions;
import io.github.aquerr.eaglefactions.logic.FactionLogic;
import io.github.aquerr.eaglefactions.logic.MainLogic;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityTypes;
import org.spongepowered.api.entity.living.monster.Monster;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.SpawnEntityEvent;
import org.spongepowered.api.world.World;

public class EntitySpawnListener
{
    @Listener
    public void onEntitySpawn(SpawnEntityEvent event)
    {
        for (Entity entity: event.getEntities())
        {
            EagleFactions.getEagleFactions().getLogger().info(entity.toString());

            if(entity instanceof Monster)
            {
                EagleFactions.getEagleFactions().getLogger().info("Entity is a monster!!!! :O");
                EagleFactions.getEagleFactions().getLogger().info("Printing enity type: " + entity.getType().toString());
                EagleFactions.getEagleFactions().getLogger().info("Prining spawn couse: " + event.getCause().toString());



                if(MainLogic.getMobSpawning() == false && FactionLogic.isClaimed(entity.getWorld().getUniqueId(), entity.getLocation().getChunkPosition()))
                {
                    event.setCancelled(true);
                    return;
                }
            }
            else
            {
                EagleFactions.getEagleFactions().getLogger().info("Entity is not a monster. :D");
                EagleFactions.getEagleFactions().getLogger().info("Printing enity type: " + entity.getType().toString());
                EagleFactions.getEagleFactions().getLogger().info("Prining spawn couse: " + event.getCause().toString());
            }

            //EntityType for CustomNPC (it counts as a monster) => EntityCustomNpc


        }
    }
}

@@ -303,16 +303,68 @@
 yTypes;%0A
+import org.spongepowered.api.entity.living.Hostile;%0A
 import o
@@ -793,32 +793,34 @@
   %7B%0A            
+//
 EagleFactions.ge
@@ -907,23 +907,196 @@
 tanceof 
-Monster
+Hostile)%0A            %7B%0A%0A%0A%0A                if(MainLogic.getMobSpawning() == false && FactionLogic.isClaimed(entity.getWorld().getUniqueId(), entity.getLocation().getChunkPosition())
 )%0A      
@@ -1093,34 +1093,42 @@
 )))%0A            
-%7B%0A
+    %7B%0A    
                 
@@ -1190,23 +1190,23 @@
 ty is a 
-monster
+Hostile
 !!!! :O%22
@@ -1216,32 +1216,36 @@
                 
+    
 EagleFactions.ge
@@ -1285,37 +1285,32 @@
 (%22Printing enity
- type
 : %22 + entity.get
@@ -1302,34 +1302,24 @@
  %22 + entity.
-getType().
 toString());
@@ -1327,32 +1327,36 @@
                 
+    
 EagleFactions.ge
@@ -1397,33 +1397,33 @@
 %22Prining spawn c
-o
+a
 use: %22 + event.g
@@ -1446,18 +1446,16 @@
 ng());%0A%0A
-%0A%0A
         
@@ -1466,239 +1466,276 @@
     
-if(MainLogic.getMobSpawning() == false && FactionLogic.isClaimed(entity.getWorld().getUniqueId(), entity.getLocation().getChunkPosition()))%0A                %7B%0A                    event.setCancelled(true);%0A                    return;
+    event.setCancelled(true);%0A                    return;%0A                %7D%0A            %7D%0A            else%0A            %7B%0A                if(FactionLogic.getFactionNameByChunk(entity.getWorld().getUniqueId(), entity.getLocation().getChunkPosition()).equals(%22SafeZone%22))
 %0A   
@@ -1739,37 +1739,34 @@
                 
-%7D%0A   
+%7B%0A
          %7D%0A     
@@ -1762,41 +1762,9 @@
     
-%7D%0A            else%0A            %7B%0A
+ 
     
@@ -1761,38 +1761,32 @@
                 
-      
 EagleFactions.ge
@@ -1834,29 +1834,24 @@
  is 
-not a monster
+friendly
 . :D%22);%0A
     
@@ -1842,24 +1842,28 @@
 ndly. :D%22);%0A
+    
             
@@ -1935,13 +1935,8 @@
 nity
- type
 : %22 
@@ -1948,18 +1948,8 @@
 ity.
-getType().
 toSt
@@ -1949,32 +1949,36 @@
 ty.toString());%0A
+    
                 
@@ -2043,17 +2043,17 @@
  spawn c
-o
+a
 use: %22 +
@@ -2075,32 +2075,50 @@
 ().toString());%0A
+                %7D%0A
             %7D%0A%0A 
@@ -2163,14 +2163,19 @@
 (it 
+isn't 
 count
-s
  as 

Check for Hostile Mobs