PlotSquared/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java

1462 lines
52 KiB
Java
Raw Normal View History

/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-04-15 21:26:54 +02:00
package com.plotsquared.core.plot;
2016-02-10 19:59:51 +01:00
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.collection.QuadMap;
2020-04-16 06:14:33 +02:00
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
2020-04-30 12:01:52 +02:00
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
2020-08-04 19:01:25 +02:00
import com.plotsquared.core.configuration.caption.TranslatableCaption;
2020-07-10 19:25:05 +02:00
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GridPlotWorld;
import com.plotsquared.core.generator.IndependentPlotGenerator;
2020-07-11 17:19:19 +02:00
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
2020-08-05 12:48:10 +02:00
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.MetaDataAccess;
import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer;
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.plot.flag.FlagContainer;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.QueueCoordinator;
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.PlotExpression;
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.util.RegionUtil;
import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
2020-08-05 12:48:10 +02:00
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
2020-08-05 12:48:10 +02:00
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2021-08-18 11:58:18 +02:00
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
2018-08-10 17:01:10 +02:00
2020-08-05 12:48:10 +02:00
import java.text.DecimalFormat;
2019-11-04 18:44:23 +01:00
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
2019-11-04 18:44:23 +01:00
import java.util.List;
import java.util.Map;
2016-02-27 21:04:57 +01:00
import java.util.Map.Entry;
2019-11-04 18:44:23 +01:00
import java.util.Set;
import java.util.UUID;
2016-02-27 21:04:57 +01:00
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
2016-02-27 21:04:57 +01:00
2016-02-10 19:59:51 +01:00
/**
* @author Jesse Boyd, Alexander Söderberg
2016-02-10 19:59:51 +01:00
*/
public abstract class PlotArea implements ComponentLike {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + PlotArea.class.getSimpleName());
2020-08-05 12:48:10 +02:00
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
2020-08-05 12:48:10 +02:00
static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
}
2020-06-26 11:03:42 +02:00
2018-08-10 17:01:10 +02:00
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
@NonNull
private final String worldName;
2020-07-17 17:24:45 +02:00
private final String id;
@NonNull
private final PlotManager plotManager;
2020-07-17 17:24:45 +02:00
private final int worldHash;
private final PlotId min;
private final PlotId max;
@NonNull
private final IndependentPlotGenerator generator;
/**
* Area flag container
*/
private final FlagContainer flagContainer =
new FlagContainer(GlobalFlagContainer.getInstance());
private final FlagContainer roadFlagContainer =
new FlagContainer(GlobalFlagContainer.getInstance());
private final YamlConfiguration worldConfiguration;
private final GlobalBlockQueue globalBlockQueue;
private boolean roadFlags = false;
2020-07-17 17:24:45 +02:00
private boolean autoMerge = false;
private boolean allowSigns = true;
private boolean miscSpawnUnowned = false;
private boolean mobSpawning = false;
private boolean mobSpawnerSpawning = false;
private BiomeType plotBiome = BiomeTypes.FOREST;
private boolean plotChat = true;
private boolean forcingPlotChat = false;
private boolean schematicClaimSpecify = false;
private boolean schematicOnClaim = false;
private String schematicFile = "null";
private boolean spawnEggs = false;
private boolean spawnCustom = true;
private boolean spawnBreeding = false;
private PlotAreaType type = PlotAreaType.NORMAL;
private PlotAreaTerrainType terrain = PlotAreaTerrainType.NONE;
private boolean homeAllowNonmember = false;
private BlockLoc nonmemberHome;
private BlockLoc defaultHome;
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
private int maxBuildHeight = PlotSquared.platform().versionMaxHeight() + 1; // Exclusive
private int minBuildHeight = PlotSquared.platform().versionMinHeight() + 1; // Inclusive
private int maxGenHeight = PlotSquared.platform().versionMaxHeight(); // Inclusive
private int minGenHeight = PlotSquared.platform().versionMinHeight(); // Inclusive
2020-07-17 17:24:45 +02:00
private GameMode gameMode = GameModes.CREATIVE;
private Map<String, PlotExpression> prices = new HashMap<>();
2020-07-17 17:24:45 +02:00
private List<String> schematics = new ArrayList<>();
private boolean worldBorder = false;
private boolean useEconomy = false;
private int hash;
private CuboidRegion region;
2016-02-10 19:59:51 +01:00
private ConcurrentHashMap<String, Object> meta;
private QuadMap<PlotCluster> clusters;
2021-05-21 19:14:13 +02:00
private String signMaterial = "OAK_WALL_SIGN";
private String legacySignMaterial = "WALL_SIGN";
2016-02-10 19:59:51 +01:00
public PlotArea(
final @NonNull String worldName, final @Nullable String id,
@NonNull IndependentPlotGenerator generator, final @Nullable PlotId min,
final @Nullable PlotId max,
@WorldConfig final @Nullable YamlConfiguration worldConfiguration,
final @NonNull GlobalBlockQueue blockQueue
) {
this.worldName = worldName;
2016-02-10 19:59:51 +01:00
this.id = id;
this.plotManager = createManager();
2016-02-10 19:59:51 +01:00
this.generator = generator;
2020-07-10 22:12:37 +02:00
this.globalBlockQueue = blockQueue;
if (min == null || max == null) {
2016-02-10 19:59:51 +01:00
if (min != max) {
2018-08-10 17:01:10 +02:00
throw new IllegalArgumentException(
"None of the ids can be null for this constructor");
2016-02-10 19:59:51 +01:00
}
this.min = null;
this.max = null;
} else {
this.min = min;
this.max = max;
}
this.worldHash = worldName.hashCode();
2020-07-10 19:25:05 +02:00
this.worldConfiguration = worldConfiguration;
2016-02-10 19:59:51 +01:00
}
private static Collection<PlotFlag<?, ?>> parseFlags(List<String> flagStrings) {
final Collection<PlotFlag<?, ?>> flags = new ArrayList<>();
for (final String key : flagStrings) {
final String[] split;
if (key.contains(";")) {
split = key.split(";");
} else {
split = key.split(":");
}
final PlotFlag<?, ?> flagInstance =
GlobalFlagContainer.getInstance().getFlagFromString(split[0]);
if (flagInstance != null) {
try {
flags.add(flagInstance.parse(split[1]));
} catch (final FlagParseException e) {
LOGGER.warn(
"Failed to parse default flag with key '{}' and value '{}'. "
+ "Reason: {}. This flag will not be added as a default flag.",
e.getFlag().getName(),
e.getValue(),
e.getErrorMessage()
);
e.printStackTrace();
}
}
}
return flags;
}
@NonNull
protected abstract PlotManager createManager();
public QueueCoordinator getQueue() {
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(worldName));
}
2016-02-10 19:59:51 +01:00
/**
2019-12-09 20:43:53 +01:00
* Returns the region for this PlotArea, or a CuboidRegion encompassing
* the whole world if none exists.
*
* @return CuboidRegion
2016-02-10 19:59:51 +01:00
*/
public CuboidRegion getRegion() {
2016-03-23 02:41:37 +01:00
this.region = getRegionAbs();
if (this.region == null) {
Pull/2693 (#2694) * Commit WIP flag work. * More ported flag types, and additions to the flag API. * Make PlotFlag more generic to allow generic flag creation * Pull Captions methods into a Caption interface. * Port MusicFlag * Port flight flag * Port UntrustedVisitFlag * Port DenyExitFlag * Remove paper suggestion * Make ListFlag lists immutable * Update Flag containers. Add javadocs. Add missing methods. * Port description flag * Port greeting and farewell flags * Port weather flag * Move getExample implementation to BooleanFlag * Port reserved flags * Port all boolean flags. * Remove unused flag types * Invert liquid-flow flag * Find the real (legacy) flag name * Change NOITFY -> NOTIFY in Captions * Make IntegerFlag extendable * Port integer flags * Update Flag command to current API state * Begin remaking flag command * Create DoubleFlag + extract common parsing stuff * Supply arguments in flag parse exceptions * Implement missing flag subcommands * Update Flag command to current API state * Implement PriceFlag * Port deny-teleport * Port gamemode flags * Port BreakFlag * Port PlaceFlag * Port UseFlag * Remove old unused flag constants * Port blocked-cmds flag * Fix entity util * Port TimeFlag * Use CaptionUtility for formatting * Port keep flag * Fix imports * Reformat code * Remove unused classes * Fix MainUtil.java * Remove FlagCmd * Add flag info header and footer * Comment out flag related stuff in SchematicHandler * Remove FlagManager * Finalize Plot.java * Finalize PlotArea.java * Finalize PlotListener * Fix API issues * Fix a bunch of compile errors * Fix `/plot flag remove` * Fix initialization of GlobalFlagContainer * Apply API changes to events * Update SQLManager to new API * Invert default value for DenyExitFlag * Replace flag.getValue().toString() with flag.toString() * Make FlagContainer instance in Plot final * Fix various command issues * Clean up PlotSettings * Don't show internal flags in flag list * Fix `/plot flag add` * Remove the info inventory as it's 100% broken * Add plot info entries and fix up the default format * Fix default flag state in Captions * 781c200 part 2 * Fix odd grammar in captions * Fix odd grammar in captions v2 * Add create table statements for plot_flags * Remove old flag references in SQLManager * Use the new plot_flags table * Add tab completion to `/plot flag` * Improve parse error handling * Make flag permission check recognize parse exceptions * Initial progress towards flag conversion * Fix minor issues * Don't validate flags during flag conversion * Allow unrecognized flags to be parsed * Filter out internal flags from command sugguestions * Use the wrong caption when there's no plot description set * Limit command suggestions for boolean flags * Make blocktypelistflags accept blockcategories * Require categories to be prefixed with '#' and fix some minor display issues * Fix plot database conversion * Update PlotFlagEvent.java Updated return description * Fix command annotation wrapping * Add FLAG_UPDATE event for FlagContainer listeners * Make getParentContainer nullable * Document castUnsafe in FlagContainer * Document FlagContainer constructors * Add missing documentation to FlagContainer * Document FlagParseException * Fix wording in FlagContainer javadoc * Document InternalFlag * Document PlotFlag * Minor changes * Remove revisit comments Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
2020-02-24 18:42:02 +01:00
return new CuboidRegion(
BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
);
}
2016-03-23 02:41:37 +01:00
return this.region;
}
/**
* Returns the region for this PlotArea.
2016-03-19 19:07:55 +01:00
*
* @return CuboidRegion or null if no applicable region
*/
private CuboidRegion getRegionAbs() {
2016-03-23 02:41:37 +01:00
if (this.region == null) {
if (this.min != null) {
Location bot = getPlotManager().getPlotBottomLocAbs(this.min);
Location top = getPlotManager().getPlotTopLocAbs(this.max);
BlockVector3 pos1 = bot.getBlockVector3().subtract(BlockVector3.ONE);
BlockVector3 pos2 = top.getBlockVector3().add(BlockVector3.ONE);
this.region = new CuboidRegion(pos1, pos2);
2016-02-10 19:59:51 +01:00
}
}
2016-03-23 02:41:37 +01:00
return this.region;
2016-02-10 19:59:51 +01:00
}
2016-02-10 19:59:51 +01:00
/**
2016-06-01 22:50:35 +02:00
* Returns the minimum value of a {@link PlotId}.
2018-08-10 17:01:10 +02:00
*
* @return the minimum value for a {@link PlotId}
2016-02-10 19:59:51 +01:00
*/
public @NonNull PlotId getMin() {
2020-07-18 11:05:16 +02:00
return this.min == null ? PlotId.of(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
2016-02-10 19:59:51 +01:00
}
2016-02-10 19:59:51 +01:00
/**
* Returns the max PlotId.
2018-08-10 17:01:10 +02:00
*
* @return the maximum value for a {@link PlotId}
2016-02-10 19:59:51 +01:00
*/
public @NonNull PlotId getMax() {
2020-07-18 11:05:16 +02:00
return this.max == null ? PlotId.of(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
2016-02-10 19:59:51 +01:00
}
@Override
public boolean equals(Object obj) {
2016-02-10 19:59:51 +01:00
if (this == obj) {
return true;
}
2016-04-30 00:14:12 +02:00
if (obj == null || getClass() != obj.getClass()) {
2016-02-10 19:59:51 +01:00
return false;
}
2016-03-23 02:41:37 +01:00
PlotArea plotarea = (PlotArea) obj;
2020-04-30 12:01:52 +02:00
return this.getWorldHash() == plotarea.getWorldHash() && this.getWorldName()
.equals(plotarea.getWorldName()) && StringMan.isEqual(this.getId(), plotarea.getId());
2016-02-10 19:59:51 +01:00
}
2016-02-10 19:59:51 +01:00
public Set<PlotCluster> getClusters() {
return this.clusters == null ? new HashSet<>() : this.clusters.getAll();
2016-02-10 19:59:51 +01:00
}
/**
2021-08-24 15:34:21 +02:00
* Check if a PlotArea is compatible (move/copy etc.).
2018-08-10 17:01:10 +02:00
*
2021-08-24 15:34:21 +02:00
* @param plotArea the {@link PlotArea} to compare
* @return {@code true} if both areas are compatible
*/
public boolean isCompatible(final @NonNull PlotArea plotArea) {
2020-07-10 19:25:05 +02:00
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
Object constant = section.get(plotArea.worldName + '.' + setting.getConstant());
2018-08-10 17:01:10 +02:00
if (constant == null || !constant
.equals(section.get(this.worldName + '.' + setting.getConstant()))) {
2016-02-10 19:59:51 +01:00
return false;
}
}
return true;
}
/**
* When a world is created, the following method will be called for each.
2016-02-10 19:59:51 +01:00
*
* @param config Configuration Section
*/
2016-03-23 02:41:37 +01:00
public void loadDefaultConfiguration(ConfigurationSection config) {
if ((this.min != null || this.max != null) && !(this instanceof GridPlotWorld)) {
2016-02-10 19:59:51 +01:00
throw new IllegalArgumentException("Must extend GridPlotWorld to provide");
}
if (config.contains("generator.terrain")) {
this.terrain = ConfigurationUtil.getTerrain(config);
this.type = ConfigurationUtil.getType(config);
}
this.mobSpawning = config.getBoolean("natural_mob_spawning");
this.miscSpawnUnowned = config.getBoolean("misc_spawn_unowned");
this.mobSpawnerSpawning = config.getBoolean("mob_spawner_spawning");
this.autoMerge = config.getBoolean("plot.auto_merge");
this.allowSigns = config.getBoolean("plot.create_signs");
if (PlotSquared.platform().serverVersion()[1] == 13) {
this.legacySignMaterial = config.getString("plot.legacy_sign_material");
} else {
this.signMaterial = config.getString("plot.sign_material");
}
String biomeString = config.getString("plot.biome");
if (!biomeString.startsWith("minecraft:")) {
biomeString = "minecraft:" + biomeString;
config.set("plot.biome", biomeString.toLowerCase());
}
this.plotBiome = ConfigurationUtil.BIOME.parseString(biomeString.toLowerCase());
this.schematicOnClaim = config.getBoolean("schematic.on_claim");
this.schematicFile = config.getString("schematic.file");
this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
this.schematics.replaceAll(String::toLowerCase);
this.useEconomy = config.getBoolean("economy.use");
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
if (this.useEconomy) {
this.prices = new HashMap<>();
2016-03-19 19:07:55 +01:00
for (String key : priceSection.getKeys(false)) {
String raw = priceSection.getString(key);
if (raw.contains("{arg}")) {
raw = raw.replace("{arg}", "plots");
priceSection.set(key, raw); // update if replaced
}
this.prices.put(key, PlotExpression.compile(raw, "plots"));
2016-03-19 19:07:55 +01:00
}
}
this.plotChat = config.getBoolean("chat.enabled");
this.forcingPlotChat = config.getBoolean("chat.forced");
this.worldBorder = config.getBoolean("world.border");
this.maxBuildHeight = config.getInt("world.max_height");
this.minBuildHeight = config.getInt("world.min_height");
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
this.minGenHeight = config.getInt("world.min_gen_height");
this.maxGenHeight = config.getInt("world.max_gen_height");
2016-02-10 19:59:51 +01:00
switch (config.getString("world.gamemode").toLowerCase()) {
case "creative", "c", "1" -> this.gameMode = GameModes.CREATIVE;
case "adventure", "a", "2" -> this.gameMode = GameModes.ADVENTURE;
case "spectator", "3" -> this.gameMode = GameModes.SPECTATOR;
default -> this.gameMode = GameModes.SURVIVAL;
2016-02-10 19:59:51 +01:00
}
String homeNonMembers = config.getString("home.nonmembers");
2016-03-23 02:41:37 +01:00
String homeDefault = config.getString("home.default");
this.defaultHome = BlockLoc.fromString(homeDefault);
this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
if (this.homeAllowNonmember) {
this.nonmemberHome = defaultHome;
} else {
this.nonmemberHome = BlockLoc.fromString(homeNonMembers);
}
if ("side".equalsIgnoreCase(homeDefault)) {
this.defaultHome = null;
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle", "centre")) {
this.defaultHome = new BlockLoc(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
2016-02-10 19:59:51 +01:00
} else {
try {
/*String[] split = homeDefault.split(",");
2018-08-10 17:01:10 +02:00
this.DEFAULT_HOME =
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
this.defaultHome = BlockLoc.fromString(homeDefault);
2016-04-30 00:14:12 +02:00
} catch (NumberFormatException ignored) {
this.defaultHome = null;
2016-02-10 19:59:51 +01:00
}
}
2016-02-10 19:59:51 +01:00
List<String> flags = config.getStringList("flags.default");
2016-03-29 06:56:44 +02:00
if (flags.isEmpty()) {
2016-02-10 19:59:51 +01:00
flags = config.getStringList("flags");
2016-03-29 06:56:44 +02:00
if (flags.isEmpty()) {
2016-02-10 19:59:51 +01:00
flags = new ArrayList<>();
2016-03-23 02:41:37 +01:00
ConfigurationSection section = config.getConfigurationSection("flags");
Set<String> keys = section.getKeys(false);
for (String key : keys) {
if (!"default".equals(key)) {
2016-04-30 00:14:12 +02:00
flags.add(key + ';' + section.get(key));
2016-02-10 19:59:51 +01:00
}
}
}
}
2020-04-11 17:19:43 +02:00
this.getFlagContainer().addAll(parseFlags(flags));
ConsolePlayer.getConsole().sendMessage(
2021-05-02 20:31:23 +02:00
TranslatableCaption.of("flags.area_flags"),
TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString())))
);
this.spawnEggs = config.getBoolean("event.spawn.egg");
this.spawnCustom = config.getBoolean("event.spawn.custom");
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
2020-07-01 15:53:57 +02:00
2020-10-11 20:24:50 +02:00
List<String> roadflags = config.getStringList("road.flags");
2020-07-01 15:53:57 +02:00
if (roadflags.isEmpty()) {
2020-10-11 20:24:50 +02:00
roadflags = new ArrayList<>();
ConfigurationSection section = config.getConfigurationSection("road.flags");
Set<String> keys = section.getKeys(false);
for (String key : keys) {
if (!"default".equals(key)) {
roadflags.add(key + ';' + section.get(key));
2020-07-01 15:53:57 +02:00
}
}
}
this.roadFlags = roadflags.size() > 0;
2020-07-01 15:53:57 +02:00
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
ConsolePlayer.getConsole().sendMessage(
2021-05-02 20:31:23 +02:00
TranslatableCaption.of("flags.road_flags"),
TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString())))
);
2020-08-05 12:48:10 +02:00
loadConfiguration(config);
}
2016-03-23 02:41:37 +01:00
public abstract void loadConfiguration(ConfigurationSection config);
2018-08-10 17:01:10 +02:00
2016-02-10 19:59:51 +01:00
/**
* Saving core PlotArea settings.
2016-02-10 19:59:51 +01:00
*
* @param config Configuration Section
*/
2016-03-23 02:41:37 +01:00
public void saveConfiguration(ConfigurationSection config) {
HashMap<String, Object> options = new HashMap<>();
options.put("natural_mob_spawning", this.isMobSpawning());
options.put("misc_spawn_unowned", this.isMiscSpawnUnowned());
options.put("mob_spawner_spawning", this.isMobSpawnerSpawning());
options.put("plot.auto_merge", this.isAutoMerge());
options.put("plot.create_signs", this.allowSigns());
if (PlotSquared.platform().serverVersion()[1] == 13) {
options.put("plot.legacy_sign_material", this.legacySignMaterial);
} else {
options.put("plot.sign_material", this.signMaterial());
}
options.put("plot.biome", "minecraft:forest");
options.put("schematic.on_claim", this.isSchematicOnClaim());
options.put("schematic.file", this.getSchematicFile());
options.put("schematic.specify_on_claim", this.isSchematicClaimSpecify());
options.put("schematic.schematics", this.getSchematics());
options.put("economy.use", this.useEconomy());
options.put("economy.prices.claim", 100);
options.put("economy.prices.merge", 100);
options.put("economy.prices.sell", 100);
options.put("chat.enabled", this.isPlotChat());
options.put("chat.forced", this.isForcingPlotChat());
2016-02-10 19:59:51 +01:00
options.put("flags.default", null);
options.put("event.spawn.egg", this.isSpawnEggs());
options.put("event.spawn.custom", this.isSpawnCustom());
options.put("event.spawn.breeding", this.isSpawnBreeding());
options.put("world.border", this.hasWorldBorder());
2016-02-10 19:59:51 +01:00
options.put("home.default", "side");
String position = config.getString(
"home.nonmembers",
config.getBoolean("home.allow-nonmembers", false) ?
config.getString("home.default", "side") :
"side"
);
options.put("home.nonmembers", position);
options.put("world.max_height", this.getMaxBuildHeight());
options.put("world.min_height", this.getMinBuildHeight());
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
options.put("world.min_gen_height", this.getMinGenHeight());
options.put("world.max_gen_height", this.getMaxGenHeight());
options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
2020-07-01 15:53:57 +02:00
options.put("road.flags.default", null);
if (this.getType() != PlotAreaType.NORMAL) {
options.put("generator.terrain", this.getTerrain());
options.put("generator.type", this.getType().toString());
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
ConfigurationNode[] settings = getSettingNodes();
2016-02-10 19:59:51 +01:00
/*
* Saving generator specific settings
*/
2016-03-23 02:41:37 +01:00
for (ConfigurationNode setting : settings) {
2016-02-10 19:59:51 +01:00
options.put(setting.getConstant(), setting.getValue());
}
2016-03-23 02:41:37 +01:00
for (Entry<String, Object> stringObjectEntry : options.entrySet()) {
if (!config.contains(stringObjectEntry.getKey())) {
config.set(stringObjectEntry.getKey(), stringObjectEntry.getValue());
2016-02-10 19:59:51 +01:00
}
}
if (!config.contains("flags")) {
config.set(
"flags.use",
"63,64,68,69,71,77,96,143,167,193,194,195,196,197,77,143,69,70,72,147,148,107,183,184,185,186,187,132"
);
2016-02-10 19:59:51 +01:00
}
2020-07-01 15:53:57 +02:00
if (!config.contains("road.flags")) {
config.set("road.flags.liquid-flow", false);
}
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
@NonNull
@Override
public String toString() {
if (this.getId() == null) {
return this.getWorldName();
} else {
return this.getWorldName() + ";" + this.getId();
}
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
@Override
public @NotNull Component asComponent() {
return Component.text(toString());
}
@Override
public int hashCode() {
2016-03-23 02:41:37 +01:00
if (this.hash != 0) {
return this.hash;
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
return this.hash = toString().hashCode();
2016-02-10 19:59:51 +01:00
}
/**
* Used for the <b>/plot setup</b> command Return null if you do not want to support this feature
*
* @return ConfigurationNode[]
*/
public abstract ConfigurationNode[] getSettingNodes();
/**
2021-08-24 15:34:21 +02:00
* Gets the {@link Plot} at a location.
2018-08-10 17:01:10 +02:00
*
* @param location the location
2021-08-24 15:34:21 +02:00
* @return the {@link Plot} or null if none exists
*/
public @Nullable Plot getPlotAbs(final @NonNull Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
2016-02-10 19:59:51 +01:00
if (pid == null) {
return null;
}
return getPlotAbs(pid);
}
/**
* Gets the base plot at a location.
2018-08-10 17:01:10 +02:00
*
* @param location the location
* @return base Plot
*/
public @Nullable Plot getPlot(final @NonNull Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
2016-02-10 19:59:51 +01:00
if (pid == null) {
return null;
}
return getPlot(pid);
}
/**
* Get the owned base plot at a location.
2018-08-10 17:01:10 +02:00
*
* @param location the location
* @return the base plot or null
*/
public @Nullable Plot getOwnedPlot(final @NonNull Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
2016-02-10 19:59:51 +01:00
if (pid == null) {
return null;
}
2016-03-23 02:41:37 +01:00
Plot plot = this.plots.get(pid);
2016-02-10 19:59:51 +01:00
return plot == null ? null : plot.getBasePlot(false);
}
/**
2016-03-23 18:09:13 +01:00
* Get the owned plot at a location.
2018-08-10 17:01:10 +02:00
*
* @param location the location
* @return Plot or null
*/
public @Nullable Plot getOwnedPlotAbs(final @NonNull Location location) {
final PlotId pid =
this.getPlotManager().getPlotId(location.getX(), location.getY(), location.getZ());
2016-02-10 19:59:51 +01:00
if (pid == null) {
return null;
}
2016-03-23 02:41:37 +01:00
return this.plots.get(pid);
2016-02-10 19:59:51 +01:00
}
/**
2016-03-23 18:09:13 +01:00
* Get the owned Plot at a PlotId.
2018-08-10 17:01:10 +02:00
*
2021-08-24 15:34:21 +02:00
* @param id the {@link PlotId}
* @return the plot or null
*/
public @Nullable Plot getOwnedPlotAbs(final @NonNull PlotId id) {
2016-03-23 02:41:37 +01:00
return this.plots.get(id);
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
public @Nullable Plot getOwnedPlot(final @NonNull PlotId id) {
2016-03-23 02:41:37 +01:00
Plot plot = this.plots.get(id);
2016-02-10 19:59:51 +01:00
return plot == null ? null : plot.getBasePlot(false);
}
public boolean contains(final int x, final int z) {
return this.getType() != PlotAreaType.PARTIAL || RegionUtil.contains(getRegionAbs(), x, z);
}
2018-08-10 17:01:10 +02:00
public boolean contains(final @NonNull PlotId id) {
2020-07-18 11:05:16 +02:00
return this.min == null || (id.getX() >= this.min.getX() && id.getX() <= this.max.getX() &&
id.getY() >= this.min.getY() && id.getY() <= this.max.getY());
}
public boolean contains(final @NonNull Location location) {
return StringMan.isEqual(location.getWorldName(), this.getWorldName()) && (
getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
/**
* Get if the {@code PlotArea}'s build range (min build height -> max build height) contains the given y value
*
* @param y y height
* @return if build height contains y
*/
public boolean buildRangeContainsY(int y) {
return y >= minBuildHeight && y < maxBuildHeight;
}
/**
* Utility method to check if the player is attempting to place blocks outside the build area, and notify of this if the
* player does not have permissions.
*
* @param player Player to check
* @param y y height to check
* @return true if outside build area with no permissions
2022-06-27 14:56:44 +02:00
* @since 6.9.1
*/
public boolean notifyIfOutsideBuildArea(PlotPlayer<?> player, int y) {
if (!buildRangeContainsY(y) && !player.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
player.sendMessage(
TranslatableCaption.of("height.height_limit"),
2023-01-08 10:36:41 +01:00
TagResolver.builder()
.tag("minHeight", Tag.inserting(Component.text(minBuildHeight)))
.tag(
"maxHeight",
Tag.inserting(Component.text(maxBuildHeight))
).build()
);
// Return true if "failed" as the method will always be inverted otherwise
return true;
}
return false;
}
public @NonNull Set<Plot> getPlotsAbs(final UUID uuid) {
2016-12-10 20:33:48 +01:00
if (uuid == null) {
return Collections.emptySet();
}
2016-03-29 21:47:59 +02:00
final HashSet<Plot> myPlots = new HashSet<>();
forEachPlotAbs(value -> {
if (uuid.equals(value.getOwnerAbs())) {
myPlots.add(value);
2016-02-10 19:59:51 +01:00
}
2016-02-27 21:04:57 +01:00
});
2016-03-29 21:47:59 +02:00
return myPlots;
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
public @NonNull Set<Plot> getPlots(final @NonNull UUID uuid) {
return getPlots().stream().filter(plot -> plot.isBasePlot() && plot.isOwner(uuid))
.collect(ImmutableSet.toImmutableSet());
2016-02-10 19:59:51 +01:00
}
/**
2021-08-24 15:34:21 +02:00
* A collection of the claimed plots in this {@link PlotArea}.
2018-08-10 17:01:10 +02:00
*
* @return a collection of claimed plots
*/
public Collection<Plot> getPlots() {
return this.plots.values();
}
public int getPlotCount(final @NonNull UUID uuid) {
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
Pull/2693 (#2694) * Commit WIP flag work. * More ported flag types, and additions to the flag API. * Make PlotFlag more generic to allow generic flag creation * Pull Captions methods into a Caption interface. * Port MusicFlag * Port flight flag * Port UntrustedVisitFlag * Port DenyExitFlag * Remove paper suggestion * Make ListFlag lists immutable * Update Flag containers. Add javadocs. Add missing methods. * Port description flag * Port greeting and farewell flags * Port weather flag * Move getExample implementation to BooleanFlag * Port reserved flags * Port all boolean flags. * Remove unused flag types * Invert liquid-flow flag * Find the real (legacy) flag name * Change NOITFY -> NOTIFY in Captions * Make IntegerFlag extendable * Port integer flags * Update Flag command to current API state * Begin remaking flag command * Create DoubleFlag + extract common parsing stuff * Supply arguments in flag parse exceptions * Implement missing flag subcommands * Update Flag command to current API state * Implement PriceFlag * Port deny-teleport * Port gamemode flags * Port BreakFlag * Port PlaceFlag * Port UseFlag * Remove old unused flag constants * Port blocked-cmds flag * Fix entity util * Port TimeFlag * Use CaptionUtility for formatting * Port keep flag * Fix imports * Reformat code * Remove unused classes * Fix MainUtil.java * Remove FlagCmd * Add flag info header and footer * Comment out flag related stuff in SchematicHandler * Remove FlagManager * Finalize Plot.java * Finalize PlotArea.java * Finalize PlotListener * Fix API issues * Fix a bunch of compile errors * Fix `/plot flag remove` * Fix initialization of GlobalFlagContainer * Apply API changes to events * Update SQLManager to new API * Invert default value for DenyExitFlag * Replace flag.getValue().toString() with flag.toString() * Make FlagContainer instance in Plot final * Fix various command issues * Clean up PlotSettings * Don't show internal flags in flag list * Fix `/plot flag add` * Remove the info inventory as it's 100% broken * Add plot info entries and fix up the default format * Fix default flag state in Captions * 781c200 part 2 * Fix odd grammar in captions * Fix odd grammar in captions v2 * Add create table statements for plot_flags * Remove old flag references in SQLManager * Use the new plot_flags table * Add tab completion to `/plot flag` * Improve parse error handling * Make flag permission check recognize parse exceptions * Initial progress towards flag conversion * Fix minor issues * Don't validate flags during flag conversion * Allow unrecognized flags to be parsed * Filter out internal flags from command sugguestions * Use the wrong caption when there's no plot description set * Limit command suggestions for boolean flags * Make blocktypelistflags accept blockcategories * Require categories to be prefixed with '#' and fix some minor display issues * Fix plot database conversion * Update PlotFlagEvent.java Updated return description * Fix command annotation wrapping * Add FLAG_UPDATE event for FlagContainer listeners * Make getParentContainer nullable * Document castUnsafe in FlagContainer * Document FlagContainer constructors * Add missing documentation to FlagContainer * Document FlagParseException * Fix wording in FlagContainer javadoc * Document InternalFlag * Document PlotFlag * Minor changes * Remove revisit comments Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
2020-02-24 18:42:02 +01:00
return (int) getPlotsAbs(uuid).stream().filter(plot -> !DoneFlag.isDone(plot)).count();
2016-02-10 19:59:51 +01:00
}
2016-06-01 22:50:35 +02:00
return getPlotsAbs(uuid).size();
2016-02-10 19:59:51 +01:00
}
2016-06-01 22:50:35 +02:00
/**
* Retrieves the plots for the player in this PlotArea.
*
* @param player player to get plots of
* @return set of player's plots
* @deprecated Use {@link #getPlots(UUID)}
*/
@Deprecated
2021-05-01 18:33:02 +02:00
public Set<Plot> getPlots(final @NonNull PlotPlayer<?> player) {
return getPlots(player.getUUID());
}
//todo check if this method is needed in this class
public boolean hasPlot(final @NonNull UUID uuid) {
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
2018-04-28 13:51:26 +02:00
}
public int getPlotCount(final @Nullable PlotPlayer<?> player) {
2016-02-10 19:59:51 +01:00
return player != null ? getPlotCount(player.getUUID()) : 0;
}
2020-04-30 12:01:52 +02:00
public @Nullable Plot getPlotAbs(final @NonNull PlotId id) {
2016-02-10 19:59:51 +01:00
Plot plot = getOwnedPlotAbs(id);
if (plot == null) {
2020-07-18 11:05:16 +02:00
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|| id.getY() > this.max.getY())) {
2016-02-10 19:59:51 +01:00
return null;
}
2020-07-10 22:12:37 +02:00
return new Plot(this, id);
2016-02-10 19:59:51 +01:00
}
return plot;
}
public @Nullable Plot getPlot(final @NonNull PlotId id) {
final Plot plot = getOwnedPlotAbs(id);
2016-02-10 19:59:51 +01:00
if (plot == null) {
2020-07-18 11:05:16 +02:00
if (this.min != null && (id.getX() < this.min.getX() || id.getX() > this.max.getX() || id.getY() < this.min.getY()
|| id.getY() > this.max.getY())) {
2016-02-10 19:59:51 +01:00
return null;
}
2020-07-10 22:12:37 +02:00
return new Plot(this, id);
2016-02-10 19:59:51 +01:00
}
return plot.getBasePlot(false);
}
2016-06-01 22:50:35 +02:00
/**
2021-08-24 15:34:21 +02:00
* Retrieves the number of claimed plot in the {@link PlotArea}.
2016-06-01 22:50:35 +02:00
*
* @return the number of claimed plots
*/
2016-02-10 19:59:51 +01:00
public int getPlotCount() {
2016-03-23 02:41:37 +01:00
return this.plots.size();
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
public @Nullable PlotCluster getCluster(final @NonNull Location location) {
final Plot plot = getPlot(location);
2016-02-10 19:59:51 +01:00
if (plot == null) {
return null;
}
2020-07-18 11:05:16 +02:00
return this.clusters != null ? this.clusters.get(plot.getId().getX(), plot.getId().getY()) : null;
2016-02-10 19:59:51 +01:00
}
public @Nullable PlotCluster getFirstIntersectingCluster(
final @NonNull PlotId pos1,
final @NonNull PlotId pos2
) {
if (this.clusters == null) {
2016-02-10 19:59:51 +01:00
return null;
}
2016-03-23 02:41:37 +01:00
for (PlotCluster cluster : this.clusters.getAll()) {
2016-02-10 19:59:51 +01:00
if (cluster.intersects(pos1, pos2)) {
return cluster;
}
}
return null;
}
@Nullable PlotCluster getCluster(final @NonNull PlotId id) {
2020-07-18 11:05:16 +02:00
return this.clusters != null ? this.clusters.get(id.getX(), id.getY()) : null;
2016-02-10 19:59:51 +01:00
}
2016-02-10 19:59:51 +01:00
/**
* Session only plot metadata (session is until the server stops).
2016-02-10 19:59:51 +01:00
* <br>
* For persistent metadata use the flag system
*
* @param key metadata key
* @param value metadata value
2016-02-10 19:59:51 +01:00
*/
public void setMeta(final @NonNull String key, final @Nullable Object value) {
2016-03-23 02:41:37 +01:00
if (this.meta == null) {
this.meta = new ConcurrentHashMap<>();
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
this.meta.put(key, value);
2016-02-10 19:59:51 +01:00
}
public @NonNull <T> T getMeta(final @NonNull String key, final @NonNull T def) {
final Object v = getMeta(key);
2017-04-17 03:56:10 +02:00
return v == null ? def : (T) v;
}
2016-02-10 19:59:51 +01:00
/**
* Get the metadata for a key<br>
* <br>
* For persistent metadata use the flag system
*
* @param key metadata key to get value for
* @return metadata value
2016-02-10 19:59:51 +01:00
*/
public @Nullable Object getMeta(final @NonNull String key) {
2016-03-23 02:41:37 +01:00
if (this.meta != null) {
return this.meta.get(key);
2016-02-10 19:59:51 +01:00
}
return null;
}
2016-06-01 22:50:35 +02:00
@SuppressWarnings("unused")
public @NonNull Set<Plot> getBasePlots() {
final HashSet<Plot> myPlots = new HashSet<>(getPlots());
myPlots.removeIf(plot -> !plot.isBasePlot());
2016-03-29 21:47:59 +02:00
return myPlots;
2016-02-10 19:59:51 +01:00
}
2016-02-27 21:04:57 +01:00
private void forEachPlotAbs(Consumer<Plot> run) {
for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) {
run.accept(entry.getValue());
2016-02-27 21:04:57 +01:00
}
}
2016-04-30 00:14:12 +02:00
public void forEachBasePlot(Consumer<Plot> run) {
for (final Plot plot : getPlots()) {
2016-02-10 19:59:51 +01:00
if (plot.isBasePlot()) {
run.accept(plot);
2016-02-10 19:59:51 +01:00
}
}
}
/**
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
*
* @return map of PlotId against Plot for all plots in this area
* @deprecated Poorly implemented. May be removed in future.
*/
//todo eventually remove
@Deprecated
public @NonNull Map<PlotId, Plot> getPlotsRaw() {
return ImmutableMap.copyOf(plots);
2016-02-10 19:59:51 +01:00
}
public @NonNull Set<Entry<PlotId, Plot>> getPlotEntries() {
2016-03-23 02:41:37 +01:00
return this.plots.entrySet();
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
public boolean addPlot(final @NonNull Plot plot) {
for (final PlotPlayer<?> pp : plot.getPlayersInPlot()) {
try (final MetaDataAccess<Plot> metaDataAccess = pp.accessTemporaryMetaData(
PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
metaDataAccess.set(plot);
}
2016-02-10 19:59:51 +01:00
}
2016-03-23 02:41:37 +01:00
return this.plots.put(plot.getId(), plot) == null;
2016-02-10 19:59:51 +01:00
}
2017-04-17 03:56:10 +02:00
2021-05-01 18:33:02 +02:00
public Plot getNextFreePlot(final PlotPlayer<?> player, @Nullable PlotId start) {
2017-04-17 03:56:10 +02:00
int plots;
PlotId center;
PlotId min = getMin();
PlotId max = getMax();
if (getType() == PlotAreaType.PARTIAL) {
2020-07-18 11:05:16 +02:00
center = PlotId.of(MathMan.average(min.getX(), max.getX()), MathMan.average(min.getY(), max.getY()));
plots = Math.max(max.getX() - min.getX() + 1, max.getY() - min.getY() + 1) + 1;
if (start != null) {
2020-07-18 11:05:16 +02:00
start = PlotId.of(start.getX() - center.getX(), start.getY() - center.getY());
}
2017-04-17 03:56:10 +02:00
} else {
2020-07-18 11:05:16 +02:00
center = PlotId.of(0, 0);
2017-04-17 03:56:10 +02:00
plots = Integer.MAX_VALUE;
}
for (int i = 0; i < plots; i++) {
if (start == null) {
2020-07-18 11:05:16 +02:00
start = getMeta("lastPlot", PlotId.of(0, 0));
2017-04-17 03:56:10 +02:00
} else {
2020-07-18 11:05:16 +02:00
start = start.getNextId();
2017-04-17 03:56:10 +02:00
}
2020-07-18 11:05:16 +02:00
PlotId currentId = PlotId.of(center.getX() + start.getX(), center.getY() + start.getY());
2017-04-17 03:56:10 +02:00
Plot plot = getPlotAbs(currentId);
if (plot != null && plot.canClaim(player)) {
2019-11-22 17:11:48 +01:00
setMeta("lastPlot", start);
2017-04-17 03:56:10 +02:00
return plot;
}
}
return null;
}
2018-08-10 17:01:10 +02:00
public boolean addPlotIfAbsent(final @NonNull Plot plot) {
2016-03-23 02:41:37 +01:00
if (this.plots.putIfAbsent(plot.getId(), plot) == null) {
for (PlotPlayer<?> pp : plot.getPlayersInPlot()) {
try (final MetaDataAccess<Plot> metaDataAccess = pp.accessTemporaryMetaData(
PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
metaDataAccess.set(plot);
}
2016-02-10 19:59:51 +01:00
}
return true;
}
return false;
}
public boolean addPlotAbs(final @NonNull Plot plot) {
2016-03-23 02:41:37 +01:00
return this.plots.put(plot.getId(), plot) == null;
2016-02-10 19:59:51 +01:00
}
/**
* Get the plot border distance for a world<br>
2018-08-10 17:01:10 +02:00
*
2016-02-10 19:59:51 +01:00
* @return The border distance or Integer.MAX_VALUE if no border is set
*/
public int getBorder() {
final Integer meta = (Integer) getMeta("worldBorder");
2016-02-10 19:59:51 +01:00
if (meta != null) {
2016-12-09 14:44:42 +01:00
int border = meta + 1;
2016-02-10 19:59:51 +01:00
if (border == 0) {
return Integer.MAX_VALUE;
} else {
return border;
}
}
return Integer.MAX_VALUE;
}
2018-08-10 17:01:10 +02:00
2016-02-10 19:59:51 +01:00
/**
* Setup the plot border for a world (usually done when the world is created).
2016-02-10 19:59:51 +01:00
*/
public void setupBorder() {
if (!this.hasWorldBorder()) {
2016-02-10 19:59:51 +01:00
return;
}
final Integer meta = (Integer) getMeta("worldBorder");
2016-02-10 19:59:51 +01:00
if (meta == null) {
setMeta("worldBorder", 1);
}
for (final Plot plot : getPlots()) {
2016-02-10 19:59:51 +01:00
plot.updateWorldBorder();
}
}
/**
* Delete the metadata for a key.
2018-08-10 17:01:10 +02:00
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key Meta data key
2016-02-10 19:59:51 +01:00
*/
public void deleteMeta(final @NonNull String key) {
2016-03-23 02:41:37 +01:00
if (this.meta != null) {
this.meta.remove(key);
2016-02-10 19:59:51 +01:00
}
}
2016-03-23 02:41:37 +01:00
public @Nullable List<Plot> canClaim(
2021-05-01 18:33:02 +02:00
final @Nullable PlotPlayer<?> player, final @NonNull PlotId pos1,
final @NonNull PlotId pos2
) {
2020-07-18 11:05:16 +02:00
if (pos1.getX() == pos2.getX() && pos1.getY() == pos2.getY()) {
2017-04-15 04:40:23 +02:00
if (getOwnedPlot(pos1) != null) {
return null;
2017-04-15 04:40:23 +02:00
}
final Plot plot = getPlotAbs(pos1);
if (plot == null) {
return null;
}
if (plot.canClaim(player)) {
return Collections.singletonList(plot);
} else {
return null;
}
2017-04-15 04:40:23 +02:00
}
final List<Plot> plots = new LinkedList<>();
2020-07-18 11:05:16 +02:00
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
final PlotId id = PlotId.of(x, y);
final Plot plot = getPlotAbs(id);
if (plot == null) {
return null;
}
2016-02-10 19:59:51 +01:00
if (!plot.canClaim(player)) {
return null;
} else {
plots.add(plot);
2016-02-10 19:59:51 +01:00
}
}
}
return plots;
2016-02-10 19:59:51 +01:00
}
2016-03-19 19:07:55 +01:00
public boolean removePlot(final @NonNull PlotId id) {
2016-03-23 02:41:37 +01:00
return this.plots.remove(id) != null;
2016-02-10 19:59:51 +01:00
}
/**
* Merge a list of plots together. This is non-blocking for the world-changes that will be made. To run a task when the
* world changes are complete, use {@link PlotArea#mergePlots(List, boolean, Runnable)};
*
* @param plotIds List of plot IDs to merge
* @param removeRoads If the roads between plots should be removed
* @return if merges were completed successfully.
*/
public boolean mergePlots(final @NonNull List<PlotId> plotIds, final boolean removeRoads) {
return mergePlots(plotIds, removeRoads, null);
}
/**
* Merge a list of plots together. This is non-blocking for the world-changes that will be made.
*
* @param plotIds List of plot IDs to merge
* @param removeRoads If the roads between plots should be removed
* @param whenDone Task to run when any merge world changes are complete. Also runs if no changes were made. Does not
* run if there was an error or if too few plots IDs were supplied.
* @return if merges were completed successfully.
2022-06-13 11:23:48 +02:00
* @since 6.9.0
*/
public boolean mergePlots(
final @NonNull List<PlotId> plotIds, final boolean removeRoads, final @Nullable Runnable whenDone
) {
2016-02-10 19:59:51 +01:00
if (plotIds.size() < 2) {
return false;
}
2016-03-23 02:41:37 +01:00
final PlotId pos1 = plotIds.get(0);
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
final PlotManager manager = getPlotManager();
QueueCoordinator queue = getQueue();
manager.startPlotMerge(plotIds, queue);
final Set<UUID> trusted = new HashSet<>();
final Set<UUID> members = new HashSet<>();
final Set<UUID> denied = new HashSet<>();
2020-07-18 11:05:16 +02:00
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
PlotId id = PlotId.of(x, y);
2016-03-23 02:41:37 +01:00
Plot plot = getPlotAbs(id);
2016-02-10 19:59:51 +01:00
trusted.addAll(plot.getTrusted());
members.addAll(plot.getMembers());
denied.addAll(plot.getDenied());
if (removeRoads) {
plot.getPlotModificationManager().removeSign();
2016-02-10 19:59:51 +01:00
}
}
}
members.removeAll(trusted);
denied.removeAll(trusted);
denied.removeAll(members);
2020-07-18 11:05:16 +02:00
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
final boolean lx = x < pos2.getX();
final boolean ly = y < pos2.getY();
final PlotId id = PlotId.of(x, y);
final Plot plot = getPlotAbs(id);
2016-02-10 19:59:51 +01:00
plot.setTrusted(trusted);
plot.setMembers(members);
plot.setDenied(denied);
Plot plot2;
2016-02-10 19:59:51 +01:00
if (lx) {
if (ly) {
if (!plot.isMerged(Direction.EAST) || !plot.isMerged(Direction.SOUTH)) {
2016-02-10 19:59:51 +01:00
if (removeRoads) {
plot.getPlotModificationManager().removeRoadSouthEast(queue);
2016-02-10 19:59:51 +01:00
}
}
}
if (!plot.isMerged(Direction.EAST)) {
2016-02-10 19:59:51 +01:00
plot2 = plot.getRelative(1, 0);
plot.mergePlot(plot2, removeRoads, queue);
2016-02-10 19:59:51 +01:00
}
}
if (ly) {
if (!plot.isMerged(Direction.SOUTH)) {
2016-02-10 19:59:51 +01:00
plot2 = plot.getRelative(0, 1);
plot.mergePlot(plot2, removeRoads, queue);
2016-02-10 19:59:51 +01:00
}
}
}
}
manager.finishPlotMerge(plotIds, queue);
if (whenDone != null) {
queue.setCompleteTask(whenDone);
}
queue.enqueue();
2016-02-10 19:59:51 +01:00
return true;
}
2018-08-10 17:01:10 +02:00
2016-02-10 19:59:51 +01:00
/**
* Get a set of owned plots within a selection (chooses the best algorithm based on selection size.
2016-02-10 19:59:51 +01:00
* i.e. A selection of billions of plots will work fine
2018-08-10 17:01:10 +02:00
*
* @param pos1 first corner of selection
* @param pos2 second corner of selection
* @return the plots in the selection which are owned
2016-02-10 19:59:51 +01:00
*/
public Set<Plot> getPlotSelectionOwned(final @NonNull PlotId pos1, final @NonNull PlotId pos2) {
2020-07-18 11:05:16 +02:00
final int size = (1 + pos2.getX() - pos1.getX()) * (1 + pos2.getY() - pos1.getY());
final Set<Plot> result = new HashSet<>();
2016-02-10 19:59:51 +01:00
if (size < 16 || size < getPlotCount()) {
for (final PlotId pid : Lists.newArrayList((Iterable<? extends PlotId>)
PlotId.PlotRangeIterator.range(pos1, pos2))) {
final Plot plot = getPlotAbs(pid);
2016-02-10 19:59:51 +01:00
if (plot.hasOwner()) {
2020-07-18 11:05:16 +02:00
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY()
|| plot.getId().getX() < pos2.getX() || plot.getId().getY() < pos2.getY()) {
2016-02-10 19:59:51 +01:00
result.add(plot);
}
}
}
} else {
for (final Plot plot : getPlots()) {
2020-07-18 11:05:16 +02:00
if (plot.getId().getX() > pos1.getX() || plot.getId().getY() > pos1.getY() || plot.getId().getX() < pos2.getX()
|| plot.getId().getY() < pos2.getY()) {
2016-02-10 19:59:51 +01:00
result.add(plot);
}
}
}
return result;
}
2018-08-10 17:01:10 +02:00
@SuppressWarnings("WeakerAccess")
public void removeCluster(final @Nullable PlotCluster plotCluster) {
if (this.clusters == null) {
2016-02-10 19:59:51 +01:00
throw new IllegalAccessError("Clusters not enabled!");
}
2016-03-23 02:41:37 +01:00
this.clusters.remove(plotCluster);
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
public void addCluster(final @Nullable PlotCluster plotCluster) {
2016-03-23 02:41:37 +01:00
if (this.clusters == null) {
this.clusters = new QuadMap<>(Integer.MAX_VALUE, 0, 0, 62) {
@Override
public CuboidRegion getRegion(PlotCluster value) {
2020-07-18 11:05:16 +02:00
BlockVector2 pos1 = BlockVector2.at(value.getP1().getX(), value.getP1().getY());
BlockVector2 pos2 = BlockVector2.at(value.getP2().getX(), value.getP2().getY());
return new CuboidRegion(
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
pos1.toBlockVector3(getMinGenHeight()),
pos2.toBlockVector3(getMaxGenHeight())
);
2016-02-10 19:59:51 +01:00
}
};
}
2016-03-23 02:41:37 +01:00
this.clusters.add(plotCluster);
2016-02-10 19:59:51 +01:00
}
2018-08-10 17:01:10 +02:00
public @Nullable PlotCluster getCluster(final String string) {
2016-02-10 19:59:51 +01:00
for (PlotCluster cluster : getClusters()) {
if (cluster.getName().equalsIgnoreCase(string)) {
return cluster;
}
}
return null;
}
/**
* Get whether a schematic with that name is available or not.
* If a schematic is available, it can be used for plot claiming.
*
* @param schematic the schematic to look for.
* @return {@code true} if the schematic exists, {@code false} otherwise.
*/
public boolean hasSchematic(@NonNull String schematic) {
return getSchematics().contains(schematic.toLowerCase());
}
/**
* Get whether economy is enabled and used on this plot area or not.
*
* @return {@code true} if this plot area uses economy, {@code false} otherwise.
*/
public boolean useEconomy() {
return useEconomy;
}
/**
* Get whether the plot area is limited by a world border or not.
*
* @return {@code true} if the plot area has a world border, {@code false} otherwise.
*/
public boolean hasWorldBorder() {
return worldBorder;
}
/**
* Get whether plot signs are allowed or not.
*
* @return {@code true} if plot signs are allowed, {@code false} otherwise.
*/
public boolean allowSigns() {
2020-08-24 12:47:17 +02:00
return allowSigns;
}
2021-05-21 19:14:13 +02:00
/**
* Get the plot sign material.
*
* @return the sign material.
*/
public String signMaterial() {
return signMaterial;
}
public String legacySignMaterial() {
return legacySignMaterial;
}
2020-05-19 14:07:50 +02:00
/**
* Get the value associated with the specified flag. This will look at
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flagClass The flag type (Class)
* @param <T> The flag value type
2020-05-19 14:07:50 +02:00
* @return The flag value
*/
public <T> T getFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
return this.flagContainer.getFlag(flagClass).getValue();
}
/**
* Get the value associated with the specified flag. This will look at
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flag The flag type (Any instance of the flag)
* @param <V> The flag type (Any instance of the flag)
2021-05-11 19:26:39 +02:00
* @param <T> flag value type
2020-05-19 14:07:50 +02:00
* @return The flag value
*/
public <T, V extends PlotFlag<T, ?>> T getFlag(final V flag) {
final Class<?> flagClass = flag.getClass();
final PlotFlag<?, ?> flagInstance = this.flagContainer.getFlagErased(flagClass);
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
}
2020-07-01 15:53:57 +02:00
/**
* Get the value associated with the specified road flag. This will look at
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flagClass The flag type (Class)
* @param <T> the flag value type
2020-07-01 15:53:57 +02:00
* @return The flag value
*/
public <T> T getRoadFlag(final Class<? extends PlotFlag<T, ?>> flagClass) {
return this.roadFlagContainer.getFlag(flagClass).getValue();
}
/**
* Get the value associated with the specified road flag. This will look at
* the default values stored in {@link GlobalFlagContainer}.
*
* @param flag The flag type (Any instance of the flag)
* @param <V> The flag type (Any instance of the flag)
2021-05-11 19:26:39 +02:00
* @param <T> flag value type
2020-07-01 15:53:57 +02:00
* @return The flag value
*/
public <T, V extends PlotFlag<T, ?>> T getRoadFlag(final V flag) {
final Class<?> flagClass = flag.getClass();
final PlotFlag<?, ?> flagInstance = this.roadFlagContainer.getFlagErased(flagClass);
return FlagContainer.<T, V>castUnsafe(flagInstance).getValue();
}
2020-07-17 17:24:45 +02:00
public @NonNull String getWorldName() {
2020-07-17 17:24:45 +02:00
return this.worldName;
}
public String getId() {
return this.id;
}
public @NonNull PlotManager getPlotManager() {
2020-07-17 17:24:45 +02:00
return this.plotManager;
}
public int getWorldHash() {
return this.worldHash;
}
public @NonNull IndependentPlotGenerator getGenerator() {
2020-07-17 17:24:45 +02:00
return this.generator;
}
public boolean isAutoMerge() {
return this.autoMerge;
}
public boolean isMiscSpawnUnowned() {
return this.miscSpawnUnowned;
}
public boolean isMobSpawning() {
return this.mobSpawning;
}
public boolean isMobSpawnerSpawning() {
return this.mobSpawnerSpawning;
}
public BiomeType getPlotBiome() {
return this.plotBiome;
}
public boolean isPlotChat() {
return this.plotChat;
}
public boolean isForcingPlotChat() {
return this.forcingPlotChat;
}
public boolean isSchematicClaimSpecify() {
return this.schematicClaimSpecify;
}
public boolean isSchematicOnClaim() {
return this.schematicOnClaim;
}
public String getSchematicFile() {
return this.schematicFile;
}
public boolean isSpawnEggs() {
return this.spawnEggs;
}
2021-05-21 19:14:13 +02:00
public String getSignMaterial() {
return this.signMaterial;
}
2020-07-17 17:24:45 +02:00
public boolean isSpawnCustom() {
return this.spawnCustom;
}
public boolean isSpawnBreeding() {
return this.spawnBreeding;
}
public PlotAreaType getType() {
return this.type;
}
/**
* Set the type of this plot area.
*
* @param type the type of the plot area.
*/
public void setType(PlotAreaType type) {
// TODO this should probably work only if type == null
this.type = type;
}
2020-07-17 17:24:45 +02:00
public PlotAreaTerrainType getTerrain() {
return this.terrain;
}
/**
* Set the terrain generation type of this plot area.
*
* @param terrain the terrain type of the plot area.
*/
public void setTerrain(PlotAreaTerrainType terrain) {
this.terrain = terrain;
}
2020-07-17 17:24:45 +02:00
public boolean isHomeAllowNonmember() {
return this.homeAllowNonmember;
}
/**
* Get the location for non-members to be teleported to.
*
* @since 6.1.4
*/
public BlockLoc nonmemberHome() {
2020-07-17 17:24:45 +02:00
return this.nonmemberHome;
}
/**
* Get the default location for players to be teleported to. May be overridden by {@link #nonmemberHome} if the player is
* not a member of the plot.
*
* @since 6.1.4
*/
public BlockLoc defaultHome() {
2020-07-17 17:24:45 +02:00
return this.defaultHome;
}
protected void setDefaultHome(BlockLoc defaultHome) {
this.defaultHome = defaultHome;
}
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
/**
* Get the maximum height players may build in. Exclusive.
*/
2020-07-17 17:24:45 +02:00
public int getMaxBuildHeight() {
return this.maxBuildHeight;
}
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
/**
* Get the minimum height players may build in. Inclusive.
*/
2020-07-17 17:24:45 +02:00
public int getMinBuildHeight() {
return this.minBuildHeight;
}
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
/**
* Get the min height from which PlotSquared will generate blocks. Inclusive.
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
*
2022-03-07 15:35:00 +01:00
* @since 6.6.0
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
*/
public int getMinGenHeight() {
return this.minGenHeight;
}
/**
* Get the max height to which PlotSquared will generate blocks. Inclusive.
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
*
2022-03-07 15:35:00 +01:00
* @since 6.6.0
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
*/
public int getMaxGenHeight() {
return this.maxGenHeight;
}
2020-07-17 17:24:45 +02:00
public GameMode getGameMode() {
return this.gameMode;
}
public Map<String, PlotExpression> getPrices() {
2020-07-17 17:24:45 +02:00
return this.prices;
}
protected List<String> getSchematics() {
return this.schematics;
}
public boolean isRoadFlags() {
return this.roadFlags;
}
public FlagContainer getFlagContainer() {
return this.flagContainer;
}
public FlagContainer getRoadFlagContainer() {
return this.roadFlagContainer;
}
public void setAllowSigns(boolean allowSigns) {
this.allowSigns = allowSigns;
}
2016-02-10 19:59:51 +01:00
}