ResExtras/src/main/java/cn/citycraft/ResExtras/flags/God.java

39 lines
1.3 KiB
Java

package cn.citycraft.ResExtras.flags;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
public class God implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onGod(final EntityDamageEvent event) {
try {
final Entity entity = event.getEntity();
final Player player = ((Player) event.getEntity());
final World world = player.getWorld();
final String playername = player.getName();
final Location location = player.getLocation();
final ClaimedResidence res = Residence.getResidenceManager().getByLoc(entity.getLocation());
if (event.getEntity() instanceof Player) {
if (res != null) {
if (res.getPermissions().playerHas(playername, "god", false)) {
world.playEffect(location, Effect.MOBSPAWNER_FLAMES, 4);
event.setCancelled(true);
}
}
}
} catch (final Exception ex) {
}
}
}