Search in sources :

Example 1 with Plot

use of com.plotsquared.core.plot.Plot in project QuickShop-Hikari by Ghost-chu.

the class Plotsquared method canCreateShopHere.

@EventHandler(ignoreCancelled = true)
public boolean canCreateShopHere(ShopPreCreateEvent event) {
    Location location = event.getLocation();
    com.plotsquared.core.location.Location pLocation = com.plotsquared.core.location.Location.at(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Plot plot = pLocation.getPlot();
    if (plot == null) {
        return !whiteList;
    }
    return plot.getFlag(createFlag);
}
Also used : Plot(com.plotsquared.core.plot.Plot) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Plot

use of com.plotsquared.core.plot.Plot in project QuickShop-Hikari by Ghost-chu.

the class Plotsquared method canTradeShopHere.

@EventHandler(ignoreCancelled = true)
public boolean canTradeShopHere(ShopPurchaseEvent event) {
    Location location = event.getShop().getLocation();
    com.plotsquared.core.location.Location pLocation = com.plotsquared.core.location.Location.at(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Plot plot = pLocation.getPlot();
    if (plot == null) {
        return !whiteList;
    }
    return plot.getFlag(tradeFlag);
}
Also used : Plot(com.plotsquared.core.plot.Plot) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 3 with Plot

use of com.plotsquared.core.plot.Plot in project GSit by Gecolay.

the class PlSqLink method canCreateSeat.

public boolean canCreateSeat(org.bukkit.Location L, Player P) {
    PlotAPI plapi = new PlotAPI();
    Plot plot = plapi.wrapPlayer(P.getUniqueId()).getCurrentPlot();
    if (plot != null) {
        if (!plot.getArea().isSpawnCustom() && !(GPM.getCManager().DEV && NMSManager.isNewerOrVersion(17, 0)))
            return false;
        return !GPM.getCManager().REST_TEAM_PLOTS_ONLY || plot.isAdded(P.getUniqueId());
    }
    return !GPM.getCManager().REST_TEAM_PLOTS_ONLY;
}
Also used : PlotAPI(com.plotsquared.core.PlotAPI) Plot(com.plotsquared.core.plot.Plot)

Example 4 with Plot

use of com.plotsquared.core.plot.Plot in project FastAsyncWorldEdit by IntellectualSites.

the class PlotSetBiome method execute.

@Override
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
    final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
    checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.generatebiome"), TranslatableCaption.of("permission.no_plot_perms"));
    if (plot.getRunning() != 0) {
        player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
        return null;
    }
    checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"), Templates.of("value", getUsage()));
    final Set<CuboidRegion> regions = plot.getRegions();
    BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
    Collection<BiomeType> knownBiomes = BiomeTypes.values();
    final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry);
    if (biome == null) {
        String biomes = StringMan.join(BiomeType.REGISTRY.values(), TranslatableCaption.of("blocklist.block_list_separator").getComponent(player));
        player.sendMessage(TranslatableCaption.of("biome.need_biome"));
        player.sendMessage(TranslatableCaption.of("commandconfig.subcommand_set_options_header"), Templates.of("values", biomes));
        return CompletableFuture.completedFuture(false);
    }
    confirm.run(this, () -> {
        if (plot.getRunning() != 0) {
            player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
            return;
        }
        plot.addRunning();
        TaskManager.taskManager().async(() -> {
            EditSession session = WorldEdit.getInstance().newEditSessionBuilder().world(BukkitAdapter.adapt(Bukkit.getWorld(plot.getArea().getWorldName()))).checkMemory(false).allowedRegionsEverywhere().actor(BukkitAdapter.adapt(Bukkit.getPlayer(player.getUUID()))).limitUnlimited().build();
            long seed = ThreadLocalRandom.current().nextLong();
            for (CuboidRegion region : regions) {
                session.regenerate(region, biome, seed);
            }
            session.flushQueue();
            plot.removeRunning();
        });
    }, null);
    return CompletableFuture.completedFuture(true);
}
Also used : BiomeType(com.sk89q.worldedit.world.biome.BiomeType) BiomeRegistry(com.sk89q.worldedit.world.registry.BiomeRegistry) Plot(com.plotsquared.core.plot.Plot) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) EditSession(com.sk89q.worldedit.EditSession)

Example 5 with Plot

use of com.plotsquared.core.plot.Plot in project FastAsyncWorldEdit by IntellectualSites.

the class PlotSquaredFeature method getMask.

@Override
public FaweMask getMask(Player player, MaskType type, boolean isWhitelist) {
    final PlotPlayer<org.bukkit.entity.Player> pp = PlotPlayer.from(BukkitAdapter.adapt(player));
    if (pp == null) {
        return null;
    }
    final Set<CuboidRegion> regions;
    Plot plot = pp.getCurrentPlot();
    if (isAllowed(player, plot, type)) {
        regions = plot.getRegions();
    } else {
        plot = null;
        regions = WEManager.getMask(pp);
        if (regions.size() == 1) {
            CuboidRegion region = regions.iterator().next();
            if (region.getMinimumPoint().getX() == Integer.MIN_VALUE && region.getMaximumPoint().getX() == Integer.MAX_VALUE) {
                regions.clear();
            }
        }
    }
    if (regions.isEmpty()) {
        return null;
    }
    PlotArea area = pp.getApplicablePlotArea();
    final Plot finalPlot = plot;
    if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(finalPlot) || regions.isEmpty()) {
        return null;
    }
    Region maskedRegion;
    if (regions.size() == 1) {
        int min = area != null ? area.getMinBuildHeight() : player.getWorld().getMinY();
        int max = area != null ? Math.min(player.getWorld().getMaxY(), area.getMaxBuildHeight()) : player.getWorld().getMaxY();
        final CuboidRegion region = regions.iterator().next();
        final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
        final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
        maskedRegion = new CuboidRegion(pos1, pos2);
    } else {
        World world = FaweAPI.getWorld(area.getWorldName());
        List<Region> weRegions = regions.stream().map(r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()))).collect(Collectors.toList());
        maskedRegion = new RegionIntersection(world, weRegions);
    }
    return new FaweMask(maskedRegion) {

        @Override
        public boolean isValid(Player player, MaskType type) {
            if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(finalPlot)) {
                return false;
            }
            return isAllowed(player, finalPlot, type);
        }
    };
}
Also used : BlockVector3(com.sk89q.worldedit.math.BlockVector3) Player(com.sk89q.worldedit.entity.Player) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) World(com.sk89q.worldedit.world.World) Caption(com.fastasyncworldedit.core.configuration.Caption) DoneFlag(com.plotsquared.core.plot.flag.implementations.DoneFlag) FaweMask(com.fastasyncworldedit.core.regions.FaweMask) WEManager(com.plotsquared.core.util.WEManager) Locale(java.util.Locale) Region(com.sk89q.worldedit.regions.Region) Bukkit(org.bukkit.Bukkit) DBFunc(com.plotsquared.core.database.DBFunc) RegionIntersection(com.sk89q.worldedit.regions.RegionIntersection) Plot(com.plotsquared.core.plot.Plot) LogManagerCompat(com.sk89q.worldedit.internal.util.LogManagerCompat) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) NoWorldeditFlag(com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag) List(java.util.List) Logger(org.apache.logging.log4j.Logger) PlotPlayer(com.plotsquared.core.player.PlotPlayer) BukkitAdapter(com.sk89q.worldedit.bukkit.BukkitAdapter) FaweMaskManager(com.fastasyncworldedit.core.regions.FaweMaskManager) FaweAPI(com.fastasyncworldedit.core.FaweAPI) Settings(com.plotsquared.core.configuration.Settings) PlotArea(com.plotsquared.core.plot.PlotArea) Player(com.sk89q.worldedit.entity.Player) PlotPlayer(com.plotsquared.core.player.PlotPlayer) PlotArea(com.plotsquared.core.plot.PlotArea) FaweMask(com.fastasyncworldedit.core.regions.FaweMask) Plot(com.plotsquared.core.plot.Plot) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) BlockVector3(com.sk89q.worldedit.math.BlockVector3) World(com.sk89q.worldedit.world.World) RegionIntersection(com.sk89q.worldedit.regions.RegionIntersection) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Region(com.sk89q.worldedit.regions.Region)

Aggregations

Plot (com.plotsquared.core.plot.Plot)5 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)2 Location (org.bukkit.Location)2 EventHandler (org.bukkit.event.EventHandler)2 FaweAPI (com.fastasyncworldedit.core.FaweAPI)1 Caption (com.fastasyncworldedit.core.configuration.Caption)1 FaweMask (com.fastasyncworldedit.core.regions.FaweMask)1 FaweMaskManager (com.fastasyncworldedit.core.regions.FaweMaskManager)1 PlotAPI (com.plotsquared.core.PlotAPI)1 Settings (com.plotsquared.core.configuration.Settings)1 DBFunc (com.plotsquared.core.database.DBFunc)1 PlotPlayer (com.plotsquared.core.player.PlotPlayer)1 PlotArea (com.plotsquared.core.plot.PlotArea)1 DoneFlag (com.plotsquared.core.plot.flag.implementations.DoneFlag)1 NoWorldeditFlag (com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag)1 WEManager (com.plotsquared.core.util.WEManager)1 EditSession (com.sk89q.worldedit.EditSession)1 BukkitAdapter (com.sk89q.worldedit.bukkit.BukkitAdapter)1 Player (com.sk89q.worldedit.entity.Player)1 LogManagerCompat (com.sk89q.worldedit.internal.util.LogManagerCompat)1