/**
* Patch player teleporting through portals to be INSIDE the world border
*
* @param event Event
*/
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event)
{
if (!this.game.getPlugin().getServer().getAllowNether() || this.game.getSurvivalGameLoop().isNetherClosed())
{
event.setCancelled(true);
return;
}
TravelAgent travelAgent = event.getPortalTravelAgent();
Location destination = travelAgent.findPortal(event.getTo());
if (destination != null)
{
if (!SafePortalsUtils.isInsideBorder(destination))
{
event.useTravelAgent(false);
boolean success = travelAgent.createPortal(event.getTo());
if (success)
{
event.setTo(travelAgent.findPortal(event.getTo()));
if (!SafePortalsUtils.isSafeSpot(event.getTo()))
{
Location safeTo = SafePortalsUtils.searchSafeSpot(event.getTo());
if (safeTo != null)
{
event.setTo(safeTo);
}
}
}
}
}
else
{
event.useTravelAgent(true);
}
}
SecurityListener.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:SurvivalAPI
作者:
评论列表
文章目录