mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-26 12:36:11 +01:00
The warpevent is now activated
This commit is contained in:
parent
dff5950659
commit
ed2acbdb7a
@ -16,6 +16,7 @@ import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.portalcontrolls.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portalcontrolls.Portal;
|
||||
|
||||
@ -96,6 +97,10 @@ public class Listeners implements Listener {
|
||||
if(Portal.Portals[portalId].pos2.getX() <= loc.getX() && Portal.Portals[portalId].pos2.getY() <= loc.getY() && Portal.Portals[portalId].pos2.getZ() <= loc.getZ()){
|
||||
|
||||
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(DefaultPortalMessages && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
@ -108,6 +113,11 @@ public class Listeners implements Listener {
|
||||
player.teleport(fromloc);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(Portal.Portals[portalId].trigger.equals(Material.PORTAL)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
|
@ -5,6 +5,8 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
import com.sekwah.advancedportals.portalcontrolls.Portal;
|
||||
|
||||
public final class WarpEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
@ -14,17 +16,24 @@ public final class WarpEvent extends Event implements Cancellable {
|
||||
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private String message;
|
||||
private boolean cancelled;
|
||||
|
||||
private boolean cancelled = false;
|
||||
private Player player;
|
||||
private String portalName;
|
||||
|
||||
private boolean hasWarped = false;
|
||||
|
||||
public WarpEvent(Player player, String portalName) {
|
||||
// add code for the custom listener
|
||||
this.player = player;
|
||||
this.portalName = portalName;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the event has been cancelled
|
||||
*
|
||||
* @return cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
@ -33,6 +42,29 @@ public final class WarpEvent extends Event implements Cancellable {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the
|
||||
*
|
||||
* @param warped
|
||||
*/
|
||||
public void setHasWarped(boolean warped){
|
||||
this.hasWarped = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return true if another plugin has warped the player(and set this to true)
|
||||
*
|
||||
* @return hasWarped
|
||||
*/
|
||||
public boolean getHasWarped(){
|
||||
return hasWarped;
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
import com.sekwah.advancedportals.events.WarpEvent;
|
||||
|
||||
public class Portal {
|
||||
|
||||
@ -272,7 +273,6 @@ public class Portal {
|
||||
for(int i = keys.length - 1; i >= 0; i--){
|
||||
String key = keys[i].toString();
|
||||
if(key.startsWith(name + ".")){
|
||||
System.out.println(key);
|
||||
config.getConfig().set(key, null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user