本文整理汇总了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);
}
}
}
示例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");
}
}
示例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();
}
}
示例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();
}
示例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);
}
示例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();
}
}
}