Permalink
Browse files

Implement new Interface.

  • Loading branch information...
1 parent 2f986fc commit 0e04a9116b94b3a3575764319131daf08bde1fa6 @FernFerret FernFerret committed Aug 4, 2011
View
@@ -2,4 +2,4 @@ Copyright (c) 2011, The Multiverse Team All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the FernFerret Studios nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -10,14 +10,14 @@
import org.bukkit.util.config.Configuration;
import com.onarandombox.MultiverseCore.MVWorld;
-import com.onarandombox.utils.Destination;
+import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.ExactDestination;
import com.onarandombox.utils.InvalidDestination;
public class MVPortal {
private String name;
private PortalLocation location;
- private Destination destination;
+ private MVDestination destination;
private Configuration config;
private MultiversePortals plugin;
private String owner;
@@ -201,7 +201,7 @@ public boolean playerCanEnterPortal(Player player) {
return (this.plugin.getCore().getPermissions().hasPermission(player, this.permission.getName(), false));
}
- public Destination getDestination() {
+ public MVDestination getDestination() {
return this.destination;
}
@@ -1,5 +1,7 @@
package com.onarandombox.MultiversePortals;
+import java.util.logging.Level;
+
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@@ -11,18 +13,14 @@
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiversePortals.utils.MultiverseRegion;
import com.onarandombox.MultiversePortals.utils.PortalManager;
-//import com.sk89q.worldedit.IncompleteRegionException;
-//import com.sk89q.worldedit.LocalSession;
-//import com.sk89q.worldedit.bukkit.WorldEditAPI;
-//import com.sk89q.worldedit.regions.Region;
public class PortalPlayerSession {
private MultiversePortals plugin;
private String playerName;
private MVPortal portalSelection = null;
private MVPortal standingIn = null;
- private boolean debugMode = false ;
+ private boolean debugMode = false;
private boolean staleLocation;
private boolean hasMovedOutOfPortal = true;
private Location loc;
@@ -45,7 +43,7 @@ public boolean selectPortal(MVPortal portal) {
public MVPortal getSelectedPortal() {
return this.portalSelection;
}
-
+
private Player getPlayerFromName() {
return this.plugin.getServer().getPlayer(playerName);
}
@@ -205,9 +203,12 @@ public boolean showDebugInfo() {
}
public boolean showDebugInfo(MVPortal portal) {
-
- showStaticInfo(this.getPlayerFromName(), portal, "Portal Info ");
- showPortalPriceInfo(portal);
+ if (this.plugin.getCore().getPermissions().hasPermission(this.getPlayerFromName(), "multiverse.portal.access." + portal.getName(), true)) {
+ showStaticInfo(this.getPlayerFromName(), portal, "Portal Info ");
+ showPortalPriceInfo(portal);
+ } else {
+ this.plugin.log(Level.INFO, "Player " + this.playerName + " walked through" + portal.getName() + " with debug on.");
+ }
return true;
}
@@ -224,7 +225,11 @@ private void showPortalPriceInfo(MVPortal portal) {
public static void showStaticInfo(CommandSender sender, MVPortal portal, String message) {
sender.sendMessage(message + ChatColor.DARK_AQUA + portal.getName());
sender.sendMessage("It's coords are: " + ChatColor.GOLD + portal.getLocation().toString());
- sender.sendMessage("It will take you to a location of type: " + ChatColor.AQUA + portal.getDestination().getType());
- sender.sendMessage("The destination's name is: " + ChatColor.GREEN + portal.getDestination().getName());
+ if (portal.getDestination() == null) {
+ sender.sendMessage("This portal has " + ChatColor.RED + "NO DESTINATION SET.");
+ } else {
+ sender.sendMessage("It will take you to a location of type: " + ChatColor.AQUA + portal.getDestination().getType());
+ sender.sendMessage("The destination's name is: " + ChatColor.GREEN + portal.getDestination().getName());
+ }
}
}
@@ -17,7 +17,7 @@
import com.onarandombox.MultiversePortals.MVPortal;
import com.onarandombox.MultiversePortals.MultiversePortals;
import com.onarandombox.MultiversePortals.PortalPlayerSession;
-import com.onarandombox.utils.Destination;
+import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.InvalidDestination;
public class MVPPlayerListener extends PlayerListener {
@@ -79,7 +79,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
// AND if we did not show debug info, do the stuff
// The debug is meant to toggle.
if (portal != null && ps.doTeleportPlayer(Type.PLAYER_MOVE) && !ps.showDebugInfo()) {
- Destination d = portal.getDestination();
+ MVDestination d = portal.getDestination();
if (d == null) {
return;
}
@@ -13,7 +13,7 @@
import com.onarandombox.MultiversePortals.MultiversePortals;
import com.onarandombox.MultiversePortals.PortalPlayerSession;
import com.onarandombox.MultiversePortals.utils.PortalDestination;
-import com.onarandombox.utils.Destination;
+import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.InvalidDestination;
import com.onarandombox.utils.LocationManipulation;
@@ -47,7 +47,7 @@ private boolean teleportVehicle(Player p, Vehicle v, Location to) {
// The debug is meant to toggle.
if (portal != null && ps.doTeleportPlayer(Type.VEHICLE_MOVE) && !ps.showDebugInfo()) {
// TODO: Money
- Destination d = portal.getDestination();
+ MVDestination d = portal.getDestination();
if (d == null || d instanceof InvalidDestination) {
return false;
}
@@ -6,10 +6,10 @@
import com.onarandombox.MultiversePortals.MVPortal;
import com.onarandombox.MultiversePortals.MultiversePortals;
import com.onarandombox.MultiversePortals.PortalLocation;
-import com.onarandombox.utils.Destination;
+import com.onarandombox.utils.MVDestination;
import com.onarandombox.utils.LocationManipulation;
-public class PortalDestination extends Destination {
+public class PortalDestination implements MVDestination {
private MVPortal portal;
private boolean isValid;
private String orientationString;
@@ -101,4 +101,9 @@ public String getOrientationString() {
return this.orientationString;
}
+ public String getRequiredPermission() {
+ System.out.print("Requested permission for " + portal.getName());
+ return "multiverse.portal.access." + this.portal.getName();
+ }
+
}

0 comments on commit 0e04a91

Please sign in to comment.