diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index e32b26cb2..12a31de02 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -119,7 +119,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain new PlotSquared(this, "Bukkit"); - if (PlotSquared.get().IMP.getServerVersion()[1] < 13) { + if (PaperLib.getMinecraftVersion() < 13 && PaperLib.getMinecraftPatchVersion() < 2) { System.out.println( "You can't use this version of PlotSquared on a server less than Minecraft 1.13.2."); System.out diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 938cc8b9a..5334cafb8 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -932,10 +932,10 @@ import java.util.regex.Pattern; PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); - if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { + if (location.isPlotArea() || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { return; } - Plot plot = area.getPlot(location); + Plot plot = location.getPlot(); if (plot == null) { return; } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java index c3b7521f2..a40fb252b 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java @@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlock import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import io.papermc.lib.PaperLib; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; @@ -276,7 +277,7 @@ public class BukkitChunkManager extends ChunkManager { } final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z - && PlotSquared.imp().getServerVersion()[1] == 13) { + && PaperLib.getMinecraftVersion() == 13) { AugmentedUtils .bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.x, chunk.z)); continue; @@ -391,7 +392,7 @@ public class BukkitChunkManager extends ChunkManager { return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force); } - @SuppressWarnings("deprecation") @Override + @Override public void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe) { if (!PlotSquared.get().isMainThread(Thread.currentThread())) { diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java index 0331e948a..bc18271db 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java @@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock; import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings; import com.github.intellectualsites.plotsquared.plot.util.StringComparison; +import io.papermc.lib.PaperLib; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -829,7 +830,7 @@ public final class BukkitLegacyMappings extends LegacyMappings { LegacyBlock(final int numericalId, final int dataValue, @NonNull final String legacyName, @NonNull final String newName, @NonNull final String new14Name) { this(numericalId, dataValue, legacyName, - PlotSquared.get().IMP.getServerVersion()[1] == 13 ? newName : new14Name); + PaperLib.getMinecraftVersion() == 13 ? newName : new14Name); } LegacyBlock(final int numericalId, @NonNull final String legacyName, diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index 283e68688..2c5d9c9d0 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.sk89q.worldedit.bukkit.BukkitWorld; +import io.papermc.lib.PaperLib; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -353,7 +354,7 @@ import java.util.Set; } else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) { facing = BlockFace.SOUTH; } - if (PlotSquared.get().IMP.getServerVersion()[1] == 13) { + if (PaperLib.getMinecraftVersion() == 13) { block.setType(Material.valueOf("WALL_SIGN"), false); } else { block.setType(Material.valueOf("OAK_WALL_SIGN"), false); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java index fa187877e..c68d8ba30 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java @@ -253,6 +253,9 @@ public class Auto extends SubCommand { for (int j = start.y; j <= end.y; j++) { Plot plot = plotarea.getPlotAbs(new PlotId(i, j)); boolean teleport = i == end.x && j == end.y; + if (plot == null) { + return false; + } plot.claim(player, teleport, null); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java index ac10f7aab..2634f4af1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotManager.java @@ -12,6 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.google.common.collect.Sets; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; + import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -34,13 +35,13 @@ public class HybridPlotManager extends ClassicPlotManager { String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.worldname + File.separator; try { - File sideroad = + File sideRoad = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), dir + "sideroad.schem"); String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; - if (sideroad.exists()) { + if (sideRoad.exists()) { files.add(new FileBytes(newDir + "sideroad.schem", - Files.readAllBytes(sideroad.toPath()))); + Files.readAllBytes(sideRoad.toPath()))); } File intersection = MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "intersection.schem"); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index b1098e6f3..513a74ec0 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -21,6 +21,7 @@ import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.sk89q.jnbt.CompoundTag; +import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -46,13 +47,14 @@ import java.util.stream.Collectors; public class Plot { private static final int MAX_HEIGHT = 256; + /** * @deprecated raw access is deprecated */ @Deprecated private static HashSet connected_cache; private static HashSet regions_cache; - private final PlotId id; + @NotNull private final PlotId id; /** * plot owner @@ -62,10 +64,12 @@ public class Plot { * @deprecated */ @Deprecated public UUID owner; + /** * Has the plot changed since the last save cycle? */ public boolean countsTowardsMax = true; + /** * Represents whatever the database manager needs it to:
* - A value of -1 usually indicates the plot will not be stored in the DB
@@ -74,23 +78,28 @@ public class Plot { * @deprecated magical */ @Deprecated public int temp; + /** * Plot creation timestamp (not accurate if the plot was created before this was implemented)
* - Milliseconds since the epoch
*/ private long timestamp; + /** * List of trusted (with plot permissions). */ private HashSet trusted; + /** * List of members users (with plot permissions). */ private HashSet members; + /** * List of denied players. */ private HashSet denied; + /** * External settings class. * - Please favor the methods over direct access to this class
@@ -99,6 +108,7 @@ public class Plot { private PlotSettings settings; private PlotArea area; + /** * Session only plot metadata (session is until the server stops)
*
@@ -107,6 +117,7 @@ public class Plot { * @see FlagManager */ private ConcurrentHashMap meta; + /** * The cached origin plot. * - The origin plot is used for plot grouping and relational data @@ -117,12 +128,12 @@ public class Plot { * Constructor for a new plot. * (Only changes after plot.create() will be properly set in the database) * - * @param area the PlotArea where the plot is located - * @param id the plot id + * @param area the PlotArea where the plot is located + * @param id the plot id * @param owner the plot owner * @see Plot#getPlot(Location) for existing plots */ - public Plot(PlotArea area, PlotId id, UUID owner) { + public Plot(PlotArea area, @NotNull PlotId id, UUID owner) { this.area = area; this.id = id; this.owner = owner; @@ -133,10 +144,10 @@ public class Plot { * (Only changes after plot.create() will be properly set in the database) * * @param area the PlotArea where the plot is located - * @param id the plot id + * @param id the plot id * @see Plot#getPlot(Location) for existing plots */ - public Plot(PlotArea area, PlotId id) { + public Plot(PlotArea area, @NotNull PlotId id) { this.area = area; this.id = id; } @@ -146,13 +157,13 @@ public class Plot { * The database will ignore any queries regarding temporary plots. * Please note that some bulk plot management functions may still affect temporary plots (TODO: fix this) * - * @param area the PlotArea where the plot is located - * @param id the plot id + * @param area the PlotArea where the plot is located + * @param id the plot id * @param owner the owner of the plot - * @param temp Represents whatever the database manager needs it to + * @param temp Represents whatever the database manager needs it to * @see Plot#getPlot(Location) for existing plots */ - public Plot(PlotArea area, PlotId id, UUID owner, int temp) { + public Plot(PlotArea area, @NotNull PlotId id, UUID owner, int temp) { this.area = area; this.id = id; this.owner = owner; @@ -162,14 +173,14 @@ public class Plot { /** * Constructor for a saved plots (Used by the database manager when plots are fetched) * - * @param id the plot id - * @param owner the plot owner + * @param id the plot id + * @param owner the plot owner * @param trusted the plot trusted players - * @param denied the plot denied players - * @param merged array giving merged plots + * @param denied the plot denied players + * @param merged an array giving merged plots * @see Plot#getPlot(Location) for existing plots */ - public Plot(PlotId id, UUID owner, HashSet trusted, HashSet members, + public Plot(@NotNull PlotId id, UUID owner, HashSet trusted, HashSet members, HashSet denied, String alias, BlockLoc position, Collection flags, PlotArea area, boolean[] merged, long timestamp, int temp) { this.id = id; @@ -194,8 +205,8 @@ public class Plot { /** * Gets a plot from a string e.g. [area];[id] * - * @param defaultArea If no area is specified - * @param string plot id/area + id + * @param defaultArea if no area is specified + * @param string plot id/area + id * @return New or existing plot object */ public static Plot fromString(PlotArea defaultArea, String string) { @@ -452,7 +463,7 @@ public class Plot { * * @return the PlotId for this plot */ - public PlotId getId() { + @NotNull public PlotId getId() { return this.id; } @@ -1627,7 +1638,7 @@ public class Plot { /** * Moves the settings for a plot. * - * @param plot the plot to move + * @param plot the plot to move * @param whenDone * @return */ diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index 3ed1e2c95..50ffaf7b3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -635,7 +635,7 @@ public abstract class PlotArea { this.meta.put(key, value); } - @Nullable public T getMeta(@Nullable final String key, @Nullable final T def) { + @NotNull public T getMeta(@Nullable final String key, @NotNull final T def) { final Object v = getMeta(key); return v == null ? def : (T) v; }