mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Compatibility with new Dest Types.
This commit is contained in:
parent
de3e4ec1cb
commit
23158a0707
@ -108,6 +108,16 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
// TODO: Put our teleporter back in...
|
||||
teleportee.teleport(l);
|
||||
System.out.print("Unsure:");
|
||||
System.out.print(l);
|
||||
System.out.print("Safe:");
|
||||
Location safeLoc = this.playerTeleporter.getSafeDestination(l);
|
||||
System.out.print(safeLoc);
|
||||
if(safeLoc != null) {
|
||||
teleportee.teleport(safeLoc);
|
||||
} else {
|
||||
teleportee.teleport(l);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.onarandombox.utils.Destination;
|
||||
|
||||
public class MVTeleportEvent extends Event {
|
||||
private static final long serialVersionUID = 854826818438649269L;
|
||||
private Player player;
|
||||
private Destination dest;
|
||||
private String teleportString;
|
||||
|
||||
|
||||
public MVTeleportEvent(Destination dest, Player p, String teleportString) {
|
||||
super("MVTeleport");
|
||||
this.player = p;
|
||||
this.dest = dest;
|
||||
this.teleportString = teleportString;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getDestString() {
|
||||
return this.teleportString;
|
||||
}
|
||||
|
||||
public Class<? extends Destination> getDestType() {
|
||||
return this.dest.getClass();
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public abstract class Destination {
|
||||
public abstract String getIdentifer();
|
||||
public abstract boolean isThisType(MultiverseCore plugin, String dest);
|
||||
public abstract boolean isThisType(JavaPlugin plugin, String dest);
|
||||
public abstract Location getLocation();
|
||||
public abstract boolean isValid();
|
||||
public abstract void setDestination(MultiverseCore plugin, String dest);
|
||||
public abstract void setDestination(JavaPlugin plugin, String dest);
|
||||
public abstract String getType();
|
||||
public abstract String getName();
|
||||
public abstract String toString();
|
||||
|
@ -26,7 +26,7 @@ public class DestinationFactory {
|
||||
try {
|
||||
Destination mydest = myClass.newInstance();
|
||||
System.out.print(idenChar);
|
||||
if(!mydest.isThisType(plugin, dest)) {
|
||||
if(!mydest.isThisType((MultiverseCore) this.plugin, dest)) {
|
||||
System.out.print("Invalid A!");
|
||||
return new InvalidDestination();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
@ -18,7 +19,10 @@ public class ExactDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(MultiverseCore plugin, String destination) {
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return false;
|
||||
}
|
||||
System.out.print("Checking Exact Dest");
|
||||
List<String> parsed = Arrays.asList(destination.split(":"));
|
||||
// Need at least: e:world:x,y,z
|
||||
@ -35,7 +39,7 @@ public class ExactDestination extends Destination {
|
||||
}
|
||||
|
||||
// If it's not a MV world
|
||||
if (!plugin.isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore)plugin).isMVWorld(parsed.get(1))) {
|
||||
System.out.print("Not a MV world");
|
||||
return false;
|
||||
}
|
||||
@ -75,7 +79,10 @@ public class ExactDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(MultiverseCore plugin, String dest) {
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
if (!(plugin instanceof MultiverseCore)) {
|
||||
return;
|
||||
}
|
||||
List<String> parsed = Arrays.asList(dest.split(":"));
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
@ -90,11 +97,11 @@ public class ExactDestination extends Destination {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.isMVWorld(parsed.get(1))) {
|
||||
if (!((MultiverseCore)plugin).isMVWorld(parsed.get(1))) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
this.location = new Location(plugin.getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
this.location = new Location(((MultiverseCore)plugin).getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
|
||||
|
||||
if (!parsed.get(2).matches(this.coordRegex)) {
|
||||
this.isValid = false;
|
||||
|
@ -2,8 +2,7 @@ package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class InvalidDestination extends Destination {
|
||||
|
||||
@ -13,7 +12,7 @@ public class InvalidDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(MultiverseCore plugin, String dest) {
|
||||
public boolean isThisType(JavaPlugin plugin, String dest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -28,7 +27,7 @@ public class InvalidDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(MultiverseCore plugin, String dest) {
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
// Nothing needed, it's invalid.
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@ -15,15 +16,15 @@ public class WorldDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(MultiverseCore plugin, String destination) {
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] items = destination.split(":");
|
||||
if (items.length > 2) {
|
||||
return false;
|
||||
}
|
||||
if (items.length == 1 && plugin.isMVWorld(items[0])) {
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
return true;
|
||||
}
|
||||
if (items[0].equalsIgnoreCase("w") && plugin.isMVWorld(items[1])) {
|
||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -40,19 +41,19 @@ public class WorldDestination extends Destination {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(MultiverseCore plugin, String dest) {
|
||||
public void setDestination(JavaPlugin plugin, String dest) {
|
||||
String[] items = dest.split(":");
|
||||
if (items.length > 2) {
|
||||
isValid = false;
|
||||
return;
|
||||
}
|
||||
if(items.length == 1 && plugin.isMVWorld(items[0])) {
|
||||
if(items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||
isValid = true;
|
||||
this.world = plugin.getMVWorld(items[0]);
|
||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
||||
return;
|
||||
}
|
||||
if (items[0].equalsIgnoreCase("w") && plugin.isMVWorld(items[1])) {
|
||||
this.world = plugin.getMVWorld(items[1]);
|
||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[1]);
|
||||
isValid = true;
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user