diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java index ca389cd30..5abbbd378 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ChunkListener.java @@ -111,7 +111,7 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils } Object c = this.methodGetHandleChunk.of(chunk).call(); RefField.RefExecutor field = this.mustSave.of(c); - if ((Boolean) field.get() == true) { + if ((Boolean) field.get()) { field.set(false); if (chunk.isLoaded()) { ignoreUnload = true; @@ -122,9 +122,9 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils return true; } - public boolean shouldSave(String world, int X, int Z) { - int x = X << 4; - int z = Z << 4; + public boolean shouldSave(String world, int chunkX, int chunkZ) { + int x = chunkX << 4; + int z = chunkZ << 4; int x2 = x + 15; int z2 = z + 15; Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java index 0faf0c198..6e167d548 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntitySpawnListener.java @@ -131,7 +131,7 @@ public class EntitySpawnListener implements Listener { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException { + public void vehicleMove(VehicleMoveEvent event) { test(event.getVehicle()); } 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 833e02968..11d9c30f4 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 @@ -21,26 +21,26 @@ public class Auto extends SubCommand { } private static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea, - @Nullable Integer allowed_plots, int size_x, int size_z) { - if (allowed_plots == null) { - allowed_plots = player.getAllowedPlots(); + @Nullable Integer allowedPlots, int sizeX, int sizeZ) { + if (allowedPlots == null) { + allowedPlots = player.getAllowedPlots(); } int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname); - int diff = currentPlots - allowed_plots; - if (diff + size_x * size_z > 0) { + int diff = currentPlots - allowedPlots; + if (diff + sizeX * sizeZ > 0) { if (diff < 0) { MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + ""); return false; } else if (player.hasPersistentMeta("grantedPlots")) { int grantedPlots = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots")); - if (grantedPlots - diff < size_x * size_z) { + if (grantedPlots - diff < sizeX * sizeZ) { player.removePersistentMeta("grantedPlots"); MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS); return false; } else { - int left = grantedPlots - diff - size_x * size_z; + int left = grantedPlots - diff - sizeX * sizeZ; if (left == 0) { player.removePersistentMeta("grantedPlots"); } else { @@ -98,7 +98,7 @@ public class Auto extends SubCommand { * @param schem */ public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start, - final String schem, @Nullable final Integer allowed_plots) { + final String schem, @Nullable final Integer allowedPlots) { player.setMeta(Auto.class.getName(), true); autoClaimFromDatabase(player, area, start, new RunnableVal() { @Override public void run(final Plot plot) { @@ -107,7 +107,7 @@ public class Auto extends SubCommand { player.deleteMeta(Auto.class.getName()); if (plot == null) { MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS); - } else if (checkAllowedPlots(player, area, allowed_plots, 1, 1)) { + } else if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) { plot.claim(player, true, schem, false); if (area.AUTO_MERGE) { plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true); 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 1f6429dbd..b95913102 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 @@ -9,12 +9,12 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; +import com.google.common.collect.Sets; import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.util.Collections; import java.util.HashSet; public class HybridPlotManager extends ClassicPlotManager { @@ -22,9 +22,8 @@ public class HybridPlotManager extends ClassicPlotManager { public static boolean REGENERATIVE_CLEAR = true; @Override public void exportTemplate(PlotArea plotArea) throws IOException { - HashSet files = new HashSet<>(Collections.singletonList( - new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", - Template.getBytes(plotArea)))); + HashSet files = Sets.newHashSet( + new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))); String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotArea.worldname + File.separator; String newDir = 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 88ac6dc31..9733918f3 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 @@ -19,6 +19,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.sk89q.jnbt.CompoundTag; import javax.annotation.Nonnull; @@ -607,8 +608,17 @@ public class Plot { */ public void setDenied(Set uuids) { boolean larger = uuids.size() > getDenied().size(); - HashSet intersection = new HashSet<>(larger ? getDenied() : uuids); - intersection.retainAll(larger ? uuids : getDenied()); + HashSet intersection; + if (larger) { + intersection = new HashSet<>(getDenied()); + } else { + intersection = new HashSet<>(uuids); + } + if (larger) { + intersection.retainAll(uuids); + } else { + intersection.retainAll(getDenied()); + } uuids.removeAll(intersection); HashSet toRemove = new HashSet<>(getDenied()); toRemove.removeAll(intersection); @@ -2500,16 +2510,15 @@ public class Plot { * * @return */ - public HashSet getRegions() { + @Nonnull public HashSet getRegions() { if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { return regions_cache; } if (!this.isMerged()) { Location pos1 = this.getBottomAbs(); Location pos2 = this.getTopAbs(); - connected_cache = new HashSet<>(Collections.singletonList(this)); - regions_cache = new HashSet<>(1); - regions_cache.add( + connected_cache = Sets.newHashSet(this); + regions_cache = Sets.newHashSet( new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ())); return regions_cache; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java index 8dfdeaaac..36d23c8f6 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java @@ -3,19 +3,17 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.object.*; +import com.google.common.collect.Sets; +import javax.annotation.Nonnull; import java.util.Collection; import java.util.HashSet; import java.util.UUID; public class SinglePlot extends Plot { - private HashSet regions; - - { - regions = new HashSet<>(); - regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, + private HashSet regions = Sets.newHashSet( + new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)); - } public SinglePlot(PlotArea area, PlotId id, UUID owner) { super(area, id, owner); @@ -62,7 +60,7 @@ public class SinglePlot extends Plot { return super.isLoaded(); } - @Override public HashSet getRegions() { + @Nonnull @Override public HashSet getRegions() { return regions; }