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


Java Boat类代码示例

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


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

示例1: onBoatHit

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
 * @param e
 *            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);
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:22,代码来源:SafeBoat.java

示例2: onVehicleCreate

import org.bukkit.entity.Boat; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onVehicleCreate(VehicleCreateEvent event) {
    Vehicle vehicle = event.getVehicle();
    if (vehicle instanceof Boat) {
        Boat boat = (Boat) vehicle;
        Block belowBlock = boat.getLocation().add(0, -1, 0).getBlock();
        if (belowBlock.getType() != Material.WATER && belowBlock.getType() != Material.STATIONARY_WATER) {
            boat.remove();
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:BoatGlitchFixListener.java

示例3: kickBoats

import org.bukkit.entity.Boat; //导入依赖的package包/类
public static void kickBoats() {
	for (Player player : Bukkit.getOnlinePlayers()) {
		if(player.isInsideVehicle() && player.getVehicle() instanceof Boat && ProtocolSupportAPI.getProtocolVersion(player).isBefore(ProtocolVersion.MINECRAFT_1_9)){
			player.getVehicle().eject();
			player.sendMessage(ChatColor.RED + "Boats are currently disabled for versions lower than " + ChatColor.DARK_RED + "1.9");
		}
	}
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:9,代码来源:Util.java

示例4: onPlayerInteract

import org.bukkit.entity.Boat; //导入依赖的package包/类
@EventHandler
   public void onPlayerInteract(PlayerInteractEntityEvent e) {
   	if (e.isCancelled()) {
           return;
       }

   	Player p = e.getPlayer();
       Entity ent = e.getRightClicked();
       Location l = ent.getLocation();
       Region r = RedProtect.get().rm.getTopRegion(l);
       if (r != null){
		return;
	}
       
       if (ent instanceof ItemFrame || ent instanceof Painting) {
           if (!bypassBuild(p, null, 0)) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (ent instanceof Minecart || ent instanceof Boat){
       	if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".use-minecart") && !p.hasPermission("redprotect.bypass.world")) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".interact") && !p.hasPermission("redprotect.bypass.world") && (!(ent instanceof Player))) {
   		if (RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-interact-false.allow-entities").contains(ent.getType().name())){
   			return;
   		} 
           e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:36,代码来源:RPGlobalListener.java

示例5: homeTeleport

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
    * Teleport player to a home location. If one cannot be found a search is done to
    * find a safe place.
    * @param player
    * @param number - home location to do to
    * @return true if successful, false if not
    */
   public boolean 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 SafeSpotTeleport(plugin, player, plugin.getPlayers().getHomeLocation(player.getUniqueId(), number), number);
    return true;
}
//plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
//home.getChunk().load();
player.teleport(home);
player.setFallDistance(0);
//player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
if (number ==1 ) {
    player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).homeTeleport);
} else {
    player.sendMessage(ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).homeTeleport + " #" + number);
}
return true;

   }
 
开发者ID:tastybento,项目名称:askygrid,代码行数:43,代码来源:GridManager.java

示例6: homeTeleport

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
 * Teleport player to a home location. If one cannot be found a search is done to
 * find a safe place.
 * @param player
 * @param number - home location to do to
 * @return true if successful, false if not
 */
public boolean 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 SafeSpotTeleport(plugin, player, plugin.getPlayers().getHomeLocation(player.getUniqueId(), number), number);
        return true;
    }
    //plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
    //home.getChunk().load();
    player.teleport(home);
    //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);
    }
    return true;

}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:42,代码来源:GridManager.java

示例7: onClick

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
 * @param e
 *            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);
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:44,代码来源:SafeBoat.java

示例8: canWipe

import org.bukkit.entity.Boat; //导入依赖的package包/类
private static boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
{
    if (wipeExplosives)
    {
        if (Explosive.class.isAssignableFrom(entity.getClass()))
        {
            return true;
        }
    }

    if (wipeVehicles)
    {
        if (Boat.class.isAssignableFrom(entity.getClass()))
        {
            return true;
        }
        else if (Minecart.class.isAssignableFrom(entity.getClass()))
        {
            return true;
        }
    }

    Iterator<Class<? extends Entity>> it = WIPEABLES.iterator();
    while (it.hasNext())
    {
        if (it.next().isAssignableFrom(entity.getClass()))
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:Yoshi41023,项目名称:TatsuCraftMod,代码行数:34,代码来源:TFM_Util.java

示例9: homeTeleport

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
 * Teleport player to a home location. If one cannot be found a search is done to
 * find a safe place.
 * @param player
 * @param number - home location to do to
 * @return true if successful, false if not
 */
@SuppressWarnings("deprecation")
public boolean homeTeleport(final Player player, int number) {
    Location home;
    if (DEBUG)
        plugin.getLogger().info("home teleport called for #" + number);
    home = getSafeHomeLocation(player.getUniqueId(), number);
    if (DEBUG)
        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) {
        if (DEBUG)
            plugin.getLogger().info("Fixing home location using safe spot teleport");
        // Try to fix this teleport location and teleport the player if possible
        new SafeSpotTeleport(plugin, player, plugin.getPlayers().getHomeLocation(player.getUniqueId(), number), number);
        return true;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
    //home.getChunk().load();
    player.teleport(home);
    //player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
    if (number ==1 ) {
        Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("island.teleport").replace("[label]", Settings.ISLANDCOMMAND));
    } else {
        Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("island.teleported").replace("[number]", String.valueOf(number)));
    }
    // Exit spectator mode if in it
    if (player.getGameMode().equals(GameMode.SPECTATOR)) {
        player.setGameMode(GameMode.SURVIVAL);
    }
    return true;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:50,代码来源:IslandsManager.java

示例10: CanaryBoat

import org.bukkit.entity.Boat; //导入依赖的package包/类
public CanaryBoat(net.canarymod.api.entity.vehicle.Boat entity) {
    super(entity);
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:4,代码来源:CanaryBoat.java

示例11: getHandle

import org.bukkit.entity.Boat; //导入依赖的package包/类
@Override
protected net.canarymod.api.entity.vehicle.Boat getHandle() {
    return (net.canarymod.api.entity.vehicle.Boat) super.getHandle();
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:5,代码来源:CanaryBoat.java

示例12: validateMovementAndUpdateDistance

import org.bukkit.entity.Boat; //导入依赖的package包/类
/**
 * Update distances and store them into server's memory until player disconnects.
 * 
 * @param player
 */
private void validateMovementAndUpdateDistance(Player player) {
	String uuid = player.getUniqueId().toString();
	Location previousLocation = playerLocations.get(uuid);

	// Update new location.
	playerLocations.put(uuid, player.getLocation());

	// If player location not found or if player has changed world, ignore previous location.
	// Evaluating distance would give an exception.
	if (previousLocation == null || !previousLocation.getWorld().getName().equals(player.getWorld().getName())) {
		return;
	}

	// If player is in restricted game mode or is in a blocked world, don't update distances.
	if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) {
		return;
	}

	int difference = getDistanceDifference(player, previousLocation);
	// Player has not moved.
	if (difference == 0L) {
		return;
	}

	if (player.getVehicle() instanceof Horse) {
		updateDistance(difference, player, NormalAchievements.DISTANCEHORSE);
	} else if (player.getVehicle() instanceof Pig) {
		updateDistance(difference, player, NormalAchievements.DISTANCEPIG);
	} else if (player.getVehicle() instanceof Minecart) {
		updateDistance(difference, player, NormalAchievements.DISTANCEMINECART);
	} else if (player.getVehicle() instanceof Boat) {
		updateDistance(difference, player, NormalAchievements.DISTANCEBOAT);
	} else if (plugin.getServerVersion() >= 11 && player.getVehicle() instanceof Llama) {
		updateDistance(difference, player, NormalAchievements.DISTANCELLAMA);
	} else if (!player.isFlying() && (plugin.getServerVersion() < 9 || !player.isGliding())) {
		updateDistance(difference, player, NormalAchievements.DISTANCEFOOT);
	} else if (plugin.getServerVersion() >= 9 && player.isGliding()) {
		updateDistance(difference, player, NormalAchievements.DISTANCEGLIDING);
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:46,代码来源:AchieveDistanceRunnable.java

示例13: onEntityDamageByEntityEvent

import org.bukkit.entity.Boat; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
   public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) {
   	Player p = null;        
       
   	RedProtect.get().logger.debug("RPLayerListener: Is EntityDamageByEntityEvent event"); 
   	
       if (e.getDamager() instanceof Player){
       	p = (Player)e.getDamager();
       } else if (e.getDamager() instanceof Projectile){
       	Projectile proj = (Projectile)e.getDamager();
       	if (proj.getShooter() instanceof Player){
       		p = (Player) proj.getShooter();
       	}        	
       } 
       
       if (p != null){
       	RedProtect.get().logger.debug("Player: " + p.getName()); 
       } else {
       	RedProtect.get().logger.debug("Player: is null"); 
       	return;
       }
       
       RedProtect.get().logger.debug("Damager: " + e.getDamager().getType().name()); 
       
       //check killaura or freekill
       if (RPConfig.getBool("server-protection.check-killaura-freekill.enable")){
       	startCheckRate(p.getName());
       }
       
       Location l = e.getEntity().getLocation();
       Region r = RedProtect.get().rm.getTopRegion(l);
       if (r == null){
       	return;
       }
       
       if (RedProtect.get().tpWait.contains(p.getName())){
   		RedProtect.get().tpWait.remove(p.getName());
   		RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
   	}
       
       if (e.getEntity() instanceof Player && !p.equals(e.getEntity()) && r.flagExists("pvp") && !r.canPVP((Player)e.getEntity(), p)){
       	RPLang.sendMessage(p, "entitylistener.region.cantpvp");
           e.setCancelled(true);
       }
       
       if ((e.getEntity() instanceof Hanging || e.getEntity() instanceof EnderCrystal) && !r.canBuild(p) && !r.canBreak(e.getEntityType())){
       	RPLang.sendMessage(p, "playerlistener.region.cantremove");
       	e.setCancelled(true);
       }   

       if ((e.getEntity() instanceof Boat || e.getEntity() instanceof Minecart) && !r.canMinecart(p)){
       	RPLang.sendMessage(p, "blocklistener.region.cantbreak");
       	e.setCancelled(true);
       }	
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:56,代码来源:RPPlayerListener.java


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