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 5965d612c..4fdfd28ed 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 @@ -32,8 +32,7 @@ import java.util.HashSet; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass; -@SuppressWarnings("unused") -public class ChunkListener implements Listener { +@SuppressWarnings("unused") public class ChunkListener implements Listener { private RefMethod methodGetHandleChunk; private RefField mustSave; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java index cfefc7a17..a168d8069 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java @@ -18,8 +18,7 @@ import org.bukkit.plugin.Plugin; import java.util.List; -@SuppressWarnings("unused") -public class EntityPortal_1_7_9 implements Listener { +@SuppressWarnings("unused") public class EntityPortal_1_7_9 implements Listener { private static boolean ignoreTP = false; public EntityPortal_1_7_9() { 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 60e668935..dc24740c3 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 @@ -16,8 +16,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.Plugin; -@SuppressWarnings("unused") -public class EntitySpawnListener implements Listener { +@SuppressWarnings("unused") public class EntitySpawnListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void creatureSpawnEvent(EntitySpawnEvent event) { Entity entity = event.getEntity(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ForceFieldListener.java index 81c720b13..97d1bb7d7 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -16,8 +16,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; -@SuppressWarnings("unused") -public class ForceFieldListener { +@SuppressWarnings("unused") public class ForceFieldListener { private static Set getNearbyPlayers(Player player, Plot plot) { Set players = new HashSet<>(); 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 380e7b640..41b8ec34f 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 @@ -56,8 +56,7 @@ import java.util.regex.Pattern; /** * Player Events involving plots. */ -@SuppressWarnings("unused") -public class PlayerEvents extends PlotListener implements Listener { +@SuppressWarnings("unused") public class PlayerEvents extends PlotListener implements Listener { private boolean pistonBlocks = true; private float lastRadius; @@ -175,7 +174,8 @@ public class PlayerEvents extends PlotListener implements Listener { case ZOMBIE_HORSE: case SKELETON_HORSE: // animal - return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); + return EntityUtil + .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); case BLAZE: case CAVE_SPIDER: case CREEPER: @@ -204,14 +204,16 @@ public class PlayerEvents extends PlotListener implements Listener { case VEX: case ZOMBIE_VILLAGER: // monster - return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); + return EntityUtil + .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); default: if (entity instanceof LivingEntity) { if (entity instanceof Animals) { - return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); + return EntityUtil + .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); } else if (entity instanceof Monster) { - return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, - Flags.HOSTILE_CAP); + return EntityUtil + .checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); } else { return EntityUtil.checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP); } @@ -943,8 +945,9 @@ public class PlayerEvents extends PlotListener implements Listener { return; } if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { - if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit - .getConfiguration().wandItem).getMaterial()) { + if (player.getInventory().getItemInMainHand().getType() == LegacyMappings + .fromLegacyId(PlotSquared.get().worldedit.getConfiguration().wandItem) + .getMaterial()) { return; } } @@ -1202,8 +1205,8 @@ public class PlayerEvents extends PlotListener implements Listener { Optional> destroy = plot.getFlag(Flags.BREAK); Block block = event.getBlock(); if (destroy.isPresent() && destroy.get() - .contains(PlotBlock.get(block.getType().name())) - || Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { + .contains(PlotBlock.get(block.getType().name())) || Permissions + .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) { return; } event.setCancelled(true); @@ -1679,8 +1682,9 @@ public class PlayerEvents extends PlotListener implements Listener { return; } if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) { - if (player.getInventory().getItemInMainHand().getType() == LegacyMappings.fromLegacyId(PlotSquared.get().worldedit - .getConfiguration().wandItem).getMaterial()) { + if (player.getInventory().getItemInMainHand().getType() == LegacyMappings + .fromLegacyId(PlotSquared.get().worldedit.getConfiguration().wandItem) + .getMaterial()) { return; } } @@ -1991,8 +1995,7 @@ public class PlayerEvents extends PlotListener implements Listener { } else if (!plot.isAdded(plotPlayer.getUUID())) { Optional> use = plot.getFlag(Flags.USE); Block block = event.getBlockClicked(); - if (use.isPresent() && use.get() - .contains(PlotBlock.get(block.getType().name()))) { + if (use.isPresent() && use.get().contains(PlotBlock.get(block.getType().name()))) { return; } if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) { diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents183.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents183.java index 6d1ce0ded..4b3b83045 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents183.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents183.java @@ -14,8 +14,7 @@ import org.bukkit.event.block.BlockExplodeEvent; import java.util.Iterator; -@SuppressWarnings("unused") -public class PlayerEvents183 implements Listener { +@SuppressWarnings("unused") public class PlayerEvents183 implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBigBoom(BlockExplodeEvent event) { diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_8.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_8.java index ff1c3eb4b..a8757ab97 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_8.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_8.java @@ -32,8 +32,7 @@ import java.util.HashSet; import java.util.List; import java.util.UUID; -@SuppressWarnings("unused") -public class PlayerEvents_1_8 extends PlotListener implements Listener { +@SuppressWarnings("unused") public class PlayerEvents_1_8 extends PlotListener implements Listener { @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_9.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_9.java index c89892749..51c64ea42 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_9.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents_1_9.java @@ -9,8 +9,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.LingeringPotionSplashEvent; -@SuppressWarnings("unused") -public class PlayerEvents_1_9 implements Listener { +@SuppressWarnings("unused") public class PlayerEvents_1_9 implements Listener { private final PlayerEvents parent; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java index 9d37ef09e..0daeeb26f 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener.java @@ -28,8 +28,7 @@ import java.util.Iterator; import java.util.Map.Entry; import java.util.UUID; -@SuppressWarnings("unused") -public class PlotPlusListener extends PlotListener implements Listener { +@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener { private static final HashMap feedRunnable = new HashMap<>(); private static final HashMap healRunnable = new HashMap<>(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java index 47b2e90fa..007d8b2b3 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java @@ -12,8 +12,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent; import java.util.UUID; -@SuppressWarnings("unused") -public class PlotPlusListener_1_12 implements Listener { +@SuppressWarnings("unused") public class PlotPlusListener_1_12 implements Listener { @EventHandler public void onItemPickup(EntityPickupItemEvent event) { LivingEntity ent = event.getEntity(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java index fdd762c45..28215f192 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java @@ -11,9 +11,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import java.util.UUID; -@SuppressWarnings("unused") -public class PlotPlusListener_Legacy implements Listener { - +@SuppressWarnings("unused") public class PlotPlusListener_Legacy implements Listener { + @EventHandler public void onItemPickup(PlayerPickupItemEvent event) { Player player = event.getPlayer(); PlotPlayer pp = BukkitUtil.getPlayer(player); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java index de02bb5db..6a3e26d59 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/SingleWorldListener.java @@ -19,8 +19,7 @@ import java.lang.reflect.Method; import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass; -@SuppressWarnings("unused") -public class SingleWorldListener implements Listener { +@SuppressWarnings("unused") public class SingleWorldListener implements Listener { private Method methodGetHandleChunk; private Field mustSave, done, lit, s; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitBlockRegistry.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitBlockRegistry.java index 1d416f6bf..b5ac5f1fb 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitBlockRegistry.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitBlockRegistry.java @@ -7,13 +7,12 @@ import org.bukkit.Material; public class BukkitBlockRegistry extends BlockRegistry { - public BukkitBlockRegistry(final Material... preInitializedItems) { - super(Material.class, preInitializedItems); - } + public BukkitBlockRegistry(final Material... preInitializedItems) { + super(Material.class, preInitializedItems); + } - @Override - public PlotBlock getPlotBlock(@NonNull final Material item) { - return PlotBlock.get(item.name()); - } + @Override public PlotBlock getPlotBlock(@NonNull final Material item) { + return PlotBlock.get(item.name()); + } } 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 b6bcaf62d..dd4320484 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 @@ -3,26 +3,9 @@ package com.github.intellectualsites.plotsquared.bukkit.util; import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.C; -import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock; -import com.github.intellectualsites.plotsquared.plot.object.Location; -import com.github.intellectualsites.plotsquared.plot.object.Plot; -import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; -import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; -import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock; +import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem; -import com.github.intellectualsites.plotsquared.plot.util.MainUtil; -import com.github.intellectualsites.plotsquared.plot.util.MathMan; -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 java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import javax.annotation.Nullable; +import com.github.intellectualsites.plotsquared.plot.util.*; import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -37,12 +20,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; -import org.bukkit.material.Sandstone; -import org.bukkit.material.Step; -import org.bukkit.material.Tree; -import org.bukkit.material.WoodenStep; -import org.bukkit.material.Wool; +import org.bukkit.material.*; + +import javax.annotation.Nullable; +import java.util.*; @SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil { @@ -80,14 +61,6 @@ import org.bukkit.material.Wool; return getLocation(location).getPlot(); } - @Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) { - if (block1.equals(block2)) { - return true; - } - Material mat1 = getMaterial(block1), mat2 = getMaterial(block2); - return mat1 == mat2; - } - /** * Get a plot based on the player location. * @@ -261,6 +234,30 @@ import org.bukkit.material.Wool; location.getPitch()); } + public static BukkitLegacyMappings getBukkitLegacyMappings() { + return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings(); + } + + public static Material getMaterial(@NonNull final PlotBlock plotBlock) { + if (plotBlock instanceof StringPlotBlock) { + return Material + .getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH)); + } else { + final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock; + return getBukkitLegacyMappings() + .fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData()) + .to(Material.class); + } + } + + @Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) { + if (block1.equals(block2)) { + return true; + } + Material mat1 = getMaterial(block1), mat2 = getMaterial(block2); + return mat1 == mat2; + } + @Override public boolean isWorld(@NonNull final String worldName) { return getWorld(worldName) != null; } @@ -379,10 +376,6 @@ import org.bukkit.material.Wool; return list; } - public static BukkitLegacyMappings getBukkitLegacyMappings() { - return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings(); - } - @Override public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) { final World world = getWorld(worldName); @@ -405,15 +398,6 @@ import org.bukkit.material.Wool; return false; } - public static Material getMaterial(@NonNull final PlotBlock plotBlock) { - if (plotBlock instanceof StringPlotBlock) { - return Material.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH)); - } else { - final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock; - return getBukkitLegacyMappings().fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData()).to(Material.class); - } - } - @Override public boolean isBlockSolid(@NonNull final PlotBlock block) { try { final Material material = getMaterial(block); @@ -450,7 +434,7 @@ import org.bukkit.material.Wool; public StringComparison.ComparisonResult getClosestBlock(String name) { final PlotBlock plotBlock = BukkitUtil.getBukkitLegacyMappings().fromAny(name); if (plotBlock != null) { - return new StringComparison().new ComparisonResult(1, plotBlock); + return new StringComparison().new ComparisonResult(1, plotBlock); } return BukkitUtil.getBukkitLegacyMappings().getClosestsMatch(name); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index 27c6fc41e..1e1021052 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -1939,7 +1939,7 @@ import java.util.zip.ZipInputStream; * * @param alias to search plots * @param worldname to filter alias to a specific world [optional] null means all worlds - * @return Set<{ @ link Plot }> empty if nothing found + * @return Set<{ @ link Plot }> empty if nothing found */ public Set getPlotsByAlias(@Nullable final String alias, @NonNull final String worldname) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java index ef7a92b56..7f7f64dba 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Area.java @@ -199,7 +199,8 @@ public class Area extends SubCommand { break; case "w": case "wall": - pa.WALL_FILLING = Configuration.BLOCK_BUCKET.parseString(pair[1]); + pa.WALL_FILLING = + Configuration.BLOCK_BUCKET.parseString(pair[1]); break; case "b": case "border": diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java index bd4a19d79..8dd9ce8f1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java @@ -68,7 +68,8 @@ public class Set extends SubCommand { StringComparison.ComparisonResult match = WorldUtil.IMP.getClosestBlock(unknownBlock); if (match != null) { - final String found = WorldUtil.IMP.getClosestMatchingName(match.best); + final String found = + WorldUtil.IMP.getClosestMatchingName(match.best); if (found != null) { MainUtil.sendMessage(player, C.DID_YOU_MEAN, found.toLowerCase()); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java index da6e339dd..a87377043 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Configuration.java @@ -4,11 +4,11 @@ import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; - -import java.util.ArrayList; import lombok.Getter; import lombok.NonNull; +import java.util.ArrayList; + /** * Main Configuration Utility */ @@ -104,24 +104,9 @@ public class Configuration { return value.best; } }; - - public static final class UnknownBlockException extends IllegalArgumentException { - - @Getter - private final String unknownValue; - - public UnknownBlockException(@NonNull final String unknownValue) { - super(String.format("\"%s\" is not a valid block", unknownValue)); - this.unknownValue = unknownValue; - } - - } - - public static final SettingValue BLOCK_BUCKET = new SettingValue("BLOCK_BUCKET") { - @Override - public BlockBucket parseString(final String string) { + @Override public BlockBucket parseString(final String string) { if (string == null || string.isEmpty()) { return new BlockBucket(); } @@ -151,8 +136,7 @@ public class Configuration { return blockBucket; } - @Override - public boolean validateValue(final String string) { + @Override public boolean validateValue(final String string) { try { if (string == null || string.isEmpty()) { return false; @@ -184,7 +168,6 @@ public class Configuration { return true; } }; - public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") { @Override public boolean validateValue(String string) { @@ -263,6 +246,19 @@ public class Configuration { return result; } + + public static final class UnknownBlockException extends IllegalArgumentException { + + @Getter private final String unknownValue; + + public UnknownBlockException(@NonNull final String unknownValue) { + super(String.format("\"%s\" is not a valid block", unknownValue)); + this.unknownValue = unknownValue; + } + + } + + /** * Create your own SettingValue object to make the management of plotworld configuration easier */ diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotWorld.java index 5a1fdaa43..8a0c14a99 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotWorld.java @@ -13,12 +13,18 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public int ROAD_HEIGHT = 64; public int PLOT_HEIGHT = 64; public int WALL_HEIGHT = 64; - public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone")); // new PlotBlock[] {PlotBlock.get("stone")}; - public BlockBucket TOP_BLOCK = BlockBucket.withSingle(PlotBlock.get("grass")); //new PlotBlock[] {PlotBlock.get("grass")}; - public BlockBucket WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone_slab")); // PlotBlock.get((short) 44, (byte) 0); - public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("sandstone_slab")); // PlotBlock.get((short) 44, (byte) 1); - public BlockBucket WALL_FILLING = BlockBucket.withSingle(PlotBlock.get("stone")); //PlotBlock.get((short) 1, (byte) 0); - public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(PlotBlock.get("quartz_block")); // PlotBlock.get((short) 155, (byte) 0); + public BlockBucket MAIN_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone")); + // new PlotBlock[] {PlotBlock.get("stone")}; + public BlockBucket TOP_BLOCK = BlockBucket.withSingle(PlotBlock.get("grass")); + //new PlotBlock[] {PlotBlock.get("grass")}; + public BlockBucket WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("stone_slab")); + // PlotBlock.get((short) 44, (byte) 0); + public BlockBucket CLAIMED_WALL_BLOCK = BlockBucket.withSingle(PlotBlock.get("sandstone_slab")); + // PlotBlock.get((short) 44, (byte) 1); + public BlockBucket WALL_FILLING = BlockBucket.withSingle(PlotBlock.get("stone")); + //PlotBlock.get((short) 1, (byte) 0); + public BlockBucket ROAD_BLOCK = BlockBucket.withSingle(PlotBlock.get("quartz_block")); + // PlotBlock.get((short) 155, (byte) 0); public boolean PLOT_BEDROCK = true; public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator, @@ -46,8 +52,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK_BUCKET), new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, - "Wall block (claimed)", - Configuration.BLOCK_BUCKET), + "Wall block (claimed)", Configuration.BLOCK_BUCKET), new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER), new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", @@ -77,7 +82,8 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { this.WALL_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("wall.block")); this.ROAD_HEIGHT = Math.min(255, config.getInt("road.height")); this.ROAD_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("road.block")); - this.WALL_FILLING = Configuration.BLOCK_BUCKET.parseString(config.getString("wall.filling")); + this.WALL_FILLING = + Configuration.BLOCK_BUCKET.parseString(config.getString("wall.filling")); this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height")); this.CLAIMED_WALL_BLOCK = Configuration.BLOCK_BUCKET.parseString(config.getString("wall.block_claimed")); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java index fb4716d8d..ed4060028 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java @@ -4,248 +4,236 @@ import com.github.intellectualsites.plotsquared.configuration.serialization.Conf import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import java.util.*; +import java.util.Map.Entry; + /** * A block bucket is a container of block types, where each block * has a specified chance of being randomly picked */ -@EqualsAndHashCode -@SuppressWarnings({"unused", "WeakerAccess"}) -public final class BlockBucket implements Iterable, ConfigurationSerializable { +@EqualsAndHashCode @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket + implements Iterable, ConfigurationSerializable { - private final Random random = new Random(); - private final Map ranges = new HashMap<>(); - private final Map blocks; - private final BucketIterator bucketIterator = new BucketIterator(); - private boolean compiled; + private final Random random = new Random(); + private final Map ranges = new HashMap<>(); + private final Map blocks; + private final BucketIterator bucketIterator = new BucketIterator(); + private boolean compiled; - public static BlockBucket withSingle(@NonNull final PlotBlock block) { - final BlockBucket blockBucket = new BlockBucket(); - blockBucket.addBlock(block); - return blockBucket; - } - - public static BlockBucket empty() { - final BlockBucket bucket = new BlockBucket(); - bucket.compiled = true; - return bucket; - } - - public BlockBucket() { - this.blocks = new HashMap<>(); - } - - public void addBlock(@NonNull final PlotBlock block) { - this.addBlock(block, -1); - } - - public void addBlock(@NonNull final PlotBlock block, final int chance) { - this.blocks.put(block, chance); - this.compiled = false; - } - - public boolean isEmpty() { - if (isCompiled()) { - return ranges.isEmpty(); - } - return blocks.isEmpty(); - } - - /** - * Get all blocks that are configured in the bucket - * - * @return Immutable collection containing all blocks that can - * be found in the bucket - */ - public Collection getBlocks() { - if (!isCompiled()) { - this.compile(); - } - return Collections.unmodifiableCollection(this.ranges.values()); - } - - /** - * Get a collection containing a specified amount of randomly selected blocks - * - * @param count Number of blocks - * @return Immutable collection containing randomly selected blocks - */ - public Collection getBlocks(final int count) { - final List blocks = new ArrayList<>(count); - for (int i = 0; i < count; i++) { - blocks.add(getBlock()); - } - return Collections.unmodifiableCollection(blocks); - } - - public void compile() { - if (isCompiled()) { - return; + public BlockBucket() { + this.blocks = new HashMap<>(); } - if (blocks.size() == 1) { - this.ranges.put(new Range(0, 100, true), blocks.keySet().toArray(new PlotBlock[1])[0]); - this.compiled = true; - return; + public static BlockBucket withSingle(@NonNull final PlotBlock block) { + final BlockBucket blockBucket = new BlockBucket(); + blockBucket.addBlock(block); + return blockBucket; } - final Map temp = new HashMap<>(blocks.size()); - final List unassigned = new ArrayList<>(blocks.size()); + public static BlockBucket empty() { + final BlockBucket bucket = new BlockBucket(); + bucket.compiled = true; + return bucket; + } - int sum = 0; - for (final Map.Entry entry : blocks.entrySet()) { - if (entry.getValue() == -1) { - unassigned.add(entry.getKey()); - } else { - sum += entry.getValue(); - } - } - // - // If this doesn't amount to 100 add it up to exactly 100. - // - if (sum < 100) { - final int remaining = 100 - sum; - final int perUnassigned = remaining / unassigned.size(); - for (final PlotBlock block : unassigned) { - temp.put(block, perUnassigned); - sum += perUnassigned; - } - // Make sure there isn't a tiny difference remaining - if (sum < 100) { - final int difference = 100 - sum; - temp.put(unassigned.get(0), perUnassigned + difference); - sum = 100; - } - } else if (!unassigned.isEmpty()) { - C.BUCKET_ENTRIES_IGNORED.send(ConsolePlayer.getConsole()); - } - // - // If the sum adds up to more than 100, divide all values - // - if (sum > 100) { - final double ratio = 100D / sum; - for (final Map.Entry entry : blocks.entrySet()) { - if (entry.getValue() == -1) { - continue; + public static BlockBucket deserialize(@NonNull final Map map) { + if (!map.containsKey("blocks")) { + return null; } - temp.put(entry.getKey(), (int)(entry.getValue() * ratio)); - } - } else { - temp.forEach(temp::put); - } - int start = 0; - for (final Map.Entry entry : temp.entrySet()) { - final int rangeStart = start; - final int rangeEnd = rangeStart + entry.getValue(); - start = rangeEnd + 1; - final Range range = new Range(rangeStart, rangeEnd, unassigned.contains(entry.getKey())); - this.ranges.put(range, entry.getKey()); - } - this.blocks.clear(); - this.compiled = true; - } - - @Override - public Iterator iterator() { - return this.bucketIterator; - } - - public boolean isCompiled() { - return this.compiled; - } - - /** - * Get a random block out of the bucket - * - * @return Randomly picked block (cased on specified rates) - */ - public PlotBlock getBlock() { - if (!isCompiled()) { - this.compile(); - } - if (this.isEmpty()) { - return StringPlotBlock.EVERYTHING; - } - final int number = random.nextInt(101); - for (final Map.Entry entry : ranges.entrySet()) { - if (entry.getKey().isInRange(number)) { - return entry.getValue(); - } - } - // Didn't find a block? Try again - return getBlock(); - } - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - final Iterator> iterator = this.ranges.entrySet().iterator(); - while (iterator.hasNext()) { - final Entry entry = iterator.next(); - builder.append(entry.getValue().getRawId()); - if (!entry.getKey().isAutomatic()) { - builder.append(":").append(entry.getKey().getWeight()); - } - if (iterator.hasNext()) { - builder.append(","); - } - } - return builder.toString(); - } - - @Override - public Map serialize() { - return ImmutableMap.of("blocks", this.toString()); - } - - public static BlockBucket deserialize(@NonNull final Map map) { - if (!map.containsKey("blocks")) { - return null; - } - return Configuration.BLOCK_BUCKET.parseString(map.get("blocks").toString()); - } - - private final class BucketIterator implements Iterator { - - @Override - public boolean hasNext() { - return true; + return Configuration.BLOCK_BUCKET.parseString(map.get("blocks").toString()); } - @Override - public PlotBlock next() { - return getBlock(); - } - } - - @Getter - @EqualsAndHashCode - @RequiredArgsConstructor - private final static class Range { - - private final int min; - private final int max; - @Getter - private final boolean automatic; - - public int getWeight() { - return max - min; + public void addBlock(@NonNull final PlotBlock block) { + this.addBlock(block, -1); } - public boolean isInRange(final int num) { - return num <= max && num >= min; + public void addBlock(@NonNull final PlotBlock block, final int chance) { + this.blocks.put(block, chance); + this.compiled = false; + } + + public boolean isEmpty() { + if (isCompiled()) { + return ranges.isEmpty(); + } + return blocks.isEmpty(); + } + + /** + * Get all blocks that are configured in the bucket + * + * @return Immutable collection containing all blocks that can + * be found in the bucket + */ + public Collection getBlocks() { + if (!isCompiled()) { + this.compile(); + } + return Collections.unmodifiableCollection(this.ranges.values()); + } + + /** + * Get a collection containing a specified amount of randomly selected blocks + * + * @param count Number of blocks + * @return Immutable collection containing randomly selected blocks + */ + public Collection getBlocks(final int count) { + final List blocks = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + blocks.add(getBlock()); + } + return Collections.unmodifiableCollection(blocks); + } + + public void compile() { + if (isCompiled()) { + return; + } + + if (blocks.size() == 1) { + this.ranges.put(new Range(0, 100, true), blocks.keySet().toArray(new PlotBlock[1])[0]); + this.compiled = true; + return; + } + + final Map temp = new HashMap<>(blocks.size()); + final List unassigned = new ArrayList<>(blocks.size()); + + int sum = 0; + for (final Map.Entry entry : blocks.entrySet()) { + if (entry.getValue() == -1) { + unassigned.add(entry.getKey()); + } else { + sum += entry.getValue(); + } + } + // + // If this doesn't amount to 100 add it up to exactly 100. + // + if (sum < 100) { + final int remaining = 100 - sum; + final int perUnassigned = remaining / unassigned.size(); + for (final PlotBlock block : unassigned) { + temp.put(block, perUnassigned); + sum += perUnassigned; + } + // Make sure there isn't a tiny difference remaining + if (sum < 100) { + final int difference = 100 - sum; + temp.put(unassigned.get(0), perUnassigned + difference); + sum = 100; + } + } else if (!unassigned.isEmpty()) { + C.BUCKET_ENTRIES_IGNORED.send(ConsolePlayer.getConsole()); + } + // + // If the sum adds up to more than 100, divide all values + // + if (sum > 100) { + final double ratio = 100D / sum; + for (final Map.Entry entry : blocks.entrySet()) { + if (entry.getValue() == -1) { + continue; + } + temp.put(entry.getKey(), (int) (entry.getValue() * ratio)); + } + } else { + temp.forEach(temp::put); + } + int start = 0; + for (final Map.Entry entry : temp.entrySet()) { + final int rangeStart = start; + final int rangeEnd = rangeStart + entry.getValue(); + start = rangeEnd + 1; + final Range range = + new Range(rangeStart, rangeEnd, unassigned.contains(entry.getKey())); + this.ranges.put(range, entry.getKey()); + } + this.blocks.clear(); + this.compiled = true; + } + + @Override public Iterator iterator() { + return this.bucketIterator; + } + + public boolean isCompiled() { + return this.compiled; + } + + /** + * Get a random block out of the bucket + * + * @return Randomly picked block (cased on specified rates) + */ + public PlotBlock getBlock() { + if (!isCompiled()) { + this.compile(); + } + if (this.isEmpty()) { + return StringPlotBlock.EVERYTHING; + } + final int number = random.nextInt(101); + for (final Map.Entry entry : ranges.entrySet()) { + if (entry.getKey().isInRange(number)) { + return entry.getValue(); + } + } + // Didn't find a block? Try again + return getBlock(); + } + + @Override public String toString() { + final StringBuilder builder = new StringBuilder(); + final Iterator> iterator = this.ranges.entrySet().iterator(); + while (iterator.hasNext()) { + final Entry entry = iterator.next(); + builder.append(entry.getValue().getRawId()); + if (!entry.getKey().isAutomatic()) { + builder.append(":").append(entry.getKey().getWeight()); + } + if (iterator.hasNext()) { + builder.append(","); + } + } + return builder.toString(); + } + + @Override public Map serialize() { + return ImmutableMap.of("blocks", this.toString()); + } + + + @Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range { + + private final int min; + private final int max; + @Getter private final boolean automatic; + + public int getWeight() { + return max - min; + } + + public boolean isInRange(final int num) { + return num <= max && num >= min; + } + } + + + private final class BucketIterator implements Iterator { + + @Override public boolean hasNext() { + return true; + } + + @Override public PlotBlock next() { + return getBlock(); + } } - } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockRegistry.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockRegistry.java index 49c6ab0b4..e125ca188 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockRegistry.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockRegistry.java @@ -1,34 +1,34 @@ package com.github.intellectualsites.plotsquared.plot.object; -import java.util.HashMap; -import java.util.Map; import lombok.Getter; import lombok.NonNull; +import java.util.HashMap; +import java.util.Map; + public abstract class BlockRegistry { - @Getter - private final Class type; - private final Map map = new HashMap<>(); + @Getter private final Class type; + private final Map map = new HashMap<>(); - public BlockRegistry(@NonNull final Class type, final T... preInitializedItems) { - this.type = type; - for (final T preInitializedItem : preInitializedItems) { - this.addMapping(getPlotBlock(preInitializedItem), preInitializedItem); + public BlockRegistry(@NonNull final Class type, final T... preInitializedItems) { + this.type = type; + for (final T preInitializedItem : preInitializedItems) { + this.addMapping(getPlotBlock(preInitializedItem), preInitializedItem); + } } - } - public final void addMapping(@NonNull final PlotBlock plotBlock, @NonNull final T t) { - if (map.containsKey(plotBlock)) { - return; + public final void addMapping(@NonNull final PlotBlock plotBlock, @NonNull final T t) { + if (map.containsKey(plotBlock)) { + return; + } + this.map.put(plotBlock, t); } - this.map.put(plotBlock, t); - } - public abstract PlotBlock getPlotBlock(final T item); + public abstract PlotBlock getPlotBlock(final T item); - public final T getItem(final PlotBlock plotBlock) { - return this.map.get(plotBlock); - } + public final T getItem(final PlotBlock plotBlock) { + return this.map.get(plotBlock); + } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/LegacyPlotBlock.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/LegacyPlotBlock.java index b90995ddc..be551b372 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/LegacyPlotBlock.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/LegacyPlotBlock.java @@ -15,10 +15,8 @@ public class LegacyPlotBlock extends PlotBlock { } } - @Getter - public final short id; - @Getter - public final byte data; + @Getter public final short id; + @Getter public final byte data; public LegacyPlotBlock(short id, byte data) { this.id = id; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotItemStack.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotItemStack.java index e3dacc689..05f427ff7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotItemStack.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotItemStack.java @@ -5,13 +5,12 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import lombok.Getter; public class PlotItemStack { - // public final int id; - // public final short data; - @Getter - private final PlotBlock plotBlock; public final int amount; public final String name; public final String[] lore; + // public final int id; + // public final short data; + @Getter private final PlotBlock plotBlock; @Deprecated public PlotItemStack(final int id, final short data, final int amount, final String name, diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index bc34ac2ec..23224c74c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -12,46 +12,41 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAre import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; +import lombok.NonNull; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import lombok.NonNull; /** * The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}. */ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { - public interface PlotPlayerConverter { - PlotPlayer convert(BaseObject object); - } + public static final String META_LAST_PLOT = "lastplot"; + public static final String META_LOCATION = "location"; private static final Map converters = new HashMap<>(); + private Map metaMap = new HashMap<>(); + /** + * The metadata map. + */ + private ConcurrentHashMap meta; public static PlotPlayer from(@NonNull final T object) { if (!converters.containsKey(object.getClass())) { - throw new IllegalArgumentException( - String.format("There is no registered PlotPlayer converter for type %s", + throw new IllegalArgumentException(String + .format("There is no registered PlotPlayer converter for type %s", object.getClass().getSimpleName())); } return converters.get(object.getClass()).convert(object); } - public static void registerConverter(@NonNull final Class clazz, final PlotPlayerConverter converter) { + public static void registerConverter(@NonNull final Class clazz, + final PlotPlayerConverter converter) { converters.put(clazz, converter); } - public static final String META_LAST_PLOT = "lastplot"; - public static final String META_LOCATION = "location"; - - private Map metaMap = new HashMap<>(); - - /** - * The metadata map. - */ - private ConcurrentHashMap meta; - /** * Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)
* - Accepts sponge/bukkit Player (online) @@ -304,10 +299,6 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { return RequiredType.PLAYER; } - /////////////// PLAYER META /////////////// - - ////////////// PARTIALLY IMPLEMENTED /////////// - /** * Get this player's last recorded location or null if they don't any plot relevant location. * @@ -321,7 +312,9 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { return getLocationFull(); } - //////////////////////////////////////////////// + /////////////// PLAYER META /////////////// + + ////////////// PARTIALLY IMPLEMENTED /////////// /** * Get this player's full location (including yaw/pitch) @@ -330,6 +323,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { */ public abstract Location getLocationFull(); + //////////////////////////////////////////////// + /** * Get this player's UUID. * === !IMPORTANT ===
@@ -376,7 +371,6 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { setPersistentMeta("attrib_" + key, new byte[] {(byte) 1}); } - /** * Retrieves the attribute of this player. * @@ -666,4 +660,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { EconHandler.manager.depositMoney(this, amount); } } + + public interface PlotPlayerConverter { + PlotPlayer convert(BaseObject object); + } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java index 2703dc6f1..6a2796f2b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/StringPlotBlock.java @@ -17,6 +17,7 @@ public class StringPlotBlock extends PlotBlock { @Getter private final String itemId; @Getter @Setter private BaseBlock baseBlock = null; private boolean isForeign = false; + public StringPlotBlock(@NonNull final String nameSpace, @NonNull final String itemId) { this.nameSpace = nameSpace.toLowerCase(Locale.ENGLISH); this.itemId = itemId.toLowerCase(Locale.ENGLISH); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java index c62b226d4..fa543b21a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java @@ -10,8 +10,7 @@ import lombok.experimental.UtilityClass; /** * Entity related general utility methods */ -@UtilityClass -public final class EntityUtil { +@UtilityClass public final class EntityUtil { private static int capNumeral(@NonNull final String flagName) { int i; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index 16ce6a42c..45052042a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -134,14 +134,16 @@ public abstract class EventUtil { Optional> use = plot.getFlag(Flags.USE); if (use.isPresent()) { HashSet value = use.get(); - if (PlotBlock.containsEverything(value) || value.contains(block.getPlotBlock())) { + if (PlotBlock.containsEverything(value) || value + .contains(block.getPlotBlock())) { return true; } } Optional> destroy = plot.getFlag(Flags.BREAK); if (destroy.isPresent()) { HashSet value = destroy.get(); - if (PlotBlock.containsEverything(value) || value.contains(block.getPlotBlock())) { + if (PlotBlock.containsEverything(value) || value + .contains(block.getPlotBlock())) { return true; } }