Java 类org.bukkit.entity.minecart.RideableMinecart 实例源码

项目:DeinCart    文件:CartManager.java   
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;
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@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;
                    }
                }
            }
        }
    }
}