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


Java RideableMinecart类代码示例

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


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

示例1: startRoute

import org.bukkit.entity.minecart.RideableMinecart; //导入依赖的package包/类
public RoutePlayer startRoute(final Player player, Route route, Location loc) {
	if (!route.isComplete() || this.isRoutePlayer(player)) return null;
	
	if (this.isDeincartItem(player.getItemInHand())) {
		player.setItemInHand(null);
		player.updateInventory();
	}
	
	FakeMinecart entity = new FakeMinecart(((CraftWorld)loc.getWorld()).getHandle(), loc.getX() + 0.5D, loc.getY() + 0.5D, loc.getZ() + 0.5D);
	((CraftWorld)loc.getWorld()).getHandle().addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
	
	RideableMinecart minecart = (RideableMinecart) entity.getBukkitEntity();
	minecart.setPassenger(player);
	
	RoutePlayer user = new RoutePlayer(player, minecart, route);
	user.setInventory(player.getInventory().getContents());
	this.players.put(player, user);
	
	player.getInventory().clear();
	
	ItemStack stack = new ItemStack(Material.WOOD_DOOR);
	ItemMeta meta = stack.getItemMeta();
	meta.setDisplayName("§6Fahrt abbrechen.");
	stack.setItemMeta(meta);
	
	player.getInventory().setItem(0, stack);
	player.updateInventory();
	return user;
}
 
开发者ID:Howaner,项目名称:DeinCart,代码行数:30,代码来源:CartManager.java

示例2: onPlayerInteractEntity

import org.bukkit.entity.minecart.RideableMinecart; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
    final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
    if (PlotSquared.isPlotWorld(l.getWorld())) {
        final Player p = e.getPlayer();
        final PlotPlayer pp = BukkitUtil.getPlayer(p);
        Plot plot = MainUtil.getPlot(l);
        if (plot == null) {
            if (!MainUtil.isPlotAreaAbs(l)) {
                return;
            }
            if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
                MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
                e.setCancelled(true);
                return;
            }
        } else {
            if (!plot.hasOwner()) {
                if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
                    MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
                    e.setCancelled(true);
                    return;
                }
            } else if (!plot.isAdded(pp.getUUID())) {
                final Entity entity = e.getRightClicked();
                if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, "hostile-interact")) {
                    return;
                }
                if ((entity instanceof Animals) && FlagManager.isPlotFlagTrue(plot, "animal-interact")) {
                    return;
                }
                if ((entity instanceof Tameable) && ((Tameable) entity).isTamed() && FlagManager.isPlotFlagTrue(plot, "tamed-interact")) {
                    return;
                }
                if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
                    return;
                }
                if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
                    if (MainUtil.isPlotArea(l)) {
                        MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
                        e.setCancelled(true);
                        return;
                    }
                }
            }
        }
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:49,代码来源:PlayerEvents.java


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