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


Java Entity.eject方法代码示例

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


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

示例1: onPlayerMove

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }
    if (!isWithinBorder(to) && isWithinBorder(from)) {
        final Player player = event.getPlayer();
        player.sendMessage(ChatColor.RED + "You cannot go past the border.");
        event.setTo(from);
        final Entity vehicle = player.getVehicle();
        if (vehicle != null) {
            vehicle.eject();
            vehicle.teleport(from);
            vehicle.setPassenger((Entity)player);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:BorderListener.java

示例2: onPlayerInteractEntity

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
	Player p = event.getPlayer();
	Entity t = event.getRightClicked();
	PetInstance pet = PetInstance.get(t);
	if (pet == null)
		return;
	
	if (pet.getOwner().equalsIgnoreCase(p.getName())) {
		if (t.getPassenger() != null) {
			t.eject();
			t.setPassenger(null);
		}
		else {
			if (!p.isInsideVehicle())
				t.setPassenger(p);
		}
	}
	else {
		Chat.player(p, "&2[Pets] &cBuy pets at www.mczone.co/shop");
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:23,代码来源:PlayerEvents.java

示例3: onSpec

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onSpec(PlayerAliveStatusEvent e) {
    if (e.isAlive()) {
        return;
    }

    Entity entity = e.getPlayer().getVehicle();

    if (entity != null) {
        entity.eject();
        entity.remove();
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:14,代码来源:HorseRaceGame.java

示例4: onDisable

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void onDisable() {
    this.getAPI().getGameManager().setGameState(GameState.FINISHED);
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(player.getVehicle() != null) {
            Entity vehicle = player.getVehicle();
            vehicle.eject();
            vehicle.remove();
        }
        this.getAPI().getGameManager().setAlive(player, false);
    }
    this.getAPI().getTranslationManager().kickPlayers("common.server-restarting");
    removeCustomWorlds();
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:14,代码来源:Arcadia.java

示例5: preHit

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
/**
 * Subclasses are encouraged to override this.
 * Default behavior is to eject off of what you are riding, play a sound and spawn particle.
 *
 * 
 * @param hitData Data matrix showing hit
 * @param hit What entity was hit
 * @param bullet The bullet data.
 */
public void preHit(HitDigest hitData, Entity hit, Projectile bullet, Bullet type) {
	Location end = hitData.hitLocation;
	World world = end.getWorld();
	hit.eject(); // eject the player
	hit.getPassengers().forEach(e -> e.eject()); // and ejects your passengers
	// make a new sound where it hits.
	world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	// make a splash
	world.spawnParticle(Particle.SMOKE_NORMAL, end, 35, 0.1, 0.1, 0.1, 0.1);
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:20,代码来源:StandardGun.java

示例6: onPlayerMove

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (!this.getAPI().getGameManager().isAlive(player)) {
        return;
    }

    if(event.getTo().getY() <= floorLevel) {
        if(event.getPlayer().getVehicle() != null) {
            Entity vehicle = event.getPlayer().getVehicle();
            vehicle.eject();
            vehicle.remove();
        }
        this.createHorse(event.getPlayer(), this.spawn);
    }

    int current = checkpoints.get(player);
    int checkpointIndex = getCheckpoint(player);

    int distance;

    if (current == -1) {
        distance = (int) player.getLocation().distance(spawn);
    } else {
        distance = distances[current] + (int) player.getLocation().distance(checkpointLocs.get(current));
    }

    distance = -(totalDistance - distance);

    ((ScoreSidebar) getSidebar()).setScore(player, distance);

    // Not near a checkpoint
    if (checkpointIndex == -1) {
        return;
    }

    if (checkpointIndex < current) {
        this.getAPI().getTranslationManager().sendTranslation("game.horserace.wrong-way", event.getPlayer());
        return;
    }

    if (checkpointIndex > current) {
        checkpoints.put(player, checkpointIndex);
    }

    // Last checkpoint
    if (checkpointIndex == checkpointLocs.size() - 1) {
        double lastDistance = start.distanceSquared(player.getLocation());

        if (lastDistance < checkpointSize) {
            // Player won
            endGame();
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:57,代码来源:HorseRaceGame.java


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