mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 17:18:37 +01:00
parent
edd15132fd
commit
494e82e581
@ -38,6 +38,11 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarp(String name) {
|
||||
return warpPoints.containsKey(new StringIgnoreCase(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getList() {
|
||||
final List<String> keys = new ArrayList<>();
|
||||
|
@ -26,6 +26,14 @@ public interface IWarps extends IConf {
|
||||
*/
|
||||
Location getWarp(String warp) throws WarpNotFoundException, net.ess3.api.InvalidWorldException;
|
||||
|
||||
/**
|
||||
* Checks if the provided name is a warp.
|
||||
*
|
||||
* @param name The warp name.
|
||||
* @return true if a warp by that name exists.
|
||||
*/
|
||||
boolean isWarp(String name);
|
||||
|
||||
/**
|
||||
* Gets a list of warps
|
||||
*
|
||||
|
@ -23,8 +23,14 @@ public class Commanddelwarp extends EssentialsCommand {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
//Check if warp exists before calling the event
|
||||
final Location location = ess.getWarps().getWarp(args[0]);
|
||||
if (location != null) {
|
||||
if (ess.getWarps().isWarp(args[0])) {
|
||||
Location location;
|
||||
try {
|
||||
location = ess.getWarps().getWarp(args[0]);
|
||||
} catch (Exception ignored) {
|
||||
// World is unloaded/deleted
|
||||
location = null;
|
||||
}
|
||||
final WarpModifyEvent event = new WarpModifyEvent(sender.getUser(this.ess), args[0], location, null, WarpModifyEvent.WarpModifyCause.DELETE);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
|
@ -23,7 +23,7 @@ public class WarpModifyEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* @param user the {@link IUser} who is modifing the warp.
|
||||
* @param warpName the name of the warp that's being altered.
|
||||
* @param oldLocation the old location before being modified. Null if {@link WarpModifyCause#CREATE}.
|
||||
* @param oldLocation the old location before being modified. Null if {@link WarpModifyCause#CREATE} or if the previous location's world is not loaded.
|
||||
* @param newLocation the new location after being modified. Null if {@link WarpModifyCause#DELETE}.
|
||||
* @param cause the cause of change.
|
||||
*/
|
||||
@ -58,7 +58,7 @@ public class WarpModifyEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current location of the warp or null if it's being created.
|
||||
* Gets the current location of the warp or null if it's being created or if the previous location's world is not loaded.
|
||||
* @return The warps new location or null.
|
||||
*/
|
||||
public Location getOldLocation() {
|
||||
|
Loading…
Reference in New Issue
Block a user