package net.simpvp.Misc;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPotionEffectEvent;
import org.bukkit.potion.PotionEffectType;

//This file disables elder guardians from giving mining fatigue within 100 blocks of spawn
public class PotionEffectListener implements Listener {
	
	@EventHandler
	public void potionEffectEvent(EntityPotionEffectEvent event) {
		
		//Check if world name is in the config
		if (!Misc.instance.getConfig().getList("disableElderGuardians").contains(event.getEntity().getWorld().getName())) {
			return;
		}
		
		//If entity is less than 100 blocks from spawn
		if (event.getEntity().getLocation().distance(event.getEntity().getWorld().getSpawnLocation()) <= 100) {
			//If potion equals mining fatigue and the event is from the "attack" cause
			if (event.getModifiedType().equals(PotionEffectType.SLOW_DIGGING) && event.getCause().equals(EntityPotionEffectEvent.Cause.ATTACK)) {
				//Cancel event
				event.setCancelled(true);
			}
		}
	}
}

@@ -350,16 +350,104 @@
 r %7B%0D%0A%09%0D%0A
+%09List%3C?%3E listOfWorlds = Misc.instance.getConfig().getList(%22disableElderGuardians%22);%0D%0A%09%0D%0A
 %09@EventH
@@ -576,66 +576,20 @@
 f (!
-Misc.instance.getConfig().getList(%22disableElderGuardians%22)
+listOfWorlds
 .con
@@ -755,16 +755,23 @@
 distance
+Squared
 (event.g
@@ -815,16 +815,20 @@
 n()) %3C= 
+100*
 100) %7B%0D%0A

Update PotionEffectListener.java