當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。