Compare commits

..

1 Commits

Author SHA1 Message Date
1646f2f426 Added disclaimer to PlotSettings.
This class is not and never has been proper API.
2022-11-30 16:36:33 -05:00
13 changed files with 50 additions and 91 deletions

View File

@ -33,6 +33,7 @@ import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@ -50,7 +51,7 @@ final class LegacyBlockStatePopulator extends BlockPopulator {
}
@Override
public void populate(@NonNull final World world, @NonNull final Random random, @NonNull final Chunk source) {
public void populate(@NotNull final World world, @NotNull final Random random, @NotNull final Chunk source) {
int chunkMinX = source.getX() << 4;
int chunkMinZ = source.getZ() << 4;
PlotArea area = Location.at(world.getName(), chunkMinX, 0, chunkMinZ).getPlotArea();

View File

@ -36,7 +36,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
@ -45,7 +46,10 @@ public class FaweRegionManager extends BukkitRegionManager {
private final FaweDelegateRegionManager delegate = new FaweDelegateRegionManager();
@Inject
public FaweRegionManager(WorldUtil worldUtil, GlobalBlockQueue blockQueue, ProgressSubscriberFactory subscriberFactory) {
public FaweRegionManager(
@NonNull WorldUtil worldUtil, @NonNull GlobalBlockQueue blockQueue, @NonNull
ProgressSubscriberFactory subscriberFactory
) {
super(worldUtil, blockQueue, subscriberFactory);
}
@ -72,9 +76,9 @@ public class FaweRegionManager extends BukkitRegionManager {
@Override
public boolean handleClear(
@NonNull Plot plot,
@NotNull Plot plot,
@Nullable Runnable whenDone,
@NonNull PlotManager manager,
@NotNull PlotManager manager,
final @Nullable PlotPlayer<?> player
) {
if (!Settings.FAWE_Components.CLEAR || !(manager instanceof HybridPlotManager)) {

View File

@ -29,7 +29,7 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.net.URL;
@ -40,7 +40,7 @@ public class FaweSchematicHandler extends SchematicHandler {
private final FaweDelegateSchematicHandler delegate = new FaweDelegateSchematicHandler();
@Inject
public FaweSchematicHandler(WorldUtil worldUtil, ProgressSubscriberFactory subscriberFactory) {
public FaweSchematicHandler(@NotNull WorldUtil worldUtil, @NotNull ProgressSubscriberFactory subscriberFactory) {
super(worldUtil, subscriberFactory);
}
@ -75,7 +75,7 @@ public class FaweSchematicHandler extends SchematicHandler {
}
@Override
public Schematic getSchematic(@NonNull InputStream is) {
public Schematic getSchematic(@NotNull InputStream is) {
return delegate.getSchematic(is);
}

View File

@ -35,9 +35,6 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import jdk.jfr.Category;
import jdk.jfr.Event;
import jdk.jfr.Label;
import net.kyori.adventure.text.minimessage.Template;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -62,24 +59,13 @@ public class HomeCommand extends Command {
this.plotAreaManager = plotAreaManager;
}
@Label("Home Query")
@Category("PlotSquared")
static class HomeQueryEvent extends Event {
@Label("Result Size")
public int size;
}
private void home(
final @NonNull PlotPlayer<?> player,
final @NonNull PlotQuery query, final int page,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone
) {
final HomeQueryEvent event = new HomeQueryEvent();
event.begin();
List<Plot> plots = query.asList();
event.size = plots.size();
event.commit();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
return;

View File

@ -21,15 +21,16 @@ package com.plotsquared.core.configuration.caption;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.EnumSet;
import java.util.Set;
final class ClickStripTransform implements ComponentTransform {
private final Set<ClickEvent.@NonNull Action> actionsToStrip;
private final Set<ClickEvent.@NotNull Action> actionsToStrip;
public ClickStripTransform(final Set<ClickEvent.@NonNull Action> actionsToStrip) {
public ClickStripTransform(final Set<ClickEvent.@NotNull Action> actionsToStrip) {
this.actionsToStrip = EnumSet.copyOf(actionsToStrip);
}

View File

@ -93,10 +93,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
@Inject
public HybridPlotWorld(
@Assisted("world") final String worldName,
@javax.annotation.Nullable @Assisted("id") final String id,
@Nullable @Assisted("id") final String id,
@Assisted final @NonNull IndependentPlotGenerator generator,
@javax.annotation.Nullable @Assisted("min") final PlotId min,
@javax.annotation.Nullable @Assisted("max") final PlotId max,
@Nullable @Assisted("min") final PlotId min,
@Nullable @Assisted("max") final PlotId max,
@WorldConfig final @NonNull YamlConfiguration worldConfiguration,
final @NonNull GlobalBlockQueue blockQueue
) {

View File

@ -68,9 +68,6 @@ import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import jdk.jfr.Category;
import jdk.jfr.Event;
import jdk.jfr.Label;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
@ -125,6 +122,9 @@ public class Plot {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private static final Cleaner CLEANER = Cleaner.create();
static Set<Plot> connected_cache;
static Set<CuboidRegion> regions_cache;
static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
}
@ -207,8 +207,6 @@ public class Plot {
*/
private Plot origin;
private Set<Plot> connectedCache;
/**
* Constructor for a new plot.
* (Only changes after plot.create() will be properly set in the database)
@ -578,14 +576,7 @@ public class Plot {
return false;
}
final Set<Plot> connected = getConnectedPlots();
for (Plot current : connected) {
// can skip ServerPlotFlag check in getOwner()
// as flags are synchronized between plots
if (uuid.equals(current.getOwnerAbs())) {
return true;
}
}
return false;
return connected.stream().anyMatch(current -> uuid.equals(current.getOwner()));
}
/**
@ -1303,7 +1294,6 @@ public class Plot {
DBFunc.delete(current);
current.setOwnerAbs(null);
current.settings = null;
current.clearCache();
for (final PlotPlayer<?> pp : players) {
this.plotListener.plotEntry(pp, current);
}
@ -1874,7 +1864,6 @@ public class Plot {
this.area.removePlot(this.id);
this.id = plot.getId();
this.area.addPlotAbs(this);
clearCache();
DBFunc.movePlot(this, plot);
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
return true;
@ -2139,16 +2128,17 @@ public class Plot {
this.origin.origin = base;
other.origin = base;
this.origin = base;
this.connectedCache = null;
connected_cache = null;
}
} else {
if (this.origin != null) {
this.origin.origin = null;
this.origin = null;
}
this.connectedCache = null;
connected_cache = null;
}
DBFunc.setMerged(this, this.getSettings().getMerged());
regions_cache = null;
}
}
@ -2183,7 +2173,8 @@ public class Plot {
}
public void clearCache() {
this.connectedCache = null;
connected_cache = null;
regions_cache = null;
if (this.origin != null) {
this.origin.origin = null;
this.origin = null;
@ -2297,25 +2288,6 @@ public class Plot {
return this.area.getPlotAbs(this.id.getRelative(direction));
}
@Label("Connected Plots Search")
@Category("PlotSquared")
static class ConnectedPlotsEvent extends Event {
public ConnectedPlotsEvent(final int x, final int y) {
this.x = x;
this.y = y;
}
@Label("Plot Id X")
public int x;
@Label("Plot Id Y")
public int y;
@Label("Merged Plots Count")
public int mergedSize;
@Label("Connected Plots Cache Miss")
public boolean cacheMiss;
}
/**
* Gets a set of plots connected (and including) this plot<br>
* - This result is cached globally
@ -2323,21 +2295,16 @@ public class Plot {
* @return a Set of Plots connected to this Plot
*/
public Set<Plot> getConnectedPlots() {
ConnectedPlotsEvent event = new ConnectedPlotsEvent(this.id.getX(), this.id.getY());
event.begin();
if (this.settings == null) {
event.commit();
return Collections.singleton(this);
}
if (!this.isMerged()) {
event.commit();
return Collections.singleton(this);
}
if (this.connectedCache != null && this.connectedCache.contains(this)) {
event.mergedSize = this.connectedCache.size();
event.commit();
return this.connectedCache;
if (connected_cache != null && connected_cache.contains(this)) {
return connected_cache;
}
regions_cache = null;
HashSet<Plot> tmpSet = new HashSet<>();
tmpSet.add(this);
@ -2442,10 +2409,7 @@ public class Plot {
}
}
}
this.connectedCache = tmpSet;
event.mergedSize = tmpSet.size();
event.cacheMiss = true;
event.commit();
connected_cache = tmpSet;
return tmpSet;
}
@ -2457,15 +2421,19 @@ public class Plot {
* @return all regions within the plot
*/
public @NonNull Set<CuboidRegion> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache;
}
if (!this.isMerged()) {
Location pos1 = this.getBottomAbs().withY(getArea().getMinBuildHeight());
Location pos2 = this.getTopAbs().withY(getArea().getMaxBuildHeight());
this.connectedCache = Sets.newHashSet(this);
connected_cache = Sets.newHashSet(this);
CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
return Collections.singleton(rg);
regions_cache = Collections.singleton(rg);
return regions_cache;
}
Set<Plot> plots = this.getConnectedPlots();
Set<CuboidRegion> regions = new HashSet<>();
Set<CuboidRegion> regions = regions_cache = new HashSet<>();
Set<PlotId> visited = new HashSet<>();
for (Plot current : plots) {
if (visited.contains(current.getId())) {

View File

@ -263,7 +263,6 @@ public final class PlotModificationManager {
return;
}
Plot current = queue.poll();
current.clearCache();
if (plot.getArea().getTerrain() != PlotAreaTerrainType.NONE) {
try {
PlotSquared.platform().regionManager().regenerateRegion(
@ -328,7 +327,6 @@ public final class PlotModificationManager {
ArrayList<PlotId> ids = new ArrayList<>(plots.size());
for (Plot current : plots) {
current.setHome(null);
current.clearCache();
ids.add(current.getId());
}
this.plot.clearRatings();
@ -480,7 +478,8 @@ public final class PlotModificationManager {
this.plot.updateWorldBorder();
}
}
this.plot.clearCache();
Plot.connected_cache = null;
Plot.regions_cache = null;
this.plot.getTrusted().clear();
this.plot.getMembers().clear();
this.plot.getDenied().clear();
@ -631,7 +630,6 @@ public final class PlotModificationManager {
if (queue.size() > 0) {
queue.enqueue();
}
visited.forEach(Plot::clearCache);
return toReturn;
}

View File

@ -34,7 +34,9 @@ import java.util.UUID;
* Generic settings class.
* - Does not keep a reference to a parent class
* - Direct changes here will not occur in the db (Use the parent plot object for that)
* This class is not part of the API and may change at any time. It is recommended to use equivalent methods in the Plot class.
*/
@Deprecated
public class PlotSettings {
/**

View File

@ -18,8 +18,7 @@
*/
package com.plotsquared.core.plot;
import org.checkerframework.checker.nullness.qual.Nullable;
import javax.annotation.Nullable;
import java.util.Objects;
public class PlotTitle {

View File

@ -23,9 +23,9 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
class GlobalPlotProvider implements PlotProvider {
@ -37,7 +37,7 @@ class GlobalPlotProvider implements PlotProvider {
@Override
public Collection<Plot> getPlots() {
final List<Plot> plots = new ArrayList<>();
final Set<Plot> plots = new HashSet<>();
for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
plots.addAll(plotArea.getPlots());
}

View File

@ -65,7 +65,7 @@ subprojects {
}
dependencies {
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.21"))
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.20"))
}
dependencies {

View File

@ -4,7 +4,7 @@ guice = "5.1.0"
spotbugs = "4.7.3"
# Plugins
worldedit = "7.2.13"
worldedit = "7.2.12"
placeholderapi = "2.11.2"
luckperms = "5.4"
essentialsx = "2.19.7"
@ -13,7 +13,7 @@ mvdwapi = "3.1.1"
# Third party
prtree = "2.0.0"
aopalliance = "1.0"
cloud-services = "1.8.0"
cloud-services = "1.7.1"
arkitektonika = "2.1.1"
squirrelid = "0.3.1"
http4j = "1.3"