本文整理汇总了Java中org.bukkit.entity.Vehicle类的典型用法代码示例。如果您正苦于以下问题:Java Vehicle类的具体用法?Java Vehicle怎么用?Java Vehicle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vehicle类属于org.bukkit.entity包,在下文中一共展示了Vehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onVehicleBreak
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onVehicleBreak(VehicleDestroyEvent e){
if (e.isCancelled()){
return;
}
if (!(e.getAttacker() instanceof Player)){
return;
}
Vehicle cart = e.getVehicle();
Player p = (Player) e.getAttacker();
Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());
if (r != null){
return;
}
if (!RPConfig.getGlobalFlagBool(p.getWorld().getName()+".use-minecart") && !p.hasPermission("redprotect.bypass.world")){
e.setCancelled(true);
}
}
示例2: onVehicleBreak
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onVehicleBreak(VehicleDestroyEvent e){
RedProtect.get().logger.debug("RPBlockListener - Is VehicleDestroyEvent event");
if (e.isCancelled()){
return;
}
if (!(e.getAttacker() instanceof Player)){
return;
}
Vehicle cart = e.getVehicle();
Player p = (Player) e.getAttacker();
Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());
if (r != null && !r.canMinecart(p)){
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
}
}
示例3: teleportVehicle
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
public static void teleportVehicle(final Player player, final String vehicleTypeName, final double velocity, final Location location) {
checkChunkLoad(location.getBlock());
// Crete new velocity
final Vector newVelocity = location.getDirection();
newVelocity.multiply(velocity);
final Vehicle v = (Vehicle) location.getWorld().spawnEntity(location, EntityUtil.entityType(vehicleTypeName));
player.teleport(location);
Plugin.instance.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() {
@Override
public void run() {
v.setPassenger(player);
v.setVelocity(newVelocity);
}
}, 2);
}
示例4: onPlayerUnleashEntity
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onPlayerUnleashEntity(PlayerUnleashEntityEvent event) {
List<String> denyRiding = Config.REGION_DENYRIDING.getStringList();
Player player = event.getPlayer();
Entity entity = event.getEntity();
NovaPlayer nPlayer = PlayerManager.getPlayer(player);
if(denyRiding.contains(entity.getType().name())) {
if(RegionManager.get(entity) != null
&& (!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_LEASH)))
&& !(entity instanceof Vehicle) || !PlayerManager.getPlayer(player).isVehicleListed((Vehicle) event.getEntity())) {
event.setCancelled(true);
Message.CHAT_REGION_DENY_UNLEASH.send(player);
}
}
}
示例5: onVehicleEnter
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
Vehicle vehicle = event.getVehicle();
if(!(event.getEntered() instanceof Player)) {
return;
}
final Player player = (Player) event.getEntered();
NovaPlayer nPlayer = PlayerManager.getPlayer(player);
List<String> denyRiding = Config.REGION_DENYRIDING.getStringList();
if(denyRiding.contains(vehicle.getType().name())
&& RegionManager.get(vehicle) != null
&& (!plugin.getRegionManager().canInteract(player, vehicle) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_RIDE)))
&& !PlayerManager.getPlayer(event.getEntered()).isVehicleListed(vehicle)) {
event.setCancelled(true);
Message.CHAT_REGION_DENY_RIDEMOB.send(event.getEntered());
}
}
示例6: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVehicleCreate(VehicleCreateEvent event) {
Vehicle entity = event.getVehicle();
Location location = BukkitUtil.getLocation(entity);
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
if (plot == null || checkEntity(entity, plot)) {
entity.remove();
return;
}
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
}
}
示例7: applyEntityCollision
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@Override
/**
* Applies a velocity to each of the entities pushing them away from each other. Args: entity
*/
public void applyEntityCollision(Entity entity)
{
org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
this.worldObj.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
super.applyEntityCollision(entity);
}
示例8: p
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
protected void p(Entity entity) {
if (entity.bz() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent(
(Vehicle) getBukkitEntity(),
(LivingEntity) entity.getBukkitEntity()
);
Bukkit.getPluginManager().callEvent(event);
CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity n = craftn == null ? null : craftn.getHandle();
if (event.isCancelled() || n != orig) {
return;
}
}
// CraftBukkit end
Bukkit.getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity())); // Spigot
this.passengers.remove(entity);
entity.j = 60;
}
}
示例9: onVehicleDestroy
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
Vehicle v = event.getVehicle();
Entity attacker = event.getAttacker();
ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
for(Arena a : am.getArenas()) {
if(a.isArenaCuboidSet()) {
if(a.getArenaCuboid().isInsideCuboid(v.getLocation())) {
if(!a.isInEditMode()) {
event.setCancelled(true);
if(attacker instanceof Player) {
Player p = (Player) attacker;
p.sendMessage(ChatColor.DARK_RED + "You may not destroy this vehicle!");
}
}
}
}
}
}
示例10: onDismount
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@EventHandler
public void onDismount(VehicleExitEvent event) {
if (event.getExited() instanceof Player) {
Player p = (Player) event.getExited();
if (plugin.getPD(p) != null)
plugin.getPD(p).riding = false;
}
if (horseUUIDs.contains(event.getVehicle().getUniqueId())) {
Vehicle v = event.getVehicle();
RScheduler.schedule(plugin, new Runnable() {
public void run() {
if (v != null && v.isValid()) {
if (v instanceof Horse) {
if (((CraftHorse) v).getHandle() instanceof CustomHorse) {
((CustomHorse) ((CraftHorse) v).getHandle()).rearUp();
}
}
}
}
}, 10);
RScheduler.schedule(plugin, new Runnable() {
public void run() {
if (v != null && v.isValid()) {
RParticles.show(ParticleEffect.CLOUD, v.getLocation().add(0, 1, 0), 10);
v.remove();
}
}
}, 35);
}
}
示例11: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入依赖的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();
}
}
}
示例12: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
/**
* Handles vehicle spawning
*
* @param e an event representing a vehicle that has spawned
* @see VehicleCreateEvent
* @since 4.0.0
*/
@EventHandler(ignoreCancelled = true)
public void onVehicleCreate(VehicleCreateEvent e) {
Vehicle vehicle = e.getVehicle();
Plot plot;
if ((plot = Plot.getPlot(vehicle.getLocation())) != null) {
if (!plot.addEntity(vehicle))
vehicle.remove();
}
}
示例13: EntityMinecartAbstract
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
public EntityMinecartAbstract(World world, double d0, double d1, double d2) {
this(world);
this.setPosition(d0, d1, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
示例14: collide
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
@Override
public void collide(Entity entity) {
org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
super.collide(entity);
}
示例15: EntityBoat
import org.bukkit.entity.Vehicle; //导入依赖的package包/类
public EntityBoat(World world, double d0, double d1, double d2) {
this(world);
this.setPosition(d0, d1 + (double) this.height, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}