Factions/src/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java

57 lines
2.0 KiB
Java
Raw Normal View History

2013-09-21 11:32:39 +02:00
package com.massivecraft.factions.event;
2017-03-24 13:05:58 +01:00
import com.massivecraft.factions.engine.DisallowCause;
import com.massivecraft.factions.entity.MPlayer;
2013-09-21 11:32:39 +02:00
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
2013-09-21 11:43:11 +02:00
* This event is fired when PVP is disallowed between players due to any rules in Factions.
* Canceling this event allows the PVP in spite of this and stops text messages from being sent.
2013-09-21 11:32:39 +02:00
*
* Note that the defender field always is set but the attacker can be null.
* Some other plugins seem to fire EntityDamageByEntityEvent without an attacker.
*/
2014-06-04 16:47:01 +02:00
public class EventFactionsPvpDisallowed extends EventFactionsAbstract
2013-09-21 11:32:39 +02:00
{
// -------------------------------------------- //
// REQUIRED EVENT CODE
// -------------------------------------------- //
private static final HandlerList handlers = new HandlerList();
@Override public HandlerList getHandlers() { return handlers; }
public static HandlerList getHandlerList() { return handlers; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final Player attacker;
public Player getAttacker() { return this.attacker; }
public MPlayer getMAttacker() { return this.attacker == null ? null : MPlayer.get(this.attacker); }
2013-09-21 11:32:39 +02:00
private final Player defender;
public Player getDefender() { return this.defender; }
public MPlayer getMDefender() { return this.defender == null ? null : MPlayer.get(this.defender); }
2013-09-21 11:32:39 +02:00
private final DisallowCause cause;
public DisallowCause getCause() { return this.cause; }
2013-09-21 11:32:39 +02:00
private final EntityDamageByEntityEvent event;
public EntityDamageByEntityEvent getEvent() { return this.event; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public EventFactionsPvpDisallowed(Player attacker, Player defender, DisallowCause cause, EntityDamageByEntityEvent event)
2013-09-21 11:32:39 +02:00
{
this.attacker = attacker;
this.defender = defender;
this.cause = cause;
2013-09-21 11:32:39 +02:00
this.event = event;
}
}