Add the PrePrisonerReleasedEvent for #9, not all that useful event tbh.
This commit is contained in:
parent
d0763b6c00
commit
22f2b66cf5
@ -11,6 +11,7 @@ import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
import com.graywolf336.jail.events.PrePrisonerReleasedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerReleasedEvent;
|
||||
|
||||
@ -316,6 +317,10 @@ public class PrisonerManager {
|
||||
if(prisoner == null)
|
||||
throw new Exception("Prisoner data can not be null.");
|
||||
|
||||
//Throw the custom event which is called before we start releasing them
|
||||
PrePrisonerReleasedEvent preEvent = new PrePrisonerReleasedEvent(jail, cell, prisoner, player);
|
||||
pl.getServer().getPluginManager().callEvent(preEvent);
|
||||
|
||||
//We are getting ready to teleport them, so set it to true so that
|
||||
//the *future* move checkers won't be canceling our moving.
|
||||
prisoner.setTeleporting(true);
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.graywolf336.jail.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
/**
|
||||
* Event thrown after a prisoner is released.
|
||||
*
|
||||
* <p />
|
||||
*
|
||||
* This event is called before everything for the releasing takes place.
|
||||
* This event is called for informative purposes, see {@link PrisonerReleasedEvent}
|
||||
* for the event called after they get teleported out and all that fancy stuff.
|
||||
*
|
||||
* @author graywolf336
|
||||
* @since 3.0.0
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrePrisonerReleasedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerReleasedEvent pre-prisoner released event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrePrisonerReleasedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being released. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user