Add the missing files, Github for windows missed it
This commit is contained in:
parent
384fa3601b
commit
806176ca1c
@ -18,6 +18,7 @@ import com.graywolf336.jail.beans.NoCell;
|
|||||||
import com.graywolf336.jail.beans.Prisoner;
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
import com.graywolf336.jail.enums.Lang;
|
import com.graywolf336.jail.enums.Lang;
|
||||||
import com.graywolf336.jail.enums.Settings;
|
import com.graywolf336.jail.enums.Settings;
|
||||||
|
import com.graywolf336.jail.events.OfflinePrisonerJailedEvent;
|
||||||
import com.graywolf336.jail.events.PrePrisonerReleasedEvent;
|
import com.graywolf336.jail.events.PrePrisonerReleasedEvent;
|
||||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||||
import com.graywolf336.jail.events.PrisonerReleasedEvent;
|
import com.graywolf336.jail.events.PrisonerReleasedEvent;
|
||||||
@ -89,11 +90,11 @@ public class PrisonerManager {
|
|||||||
* @throws JailRequiredException if the jail provided is null.
|
* @throws JailRequiredException if the jail provided is null.
|
||||||
* @throws PrisonerAlreadyJailedException if the prisoner is already jailed.
|
* @throws PrisonerAlreadyJailedException if the prisoner is already jailed.
|
||||||
* @throws PrisonerRequiredException if the prisoner's data provided is null.
|
* @throws PrisonerRequiredException if the prisoner's data provided is null.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void prepareJail(Jail jail, ICell cell, Player player, Prisoner prisoner) throws AsyncJailingNotSupportedException, JailRequiredException, PrisonerAlreadyJailedException, PrisonerRequiredException {
|
public void prepareJail(Jail jail, ICell cell, Player player, Prisoner prisoner) throws AsyncJailingNotSupportedException, JailRequiredException, PrisonerAlreadyJailedException, PrisonerRequiredException {
|
||||||
if(!pl.getServer().isPrimaryThread()) throw new AsyncJailingNotSupportedException();
|
if(!pl.getServer().isPrimaryThread()) throw new AsyncJailingNotSupportedException();
|
||||||
|
|
||||||
//Do some checks of whether the passed params are null.
|
//Do some checks of whether the passed params are null.
|
||||||
if(jail == null)
|
if(jail == null)
|
||||||
throw new JailRequiredException("jailing a prisoner");
|
throw new JailRequiredException("jailing a prisoner");
|
||||||
@ -106,7 +107,7 @@ public class PrisonerManager {
|
|||||||
|
|
||||||
if(this.pl.getJailManager().isPlayerJailed(prisoner.getUUID()))
|
if(this.pl.getJailManager().isPlayerJailed(prisoner.getUUID()))
|
||||||
throw new PrisonerAlreadyJailedException(prisoner.getLastKnownName(), prisoner.getUUID().toString());
|
throw new PrisonerAlreadyJailedException(prisoner.getLastKnownName(), prisoner.getUUID().toString());
|
||||||
|
|
||||||
//Set whether the prisoner is offline or not.
|
//Set whether the prisoner is offline or not.
|
||||||
prisoner.setOfflinePending(player == null);
|
prisoner.setOfflinePending(player == null);
|
||||||
|
|
||||||
@ -125,8 +126,10 @@ public class PrisonerManager {
|
|||||||
cell.setPrisoner(prisoner);
|
cell.setPrisoner(prisoner);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If they are NOT offline, jail them
|
//If they are are offline then throw the event otherwise jail them
|
||||||
if(!prisoner.isOfflinePending()) {
|
if(prisoner.isOfflinePending()) {
|
||||||
|
pl.getServer().getPluginManager().callEvent(new OfflinePrisonerJailedEvent(jail, cell, prisoner));
|
||||||
|
}else {
|
||||||
jailPrisoner(jail, cell, player, prisoner);
|
jailPrisoner(jail, cell, player, prisoner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +177,7 @@ public class PrisonerManager {
|
|||||||
cell = null;
|
cell = null;
|
||||||
else if(cell instanceof AnyCell)
|
else if(cell instanceof AnyCell)
|
||||||
cell = null;
|
cell = null;
|
||||||
|
|
||||||
//If they have handcuffs on them, then let's remove them before we continue
|
//If they have handcuffs on them, then let's remove them before we continue
|
||||||
//this way the handcuff listeners and this aren't battleing each other
|
//this way the handcuff listeners and this aren't battleing each other
|
||||||
if(pl.getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
if(pl.getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
||||||
@ -216,10 +219,10 @@ public class PrisonerManager {
|
|||||||
for(GameMode m : GameMode.values()) {
|
for(GameMode m : GameMode.values()) {
|
||||||
if(gamemodes.length() != 0)
|
if(gamemodes.length() != 0)
|
||||||
gamemodes.append(", ");
|
gamemodes.append(", ");
|
||||||
|
|
||||||
gamemodes.append(m.toString().toLowerCase());
|
gamemodes.append(m.toString().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.getLogger().warning("Your jailed gamemode setting is problematic. It is currently '"
|
pl.getLogger().warning("Your jailed gamemode setting is problematic. It is currently '"
|
||||||
+ pl.getConfig().getString(Settings.JAILEDGAMEMODE.getPath())
|
+ pl.getConfig().getString(Settings.JAILEDGAMEMODE.getPath())
|
||||||
+ "' and should be one of the following: " + gamemodes.toString());
|
+ "' and should be one of the following: " + gamemodes.toString());
|
||||||
@ -369,7 +372,7 @@ public class PrisonerManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules a prisoner to be released, this method is to be used <strong>async</strong>.
|
* Schedules a prisoner to be released, this method is to be used <strong>async</strong>.
|
||||||
*
|
*
|
||||||
* If you're wanting to unjail a prisoner, see the {@link #unJail(Jail, ICell, Player, Prisoner, CommandSender)} method.
|
* If you're wanting to unjail a prisoner, see the {@link #unJail(Jail, ICell, Player, Prisoner, CommandSender)} method.
|
||||||
*
|
*
|
||||||
* @param prisoner to be released.
|
* @param prisoner to be released.
|
||||||
@ -431,7 +434,7 @@ public class PrisonerManager {
|
|||||||
*/
|
*/
|
||||||
public void unJail(Jail jail, ICell cell, Player player, Prisoner prisoner, CommandSender sender) throws AsyncUnJailingNotSupportedException, JailRequiredException, PrisonerRequiredException {
|
public void unJail(Jail jail, ICell cell, Player player, Prisoner prisoner, CommandSender sender) throws AsyncUnJailingNotSupportedException, JailRequiredException, PrisonerRequiredException {
|
||||||
if(!pl.getServer().isPrimaryThread()) throw new AsyncUnJailingNotSupportedException();
|
if(!pl.getServer().isPrimaryThread()) throw new AsyncUnJailingNotSupportedException();
|
||||||
|
|
||||||
//Do some checks of whether the passed params are null.
|
//Do some checks of whether the passed params are null.
|
||||||
if(jail == null)
|
if(jail == null)
|
||||||
throw new JailRequiredException("unjailing a prisoner");
|
throw new JailRequiredException("unjailing a prisoner");
|
||||||
@ -440,7 +443,7 @@ public class PrisonerManager {
|
|||||||
cell = null;
|
cell = null;
|
||||||
else if(cell instanceof AnyCell)
|
else if(cell instanceof AnyCell)
|
||||||
cell = null;
|
cell = null;
|
||||||
|
|
||||||
if(prisoner == null)
|
if(prisoner == null)
|
||||||
throw new PrisonerRequiredException("unjailing a prisoner");
|
throw new PrisonerRequiredException("unjailing a prisoner");
|
||||||
|
|
||||||
@ -616,7 +619,7 @@ public class PrisonerManager {
|
|||||||
|
|
||||||
if(prisoner == null)
|
if(prisoner == null)
|
||||||
throw new PrisonerRequiredException("jailing a prisoner");
|
throw new PrisonerRequiredException("jailing a prisoner");
|
||||||
|
|
||||||
if(player == null) {
|
if(player == null) {
|
||||||
//Player is offline, we just forcefully remove them from the database
|
//Player is offline, we just forcefully remove them from the database
|
||||||
pl.getJailIO().removePrisoner(jail, cell, prisoner);
|
pl.getJailIO().removePrisoner(jail, cell, prisoner);
|
||||||
@ -627,6 +630,10 @@ public class PrisonerManager {
|
|||||||
cell.removePrisoner();
|
cell.removePrisoner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Call the prisoner released event as we have released them.
|
||||||
|
PrisonerReleasedEvent event = new PrisonerReleasedEvent(jail, cell, prisoner, player);
|
||||||
|
pl.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if(sender != null) sender.sendMessage(Lang.FORCEUNJAILED.get(prisoner.getLastKnownName()));
|
if(sender != null) sender.sendMessage(Lang.FORCEUNJAILED.get(prisoner.getLastKnownName()));
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
package com.graywolf336.jail.events;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.graywolf336.jail.beans.Jail;
|
||||||
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
|
import com.graywolf336.jail.interfaces.ICell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event thrown when a prisoner is offline put will be put into jail next time they come online.
|
||||||
|
*
|
||||||
|
* <p />
|
||||||
|
*
|
||||||
|
* This event is called before everything for the jailing takes place, as the player is offline.
|
||||||
|
* This event is called for informative purposes, see {@link PrePrisonerJailedEvent}
|
||||||
|
* for the event called before they teleported in and all that fancy stuff.
|
||||||
|
*
|
||||||
|
* @author graywolf336
|
||||||
|
* @since 3.0.0
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
public class OfflinePrisonerJailedEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private Jail jail;
|
||||||
|
private ICell cell;
|
||||||
|
private Prisoner prisoner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link OfflinePrisonerJailedEvent prisoner jailed event} for the given prisoner.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
public OfflinePrisonerJailedEvent(Jail jail, ICell cell, Prisoner prisoner) {
|
||||||
|
this.jail = jail;
|
||||||
|
this.cell = cell;
|
||||||
|
this.prisoner = prisoner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||||
|
public Jail getJail() {
|
||||||
|
return this.jail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the cell we're going to be sending the prisoner to, can be null. */
|
||||||
|
public ICell getCell() {
|
||||||
|
return this.cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Checks if there was a cell involved. */
|
||||||
|
public boolean hasCell() {
|
||||||
|
return this.cell != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||||
|
public Prisoner getPrisoner() {
|
||||||
|
return this.prisoner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the jailer who jailed this prisoner. */
|
||||||
|
public String getJailer() {
|
||||||
|
return this.prisoner.getJailer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the reason the prisoner was jailed. */
|
||||||
|
public String getReason() {
|
||||||
|
return this.prisoner.getReason();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user