-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an OnPvP compatability event (#356)
* Added an OnPvP compatability event See Issue #338: #338 * Fixed duplicate LivingAttackEvents Alleviate the Forge bug causing duplicate posts of the LivingAttackEvent. Forge posts this event twice, once in EntityPlayer, and once in EntityLivingBase, so this tells if an EntityPlayer got hurt but the event was posted as an EntityLivingBase, then immediately returns, so nothing important gets run twice. * Review 1: Added an OnPvP compatability event * Improved pvpadmin command `pvpadmin resetCooldown <player>` and `pvpadmin spy <player> [on|off]` * Review 2: Added an OnPvP compatability event Co-Authored-By: Mahtaran <[email protected]> Update src/main/java/pvpmode/api/server/compatibility/events/OnPvPEvent.java Co-Authored-By: Mahtaran <[email protected]>
- Loading branch information
1 parent
6ac8c46
commit 1bd1f48
Showing
3 changed files
with
156 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/pvpmode/api/server/compatibility/events/OnPvPEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package pvpmode.api.server.compatibility.events; | ||
|
||
import cpw.mods.fml.common.eventhandler.*; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.DamageSource; | ||
import pvpmode.api.common.EnumPvPMode; | ||
|
||
/** | ||
* Fired when a player attacks another player. | ||
* | ||
* @author Vinyarion | ||
* | ||
*/ | ||
@Cancelable | ||
public class OnPvPEvent extends Event | ||
{ | ||
|
||
private final EntityPlayer attacker; | ||
private final EnumPvPMode attackerMode; | ||
private final EntityPlayer victim; | ||
private final EnumPvPMode victimMode; | ||
private final float damageAmount; | ||
private final DamageSource source; | ||
|
||
public OnPvPEvent (EntityPlayer attacker, EnumPvPMode attackerMode, EntityPlayer victim, EnumPvPMode victimMode, float damageAmount, DamageSource source) | ||
{ | ||
this.attacker = attacker; | ||
this.attackerMode = attackerMode; | ||
this.victim = victim; | ||
this.victimMode = victimMode; | ||
this.damageAmount = damageAmount; | ||
this.source = source; | ||
} | ||
|
||
/** | ||
* Returns the attacker | ||
*/ | ||
public EntityPlayer getAttacker () | ||
{ | ||
return attacker; | ||
} | ||
|
||
/** | ||
* Returns the attacker's mode | ||
*/ | ||
public EnumPvPMode getAttackerMode () | ||
{ | ||
return attackerMode; | ||
} | ||
|
||
/** | ||
* Returns the victim | ||
*/ | ||
public EntityPlayer getVictim () | ||
{ | ||
return victim; | ||
} | ||
|
||
/** | ||
* Returns the victim's mode | ||
*/ | ||
public EnumPvPMode getVictimMode () | ||
{ | ||
return victimMode; | ||
} | ||
|
||
/** | ||
* Returns the amount of damage to be dealt | ||
*/ | ||
public float getDamageAmount () | ||
{ | ||
return damageAmount; | ||
} | ||
|
||
/** | ||
* Returns the damage source | ||
*/ | ||
public DamageSource getSource () | ||
{ | ||
return source; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters