类org.bukkit.entity.Boat源码实例Demo

下面列出了怎么用org.bukkit.entity.Boat的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: askyblock   文件: SafeBoat.java
/**
 * @param e - event
 *            This function prevents boats from exploding when they hit
 *            something
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
public void onBoatHit(VehicleDestroyEvent e) {
    // plugin.getLogger().info("Vehicle destroyed event called");
    final Entity boat = e.getVehicle();
    if (!(boat instanceof Boat)) {
        return;
    }
    if (!boat.getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        // Not the right world
        return;
    }
    if (!(e.getAttacker() instanceof Player)) {
        // plugin.getLogger().info("Attacker is not a player so cancel event");
        e.setCancelled(true);
    }
}
 
源代码2 项目: Hawk   文件: FlyOld.java
private boolean isOnBoat(Player p, Location loc) {
    Set<Entity> trackedEntities = hawk.getLagCompensator().getPositionTrackedEntities();
    int ping = ServerUtils.getPing(p);
    for(Entity entity : trackedEntities) {
        if (entity instanceof Boat) {
            AABB boatBB = WrappedEntity.getWrappedEntity(entity).getCollisionBox(hawk.getLagCompensator().getHistoryLocation(ping, entity).toVector());
            AABB feet = new AABB(
                    new Vector(-0.3, -0.4, -0.3).add(loc.toVector()),
                    new Vector(0.3, 0, 0.3).add(loc.toVector()));
            if (feet.isColliding(boatBB))
                return true;
        }
    }
    return false;
}
 
源代码3 项目: Hawk   文件: Fly.java
private boolean isOnBoat(Player p, Location loc) {
    Set<Entity> trackedEntities = hawk.getLagCompensator().getPositionTrackedEntities();
    int ping = ServerUtils.getPing(p);
    for(Entity entity : trackedEntities) {
        if (entity instanceof Boat) {
            AABB boatBB = WrappedEntity.getWrappedEntity(entity).getCollisionBox(hawk.getLagCompensator().getHistoryLocation(ping, entity).toVector());
            AABB feet = new AABB(
                    new Vector(-0.3, -0.4, -0.3).add(loc.toVector()),
                    new Vector(0.3, 0, 0.3).add(loc.toVector()));
            if (feet.isColliding(boatBB))
                return true;
        }
    }
    return false;
}
 
源代码4 项目: Skript   文件: BoatData.java
@Override
public void set(Boat entity) {
	if (matchedPattern == 1) // If the type is 'any boat'.
		matchedPattern += new Random().nextInt(TreeSpecies.values().length); // It will spawn a random boat type in case is 'any boat'.
	if (matchedPattern > 1) // 0 and 1 are excluded
		entity.setWoodType(TreeSpecies.values()[matchedPattern - 2]); // Removes 2 to fix the index.
}
 
源代码5 项目: askyblock   文件: SafeBoat.java
/**
 * @param e - event
 *            This event check throws the boat at a player when they hit it
 *            unless someone is in it
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onClick(VehicleDamageEvent e) {
    // plugin.getLogger().info("Damage event " + e.getDamage());
    // Find out what block is being clicked
    Vehicle boat = e.getVehicle();
    if (!(boat instanceof Boat)) {
        return;
    }
    if (!boat.isEmpty()) {
        return;
    }
    final World playerWorld = boat.getWorld();
    if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) {
        // Not the right world
        return;
    }
    // plugin.getLogger().info("Boat ");
    // Find out who is doing the clicking
    if (!(e.getAttacker() instanceof Player)) {
        // If a creeper blows up the boat, tough cookies!
        return;
    }
    Player p = (Player) e.getAttacker();
    if (p == null) {
        return;
    }
    // Try to remove the boat and throw it at the player
    Location boatSpot = new Location(boat.getWorld(), boat.getLocation().getX(), boat.getLocation().getY() + 2, boat.getLocation().getZ());
    Location throwTo = new Location(boat.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ());
    ItemStack newBoat = new ItemStack(Material.BOAT, 1);
    // Find the direction the boat should move in
    Vector dir = throwTo.toVector().subtract(boatSpot.toVector()).normalize();
    dir = dir.multiply(0.5);
    Entity newB = boat.getWorld().dropItem(boatSpot, newBoat);
    newB.setVelocity(dir);
    boat.remove();
    e.setCancelled(true);
}
 
源代码6 项目: Skript   文件: BoatData.java
@Override
protected boolean init(@Nullable Class<? extends Boat> c, @Nullable Boat e) {
	if (e != null)
		matchedPattern = 2 + e.getWoodType().ordinal();
	return true;
}
 
源代码7 项目: Skript   文件: BoatData.java
@Override
protected boolean match(Boat entity) {
	return matchedPattern <= 1 || entity.getWoodType().ordinal() == matchedPattern - 2;
}
 
源代码8 项目: Skript   文件: BoatData.java
@Override
public Class<? extends Boat> getType() {
	return Boat.class;
}
 
源代码9 项目: askyblock   文件: GridManager.java
/**
 * Teleport player to a home location. If one cannot be found a search is done to
 * find a safe place.
 * @param player player object
 * @param number - home location to do to
 * @return true if successful, false if not
 */
@SuppressWarnings("deprecation")
public void homeTeleport(final Player player, int number) {
    Location home = null;
    //plugin.getLogger().info("home teleport called for #" + number);
    home = getSafeHomeLocation(player.getUniqueId(), number);
    //plugin.getLogger().info("home get safe loc = " + home);
    // Check if the player is a passenger in a boat
    if (player.isInsideVehicle()) {
        Entity boat = player.getVehicle();
        if (boat instanceof Boat) {
            player.leaveVehicle();
            // Remove the boat so they don't lie around everywhere
            boat.remove();
            player.getInventory().addItem(new ItemStack(Material.BOAT, 1));
            player.updateInventory();
        }
    }
    if (home == null) {
        //plugin.getLogger().info("Fixing home location using safe spot teleport");
        // Try to fix this teleport location and teleport the player if possible
        new SafeTeleportBuilder(plugin)
        .entity(player)
        .location(plugin.getPlayers().getHomeLocation(player.getUniqueId(), number))
        .homeNumber(number)
        .build();
        return;
    }
    //plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
    //home.getChunk().load();
    IslandPreTeleportEvent event = new IslandPreTeleportEvent(player, IslandPreTeleportEvent.Type.HOME, home);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCancelled()) {
        player.teleport(event.getLocation());
        //player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
        if (number ==1 ) {
            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandteleport);
        } else {
            Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).islandteleport + " #" + number);
        }
    }
    plugin.getPlayers().setInTeleport(player.getUniqueId(), false);
}
 
 类所在包
 类方法
 同包方法