Prevent Enderdragon from creating portal.
This commit is contained in:
parent
ce4eb43145
commit
09a77e98cc
@ -33,6 +33,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCreatePortalEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
@ -185,12 +186,40 @@ public class UHC extends TeamGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void endPortalTransfer(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);
|
||||||
event.getPlayer().teleport(((CraftServer)Bukkit.getServer()).getHandle().getServer().getPlayerList().calculateTarget(event.getPlayer().getLocation(), ((CraftWorld)Bukkit.getWorld("world_the_end")).getHandle()));
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void endPortalCreation(final EntityCreatePortalEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof EnderDragon)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user