2020-04-16 04:52:39 +02:00
|
|
|
/*
|
2022-06-15 20:17:17 +02:00
|
|
|
* PlotSquared, a land and world management plugin for Minecraft.
|
|
|
|
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
|
|
|
* Copyright (C) IntellectualSites team and contributors
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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-16 04:52:39 +02:00
|
|
|
*/
|
2020-04-15 21:26:54 +02:00
|
|
|
package com.plotsquared.core.plot;
|
2016-02-10 19:59:51 +01:00
|
|
|
|
2019-02-07 03:29:51 +01:00
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
import com.google.common.collect.ImmutableSet;
|
2020-07-19 14:23:55 +02:00
|
|
|
import com.google.common.collect.Lists;
|
2020-08-23 21:28:08 +02:00
|
|
|
import com.plotsquared.core.PlotSquared;
|
2020-04-16 06:11:03 +02:00
|
|
|
import com.plotsquared.core.collection.QuadMap;
|
2020-04-16 06:14:33 +02:00
|
|
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
2020-04-16 06:11:03 +02:00
|
|
|
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;
|
2020-04-16 06:11:03 +02:00
|
|
|
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;
|
2021-10-29 11:48:35 +02:00
|
|
|
import com.plotsquared.core.location.BlockLoc;
|
2020-04-16 06:11:03 +02:00
|
|
|
import com.plotsquared.core.location.Direction;
|
|
|
|
import com.plotsquared.core.location.Location;
|
2022-06-21 19:09:29 +02:00
|
|
|
import com.plotsquared.core.permissions.Permission;
|
2020-08-05 12:48:10 +02:00
|
|
|
import com.plotsquared.core.player.ConsolePlayer;
|
2020-07-23 20:52:32 +02:00
|
|
|
import com.plotsquared.core.player.MetaDataAccess;
|
|
|
|
import com.plotsquared.core.player.PlayerMetaDataKeys;
|
2020-04-16 06:11:03 +02:00
|
|
|
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;
|
2020-04-16 06:11:03 +02:00
|
|
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
2020-07-17 16:41:06 +02:00
|
|
|
import com.plotsquared.core.queue.QueueCoordinator;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.util.MathMan;
|
2021-01-02 17:32:07 +01:00
|
|
|
import com.plotsquared.core.util.PlotExpression;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.util.RegionUtil;
|
2020-04-16 06:11:03 +02:00
|
|
|
import com.plotsquared.core.util.StringMan;
|
2019-11-04 22:08:33 +01:00
|
|
|
import com.sk89q.worldedit.math.BlockVector2;
|
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
|
|
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
2019-11-10 18:47:37 +01:00
|
|
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
|
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
2019-11-29 03:50:21 +01:00
|
|
|
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;
|
2022-05-14 17:05:28 +02:00
|
|
|
import net.kyori.adventure.text.ComponentLike;
|
2020-08-05 12:48:10 +02:00
|
|
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
2022-05-14 17:05:28 +02:00
|
|
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
|
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
2021-06-03 12:40:27 +02:00
|
|
|
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;
|
2022-05-14 17:05:28 +02:00
|
|
|
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;
|
2020-08-14 17:24:34 +02:00
|
|
|
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;
|
2019-02-20 00:39:43 +01:00
|
|
|
import java.util.function.Consumer;
|
2016-02-27 21:04:57 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
/**
|
2018-12-28 07:39:39 +01:00
|
|
|
* @author Jesse Boyd, Alexander Söderberg
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2022-05-14 17:05:28 +02:00
|
|
|
public abstract class PlotArea implements ComponentLike {
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2021-06-03 12:40:27 +02:00
|
|
|
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");
|
2021-01-09 22:28:41 +01:00
|
|
|
|
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<>();
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull
|
|
|
|
private final String worldName;
|
2020-07-17 17:24:45 +02:00
|
|
|
private final String id;
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull
|
|
|
|
private final PlotManager plotManager;
|
2020-07-17 17:24:45 +02:00
|
|
|
private final int worldHash;
|
2016-02-14 02:01:18 +01:00
|
|
|
private final PlotId min;
|
|
|
|
private final PlotId max;
|
2021-01-09 22:28:41 +01:00
|
|
|
@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;
|
2022-01-05 21:21:58 +01:00
|
|
|
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;
|
2021-10-29 11:48:35 +02:00
|
|
|
private BlockLoc nonmemberHome;
|
|
|
|
private BlockLoc defaultHome;
|
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;
|
2021-01-02 17:32:07 +01:00
|
|
|
private Map<String, PlotExpression> prices = new HashMap<>();
|
2020-07-17 17:24:45 +02:00
|
|
|
private List<String> schematics = new ArrayList<>();
|
2020-04-02 14:34:38 +02:00
|
|
|
private boolean worldBorder = false;
|
|
|
|
private boolean useEconomy = false;
|
2016-04-02 01:14:46 +02:00
|
|
|
private int hash;
|
2019-11-04 22:08:33 +01:00
|
|
|
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";
|
2021-05-22 12:34:04 +02:00
|
|
|
private String legacySignMaterial = "WALL_SIGN";
|
2016-02-10 19:59:51 +01:00
|
|
|
|
2021-01-09 22:28:41 +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
|
|
|
|
) {
|
2020-04-02 14:34:38 +02:00
|
|
|
this.worldName = worldName;
|
2016-02-10 19:59:51 +01:00
|
|
|
this.id = id;
|
2020-04-02 14:34:38 +02:00
|
|
|
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;
|
2016-02-14 02:01:18 +01:00
|
|
|
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(
|
2021-01-09 22:28:41 +01:00
|
|
|
"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;
|
|
|
|
}
|
2020-04-02 14:34:38 +02:00
|
|
|
this.worldHash = worldName.hashCode();
|
2020-07-10 19:25:05 +02:00
|
|
|
this.worldConfiguration = worldConfiguration;
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-03-12 17:57:24 +01:00
|
|
|
|
2021-01-09 22:28:41 +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) {
|
2021-06-03 12:40:27 +02:00
|
|
|
LOGGER.warn(
|
2021-01-09 22:28:41 +01:00
|
|
|
"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();
|
2019-05-31 15:32:24 +02:00
|
|
|
|
2020-07-18 14:55:54 +02:00
|
|
|
public QueueCoordinator getQueue() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().worldUtil().getWeWorld(worldName));
|
2016-06-24 02:12:17 +02:00
|
|
|
}
|
|
|
|
|
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
|
2016-04-05 18:37:11 +02:00
|
|
|
* the whole world if none exists.
|
|
|
|
*
|
2019-11-04 22:08:33 +01:00
|
|
|
* @return CuboidRegion
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2019-11-04 22:08:33 +01:00
|
|
|
public CuboidRegion getRegion() {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.region = getRegionAbs();
|
|
|
|
if (this.region == null) {
|
2020-02-24 18:42:02 +01:00
|
|
|
return new CuboidRegion(
|
2021-01-09 22:28:41 +01:00
|
|
|
BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
|
|
|
|
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)
|
|
|
|
);
|
2016-02-13 12:01:22 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.region;
|
2016-02-13 12:01:22 +01:00
|
|
|
}
|
2016-03-12 17:57:24 +01:00
|
|
|
|
|
|
|
/**
|
2016-04-05 18:37:11 +02:00
|
|
|
* Returns the region for this PlotArea.
|
2016-03-19 19:07:55 +01:00
|
|
|
*
|
2019-11-04 22:08:33 +01:00
|
|
|
* @return CuboidRegion or null if no applicable region
|
2016-03-12 17:57:24 +01:00
|
|
|
*/
|
2019-11-04 22:08:33 +01:00
|
|
|
private CuboidRegion getRegionAbs() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.region == null) {
|
|
|
|
if (this.min != null) {
|
2019-05-31 15:05:37 +02:00
|
|
|
Location bot = getPlotManager().getPlotBottomLocAbs(this.min);
|
|
|
|
Location top = getPlotManager().getPlotTopLocAbs(this.max);
|
2019-11-04 22:08:33 +01:00
|
|
|
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-13 12:01:22 +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
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @return the minimum value for a {@link PlotId}
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +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-14 02:01:18 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
/**
|
2016-04-05 18:37:11 +02:00
|
|
|
* Returns the max PlotId.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @return the maximum value for a {@link PlotId}
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +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
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +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()
|
2021-01-09 22:28:41 +01:00
|
|
|
.equals(plotarea.getWorldName()) && StringMan.isEqual(this.getId(), plotarea.getId());
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
public Set<PlotCluster> getClusters() {
|
2018-12-28 07:39:39 +01:00
|
|
|
return this.clusters == null ? new HashSet<>() : this.clusters.getAll();
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
|
2016-03-12 17:57:24 +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
|
2022-01-24 21:41:54 +01:00
|
|
|
* @return {@code true} if both areas are compatible
|
2016-03-12 17:57:24 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean isCompatible(final @NonNull PlotArea plotArea) {
|
2020-07-10 19:25:05 +02:00
|
|
|
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
2016-04-02 01:14:46 +02:00
|
|
|
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
|
2020-04-02 14:34:38 +02:00
|
|
|
Object constant = section.get(plotArea.worldName + '.' + setting.getConstant());
|
2018-08-10 17:01:10 +02:00
|
|
|
if (constant == null || !constant
|
2021-01-09 22:28:41 +01:00
|
|
|
.equals(section.get(this.worldName + '.' + setting.getConstant()))) {
|
2016-02-10 19:59:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-05 18:37:11 +02:00
|
|
|
* 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")) {
|
2020-07-19 14:23:55 +02:00
|
|
|
this.terrain = ConfigurationUtil.getTerrain(config);
|
|
|
|
this.type = ConfigurationUtil.getType(config);
|
2020-04-02 14:34:38 +02:00
|
|
|
}
|
|
|
|
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");
|
2021-05-22 12:34:04 +02:00
|
|
|
if (PlotSquared.platform().serverVersion()[1] == 13) {
|
|
|
|
this.legacySignMaterial = config.getString("plot.legacy_sign_material");
|
|
|
|
} else {
|
|
|
|
this.signMaterial = config.getString("plot.sign_material");
|
|
|
|
}
|
2020-04-22 09:22:14 +02:00
|
|
|
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());
|
2020-04-02 14:34:38 +02:00
|
|
|
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);
|
2020-08-23 21:28:08 +02:00
|
|
|
this.useEconomy = config.getBoolean("economy.use");
|
2016-03-06 09:07:40 +01:00
|
|
|
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
|
2020-04-02 14:34:38 +02:00
|
|
|
if (this.useEconomy) {
|
|
|
|
this.prices = new HashMap<>();
|
2016-03-19 19:07:55 +01:00
|
|
|
for (String key : priceSection.getKeys(false)) {
|
2021-01-02 17:32:07 +01:00
|
|
|
String raw = priceSection.getString(key);
|
2021-06-24 19:14:59 +02:00
|
|
|
if (raw.contains("{arg}")) {
|
|
|
|
raw = raw.replace("{arg}", "plots");
|
2021-01-02 17:32:07 +01:00
|
|
|
priceSection.set(key, raw); // update if replaced
|
|
|
|
}
|
|
|
|
this.prices.put(key, PlotExpression.compile(raw, "plots"));
|
2016-03-19 19:07:55 +01:00
|
|
|
}
|
2016-03-06 09:07:40 +01:00
|
|
|
}
|
2020-04-02 14:34:38 +02:00
|
|
|
this.plotChat = config.getBoolean("chat.enabled");
|
2020-04-16 17:55:14 +02:00
|
|
|
this.forcingPlotChat = config.getBoolean("chat.forced");
|
2020-04-02 14:34:38 +02:00
|
|
|
this.worldBorder = config.getBoolean("world.border");
|
|
|
|
this.maxBuildHeight = config.getInt("world.max_height");
|
|
|
|
this.minBuildHeight = config.getInt("world.min_height");
|
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-14 02:01:18 +01:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
switch (config.getString("world.gamemode").toLowerCase()) {
|
2021-05-15 20:39:16 +02:00
|
|
|
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
|
|
|
}
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2017-09-23 11:10:57 +02:00
|
|
|
String homeNonMembers = config.getString("home.nonmembers");
|
2016-03-23 02:41:37 +01:00
|
|
|
String homeDefault = config.getString("home.default");
|
2021-10-29 11:48:35 +02:00
|
|
|
this.defaultHome = BlockLoc.fromString(homeDefault);
|
2020-04-02 14:34:38 +02:00
|
|
|
this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
|
|
|
|
if (this.homeAllowNonmember) {
|
|
|
|
this.nonmemberHome = defaultHome;
|
2017-09-23 11:10:57 +02:00
|
|
|
} else {
|
2021-10-29 11:48:35 +02:00
|
|
|
this.nonmemberHome = BlockLoc.fromString(homeNonMembers);
|
2017-09-23 11:10:57 +02:00
|
|
|
}
|
|
|
|
|
2016-02-14 02:01:18 +01:00
|
|
|
if ("side".equalsIgnoreCase(homeDefault)) {
|
2020-04-02 14:34:38 +02:00
|
|
|
this.defaultHome = null;
|
2021-11-02 16:41:16 +01:00
|
|
|
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle", "centre")) {
|
2021-10-29 11:48:35 +02:00
|
|
|
this.defaultHome = new BlockLoc(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
2016-02-10 19:59:51 +01:00
|
|
|
} else {
|
|
|
|
try {
|
2018-12-27 16:18:54 +01:00
|
|
|
/*String[] split = homeDefault.split(",");
|
2018-08-10 17:01:10 +02:00
|
|
|
this.DEFAULT_HOME =
|
2018-12-27 16:18:54 +01:00
|
|
|
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
|
2021-10-29 11:48:35 +02:00
|
|
|
this.defaultHome = BlockLoc.fromString(homeDefault);
|
2016-04-30 00:14:12 +02:00
|
|
|
} catch (NumberFormatException ignored) {
|
2020-04-02 14:34:38 +02:00
|
|
|
this.defaultHome = null;
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-14 02:01:18 +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) {
|
2016-02-14 02:01:18 +01:00
|
|
|
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));
|
2021-01-09 22:28:41 +01:00
|
|
|
ConsolePlayer.getConsole().sendMessage(
|
2021-05-02 20:31:23 +02:00
|
|
|
TranslatableCaption.of("flags.area_flags"),
|
2022-05-14 17:05:28 +02:00
|
|
|
TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString())))
|
2021-01-09 22:28:41 +01:00
|
|
|
);
|
2020-04-11 17:58:08 +02:00
|
|
|
|
2020-04-02 14:34:38 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-05 21:21:58 +01:00
|
|
|
this.roadFlags = roadflags.size() > 0;
|
2020-07-01 15:53:57 +02:00
|
|
|
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
|
2021-01-09 22:28:41 +01:00
|
|
|
ConsolePlayer.getConsole().sendMessage(
|
2021-05-02 20:31:23 +02:00
|
|
|
TranslatableCaption.of("flags.road_flags"),
|
2022-05-14 17:05:28 +02:00
|
|
|
TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString())))
|
2021-01-09 22:28:41 +01:00
|
|
|
);
|
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
|
|
|
/**
|
2016-06-24 02:12:17 +02: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<>();
|
2020-04-02 14:34:38 +02:00
|
|
|
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());
|
2021-05-22 12:34:04 +02:00
|
|
|
if (PlotSquared.platform().serverVersion()[1] == 13) {
|
|
|
|
options.put("plot.legacy_sign_material", this.legacySignMaterial);
|
|
|
|
} else {
|
|
|
|
options.put("plot.sign_material", this.signMaterial());
|
|
|
|
}
|
2020-04-21 10:16:02 +02:00
|
|
|
options.put("plot.biome", "minecraft:forest");
|
2020-04-02 14:34:38 +02:00
|
|
|
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());
|
2016-03-06 09:07:40 +01:00
|
|
|
options.put("economy.prices.claim", 100);
|
|
|
|
options.put("economy.prices.merge", 100);
|
|
|
|
options.put("economy.prices.sell", 100);
|
2020-04-02 14:34:38 +02:00
|
|
|
options.put("chat.enabled", this.isPlotChat());
|
2020-04-16 17:55:14 +02:00
|
|
|
options.put("chat.forced", this.isForcingPlotChat());
|
2016-02-10 19:59:51 +01:00
|
|
|
options.put("flags.default", null);
|
2020-04-02 14:34:38 +02:00
|
|
|
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");
|
2021-01-09 22:28:41 +01:00
|
|
|
String position = config.getString(
|
|
|
|
"home.nonmembers",
|
|
|
|
config.getBoolean("home.allow-nonmembers", false) ?
|
|
|
|
config.getString("home.default", "side") :
|
|
|
|
"side"
|
|
|
|
);
|
2017-09-23 11:10:57 +02:00
|
|
|
options.put("home.nonmembers", position);
|
2020-04-02 14:34:38 +02:00
|
|
|
options.put("world.max_height", this.getMaxBuildHeight());
|
|
|
|
options.put("world.min_height", this.getMinBuildHeight());
|
2022-03-05 19:03:39 +01:00
|
|
|
options.put("world.min_gen_height", this.getMinGenHeight());
|
|
|
|
options.put("world.max_gen_height", this.getMaxGenHeight());
|
2020-04-02 14:34:38 +02:00
|
|
|
options.put("world.gamemode", this.getGameMode().getName().toLowerCase());
|
2020-07-01 15:53:57 +02:00
|
|
|
options.put("road.flags.default", null);
|
2016-02-14 02:01:18 +01:00
|
|
|
|
2020-04-02 14:34:38 +02:00
|
|
|
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()) {
|
2016-02-14 02:01:18 +01:00
|
|
|
if (!config.contains(stringObjectEntry.getKey())) {
|
|
|
|
config.set(stringObjectEntry.getKey(), stringObjectEntry.getValue());
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!config.contains("flags")) {
|
2021-01-09 22:28:41 +01:00
|
|
|
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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2020-04-02 14:34:38 +02:00
|
|
|
if (this.getId() == null) {
|
|
|
|
return this.getWorldName();
|
2016-04-02 01:14:46 +02:00
|
|
|
} else {
|
2020-04-02 14:34:38 +02:00
|
|
|
return this.getWorldName() + ";" + this.getId();
|
2016-04-02 01:14:46 +02:00
|
|
|
}
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2022-05-14 17:05:28 +02:00
|
|
|
@Override
|
|
|
|
public @NotNull Component asComponent() {
|
|
|
|
return Component.text(toString());
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
@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[]
|
|
|
|
*/
|
2019-01-17 02:04:00 +01:00
|
|
|
public abstract ConfigurationNode[] getSettingNodes();
|
2016-03-12 17:57:24 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-24 15:34:21 +02:00
|
|
|
* Gets the {@link Plot} at a location.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @param location the location
|
2021-08-24 15:34:21 +02:00
|
|
|
* @return the {@link Plot} or null if none exists
|
2016-03-12 17:57:24 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable Plot getPlotAbs(final @NonNull Location location) {
|
2018-12-28 07:39:39 +01:00
|
|
|
final PlotId pid =
|
2021-01-09 22:28:41 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-03-12 17:57:24 +01:00
|
|
|
|
|
|
|
/**
|
2016-06-24 02:12:17 +02:00
|
|
|
* Gets the base plot at a location.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @param location the location
|
2016-03-12 17:57:24 +01:00
|
|
|
* @return base Plot
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable Plot getPlot(final @NonNull Location location) {
|
2018-12-28 07:39:39 +01:00
|
|
|
final PlotId pid =
|
2021-01-09 22:28:41 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-03-12 17:57:24 +01:00
|
|
|
|
|
|
|
/**
|
2016-06-24 02:12:17 +02:00
|
|
|
* Get the owned base plot at a location.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @param location the location
|
|
|
|
* @return the base plot or null
|
2016-03-12 17:57:24 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable Plot getOwnedPlot(final @NonNull Location location) {
|
2018-12-28 07:39:39 +01:00
|
|
|
final PlotId pid =
|
2021-01-09 22:28:41 +01:00
|
|
|
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-12 17:57:24 +01:00
|
|
|
|
|
|
|
/**
|
2016-03-23 18:09:13 +01:00
|
|
|
* Get the owned plot at a location.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @param location the location
|
2016-03-12 17:57:24 +01:00
|
|
|
* @return Plot or null
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable Plot getOwnedPlotAbs(final @NonNull Location location) {
|
2018-12-28 07:39:39 +01:00
|
|
|
final PlotId pid =
|
2021-01-09 22:28:41 +01:00
|
|
|
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-12 17:57:24 +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}
|
2016-06-24 02:12:17 +02:00
|
|
|
* @return the plot or null
|
2016-03-12 17:57:24 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
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
|
|
|
|
2021-01-09 22:28:41 +01: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);
|
|
|
|
}
|
|
|
|
|
2018-12-28 07:39:39 +01:00
|
|
|
public boolean contains(final int x, final int z) {
|
2020-04-02 14:34:38 +02:00
|
|
|
return this.getType() != PlotAreaType.PARTIAL || RegionUtil.contains(getRegionAbs(), x, z);
|
2016-02-13 12:01:22 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2021-01-09 22:28:41 +01: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() &&
|
2021-01-09 22:28:41 +01:00
|
|
|
id.getY() >= this.min.getY() && id.getY() <= this.max.getY());
|
2016-02-17 13:38:36 +01:00
|
|
|
}
|
2016-02-13 12:01:22 +01:00
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean contains(final @NonNull Location location) {
|
2020-07-10 12:21:29 +02:00
|
|
|
return StringMan.isEqual(location.getWorldName(), this.getWorldName()) && (
|
2021-01-09 22:28:41 +01:00
|
|
|
getRegionAbs() == null || this.region.contains(location.getBlockVector3()));
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2022-06-21 19:09:29 +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
|
2022-06-21 19:09:29 +02:00
|
|
|
*/
|
|
|
|
public boolean notifyIfOutsideBuildArea(PlotPlayer<?> player, int y) {
|
2023-01-15 14:08:59 +01:00
|
|
|
if (!buildRangeContainsY(y) && !player.hasPermission(Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
|
2022-06-21 19:09:29 +02:00
|
|
|
player.sendMessage(
|
|
|
|
TranslatableCaption.of("height.height_limit"),
|
2023-01-08 10:36:41 +01:00
|
|
|
TagResolver.builder()
|
|
|
|
.tag("minHeight", Tag.inserting(Component.text(minBuildHeight)))
|
2023-03-06 11:38:30 +01:00
|
|
|
.tag(
|
|
|
|
"maxHeight",
|
|
|
|
Tag.inserting(Component.text(maxBuildHeight))
|
|
|
|
).build()
|
2022-06-21 19:09:29 +02:00
|
|
|
);
|
|
|
|
// Return true if "failed" as the method will always be inverted otherwise
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
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<>();
|
2019-02-20 00:39:43 +01:00
|
|
|
forEachPlotAbs(value -> {
|
2020-04-10 14:05:01 +02:00
|
|
|
if (uuid.equals(value.getOwnerAbs())) {
|
2019-02-20 00:39:43 +01:00
|
|
|
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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @NonNull Set<Plot> getPlots(final @NonNull UUID uuid) {
|
2019-02-07 03:29:51 +01:00
|
|
|
return getPlots().stream().filter(plot -> plot.isBasePlot() && plot.isOwner(uuid))
|
2021-01-09 22:28:41 +01:00
|
|
|
.collect(ImmutableSet.toImmutableSet());
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-06-24 02:12:17 +02: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
|
|
|
*
|
2016-06-24 02:12:17 +02:00
|
|
|
* @return a collection of claimed plots
|
|
|
|
*/
|
|
|
|
public Collection<Plot> getPlots() {
|
|
|
|
return this.plots.values();
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public int getPlotCount(final @NonNull UUID uuid) {
|
2016-06-10 19:00:34 +02:00
|
|
|
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
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
|
|
|
|
2019-02-07 03:29:51 +01:00
|
|
|
/**
|
|
|
|
* Retrieves the plots for the player in this PlotArea.
|
|
|
|
*
|
2020-08-16 14:22:49 +02:00
|
|
|
* @param player player to get plots of
|
|
|
|
* @return set of player's plots
|
2021-01-09 22:28:41 +01:00
|
|
|
* @deprecated Use {@link #getPlots(UUID)}
|
2019-02-07 03:29:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@Deprecated
|
2021-05-01 18:33:02 +02:00
|
|
|
public Set<Plot> getPlots(final @NonNull PlotPlayer<?> player) {
|
2019-02-07 03:29:51 +01:00
|
|
|
return getPlots(player.getUUID());
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
//todo check if this method is needed in this class
|
|
|
|
|
|
|
|
public boolean hasPlot(final @NonNull UUID uuid) {
|
2019-02-13 18:05:28 +01:00
|
|
|
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
|
2018-04-28 13:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01: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
|
|
|
|
2021-01-09 22:28:41 +01: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()
|
2021-01-09 22:28:41 +01:00
|
|
|
|| 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;
|
|
|
|
}
|
2016-06-24 02:12:17 +02:00
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable Plot getPlot(final @NonNull PlotId id) {
|
2018-12-28 07:39:39 +01:00
|
|
|
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()
|
2021-01-09 22:28:41 +01:00
|
|
|
|| 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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable PlotCluster getCluster(final @NonNull Location location) {
|
2018-12-28 07:39:39 +01:00
|
|
|
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
|
|
|
}
|
2016-06-24 02:12:17 +02:00
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable PlotCluster getFirstIntersectingCluster(
|
|
|
|
final @NonNull PlotId pos1,
|
|
|
|
final @NonNull PlotId pos2
|
|
|
|
) {
|
2016-03-24 10:57:59 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
@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-06-24 02:12:17 +02:00
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
/**
|
2016-06-24 02:12:17 +02: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
|
2020-08-16 14:22:49 +02:00
|
|
|
*
|
2021-01-09 22:28:41 +01:00
|
|
|
* @param key metadata key
|
2020-08-16 14:22:49 +02:00
|
|
|
* @param value metadata value
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +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
|
|
|
}
|
2016-06-24 02:12:17 +02:00
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @NonNull <T> T getMeta(final @NonNull String key, final @NonNull T def) {
|
2018-12-28 07:39:39 +01:00
|
|
|
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
|
2021-01-09 22:28:41 +01:00
|
|
|
*
|
2020-08-16 14:22:49 +02:00
|
|
|
* @param key metadata key to get value for
|
|
|
|
* @return metadata value
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public @NonNull Set<Plot> getBasePlots() {
|
2018-12-28 07:39:39 +01:00
|
|
|
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
|
|
|
|
2019-02-20 00:39:43 +01:00
|
|
|
private void forEachPlotAbs(Consumer<Plot> run) {
|
2018-12-28 07:39:39 +01:00
|
|
|
for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) {
|
2019-02-20 00:39:43 +01:00
|
|
|
run.accept(entry.getValue());
|
2016-02-27 21:04:57 +01:00
|
|
|
}
|
|
|
|
}
|
2016-04-30 00:14:12 +02:00
|
|
|
|
2019-02-20 00:39:43 +01:00
|
|
|
public void forEachBasePlot(Consumer<Plot> run) {
|
2018-12-28 07:39:39 +01:00
|
|
|
for (final Plot plot : getPlots()) {
|
2016-02-10 19:59:51 +01:00
|
|
|
if (plot.isBasePlot()) {
|
2019-02-20 00:39:43 +01:00
|
|
|
run.accept(plot);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-07 03:29:51 +01:00
|
|
|
/**
|
|
|
|
* Returns an ImmutableMap of PlotId's and Plots in this PlotArea.
|
2019-02-08 17:21:53 +01:00
|
|
|
*
|
2020-08-16 14:22:49 +02:00
|
|
|
* @return map of PlotId against Plot for all plots in this area
|
2021-01-09 22:28:41 +01:00
|
|
|
* @deprecated Poorly implemented. May be removed in future.
|
2019-02-07 03:29:51 +01:00
|
|
|
*/
|
|
|
|
//todo eventually remove
|
2021-01-09 22:28:41 +01:00
|
|
|
@Deprecated
|
|
|
|
public @NonNull Map<PlotId, Plot> getPlotsRaw() {
|
2019-02-07 03:29:51 +01:00
|
|
|
return ImmutableMap.copyOf(plots);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean addPlot(final @NonNull Plot plot) {
|
2020-07-23 20:52:32 +02:00
|
|
|
for (final PlotPlayer<?> pp : plot.getPlayersInPlot()) {
|
|
|
|
try (final MetaDataAccess<Plot> metaDataAccess = pp.accessTemporaryMetaData(
|
2021-01-09 22:28:41 +01:00
|
|
|
PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
|
2020-07-23 20:52:32 +02:00
|
|
|
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();
|
2020-04-02 14:34:38 +02:00
|
|
|
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;
|
2019-02-22 03:14:48 +01:00
|
|
|
if (start != null) {
|
2020-07-18 11:05:16 +02:00
|
|
|
start = PlotId.of(start.getX() - center.getX(), start.getY() - center.getY());
|
2019-02-22 03:14:48 +01:00
|
|
|
}
|
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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean addPlotIfAbsent(final @NonNull Plot plot) {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.plots.putIfAbsent(plot.getId(), plot) == null) {
|
2020-07-23 20:52:32 +02:00
|
|
|
for (PlotPlayer<?> pp : plot.getPlayersInPlot()) {
|
|
|
|
try (final MetaDataAccess<Plot> metaDataAccess = pp.accessTemporaryMetaData(
|
2021-01-09 22:28:41 +01:00
|
|
|
PlayerMetaDataKeys.TEMPORARY_LAST_PLOT)) {
|
2020-07-23 20:52:32 +02:00
|
|
|
metaDataAccess.set(plot);
|
|
|
|
}
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
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() {
|
2018-12-28 07:39:39 +01:00
|
|
|
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
|
|
|
/**
|
2016-06-24 02:12:17 +02: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() {
|
2020-04-02 14:34:38 +02:00
|
|
|
if (!this.hasWorldBorder()) {
|
2016-02-10 19:59:51 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-12-28 07:39:39 +01:00
|
|
|
final Integer meta = (Integer) getMeta("worldBorder");
|
2016-02-10 19:59:51 +01:00
|
|
|
if (meta == null) {
|
|
|
|
setMeta("worldBorder", 1);
|
|
|
|
}
|
2018-12-28 07:39:39 +01:00
|
|
|
for (final Plot plot : getPlots()) {
|
2016-02-10 19:59:51 +01:00
|
|
|
plot.updateWorldBorder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-24 02:12:17 +02:00
|
|
|
* 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
|
|
|
|
*
|
2018-12-28 07:39:39 +01:00
|
|
|
* @param key Meta data key
|
2016-02-10 19:59:51 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @Nullable List<Plot> canClaim(
|
2021-05-01 18:33:02 +02:00
|
|
|
final @Nullable PlotPlayer<?> player, final @NonNull PlotId pos1,
|
2021-01-09 22:28:41 +01:00
|
|
|
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) {
|
2020-08-14 17:24:34 +02:00
|
|
|
return null;
|
2017-04-15 04:40:23 +02:00
|
|
|
}
|
2018-12-28 07:39:39 +01:00
|
|
|
final Plot plot = getPlotAbs(pos1);
|
|
|
|
if (plot == null) {
|
2020-08-14 17:24:34 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (plot.canClaim(player)) {
|
|
|
|
return Collections.singletonList(plot);
|
|
|
|
} else {
|
|
|
|
return null;
|
2018-12-28 07:39:39 +01:00
|
|
|
}
|
2017-04-15 04:40:23 +02:00
|
|
|
}
|
2020-08-14 17:24:34 +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);
|
2018-12-28 07:39:39 +01:00
|
|
|
final Plot plot = getPlotAbs(id);
|
|
|
|
if (plot == null) {
|
2020-08-14 17:24:34 +02:00
|
|
|
return null;
|
2018-12-28 07:39:39 +01:00
|
|
|
}
|
2016-02-10 19:59:51 +01:00
|
|
|
if (!plot.canClaim(player)) {
|
2020-08-14 17:24:34 +02:00
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
plots.add(plot);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-14 17:24:34 +02:00
|
|
|
return plots;
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
2016-03-19 19:07:55 +01:00
|
|
|
|
2021-01-09 22:28:41 +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
|
|
|
}
|
|
|
|
|
2022-06-13 09:06:01 +02: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.
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean mergePlots(final @NonNull List<PlotId> plotIds, final boolean removeRoads) {
|
2022-06-13 09:06:01 +02:00
|
|
|
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
|
2023-03-06 11:38:30 +01:00
|
|
|
* @param whenDone Task to run when any merge world changes are complete. Also runs if no changes were made. Does not
|
2022-06-13 09:06:01 +02:00
|
|
|
* 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
|
2022-06-13 09:06:01 +02:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
2018-12-28 07:39:39 +01:00
|
|
|
final PlotId pos1 = plotIds.get(0);
|
|
|
|
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
|
|
|
final PlotManager manager = getPlotManager();
|
|
|
|
|
2020-07-28 11:17:15 +02:00
|
|
|
QueueCoordinator queue = getQueue();
|
|
|
|
manager.startPlotMerge(plotIds, queue);
|
2018-12-28 07:39:39 +01:00
|
|
|
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) {
|
2020-08-20 17:10:50 +02:00
|
|
|
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);
|
2018-12-28 07:39:39 +01:00
|
|
|
final Plot plot = getPlotAbs(id);
|
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
plot.setTrusted(trusted);
|
|
|
|
plot.setMembers(members);
|
|
|
|
plot.setDenied(denied);
|
2018-12-28 07:39:39 +01:00
|
|
|
|
2016-02-14 02:01:18 +01:00
|
|
|
Plot plot2;
|
2016-02-10 19:59:51 +01:00
|
|
|
if (lx) {
|
|
|
|
if (ly) {
|
2020-08-20 17:10:50 +02:00
|
|
|
if (!plot.isMerged(Direction.EAST) || !plot.isMerged(Direction.SOUTH)) {
|
2016-02-10 19:59:51 +01:00
|
|
|
if (removeRoads) {
|
2020-08-20 17:10:50 +02:00
|
|
|
plot.getPlotModificationManager().removeRoadSouthEast(queue);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 17:10:50 +02:00
|
|
|
if (!plot.isMerged(Direction.EAST)) {
|
2016-02-10 19:59:51 +01:00
|
|
|
plot2 = plot.getRelative(1, 0);
|
2020-07-28 11:17:15 +02:00
|
|
|
plot.mergePlot(plot2, removeRoads, queue);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ly) {
|
2020-08-20 17:10:50 +02:00
|
|
|
if (!plot.isMerged(Direction.SOUTH)) {
|
2016-02-10 19:59:51 +01:00
|
|
|
plot2 = plot.getRelative(0, 1);
|
2020-07-28 11:17:15 +02:00
|
|
|
plot.mergePlot(plot2, removeRoads, queue);
|
2016-02-10 19:59:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-28 11:17:15 +02:00
|
|
|
manager.finishPlotMerge(plotIds, queue);
|
2022-06-13 09:06:01 +02:00
|
|
|
if (whenDone != null) {
|
|
|
|
queue.setCompleteTask(whenDone);
|
|
|
|
}
|
2020-07-28 11:17:15 +02:00
|
|
|
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
|
|
|
/**
|
2016-06-24 02:12:17 +02: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
|
|
|
*
|
2016-06-24 02:12:17 +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
|
|
|
*/
|
2021-01-09 22:28:41 +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());
|
2018-12-28 07:39:39 +01:00
|
|
|
final Set<Plot> result = new HashSet<>();
|
2016-02-10 19:59:51 +01:00
|
|
|
if (size < 16 || size < getPlotCount()) {
|
2020-07-19 14:23:55 +02:00
|
|
|
for (final PlotId pid : Lists.newArrayList((Iterable<? extends PlotId>)
|
2021-01-09 22:28:41 +01:00
|
|
|
PlotId.PlotRangeIterator.range(pos1, pos2))) {
|
2018-12-28 07:39:39 +01:00
|
|
|
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()
|
2021-01-09 22:28:41 +01:00
|
|
|
|| plot.getId().getX() < pos2.getX() || plot.getId().getY() < pos2.getY()) {
|
2016-02-10 19:59:51 +01:00
|
|
|
result.add(plot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2018-12-28 07:39:39 +01:00
|
|
|
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()
|
2021-01-09 22:28:41 +01:00
|
|
|
|| 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
|
|
|
|
2018-12-28 07:39:39 +01:00
|
|
|
@SuppressWarnings("WeakerAccess")
|
2021-01-09 22:28:41 +01:00
|
|
|
public void removeCluster(final @Nullable PlotCluster plotCluster) {
|
2016-03-24 10:57:59 +01:00
|
|
|
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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public void addCluster(final @Nullable PlotCluster plotCluster) {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.clusters == null) {
|
2021-05-15 20:39:16 +02:00
|
|
|
this.clusters = new QuadMap<>(Integer.MAX_VALUE, 0, 0, 62) {
|
2021-01-09 22:28:41 +01:00
|
|
|
@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());
|
2021-01-09 22:28:41 +01:00
|
|
|
return new CuboidRegion(
|
2022-03-05 19:03:39 +01:00
|
|
|
pos1.toBlockVector3(getMinGenHeight()),
|
|
|
|
pos2.toBlockVector3(getMaxGenHeight())
|
2021-01-09 22:28:41 +01:00
|
|
|
);
|
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
|
|
|
|
2021-01-09 22:28:41 +01: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;
|
|
|
|
}
|
2018-12-28 07:39:39 +01:00
|
|
|
|
2020-04-02 14:34:38 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
2022-01-24 21:41:54 +01:00
|
|
|
* @return {@code true} if the schematic exists, {@code false} otherwise.
|
2020-04-02 14:34:38 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
public boolean hasSchematic(@NonNull String schematic) {
|
2020-04-02 14:34:38 +02:00
|
|
|
return getSchematics().contains(schematic.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether economy is enabled and used on this plot area or not.
|
|
|
|
*
|
2022-01-24 21:41:54 +01:00
|
|
|
* @return {@code true} if this plot area uses economy, {@code false} otherwise.
|
2020-04-02 14:34:38 +02:00
|
|
|
*/
|
|
|
|
public boolean useEconomy() {
|
|
|
|
return useEconomy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether the plot area is limited by a world border or not.
|
|
|
|
*
|
2022-01-24 21:41:54 +01:00
|
|
|
* @return {@code true} if the plot area has a world border, {@code false} otherwise.
|
2020-04-02 14:34:38 +02:00
|
|
|
*/
|
|
|
|
public boolean hasWorldBorder() {
|
|
|
|
return worldBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether plot signs are allowed or not.
|
|
|
|
*
|
2022-01-24 21:41:54 +01:00
|
|
|
* @return {@code true} if plot signs are allowed, {@code false} otherwise.
|
2020-04-02 14:34:38 +02:00
|
|
|
*/
|
|
|
|
public boolean allowSigns() {
|
2020-08-24 12:47:17 +02:00
|
|
|
return allowSigns;
|
2020-04-02 14:34:38 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 19:14:13 +02:00
|
|
|
/**
|
|
|
|
* Get the plot sign material.
|
|
|
|
*
|
|
|
|
* @return the sign material.
|
|
|
|
*/
|
|
|
|
public String signMaterial() {
|
|
|
|
return signMaterial;
|
|
|
|
}
|
|
|
|
|
2021-05-22 12:34:04 +02:00
|
|
|
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)
|
2021-01-09 22:28:41 +01:00
|
|
|
* @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)
|
2021-01-09 22:28:41 +01:00
|
|
|
* @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)
|
2021-01-09 22:28:41 +01:00
|
|
|
* @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)
|
2021-01-09 22:28:41 +01:00
|
|
|
* @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
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @NonNull String getWorldName() {
|
2020-07-17 17:24:45 +02:00
|
|
|
return this.worldName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getId() {
|
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
public @NonNull PlotManager getPlotManager() {
|
2020-07-17 17:24:45 +02:00
|
|
|
return this.plotManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getWorldHash() {
|
|
|
|
return this.worldHash;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2021-01-09 22:28:41 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2021-10-29 11:48:35 +02:00
|
|
|
/**
|
|
|
|
* Get the location for non-members to be teleported to.
|
2022-01-24 21:46:01 +01:00
|
|
|
*
|
|
|
|
* @since 6.1.4
|
2021-10-29 11:48:35 +02:00
|
|
|
*/
|
|
|
|
public BlockLoc nonmemberHome() {
|
2020-07-17 17:24:45 +02:00
|
|
|
return this.nonmemberHome;
|
|
|
|
}
|
|
|
|
|
2021-10-29 11:48:35 +02:00
|
|
|
/**
|
2022-01-24 21:46:01 +01:00
|
|
|
* Get the default location for players to be teleported to. May be overridden by {@link #nonmemberHome} if the player is
|
2021-10-29 11:48:35 +02:00
|
|
|
* not a member of the plot.
|
2022-01-24 21:46:01 +01:00
|
|
|
*
|
|
|
|
* @since 6.1.4
|
2021-10-29 11:48:35 +02:00
|
|
|
*/
|
|
|
|
public BlockLoc defaultHome() {
|
2020-07-17 17:24:45 +02:00
|
|
|
return this.defaultHome;
|
|
|
|
}
|
|
|
|
|
2021-10-29 11:48:35 +02:00
|
|
|
protected void setDefaultHome(BlockLoc defaultHome) {
|
2021-01-09 22:28:41 +01:00
|
|
|
this.defaultHome = defaultHome;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-03-05 19:03:39 +01:00
|
|
|
/**
|
2022-06-11 16:16:06 +02:00
|
|
|
* Get the min height from which PlotSquared will generate blocks. Inclusive.
|
2022-03-05 19:03:39 +01:00
|
|
|
*
|
2022-03-07 15:35:00 +01:00
|
|
|
* @since 6.6.0
|
2022-03-05 19:03:39 +01:00
|
|
|
*/
|
|
|
|
public int getMinGenHeight() {
|
|
|
|
return this.minGenHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-06-11 16:16:06 +02:00
|
|
|
* Get the max height to which PlotSquared will generate blocks. Inclusive.
|
2022-03-05 19:03:39 +01:00
|
|
|
*
|
2022-03-07 15:35:00 +01:00
|
|
|
* @since 6.6.0
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-02 17:32:07 +01:00
|
|
|
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
|
|
|
}
|