当前位置: 首页>>代码示例>>Java>>正文


Java MoveEntityEvent.Teleport方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.entity.MoveEntityEvent.Teleport方法的典型用法代码示例。如果您正苦于以下问题:Java MoveEntityEvent.Teleport方法的具体用法?Java MoveEntityEvent.Teleport怎么用?Java MoveEntityEvent.Teleport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.entity.MoveEntityEvent的用法示例。


在下文中一共展示了MoveEntityEvent.Teleport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntityTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onEntityTeleport(MoveEntityEvent.Teleport event) {
    if (event.getTargetEntity().getType() != EntityTypes.PLAYER) {
        return; // not a player
    }

    if (event.getFromTransform().getPosition().equals(event.getToTransform().getPosition())) {
        return; // player hasn't moved
    }

    Optional<Challenger> chal = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
    if (chal.isPresent() && !((CommonChallenger) chal.get()).isLeaving()) {
        Boundary bound = chal.get().getRound().getArena().getBoundary();
        if (!bound.contains(LocationConverter.of(event.getToTransform().getPosition()))) {
            if (chal.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
                chal.get().removeFromRound();;
            } else {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:23,代码来源:PlayerWorldListener.java

示例2: onMoveEntityEventTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
@IsCancelled(Tristate.FALSE)
public void onMoveEntityEventTeleport(MoveEntityEvent.Teleport event, @Root Player player) {
    if (event.getFromTransform().getExtent().equals(event.getToTransform().getExtent())) {
        return;
    }

    World world = event.getToTransform().getExtent();
    Vector3d rotation = null;
    for (SpawnEntity spawnEntity : SpawnCache.instance.get()) {
        if (spawnEntity.getWorld().getIdentifier().equals(world.getUniqueId().toString())) {
            rotation = spawnEntity.getRotation();
        }
    }

    if (rotation != null) {
        Transform<World> to = new Transform<>(world.getSpawnLocation());
        event.setToTransform(to.setRotation(rotation));
    }
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:21,代码来源:PlayerListeners.java

示例3: onWorldChange

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onWorldChange(MoveEntityEvent.Teleport event)
{
    World from = event.getFromTransform().getExtent();
    World to = event.getToTransform().getExtent();
    Entity target = event.getTargetEntity();

    if (from.equals(to) || module.getUniverse(from).equals(module.getUniverse(to)))
    {
        return;
    }

    if (target instanceof Player)
    {
        MultiverseData data = target.get(MultiverseData.class).get();
        data.from(module.getUniverse(from), from).applyFromPlayer(((Player)target)); // save playerdata
        data.from(module.getUniverse(to), to).applyToPlayer(((Player)target)); // load playerdata
        target.offer(data);
        module.getLogger().info("{} entered the universe {}", ((Player)target).getName(), module.getUniverse(to));
    }
    else
    {
        event.setCancelled(true);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:MultiverseListener.java

示例4: onTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
    public void onTeleport(MoveEntityEvent.Teleport event)
    {
        if ((this.module.getConfig().disableVanillaPortals || this.module.getConfig().disabledVanillaPortalsInWorlds.getOrDefault(new ConfigWorld(event.getFromTransform().getExtent()), false))
                && event.getCause().getContext().get(EventContextKeys.TELEPORT_TYPE).orElse(null) == TeleportTypes.PORTAL)
        {
            event.setToTransform(event.getFromTransform().addTranslation(new Vector3d(0,1.2,0)));
//            event.setCancelled(true);
            return;
        }
        Transform<World> target = event.getToTransform();
        Entity player = event.getTargetEntity();
        if (player instanceof Player)
        {
            onTeleport(target, ((Player) player)); // TODO event listener parameter
        }
    }
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:18,代码来源:PortalListener.java

示例5: onEntityTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityTeleport(MoveEntityEvent.Teleport event)
{
    if (event.getTargetEntity() instanceof Player)
    {
        return;
    }
    List<Portal> portals = module.getPortalsInChunk(event.getFromTransform().getLocation());
    if (portals == null)
    {
        return;
    }
    for (Portal portal : portals)
    {
        List<Entity> entities = module.getEntitiesInPortal(portal);
        if (portal.has(event.getToTransform().getLocation()))
        {
            entities.add(event.getTargetEntity());
            return;
        }
        else
        {
            entities.remove(event.getTargetEntity());
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:27,代码来源:PortalListener.java

示例6: onWorldChange

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onWorldChange(MoveEntityEvent.Teleport e) {
    if (!(e.getTargetEntity() instanceof Player)) return;
    if (!e.getFromTransform().getExtent().getUniqueId().equals(e.getToTransform().getExtent().getUniqueId())) {
        sendArmorUpdate((Player) e.getTargetEntity());
    }
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:8,代码来源:Sponge5ArmorListener.java

示例7: move

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void move(MoveEntityEvent event, @Getter("getTargetEntity") Player player) {
    // If the player teleported, just send the distance event (not including
    // their new location) and remove their player path
    if (event instanceof MoveEntityEvent.Teleport) {
        processEvent(event, player);
        sendAndRemove(player.getUniqueId());
        return;
    }

    PlayerPath playerPath;
    if (this.playerPaths.containsKey(player.getUniqueId())) {
        playerPath = this.playerPaths.get(player.getUniqueId());
    } else {
        playerPath = new PlayerPath();
        this.playerPaths.put(player.getUniqueId(), playerPath);
    }

    Vector3i position = player.getLocation().getBlockPosition();
    playerPath.addPoint(position);

    // Send the event every 20 blocks moved
    if (playerPath.size() >= 20) {
        sendAndRemove(player.getUniqueId());
    }

}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:28,代码来源:MoveEventListener.java

示例8: onEntityTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityTeleport(MoveEntityEvent.Teleport event, @First(typeFilter = EnderPearl.class) EnderPearl ep) {
	Entity targetEntity = event.getTargetEntity();
	IActiveCharacter iEntity = characterService.getCharacter(targetEntity.getUniqueId());
	if (iEntity.hasEffect(EnderPearlEffect.name)) {
		EnderPearlEffect.Container container = (EnderPearlEffect.Container) iEntity.getEffect(EnderPearlEffect.name);
		if (container.getLastTimeUsed() < System.currentTimeMillis() - container.getStackedValue()) {
			Gui.sendCooldownMessage(iEntity, "Ender Pearl", System.currentTimeMillis() - container.getStackedValue());
			event.setCancelled(true);
		} else {
			container.setLastTimeUsed(System.currentTimeMillis());
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:15,代码来源:SkillListener.java

示例9: onPlayerTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event, @Getter("getTargetEntity") Player player) {
  Optional<JungleRaidInstance> optInst = manager.getApplicableZone(event.getFromTransform().getLocation());
  if (optInst.isPresent() && !manager.getApplicableZone(event.getToTransform().getLocation()).isPresent()) {
    JungleRaidInstance inst = optInst.get();

    inst.playerLost(player);
    inst.tryInventoryRestore(player);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:11,代码来源:JungleRaidListener.java

示例10: onPlayerTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event, @Getter("getTargetEntity") Player player) {
  Optional<GoldRushInstance> optInst = manager.getApplicableZone(event.getFromTransform().getLocation());
  if (optInst.isPresent() && !manager.getApplicableZone(event.getToTransform().getLocation()).isPresent()) {
    GoldRushInstance inst = optInst.get();

    inst.invalidate(player);
    inst.tryInventoryRestore(player);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:11,代码来源:GoldRushListener.java

示例11: onPlayerTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerTeleport(MoveEntityEvent.Teleport event) {
  Entity entity = event.getTargetEntity();
  if (!(entity instanceof Player)) {
    return;
  }
  Player player = (Player) entity;

  Optional<CursedMineInstance> optInst = manager.getApplicableZone(player);
  HitList hitList = manager.getHitList();
  if ((optInst.isPresent() && optInst.get().hasRecordForPlayer(player)) || hitList.isOnHitList(player)) {
    event.setCancelled(true);
    player.sendMessage(Text.of(TextColors.RED, "You have been tele-blocked!"));
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:16,代码来源:CursedMineListener.java

示例12: onPlayerMove

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerMove(MoveEntityEvent playerMoveEvent, @First Player player) {
    if (playerMoveEvent instanceof MoveEntityEvent.Teleport) {
        return;
    }

    Vector3d oldLocation = playerMoveEvent.getFromTransform().getPosition();
    Vector3d newLocation = playerMoveEvent.getToTransform().getPosition();
    if ((oldLocation.getFloorX() != newLocation.getFloorX()
            || oldLocation.getFloorZ() != newLocation.getFloorZ())) {
        checkLoginStatus(playerMoveEvent, player);
    }
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:14,代码来源:PreventListener.java

示例13: onTeleport

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onTeleport(MoveEntityEvent.Teleport event)
{
    if (event.getTargetEntity() instanceof Player)
    {
        lastLocations.put(event.getTargetEntity().getUniqueId(), event.getFromTransform());
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:9,代码来源:TeleportListener.java

示例14: changeWorld

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void changeWorld(MoveEntityEvent.Teleport event)
{
    if (!(event.getTargetEntity() instanceof Player))
    {
        return;
    }
    if (!((Player)event.getTargetEntity()).hasPermission(module.perms().EDIT_USE.getId()))
    {
        manager.exitEditMode(((Player)event.getTargetEntity()));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:13,代码来源:MarketSignListener.java

示例15: onMove

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onMove(MoveEntityEvent event, @Getter("getTargetEntity") Player player)
{
    List<Region> from = manager.getRegionsAt(event.getFromTransform().getLocation());
    List<Region> to = manager.getRegionsAt(event.getToTransform().getLocation());
    if (from.isEmpty() && to.isEmpty())
    {
        return;
    }

    // Ignore subblock movements
    if (event.getFromTransform().getPosition().toInt().equals(event.getToTransform().getPosition().toInt()))
    {
        return;
    }

    if (event instanceof MoveEntityEvent.Teleport)
    {
        if (checkMove(event, player, from, to, MoveType.TELEPORT, false))
        {
            return; // Teleport out denied
        }

        if (checkMove(event, player, to, from, MoveType.TELEPORT, false))
        {
            return; // Teleport in denied
        }
    }
    else if (event.getCause().root() instanceof Player)
    {
        if (checkMove(event, player, from, to, MoveType.MOVE, false))
        {
            i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to move in here.");
            return; // Move in from denied
        }

        if (checkMove(event, player, from, to, MoveType.EXIT, true))
        {
            i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to exit this area.");
            return; // Move out of from denied
        }

        if (checkMove(event, player, to, from, MoveType.ENTER, true))
        {
            i18n.send(ACTION_BAR, player, NEGATIVE, "You are not allowed to enter this area.");
            return; // Move into to denied
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:50,代码来源:SettingsListener.java


注:本文中的org.spongepowered.api.event.entity.MoveEntityEvent.Teleport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。