summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRigby <rigby@onarandombox.com>2011-06-18 00:59:14 +0100
committerEvilSeph <evilseph@unaligned.org>2011-06-20 18:30:47 -0400
commite3462769c127b7502849a9878d295f9d92a0cd97 (patch)
treecd7b462d01a8bb2e1d2f45d6d5e06c8e9c2d06c9 /src
parent82a04fda101718271881b35fe4dd8237a3c65576 (diff)
downloadbukkit-e3462769c127b7502849a9878d295f9d92a0cd97.tar
bukkit-e3462769c127b7502849a9878d295f9d92a0cd97.tar.gz
bukkit-e3462769c127b7502849a9878d295f9d92a0cd97.tar.lz
bukkit-e3462769c127b7502849a9878d295f9d92a0cd97.tar.xz
bukkit-e3462769c127b7502849a9878d295f9d92a0cd97.zip
Implements customiseable PortalTravelAgent and updated PlayerPortalEvent.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/TravelAgent.java70
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerPortalEvent.java24
2 files changed, 88 insertions, 6 deletions
diff --git a/src/main/java/org/bukkit/TravelAgent.java b/src/main/java/org/bukkit/TravelAgent.java
new file mode 100644
index 00000000..25beb09c
--- /dev/null
+++ b/src/main/java/org/bukkit/TravelAgent.java
@@ -0,0 +1,70 @@
+package org.bukkit;
+
+public interface TravelAgent {
+
+ /**
+ * Set the Block radius to search in for available portals.
+ *
+ * @param radius The radius in which to search for a portal from the location.
+ * @return
+ */
+ public TravelAgent setSearchRadius(int radius);
+
+ /**
+ * Gets the search radius value for finding an available portal.
+ *
+ * @return Returns the currently set search radius.
+ */
+ public int getSearchRadius();
+
+ /**
+ * Sets the maximum radius from the given location to create a portal.
+ *
+ * @param radius The radius in which to create a portal from the location.
+ * @return
+ */
+ public TravelAgent setCreationRadius(int radius);
+
+ /**
+ * Gets the maximum radius from the given location to create a portal.
+ *
+ * @return Returns the currently set creation radius.
+ */
+ public int getCreationRadius();
+
+ /**
+ * Returns whether the TravelAgent will attempt to create a destination portal or not.
+ *
+ * @return Return whether the TravelAgent should create a destination portal or not.
+ */
+ public boolean getCanCreatePortal();
+
+ /**
+ * Sets whether the TravelAgent should attempt to create a destination portal or not.
+ *
+ * @param create Sets whether the TravelAgent should create a destination portal or not.
+ */
+ public void setCanCreatePortal(boolean create);
+
+ /**
+ * Attempt to find a portal near the given location, if a portal is not found it will attempt to create one.
+ *
+ * @param location The location where the search for a portal should begin.
+ * @return Returns the location of a portal which has been found or returns the location passed to the method if unsuccessful.
+ */
+ public Location findOrCreate(Location location);
+
+ /**
+ * Attempt to find a portal near the given location.
+ *
+ * @return Returns the location of the nearest portal to the location.
+ */
+ public Location findPortal(Location location);
+
+ /**
+ * Attempt to create a portal near the given location.
+ *
+ * @return True if a nether portal was successfully created.
+ */
+ public boolean createPortal(Location location);
+} \ No newline at end of file
diff --git a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
index 23b966ad..01f64362 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
@@ -1,18 +1,22 @@
package org.bukkit.event.player;
-
import org.bukkit.Location;
+import org.bukkit.TravelAgent;
import org.bukkit.entity.Player;
-import org.bukkit.block.Block;
-
/**
* Called when a player completes the portaling process by standing in a portal
*/
public class PlayerPortalEvent extends PlayerTeleportEvent {
- private boolean useTravelAgent = true;
- public PlayerPortalEvent(Player player, Location from, Location to) {
+
+ protected boolean useTravelAgent = true;
+
+ protected Player player;
+ protected TravelAgent travelAgent;
+
+ public PlayerPortalEvent(Player player, Location from, Location to, TravelAgent pta) {
super(Type.PLAYER_PORTAL, player, from, to);
+ this.travelAgent = pta;
}
public void useTravelAgent(boolean useTravelAgent) {
@@ -22,4 +26,12 @@ public class PlayerPortalEvent extends PlayerTeleportEvent {
public boolean useTravelAgent() {
return useTravelAgent;
}
-}
+
+ public TravelAgent getPortalTravelAgent() {
+ return this.travelAgent;
+ }
+
+ public void setPortalTravelAgent(TravelAgent travelAgent) {
+ this.travelAgent = travelAgent;
+ }
+} \ No newline at end of file