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);
}
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);
}
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;
}
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);
}
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);
}
};
}
Aggregations