From 1e02560039b2833185a71805009016240007f825 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Fri, 21 Jun 2019 19:58:40 -0400 Subject: [PATCH] Remove BukkitMask --- .../voxelsniper/VoxelSniperListener.java | 10 ++------ .../com/boydti/fawe/bukkit/BukkitCommand.java | 3 ++- .../com/boydti/fawe/bukkit/FaweBukkit.java | 8 +++--- .../adapter/v1_13_1/BlockMaterial_1_13.java | 10 +++++--- .../bukkit/filter/GriefPreventionFilter.java | 7 +++--- .../fawe/bukkit/regions/ASkyBlockHook.java | 14 +++-------- .../fawe/bukkit/regions/BukkitMask.java | 17 ------------- .../fawe/bukkit/regions/FactionsFeature.java | 18 ++++--------- .../bukkit/regions/FactionsOneFeature.java | 25 ++++++++----------- .../bukkit/regions/FactionsUUIDFeature.java | 14 ++++------- .../fawe/bukkit/regions/FreeBuildRegion.java | 15 ++++------- .../regions/GriefPreventionFeature.java | 18 ++++--------- .../bukkit/regions/PreciousStonesFeature.java | 2 +- .../fawe/bukkit/regions/ResidenceFeature.java | 13 ++++------ .../fawe/bukkit/regions/TownyFeature.java | 11 +++----- .../fawe/bukkit/regions/Worldguard.java | 24 ++++++++---------- .../src/main/java/com/boydti/fawe/Fawe.java | 20 --------------- .../com/boydti/fawe/regions/FaweMask.java | 20 +++------------ .../general/plot/PlotSquaredFeature.java | 2 +- .../worldedit/regions/IDelegateRegion.java | 10 ++++---- .../com/sk89q/worldedit/regions/Region.java | 22 ++++++---------- 21 files changed, 88 insertions(+), 195 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java index 3beaf5384..1d0eae2d9 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java @@ -115,9 +115,6 @@ public class VoxelSniperListener implements Listener { } } - /** - * @param event - */ @EventHandler(ignoreCancelled = false) public final void onPlayerInteract(final PlayerInteractEvent event) { Player player = event.getPlayer(); @@ -131,14 +128,11 @@ public class VoxelSniperListener implements Listener { if (sniper.isEnabled() && sniper.snipe(event.getAction(), event.getMaterial(), event.getClickedBlock(), event.getBlockFace())) { event.setCancelled(true); } - } catch (final Throwable ignored) { - ignored.printStackTrace(); + } catch (final Throwable throwable) { + throwable.printStackTrace(); } } - /** - * @param event - */ @EventHandler public final void onPlayerJoin(final PlayerJoinEvent event) { Player player = event.getPlayer(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java index 083fe3304..7904a62f7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.FawePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class BukkitCommand implements CommandExecutor { @@ -17,7 +18,7 @@ public class BukkitCommand implements CommandExecutor { } @Override - public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { + public boolean onCommand(@NotNull final CommandSender sender, final Command cmd, final String label, final String[] args) { final FawePlayer plr = Fawe.imp().wrap(sender); if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) { BBC.NO_PERM.send(plr, this.cmd.getPerm()); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 3b2624887..86ccdea01 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -73,8 +73,6 @@ public class FaweBukkit implements IFawe, Listener { private BukkitImageListener imageListener; //private CFIPacketListener packetListener; - //private boolean listeningCui; - //private CUIListener cuiListener; public VaultUtil getVault() { return this.vault; @@ -436,7 +434,7 @@ public class FaweBukkit implements IFawe, Listener { Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); } catch (Throwable e2) { try { - managers.add(new FactionsOneFeature(factionsPlugin, this)); + managers.add(new FactionsOneFeature(factionsPlugin)); Fawe.debug("Plugin 'FactionsUUID' found. Using it now."); } catch (Throwable e3) { MainUtil.handleError(e); @@ -457,7 +455,7 @@ public class FaweBukkit implements IFawe, Listener { final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention"); if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) { try { - managers.add(new GriefPreventionFeature(griefpreventionPlugin, this)); + managers.add(new GriefPreventionFeature(griefpreventionPlugin)); Fawe.debug("Plugin 'GriefPrevention' found. Using it now."); } catch (final Throwable e) { MainUtil.handleError(e); @@ -477,7 +475,7 @@ public class FaweBukkit implements IFawe, Listener { final Plugin aSkyBlock = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock"); if ((aSkyBlock != null) && aSkyBlock.isEnabled()) { try { - managers.add(new ASkyBlockHook(aSkyBlock, this)); + managers.add(new ASkyBlockHook(aSkyBlock)); Fawe.debug("Plugin 'ASkyBlock' found. Using it now."); } catch (final Throwable e) { MainUtil.handleError(e); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java index 53a59d24d..0711a6961 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/BlockMaterial_1_13.java @@ -1,9 +1,11 @@ package com.boydti.fawe.bukkit.adapter.v1_13_1; -import com.sk89q.util.ReflectionUtil; import com.sk89q.worldedit.world.registry.BlockMaterial; - -import net.minecraft.server.v1_13_R2.*; +import net.minecraft.server.v1_13_R2.Block; +import net.minecraft.server.v1_13_R2.EnumPistonReaction; +import net.minecraft.server.v1_13_R2.IBlockData; +import net.minecraft.server.v1_13_R2.ITileEntity; +import net.minecraft.server.v1_13_R2.Material; import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData; public class BlockMaterial_1_13 implements BlockMaterial { @@ -22,7 +24,7 @@ public class BlockMaterial_1_13 implements BlockMaterial { this.defaultState = defaultState; this.material = defaultState.getMaterial(); this.craftBlockData = CraftBlockData.fromData(defaultState); - this.isTranslucent = ReflectionUtil.getField(Block.class, block, "n"); + this.isTranslucent = block.f(defaultState); //isSolid } public Block getBlock() { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java index 1f49830de..30de5ffa0 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/filter/GriefPreventionFilter.java @@ -4,13 +4,12 @@ import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.regions.general.CuboidRegionFilter; import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.math.BlockVector2; - -import java.util.ArrayDeque; -import java.util.Collection; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.bukkit.World; +import java.util.ArrayDeque; +import java.util.Collection; import static com.google.common.base.Preconditions.checkNotNull; @@ -23,7 +22,7 @@ public class GriefPreventionFilter extends CuboidRegionFilter { this.claims = TaskManager.IMP.sync(new RunnableVal>() { @Override public void run(Collection claims) { - this.value = new ArrayDeque(GriefPrevention.instance.dataStore.getClaims()); + this.value = new ArrayDeque<>(GriefPrevention.instance.dataStore.getClaims()); } }); this.world = world; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java index c875f6812..2c1a58fcd 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ASkyBlockHook.java @@ -1,8 +1,8 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.wasteofplastic.askyblock.ASkyBlockAPI; import com.wasteofplastic.askyblock.Island; import org.bukkit.Location; @@ -12,13 +12,9 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class ASkyBlockHook extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin aSkyBlock; - public ASkyBlockHook(final Plugin aSkyBlock, final FaweBukkit p3) { + public ASkyBlockHook(final Plugin aSkyBlock) { super(aSkyBlock.getName()); - this.aSkyBlock = aSkyBlock; - this.plugin = p3; } @@ -33,8 +29,6 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { Island island = ASkyBlockAPI.getInstance().getIslandAt(location); if (island != null && isAllowed(player, island, type)) { - int minX = island.getMinProtectedX(); - int minZ = island.getMinProtectedZ(); World world = location.getWorld(); Location center = island.getCenter(); @@ -42,7 +36,7 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { Location pos2 = center.add(center.subtract(pos1)); pos2.setY(255); - return new BukkitMask(pos1, pos2, "ISLAND: " + minX + "," + minZ) { + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, island, type); @@ -52,4 +46,4 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { return null; } -} \ No newline at end of file +} diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java deleted file mode 100644 index 54e9f0bc9..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMask.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.boydti.fawe.bukkit.regions; - -import com.boydti.fawe.regions.FaweMask; -import com.sk89q.worldedit.math.BlockVector3; - -import org.bukkit.Location; - -public class BukkitMask extends FaweMask { - - public BukkitMask(Location pos1, Location pos2) { - this(pos1, pos2, null); - } - - public BukkitMask(Location pos1, Location pos2, String name) { - super(BlockVector3.at(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), BlockVector3.at(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name); - } -} \ No newline at end of file diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java index 64e5743f6..723a6a838 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsFeature.java @@ -1,10 +1,12 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.ps.PS; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -18,7 +20,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Location loc = player.getLocation(); final PS ps = PS.valueOf(loc); @@ -30,24 +32,14 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { final Chunk chunk = loc.getChunk(); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } } else if (fac.getOnlinePlayers().contains(player)) { if (!fac.getComparisonName().equals("wilderness")) { final Chunk chunk = loc.getChunk(); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + loc.getChunk().getX() + "," + loc.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java index 4eab92792..9be63b4d2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsOneFeature.java @@ -1,13 +1,12 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.Perm; import com.massivecraft.factions.FLocation; -import java.lang.reflect.Method; -import java.util.List; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -15,19 +14,21 @@ import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; +import java.lang.reflect.Method; +import java.util.List; + public class FactionsOneFeature extends BukkitMaskManager implements Listener { - private final Class clazzBoard; private final Method methodGetFactionAt; - public FactionsOneFeature(final Plugin factionsPlugin, final FaweBukkit p3) throws Throwable { + public FactionsOneFeature(final Plugin factionsPlugin) throws Throwable { super(factionsPlugin.getName()); - this.clazzBoard = Class.forName("com.massivecraft.factions.Board"); + Class clazzBoard = Class.forName("com.massivecraft.factions.Board"); this.methodGetFactionAt = clazzBoard.getDeclaredMethod("getFactionAt", FLocation.class); } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); @@ -40,13 +41,12 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { if (this.isAdded(locs, world, player, perm, type)) { boolean hasPerm = true; - RegionWrapper chunkSelection; while (hasPerm && (count > 0)) { count--; hasPerm = false; - chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); + RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); if (this.isAdded(chunkSelection, world, player, perm, type)) { locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ); @@ -77,12 +77,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } return null; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java index 29451faa5..12f10ae66 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FactionsUUIDFeature.java @@ -3,10 +3,12 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.Perm; import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -23,7 +25,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Chunk chunk = player.getLocation().getChunk(); final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); @@ -36,13 +38,12 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { if (this.isAdded(locs, world, player, perm, type)) { boolean hasPerm = true; - RegionWrapper chunkSelection; while (hasPerm && (count > 0)) { count--; hasPerm = false; - chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); + RegionWrapper chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ); if (this.isAdded(chunkSelection, world, player, perm, type)) { locs = new RegionWrapper(locs.minX, locs.maxX + 1, locs.minZ, locs.maxZ); @@ -73,12 +74,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4); final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4)); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CHUNK:" + pos1.getChunk().getX() + "," + pos1.getChunk().getZ(); - } - }; + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()); } return null; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java index e1aa7bbc9..b559ef377 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/FreeBuildRegion.java @@ -50,33 +50,28 @@ public class FreeBuildRegion extends BukkitMaskManager { currRegList.add(listener); } if (currRegList.isEmpty()) return null; - RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[currRegList.size()]); + RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); World bukkitWorld = player.parent.getWorld(); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); BlockVector3 vec1 = BlockVector3.at(0, 0, 0); - BlockVector3 vec2 = vec1; Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1); - Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2); + Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec1); AsyncBlock block = new AsyncBlock(asyncWorld, new NullFaweQueue(asyncWorld.getWorldName(), BlockTypes.STONE.getDefaultState()), 0, 0, 0); BlockBreakEvent event = new BlockBreakEvent(block, player.parent); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "freebuild-global"; - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { - @Override + @Override public boolean isValid(FawePlayer player, MaskType type) { return bukkitWorld == ((FawePlayer)player).parent.getWorld() && type == MaskType.MEMBER; } @Override public Region getRegion() { - return new CuboidRegion(vec1, vec2) { + return new CuboidRegion(vec1, vec1) { @Override public boolean contains(int x, int z) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java index 8832ec90b..6b987df14 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/GriefPreventionFeature.java @@ -1,9 +1,10 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.GriefPreventionFilter; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import org.bukkit.Bukkit; @@ -14,13 +15,9 @@ import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; public class GriefPreventionFeature extends BukkitMaskManager implements Listener { - FaweBukkit plugin; - Plugin griefprevention; - public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) { + public GriefPreventionFeature(final Plugin griefpreventionPlugin) { super(griefpreventionPlugin.getName()); - this.griefprevention = griefpreventionPlugin; - this.plugin = p3; } public boolean isAllowed(Player player, Claim claim, MaskType type) { @@ -28,21 +25,16 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene } @Override - public BukkitMask getMask(final FawePlayer fp, MaskType type) { + public FaweMask getMask(final FawePlayer fp, MaskType type) { final Player player = fp.parent; final Location location = player.getLocation(); final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null); if (claim != null) { - final String uuid = player.getUniqueId().toString(); if (isAllowed(player, claim, type)) { claim.getGreaterBoundaryCorner().getBlockX(); final Location pos1 = new Location(location.getWorld(), claim.getLesserBoundaryCorner().getBlockX(), 0, claim.getLesserBoundaryCorner().getBlockZ()); final Location pos2 = new Location(location.getWorld(), claim.getGreaterBoundaryCorner().getBlockX(), 256, claim.getGreaterBoundaryCorner().getBlockZ()); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "CLAIM:" + claim.toString(); - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java index 7b0af05b5..d67f9a919 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/PreciousStonesFeature.java @@ -43,7 +43,7 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener if (isAllowed(player, myField, type, member)) { BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz()); BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); - return new FaweMask(pos1, pos2, "FIELD: " + myField) { + return new FaweMask(pos1, pos2) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, myField, type, fp.hasPermission("fawe.preciousstones.member")); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java index 024fa92f2..398be6d63 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/ResidenceFeature.java @@ -5,6 +5,8 @@ import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.bekvon.bukkit.residence.protection.CuboidArea; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -26,7 +28,7 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp, final MaskType type) { + public FaweMask getMask(final FawePlayer fp, final MaskType type) { final Player player = fp.parent; final Location location = player.getLocation(); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); @@ -40,13 +42,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { final Location pos1 = area.getLowLoc(); final Location pos2 = area.getHighLoc(); final ClaimedResidence finalResidence = residence; - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "RESIDENCE: " + finalResidence.getName(); - } - - @Override + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { + @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, finalResidence, type); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java index 587dda379..06a4476d1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/TownyFeature.java @@ -2,9 +2,11 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.regions.FaweMask; import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; import com.palmergames.bukkit.towny.object.*; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -53,7 +55,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener { } @Override - public BukkitMask getMask(final FawePlayer fp) { + public FaweMask getMask(final FawePlayer fp) { final Player player = fp.parent; final Location location = player.getLocation(); try { @@ -71,12 +73,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener { final Chunk chunk = location.getChunk(); final Location pos1 = new Location(location.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos2 = new Location(location.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return "PLOT:" + location.getChunk().getX() + "," + location.getChunk().getZ(); - } - + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed((Player) player.parent, myplot); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java index 44ec28ac3..21e56280b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/Worldguard.java @@ -1,14 +1,13 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.FaweAPI; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.general.RegionFilter; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Polygonal2DRegion; @@ -18,7 +17,11 @@ import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.*; +import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion; +import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; +import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; +import com.sk89q.worldguard.protection.regions.RegionContainer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -52,7 +55,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { System.out.println("Region capability is not enabled for WorldGuard."); return null; } - RegionManager manager = container.get(FaweAPI.getWorld(location.getWorld().getName())); + RegionManager manager = container.get(BukkitAdapter.adapt(location.getWorld())); if (manager == null) { System.out.println("Region capability is not enabled for that world."); return null; @@ -107,7 +110,7 @@ public class Worldguard extends BukkitMaskManager implements Listener { pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ()); pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ()); } else { - return new FaweMask(adapt(myregion), myregion.getId()) { + return new FaweMask(adapt(myregion)) { @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); @@ -115,20 +118,15 @@ public class Worldguard extends BukkitMaskManager implements Listener { }; } } - return new BukkitMask(pos1, pos2) { - @Override - public String getName() { - return myregion.getId(); - } + return new FaweMask(BukkitAdapter.adapt(pos1).toBlockPoint(), BukkitAdapter.adapt(pos2).toBlockPoint()) { - @Override + @Override public boolean isValid(FawePlayer player, MaskType type) { return isAllowed(worldguard.wrapPlayer((Player) player.parent), myregion); } }; - } else { - return null; } + return null; } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 9d45e33ea..05a500c90 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -166,21 +166,6 @@ public class Fawe { this.timer = new FaweTimer(); Fawe.this.IMP.setupVault(); - File jar = MainUtil.getJarFile(); - // TODO FIXME remove extrablocks.json -// File extraBlocks = MainUtil.copyFile(jar, "extrablocks.json", null); -// if (extraBlocks != null && extraBlocks.exists()) { -// TaskManager.IMP.task(() -> { -// try { -// BundledBlockData.getInstance().loadFromResource(); -// BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), true); -// } catch (Throwable ignore) { -// ignore.printStackTrace(); -// Fawe.debug("Invalid format: extrablocks.json"); -// } -// }); -// } - // Delayed worldedit setup TaskManager.IMP.later(() -> { try { @@ -207,11 +192,6 @@ public class Fawe { this.chatManager = chatManager; } - // @Deprecated -// public boolean isJava8() { -// return isJava8; -// } - public DefaultTransformParser getTransformParser() { return transformParser; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java index 2714da0db..2b06d47c8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/FaweMask.java @@ -8,24 +8,14 @@ import com.sk89q.worldedit.regions.Region; public class FaweMask implements IDelegateRegion { private final Region region; - private String description = null; - - @Deprecated - public FaweMask(final BlockVector3 pos1, final BlockVector3 pos2, final String id) { - this(new CuboidRegion(pos1, pos2), id); - } @Deprecated public FaweMask(final BlockVector3 pos1, final BlockVector3 pos2) { - this(pos1, pos2, null); - if ((pos1 == null) || (pos2 == null)) { - throw new IllegalArgumentException("BlockVectors cannot be null!"); - } + this(new CuboidRegion(pos1, pos2)); } - public FaweMask(Region region, String id) { + public FaweMask(Region region) { this.region = region; - this.description = id; } @Override @@ -33,10 +23,6 @@ public class FaweMask implements IDelegateRegion { return region; } - public String getName() { - return this.description; - } - public boolean isValid(FawePlayer player, FaweMaskManager.MaskType type) { return false; } @@ -45,4 +31,4 @@ public class FaweMask implements IDelegateRegion { public Region clone() { throw new UnsupportedOperationException("Clone not supported"); } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java index 955d45c82..713bd9849 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSquaredFeature.java @@ -149,7 +149,7 @@ public class PlotSquaredFeature extends FaweMaskManager { }; } - return new FaweMask(maskedRegion, "PLOT^2") { + return new FaweMask(maskedRegion) { @Override public boolean isValid(FawePlayer player, MaskType type) { if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java index be3c64e82..ad08dbaba 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/IDelegateRegion.java @@ -1,21 +1,21 @@ package com.sk89q.worldedit.regions; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; import java.util.Iterator; import java.util.List; import java.util.Set; -import javax.annotation.Nullable; public interface IDelegateRegion extends Region { - public Region getRegion(); + Region getRegion(); - @Override + @NotNull @Override default Iterator iterator() { return getRegion().iterator(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 8c4c75a48..4076c6cd0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -61,28 +61,28 @@ public interface Region extends Iterable, Cloneable { * * @return number of blocks */ - public int getArea(); + int getArea(); /** * Get X-size. * * @return width */ - public int getWidth(); + int getWidth(); /** * Get Y-size. * * @return height */ - public int getHeight(); + int getHeight(); /** * Get Z-size. * * @return length */ - public int getLength(); + int getLength(); /** * Expand the region. @@ -121,12 +121,7 @@ public interface Region extends Iterable, Cloneable { BlockVector3 pos2 = getMaximumPoint(); return pos1.getBlockX() == Integer.MIN_VALUE && pos1.getBlockZ() == Integer.MIN_VALUE && pos2.getBlockX() == Integer.MAX_VALUE && pos2.getBlockZ() == Integer.MAX_VALUE && pos1.getBlockY() <= 0 && pos2.getBlockY() >= 255; } - /** - * Returns true based on whether the region contains the point. - * - * @param position the position - * @return true if contained - */ + /** * Returns true based on whether the region contains the point. * @@ -154,22 +149,21 @@ public interface Region extends Iterable, Cloneable { * * @return the world, or null */ - @Nullable - public World getWorld(); + @Nullable World getWorld(); /** * Sets the world that the selection is in. * * @param world the world, which may be null */ - public void setWorld(@Nullable World world); + void setWorld(@Nullable World world); /** * Make a clone of the region. * * @return a cloned version */ - public Region clone(); + Region clone(); /** * Polygonizes a cross-section or a 2D projection of the region orthogonal to the Y axis.