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


Java MoveEntityEvent类代码示例

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


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

示例1: onMoveEntity

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入依赖的package包/类
@Listener
public void onMoveEntity(MoveEntityEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);
    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())) {
        Camera camera = Vigilate.getInstance().getCameras().get(camId.get());

        if (!camera.getLocation().equals(event.getToTransform().getLocation())) {
            camera.endViewCamera(player);
        }

        return;
    }

    if(!event.getFromTransform().getLocation().equals(event.getToTransform().getLocation())) {
        Camera.resetPlayer(player);
        event.setCancelled(true);
    }
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:19,代码来源:MoveListener.java

示例2: 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

示例3: 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

示例4: 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

示例5: testDynamicListener

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入依赖的package包/类
@Test
public void testDynamicListener() throws Exception {
	Class.forName("jdk.nashorn.api.scripting.NashornScriptEngineFactory");
	ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
	ClassGenerator classGenerator = new ClassGenerator();
	try (InputStreamReader rs = new InputStreamReader(new FileInputStream(new File("./src/main/test/testfiles/js/eventgen/test.js")))) {
		engine.eval(rs);
		HashMap map = (HashMap) engine.get("events");
		Object o = classGenerator.generateDynamicListener(map);
		DamageEntityEvent mock = mock(DamageEntityEvent.class);
		o.getClass().getMethod("onDamageEntityEvent", DamageEntityEvent.class).invoke(o, mock);
		MoveEntityEvent mock2 = mock(MoveEntityEvent.class);
		o.getClass().getMethod("onDisplaceEntityEvent", MoveEntityEvent.class).invoke(o, mock2);
	} catch (ScriptException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:18,代码来源:Tests.java

示例6: onEntityMovement

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityMovement(MoveEntityEvent e) {
	Transform<World> f = e.getFromTransform();
	Transform<World> t = e.getToTransform();
	if (f.getLocation().getBlockX() == t.getLocation().getBlockX() &&
			t.getLocation().getBlockZ() == f.getLocation().getBlockZ()) {
		return;
	}
	int x = t.getLocation().getBlockX();
	int z = t.getLocation().getBlockZ();
	if (x == (x >> 4) << 4 && z == (z >> 4) << 4) {
		EntityType type = e.getTargetEntity().getType();
		if (type == EntityTypes.PLAYER) {
			Citizen citizen = playerService.getCitizen(e.getTargetEntity().getUniqueId());
			ClaimedArea nextArea = worldService.getClaimedArea(t.getLocation());
			worldService.handleChunkChange(citizen, nextArea);
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:20,代码来源:Movement.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: entityMove

import org.spongepowered.api.event.entity.MoveEntityEvent; //导入依赖的package包/类
@Listener
public void entityMove(MoveEntityEvent event){
    if(forceStop) {
        return;
    }
    if(crateUtilities.physicalCrates.containsKey(event.getFromTransform().getLocation())){
        event.setCancelled(true);
    }
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:10,代码来源:HuskyCrates.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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