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


Java MoveEntityEvent.getTargetEntity方法代码示例

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


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

示例1: onPlayerMove

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerMove(MoveEntityEvent event) {
	if (event.getTargetEntity() instanceof Player) {
		EPlayer player = this.plugin.getEServer().getEPlayer((Player) event.getTargetEntity());
			
		// AFK
		if (event.getToTransform().getPitch() != event.getFromTransform().getPitch() || 
				event.getToTransform().getYaw() != event.getFromTransform().getYaw()) {
			player.updateLastActivated();
		}
		
		if (UtilsLocation.isDifferentBlock(event.getFromTransform(), event.getToTransform())) {
			// Teleport
			Optional<TeleportDelay> teleport = player.getTeleportDelay();
			if (teleport.isPresent() && !teleport.get().canMove()) {
				player.cancelTeleportDelay();
				EEMessages.TELEPORT_ERROR_DELAY.sendTo(player);
			}
			
			// Freeze
			if(player.isFreeze()) {
				event.setCancelled(true);
			}
		}
	}
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEPlayerListeners.java

示例2: moveListener

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void moveListener(MoveEntityEvent event) {
    Entity entity = event.getTargetEntity();
    if (!entity.getType().equals(EntityTypes.PLAYER)) return;
    Player player = (Player) entity;
    if (!Animation1OpenManager.PLAYERS_OPENING_ANIMATION1.containsKey(player) || OPENED_PLAYERS.containsKey(player)) return;
    if (Utils.isLocationChanged(event.getFromTransform(), event.getToTransform(), true)) {
        event.setCancelled(true);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:11,代码来源:Animation1Listener.java

示例3: onEntityMoves

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityMoves(MoveEntityEvent evt) {
    EntityMovesScriptEvent event = (EntityMovesScriptEvent) clone();
    event.internal = evt;
    event.entity = new EntityTag(evt.getTargetEntity());
    event.toPosition = new LocationTag(evt.getToTransform().getLocation());
    event.toRotation = new LocationTag(evt.getToTransform().getRotation());
    event.fromPosition = new LocationTag(evt.getFromTransform().getLocation());
    event.fromRotation = new LocationTag(evt.getFromTransform().getRotation());
    event.cancelled = evt.isCancelled();
    // TODO: Cause viewing
    event.run();
    // TODO: Set To Transform determinations.
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:16,代码来源:EntityMovesScriptEvent.java

示例4: onEntityLeavesArea

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityLeavesArea(MoveEntityEvent evt) {
    EntityLeavesAreaScriptEvent event = (EntityLeavesAreaScriptEvent) clone();
    event.internal = evt;
    event.entity = new EntityTag(evt.getTargetEntity());
    event.toPosition = new LocationTag(evt.getToTransform().getLocation());
    event.fromPosition = new LocationTag(evt.getFromTransform().getLocation());
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityLeavesAreaScriptEvent.java

示例5: onEntityEntersArea

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityEntersArea(MoveEntityEvent evt) {
    EntityEntersAreaScriptEvent event = (EntityEntersAreaScriptEvent) clone();
    event.internal = evt;
    event.entity = new EntityTag(evt.getTargetEntity());
    event.toPosition = new LocationTag(evt.getToTransform().getLocation());
    event.fromPosition = new LocationTag(evt.getFromTransform().getLocation());
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityEntersAreaScriptEvent.java

示例6: onMove

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入方法依赖的package包/类
@Listener(order = POST)
public void onMove(MoveEntityEvent event)
{
    if (event.getTargetEntity() instanceof Player)
    {
        if (event.getFromTransform().getLocation().getBlockX() == event.getToTransform().getLocation().getBlockX()
                && event.getFromTransform().getLocation().getBlockZ() == event.getToTransform().getLocation().getBlockZ())
        {
            return;
        }
        this.updateLastAction(((Player) event.getTargetEntity()));
    }

}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:15,代码来源:AfkListener.java

示例7: onPlayerMove

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

		if (Utils.isTeleportCooldownEnabled() && EssentialCmds.teleportingPlayers.contains(player.getUniqueId()))
		{
			EssentialCmds.teleportingPlayers.remove(player.getUniqueId());
			player.sendMessage(Text.of(TextColors.RED, "Teleportation canceled due to movement."));
		}

		if (EssentialCmds.frozenPlayers.contains(player.getUniqueId()))
		{
			player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot move while frozen."));
			event.setCancelled(true);
			return;
		}

		if (EssentialCmds.recentlyJoined.contains(player))
		{
			EssentialCmds.recentlyJoined.remove(player);

			if (EssentialCmds.afkList.containsKey(player.getUniqueId()))
			{
				EssentialCmds.afkList.remove(player.getUniqueId());
			}
		}
		else
		{
			if (EssentialCmds.afkList.containsKey(player.getUniqueId()))
			{
				AFK removeAFK = EssentialCmds.afkList.get(player.getUniqueId());

				if (removeAFK.getAFK())
				{
					if (Utils.shouldAnnounceAFK())
					{
						MessageChannel.TO_ALL.send(Text.of(TextColors.BLUE, player.getName(), TextColors.GOLD, " is no longer AFK."));
					}
				}

				EssentialCmds.afkList.remove(removeAFK);
			}

			AFK afk = new AFK(System.currentTimeMillis());
			EssentialCmds.afkList.put(player.getUniqueId(), afk);
		}

		if (!event.getFromTransform().getExtent().getUniqueId().equals(event.getToTransform().getExtent().getUniqueId()))
		{
			World oldWorld = event.getFromTransform().getExtent();
			World newWorld = event.getToTransform().getExtent();

			Utils.savePlayerInventory(player, oldWorld.getUniqueId());

			if (!Utils.doShareInventories(oldWorld.getName(), newWorld.getName()))
			{
				Utils.updatePlayerInventory(player, newWorld.getUniqueId());
			}

			player.offer(Keys.GAME_MODE, newWorld.getProperties().getGameMode());
		}
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:67,代码来源:PlayerMoveListener.java

示例8: onMove

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


    if (event.getFromTransform().getExtent() != event.getToTransform().getExtent()
        || (event.getFromTransform().getLocation().getBlockX() == event.getToTransform().getLocation().getBlockX()
        && event.getFromTransform().getLocation().getBlockY() == event.getToTransform().getLocation().getBlockY()
        && event.getFromTransform().getLocation().getBlockZ() == event.getToTransform().getLocation().getBlockZ()))
    {
        return;
    }
    List<Portal> portals = module.getPortalsInChunk(event.getToTransform().getLocation());
    PortalsAttachment attachment = module.getPortalsAttachment(player.getUniqueId());
    if (portals != null)
    {
        for (Portal portal : portals)
        {
            if (portal.has(event.getToTransform().getLocation()))
            {
                if (attachment.isDebug())
                {
                    if (attachment.isInPortal())
                    {
                        i18n.send(player, POSITIVE, "{text:[Portals] Debug} Move in portal: {name}", portal.getName());
                    }
                    else
                    {
                        i18n.send(player, POSITIVE, "{text:[Portals] Debug} Entered portal: {name}", portal.getName());
                        portal.showInfo(player);
                        attachment.setInPortal(true);
                    }
                }
                else if (!attachment.isInPortal())
                {
                    portal.teleport(player);
                    onTeleport(player.getTransform(), player); // TODO remove when DisplaceEntityEvent.Teleport is implemented
                }
                return;
            }
            // else ignore
        }
    }
    attachment.setInPortal(false);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:51,代码来源:PortalListener.java


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