Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Essentials/src/com/earth2me/essentials/Teleport.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.earth2me.essentials.utils.LocationUtil;
import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.api.events.UserWarpEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerRespawnEvent;
Expand Down Expand Up @@ -247,6 +249,13 @@ protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exceptio
//The warp function is a wrapper used to teleportPlayer a player to a /warp
@Override
public void warp(IUser teleportee, String warp, Trade chargeFor, TeleportCause cause) throws Exception {
UserWarpEvent event = new UserWarpEvent(teleportee, warp, chargeFor);
Bukkit.getServer().getPluginManager().callEvent(event);

if(event.isCancelled()) {
return;
}
warp = event.getWarp();
Location loc = ess.getWarps().getWarp(warp);
teleportee.sendMessage(tl("warpingTo", warp, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
if (!teleportee.equals(teleportOwner)) {
Expand Down
65 changes: 65 additions & 0 deletions Essentials/src/net/ess3/api/events/UserWarpEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package net.ess3.api.events;

import com.earth2me.essentials.Trade;
import net.ess3.api.IUser;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when the player use the command /warp
*/
public class UserWarpEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();

private IUser user;
private String warp;
private Trade trade;
private boolean cancelled = false;


public UserWarpEvent(IUser user, String warp, Trade trade){
this.user = user;
this.warp = warp;
this.trade = trade;
}

public IUser getUser() {
return user;
}

public String getWarp() {
return warp;
}

/**
* Getting payment handling information
* @return The payment handling class
*/
public Trade getTrade() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps some javadocs would help?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should help. I am not that familiar with Javadocs tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I were to left documentation there, providing that all of other Events doesn't have any documentation except the heading of the class.

return trade;
}

public void setWarp(String warp) {
this.warp = warp;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean b) {
cancelled = b;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}
}