Cleaned up portal cancellation.

This commit is contained in:
Jonathan Williams 2013-12-03 17:41:58 -08:00
parent 022c343a98
commit 8984309c56

View File

@ -9,12 +9,14 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer; import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -102,6 +104,8 @@ public class UHC extends TeamGame
private boolean _portalCreated = false; private boolean _portalCreated = false;
private GameTeam _lastDragonDamager = null; private GameTeam _lastDragonDamager = null;
private Location _exitLocation = null;
public UHC(ArcadeManager manager) public UHC(ArcadeManager manager)
{ {
super(manager, GameType.UHC, super(manager, GameType.UHC,
@ -178,28 +182,9 @@ public class UHC extends TeamGame
@EventHandler @EventHandler
public void endPortalTransfer(final PlayerPortalEvent event) public void endPortalTransfer(final PlayerPortalEvent event)
{ {
System.out.println(event.getCause());
if (event.getCause() == TeleportCause.END_PORTAL) if (event.getCause() == TeleportCause.END_PORTAL)
{ {
event.setCancelled(true); event.setCancelled(true);
if (event.getPlayer().getLocation().getWorld() == Bukkit.getWorld("world_the_end"))
{
System.out.println("in teleport place");
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
System.out.println("Teleporting player back to world: " + new Location(WorldData.World, 2.5, 70, 0.5));
event.getPlayer().teleport(new Location(event.getPlayer().getWorld(), 2.5, 70, 0.5));
event.getPlayer().sendMessage("Hi, get back in your world.");
}
}
}, 2L);
}
else
event.getPlayer().teleport(((CraftServer)Bukkit.getServer()).getHandle().getServer().getPlayerList().calculateTarget(event.getPlayer().getLocation(), ((CraftWorld)Bukkit.getWorld("world_the_end")).getHandle())); event.getPlayer().teleport(((CraftServer)Bukkit.getServer()).getHandle().getServer().getPlayerList().calculateTarget(event.getPlayer().getLocation(), ((CraftWorld)Bukkit.getWorld("world_the_end")).getHandle()));
} }
} }