Convert to EntityPortalEnterEvent
This commit is contained in:
parent
d59882007b
commit
11992129d1
@ -1,18 +1,17 @@
|
||||
package mineplex.hub.modules.mavericks;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
/**
|
||||
* A small teleportation manager to manage the portal from the hub to the mavericks world and back.
|
||||
*/
|
||||
@ -41,33 +40,36 @@ public class MavericksPortalManager extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
public void onEntier(EntityPortalEnterEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK) return;
|
||||
|
||||
for(Player p : Bukkit.getOnlinePlayers())
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
{
|
||||
|
||||
Box box = isInside(p);
|
||||
|
||||
if(box == null) continue;
|
||||
|
||||
_cosmeticManager.getPetManager().disableAll(p);
|
||||
_cosmeticManager.getMountManager().DisableAll(p);
|
||||
|
||||
if(box == _portalHubMavericks)
|
||||
{
|
||||
p.teleport(_destMavericks);
|
||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area."));
|
||||
}
|
||||
else if (box == _portalMavericksHub)
|
||||
{
|
||||
p.teleport(_destHub);
|
||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area."));
|
||||
}
|
||||
|
||||
p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = (Player) event.getEntity();
|
||||
Box box = isInside(p);
|
||||
|
||||
if (box == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cosmeticManager.getPetManager().disableAll(p);
|
||||
_cosmeticManager.getMountManager().DisableAll(p);
|
||||
|
||||
if (box == _portalHubMavericks)
|
||||
{
|
||||
p.teleport(_destMavericks);
|
||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area."));
|
||||
}
|
||||
else if (box == _portalMavericksHub)
|
||||
{
|
||||
p.teleport(_destHub);
|
||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area."));
|
||||
}
|
||||
|
||||
p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
|
||||
}
|
||||
|
||||
private Box isInside(Player player)
|
||||
|
Loading…
Reference in New Issue
Block a user