package tk.royalcraf.royalcommands;

import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;

public class RoyalCommandsEntityListener extends EntityListener {

	public static RoyalCommands plugin;

	public RoyalCommandsEntityListener(RoyalCommands instance) {
		plugin = instance;
	}

	public void onEntityDamage(EntityDamageEvent event) {
		if (event.getEntity() instanceof Player) {
			Player p = (Player) event.getEntity();
			if (PConfManager.getPValBoolean((OfflinePlayer) p, "godmode")) {
				event.setCancelled(true);
			}
		}
	}

	public void onEntityTarget(EntityTargetEvent event) {
		if (event.getTarget() instanceof Player) {
			Player p = (Player) event.getTarget();
			if (plugin.isAuthorized(p, "rcmds.notarget")) {
				event.setCancelled(true);
			}
		}
	}

	public void onFoodLevelChange(FoodLevelChangeEvent event) {
		if (event.getEntity() instanceof Player) {
			Player p = (Player) event.getEntity();
			if (PConfManager.getPValBoolean((OfflinePlayer) p, "godmode")) {
				event.setFoodLevel(20);
			}
		}
	}

}

@@ -88,22 +88,152 @@
 .entity.
-Player
+Entity;%0Aimport org.bukkit.entity.LivingEntity;%0Aimport org.bukkit.entity.Player;%0Aimport org.bukkit.event.entity.EntityDamageByEntityEvent
 ;%0Aimport
@@ -615,24 +615,24 @@
 stance;%0A%09%7D%0A%0A
-
 %09public void
@@ -666,32 +666,502 @@
 eEvent event) %7B%0A
+%09%09if (event instanceof EntityDamageByEntityEvent) %7B%0A%09%09%09EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;%0A%09%09%09Entity e = ev.getDamager();%0A%09%09%09Entity ed = ev.getEntity();%0A%09%09%09if (e instanceof Player) %7B%0A%09%09%09%09Player p = (Player) e;%0A%09%09%09%09if (PConfManager.getPValBoolean((OfflinePlayer) p, %22ohk%22)) %7B%0A%09%09%09%09%09if (ed instanceof LivingEntity) %7B%0A%09%09%09%09%09%09LivingEntity le = (LivingEntity) ed;%0A%09%09%09%09%09%09int leh = le.getMaxHealth();%0A%09%09%09%09%09%09le.damage(leh + 1);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A
 %09%09if (event.getE

Support for /ohk