Fix TeleportWaypointTrigger

This commit is contained in:
fullwall 2018-03-09 21:13:05 +08:00
parent d7237dff4e
commit 147a3e4c26
2 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,11 @@
package net.citizensnpcs.trait.waypoint.triggers;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
public class TeleportTrigger implements WaypointTrigger {
@Persist(required = true)
private Location location;
@ -26,7 +26,7 @@ public class TeleportTrigger implements WaypointTrigger {
@Override
public void onWaypointReached(NPC npc, Location waypoint) {
if (location != null) {
npc.teleport(waypoint, TeleportCause.PLUGIN);
npc.teleport(location, TeleportCause.PLUGIN);
}
}
}

View File

@ -2,9 +2,6 @@ package net.citizensnpcs.trait.waypoint.triggers;
import java.util.regex.Pattern;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Messages;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -17,6 +14,9 @@ import org.bukkit.entity.Player;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Messages;
public class TeleportTriggerPrompt extends RegexPrompt implements WaypointTriggerPrompt {
public TeleportTriggerPrompt() {
super(PATTERN);
@ -33,7 +33,7 @@ public class TeleportTriggerPrompt extends RegexPrompt implements WaypointTrigge
new TeleportTrigger(player.getLocation()));
return (Prompt) context.getSessionData(WaypointTriggerPrompt.RETURN_PROMPT_KEY);
}
String[] parts = Iterables.toArray(Splitter.on(':').split(input), String.class);
String[] parts = Iterables.toArray(Splitter.on(':').omitEmptyStrings().split(input), String.class);
String worldName = parts[0];
World world = Bukkit.getWorld(worldName);
if (world == null) {