From 14ed3f1d9c51bd8a39aac26acb4c009f18377bc5 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Fri, 13 Sep 2019 23:05:16 -0400 Subject: [PATCH] Remove FawePlayer and API modifications --- .../com/boydti/fawe/bukkit/BukkitCommand.java | 31 +- .../com/boydti/fawe/bukkit/BukkitPlayer.java | 74 -- .../com/boydti/fawe/bukkit/FaweBukkit.java | 79 +-- .../fawe/bukkit/listener/BrushListener.java | 18 +- .../bukkit/listener/BukkitImageListener.java | 26 +- .../bukkit/listener/CFIPacketListener.java | 22 +- .../fawe/bukkit/regions/ASkyBlockHook.java | 12 +- .../bukkit/regions/BukkitMaskManager.java | 2 +- .../fawe/bukkit/regions/FactionsFeature.java | 7 +- .../bukkit/regions/FactionsOneFeature.java | 8 +- .../bukkit/regions/FactionsUUIDFeature.java | 9 +- .../fawe/bukkit/regions/FreeBuildRegion.java | 15 +- .../regions/GriefPreventionFeature.java | 7 +- .../bukkit/regions/PreciousStonesFeature.java | 13 +- .../fawe/bukkit/regions/ResidenceFeature.java | 9 +- .../fawe/bukkit/regions/TownyFeature.java | 44 +- .../fawe/bukkit/regions/Worldguard.java | 13 +- .../fawe/bukkit/regions/WorldguardFlag.java | 7 +- .../bukkit/BukkitBlockCommandSender.java | 22 +- .../worldedit/bukkit/BukkitCommandSender.java | 29 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 9 + .../sk89q/worldedit/bukkit/BukkitWorld.java | 1 - .../worldedit/bukkit/WorldEditListener.java | 30 +- .../worldedit/bukkit/WorldEditPlugin.java | 120 ++-- .../bukkit/{MetricsLite.java => Metrics.java} | 10 +- .../src/main/java/com/boydti/fawe/Fawe.java | 33 +- .../main/java/com/boydti/fawe/FaweAPI.java | 29 +- .../src/main/java/com/boydti/fawe/IFawe.java | 7 +- .../com/boydti/fawe/command/CFICommand.java | 29 +- .../com/boydti/fawe/command/CFICommands.java | 267 ++++---- .../com/boydti/fawe/command/PlotLoader.java | 10 +- .../com/boydti/fawe/command/Rollback.java | 47 +- .../main/java/com/boydti/fawe/config/BBC.java | 11 - .../java/com/boydti/fawe/config/Settings.java | 11 +- .../boydti/fawe/logging/LoggingChangeSet.java | 11 +- .../com/boydti/fawe/object/FaweCommand.java | 6 +- .../com/boydti/fawe/object/FawePlayer.java | 643 ------------------ .../fawe/object/brush/CatenaryBrush.java | 5 +- .../boydti/fawe/object/brush/CircleBrush.java | 5 +- .../fawe/object/brush/CommandBrush.java | 12 +- .../fawe/object/brush/CopyPastaBrush.java | 5 +- .../boydti/fawe/object/brush/ImageBrush.java | 4 +- .../fawe/object/brush/InspectBrush.java | 9 +- .../fawe/object/brush/ScatterCommand.java | 13 +- .../fawe/object/brush/StencilBrush.java | 6 +- .../fawe/object/brush/SurfaceSpline.java | 4 +- .../fawe/object/brush/sweep/SweepBrush.java | 4 +- .../brush/visualization/VirtualWorld.java | 3 +- .../brush/visualization/VisualExtent.java | 12 +- .../brush/visualization/VisualQueue.java | 12 +- .../cfi/HeightMapMCAGenerator.java | 18 +- .../changeset/AbstractDelegateChangeSet.java | 14 +- .../object/changeset/DiskStorageHistory.java | 10 +- .../fawe/object/changeset/FaweChangeSet.java | 6 +- .../object/extent/MemoryCheckingExtent.java | 14 +- .../fawe/object/pattern/BufferedPattern.java | 10 +- .../object/pattern/BufferedPattern2D.java | 4 +- .../object/progress/ChatProgressTracker.java | 6 +- .../progress/DefaultProgressTracker.java | 8 +- .../regions/selector/FuzzyRegionSelector.java | 6 +- .../task/SingleThreadIntervalQueue.java | 3 +- .../com/boydti/fawe/regions/FaweMask.java | 4 +- .../boydti/fawe/regions/FaweMaskManager.java | 14 +- .../regions/general/RedProtectFeature.java | 16 - .../regions/general/plot/PlotSetBiome.java | 4 +- .../general/plot/PlotSquaredFeature.java | 14 +- .../boydti/fawe/util/EditSessionBuilder.java | 16 +- .../java/com/boydti/fawe/util/MainUtil.java | 16 +- .../java/com/boydti/fawe/util/WEManager.java | 14 +- .../wrappers/LocationMaskedPlayerWrapper.java | 41 -- .../boydti/fawe/wrappers/PlayerWrapper.java | 424 ------------ .../fawe/wrappers/SilentPlayerWrapper.java | 24 - .../main/java/com/sk89q/jnbt/CompoundTag.java | 38 +- .../java/com/sk89q/worldedit/EditSession.java | 196 +++--- .../com/sk89q/worldedit/LocalSession.java | 27 +- .../worldedit/command/BiomeCommands.java | 2 +- .../worldedit/command/BrushCommands.java | 5 +- .../worldedit/command/ClipboardCommands.java | 17 +- .../worldedit/command/GenerationCommands.java | 35 +- .../worldedit/command/HistoryCommands.java | 15 +- .../worldedit/command/PatternCommands.java | 47 +- .../worldedit/command/RegionCommands.java | 76 +-- .../worldedit/command/SchematicCommands.java | 52 +- .../worldedit/command/ScriptingCommands.java | 27 +- .../worldedit/command/UtilityCommands.java | 12 +- .../worldedit/command/WorldEditCommands.java | 5 +- .../worldedit/command/tool/BrushTool.java | 15 +- .../command/tool/FloatingTreeRemover.java | 2 +- .../command/tool/brush/GravityBrush.java | 24 +- .../command/util/PrintCommandHelp.java | 32 +- .../sk89q/worldedit/entity/Metadatable.java | 53 ++ .../com/sk89q/worldedit/entity/Player.java | 203 +++++- .../parser/mask/ExpressionMaskParser.java | 3 +- .../platform/AbstractNonPlayerActor.java | 100 +++ .../platform/AbstractPlayerActor.java | 256 ++++++- .../worldedit/extension/platform/Actor.java | 5 +- .../platform/PlatformCommandManager.java | 58 +- .../extension/platform/PlatformManager.java | 49 +- .../platform/binding/ProvideBindings.java | 22 +- .../function/mask/ExpressionMask.java | 14 +- .../function/mask/ExpressionMask2D.java | 16 +- .../internal/expression/Expression.java | 5 - .../formatting/component/CommandListBox.java | 8 +- .../formatting/component/CommandUsageBox.java | 27 +- .../component/SchematicPaginationBox.java | 74 -- 105 files changed, 1614 insertions(+), 2407 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java rename worldedit-bukkit/src/main/java/org/bstats/bukkit/{MetricsLite.java => Metrics.java} (97%) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/FawePlayer.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/regions/general/RedProtectFeature.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/wrappers/LocationMaskedPlayerWrapper.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/wrappers/SilentPlayerWrapper.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/entity/Metadatable.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/SchematicPaginationBox.java 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 ed7490872..13094b551 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 @@ -1,12 +1,17 @@ package com.boydti.fawe.bukkit; -import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FawePlayer; +import com.sk89q.worldedit.bukkit.BukkitBlockCommandSender; +import com.sk89q.worldedit.bukkit.BukkitCommandSender; +import com.sk89q.worldedit.bukkit.BukkitPlayer; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extension.platform.Actor; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class BukkitCommand implements CommandExecutor { @@ -19,7 +24,7 @@ public class BukkitCommand implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, Command cmd, String label, String[] args) { - final FawePlayer plr = Fawe.imp().wrap(sender); + final Actor plr = wrapCommandSender(sender); if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) { BBC.NO_PERM.send(plr, this.cmd.getPerm()); return true; @@ -27,4 +32,24 @@ public class BukkitCommand implements CommandExecutor { this.cmd.executeSafe(plr, args); return true; } + + /** + * Used to wrap a Bukkit Player as a WorldEdit Player. + * + * @param player a player + * @return a wrapped player + */ + public com.sk89q.worldedit.bukkit.BukkitPlayer wrapPlayer(Player player) { + return new BukkitPlayer(WorldEditPlugin.getInstance(), player); + } + + public Actor wrapCommandSender(CommandSender sender) { + if (sender instanceof Player) { + return wrapPlayer((Player) sender); + } else if (sender instanceof BlockCommandSender) { + return new BukkitBlockCommandSender(WorldEditPlugin.getInstance(), (BlockCommandSender) sender); + } + + return new BukkitCommandSender(WorldEditPlugin.getInstance(), sender); + } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java deleted file mode 100644 index 2c811f70c..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.boydti.fawe.bukkit; - -import com.boydti.fawe.object.FawePlayer; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; - -public class BukkitPlayer extends FawePlayer { - - private static ConsoleCommandSender console; - - public BukkitPlayer(final Player parent) { - super(parent); - } - - @Override - public String getName() { - return this.parent.getName(); - } - - @Override - public UUID getUUID() { - return this.parent.getUniqueId(); - } - - @Override - public boolean hasPermission(final String perm) { - return this.parent.hasPermission(perm); - } - - @Override - public boolean isSneaking() { - return parent.isSneaking(); - } - - @Override - public void resetTitle() { - parent.resetTitle(); - } - - public void sendTitle(String title, String sub) { - parent.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); - if (console == null) { - console = Bukkit.getConsoleSender(); - Bukkit.getServer().dispatchCommand(console, "gamerule sendCommandFeedback false"); - Bukkit.getServer().dispatchCommand(console, "title " + getName() + " times 0 60 20"); - } - Bukkit.getServer().dispatchCommand(console, "title " + getName() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]"); - Bukkit.getServer().dispatchCommand(console, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); - } - - @Override - public void sendMessage(final String message) { - this.parent.sendMessage(message); - } - - @Override public void printError(String msg) { - this.sendMessage(msg); - } - - @Override - public void executeCommand(final String cmd) { - Bukkit.getServer().dispatchCommand(this.parent, cmd); - } - - @Override - public com.sk89q.worldedit.entity.Player toWorldEditPlayer() { - return WorldEditPlugin.getInstance().wrapPlayer(this.parent); - } - -} 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 e0b76da4a..ee6d6d847 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 @@ -6,25 +6,40 @@ import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener; +import com.boydti.fawe.bukkit.listener.ChunkListener_8; +import com.boydti.fawe.bukkit.listener.ChunkListener_9; import com.boydti.fawe.bukkit.listener.RenderListener; -import com.boydti.fawe.bukkit.regions.*; +import com.boydti.fawe.bukkit.regions.ASkyBlockHook; +import com.boydti.fawe.bukkit.regions.FactionsFeature; +import com.boydti.fawe.bukkit.regions.FactionsOneFeature; +import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature; +import com.boydti.fawe.bukkit.regions.FreeBuildRegion; +import com.boydti.fawe.bukkit.regions.GriefPreventionFeature; +import com.boydti.fawe.bukkit.regions.PreciousStonesFeature; +import com.boydti.fawe.bukkit.regions.ResidenceFeature; +import com.boydti.fawe.bukkit.regions.TownyFeature; +import com.boydti.fawe.bukkit.regions.Worldguard; +import com.boydti.fawe.bukkit.regions.WorldguardFlag; import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.VaultUtil; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; -import com.boydti.fawe.bukkit.listener.ChunkListener_8; -import com.boydti.fawe.bukkit.listener.ChunkListener_9; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.Jars; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; - import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.World; -import org.bstats.bukkit.MetricsLite; +import io.papermc.lib.PaperLib; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.UUID; +import java.util.function.Supplier; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; @@ -38,14 +53,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.io.FileOutputStream; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.UUID; -import java.util.function.Supplier; - public class FaweBukkit implements IFawe, Listener { // private final WorldEditPlugin plugin; @@ -74,14 +81,7 @@ public class FaweBukkit implements IFawe, Listener { e.printStackTrace(); debug("==================================="); } - if (Bukkit.getVersion().contains("git-Spigot")) { - debug("====== USE PAPER ======"); - debug("DOWNLOAD: https://papermc.io/ci/job/Paper-1.13/"); - debug("GUIDE: https://www.spigotmc.org/threads/21726/"); - debug(" - This is only a recommendation"); - debug("=============================="); - } - if (Bukkit.getVersion().contains("git-Paper") && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { + if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { new RenderListener(plugin); } } catch (final Throwable e) { @@ -122,7 +122,7 @@ public class FaweBukkit implements IFawe, Listener { } @Override - public synchronized ImageViewer getImageViewer(FawePlayer fp) { + public synchronized ImageViewer getImageViewer(com.sk89q.worldedit.entity.Player fp) { if (listeningImages && imageListener == null) return null; try { listeningImages = true; @@ -143,7 +143,7 @@ public class FaweBukkit implements IFawe, Listener { fos.write(jarData); } } - BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp.toWorldEditPlayer())); + BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp)); if (imageListener == null) { this.imageListener = new BukkitImageListener(plugin); } @@ -195,34 +195,21 @@ public class FaweBukkit implements IFawe, Listener { } @Override - public FawePlayer wrap(final Object obj) { + public com.sk89q.worldedit.entity.Player wrap(final Object obj) { if (obj.getClass() == String.class) { String name = (String) obj; - FawePlayer existing = Fawe.get().getCachedPlayer(name); + com.sk89q.worldedit.entity.Player existing = Fawe.get().getCachedPlayer(name); if (existing != null) { return existing; } Player player = Bukkit.getPlayer(name); - return player != null ? new BukkitPlayer(player) : null; - } else if (obj instanceof Player) { - Player player = (Player) obj; - FawePlayer existing = Fawe.get().getCachedPlayer(player.getName()); - return existing != null ? existing : new BukkitPlayer(player); - } else if (obj.getClass().getName().contains("EntityPlayer")) { - try { - Method method = obj.getClass().getDeclaredMethod("getBukkitEntity"); - return wrap(method.invoke(obj)); - } catch (Throwable e) { - e.printStackTrace(); - return null; - } - } else { - return null; + return player != null ? BukkitAdapter.adapt(player) : null; } + return null; } @Override public void startMetrics() { - new MetricsLite(plugin); + new Metrics(plugin); } public ItemUtil getItemUtil() { @@ -347,7 +334,7 @@ public class FaweBukkit implements IFawe, Listener { final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) { try { - managers.add(new PreciousStonesFeature(preciousStonesPlugin, this)); + managers.add(new PreciousStonesFeature(preciousStonesPlugin)); Fawe.debug("Plugin 'PreciousStones' found. Using it now."); } catch (Throwable e) { e.printStackTrace(); @@ -399,9 +386,9 @@ public class FaweBukkit implements IFawe, Listener { public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); String name = player.getName(); - FawePlayer fp = Fawe.get().getCachedPlayer(name); - if (fp != null) { - fp.unregister(); + com.sk89q.worldedit.entity.Player wePlayer = Fawe.get().getCachedPlayer(name); + if (wePlayer != null) { + wePlayer.unregister(); Fawe.get().unregister(name); } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java index a560352ff..345775726 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BrushListener.java @@ -1,10 +1,11 @@ package com.boydti.fawe.bukkit.listener; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.scroll.ScrollTool; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.command.tool.Tool; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -29,9 +30,8 @@ public class BrushListener implements Listener { if (bukkitPlayer.isSneaking()) { return; } - FawePlayer fp = FawePlayer.wrap(bukkitPlayer); - com.sk89q.worldedit.entity.Player player = fp.getPlayer(); - LocalSession session = fp.getSession(); + BukkitPlayer player = BukkitAdapter.adapt(bukkitPlayer); + LocalSession session = player.getSession(); Tool tool = session.getTool(player); if (tool instanceof ScrollTool) { final int slot = event.getNewSlot(); @@ -55,9 +55,8 @@ public class BrushListener implements Listener { Location to = event.getTo(); if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ() || from.getBlockY() != to.getBlockY()) { Player bukkitPlayer = event.getPlayer(); - FawePlayer fp = FawePlayer.wrap(bukkitPlayer); - com.sk89q.worldedit.entity.Player player = fp.getPlayer(); - LocalSession session = fp.getSession(); + com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer); + LocalSession session = player.getSession(); Tool tool = session.getTool(player); if (tool != null) { if (tool instanceof MovableTool) { @@ -74,9 +73,8 @@ public class BrushListener implements Listener { if (event.getAction() == Action.PHYSICAL) { return; } - FawePlayer fp = FawePlayer.wrap(bukkitPlayer); - com.sk89q.worldedit.entity.Player player = fp.getPlayer(); - LocalSession session = fp.getSession(); + com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer); + LocalSession session = player.getSession(); Tool tool = session.getTool(player); if (tool instanceof ResettableTool) { if (((ResettableTool) tool).reset()) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java index 7051dd1a8..b9741ed92 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/BukkitImageListener.java @@ -3,9 +3,8 @@ package com.boydti.fawe.bukkit.listener; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; import com.boydti.fawe.command.CFICommands; -import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.brush.BrushSettings; +import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.TaskManager; @@ -13,11 +12,19 @@ import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; +import java.util.ArrayDeque; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Rotation; @@ -42,13 +49,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.plugin.Plugin; -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; - public class BukkitImageListener implements Listener { private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0); @@ -63,7 +63,7 @@ public class BukkitImageListener implements Listener { Iterator iter = recipients.iterator(); while (iter.hasNext()) { Player player = iter.next(); - FawePlayer fp = FawePlayer.wrap(player); + BukkitPlayer fp = BukkitAdapter.adapt(player); CFICommands.CFISettings settings = fp.getMeta("CFISettings"); if (player.equals(event.getPlayer()) || !fp.hasMeta() || settings == null || !settings.hasGenerator()) { continue; @@ -106,7 +106,7 @@ public class BukkitImageListener implements Listener { } Player player = event.getPlayer(); - FawePlayer fp = FawePlayer.wrap(player); + BukkitPlayer fp = BukkitAdapter.adapt(player); if (fp.getMeta("CFISettings") == null) { return; } @@ -189,7 +189,7 @@ public class BukkitImageListener implements Listener { } ItemFrame itemFrame = (ItemFrame) entity; - FawePlayer fp = FawePlayer.wrap(player); + BukkitPlayer fp = BukkitAdapter.adapt(player); CFICommands.CFISettings settings = fp.getMeta("CFISettings"); HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator(); BukkitImageViewer viewer = get(generator); @@ -204,7 +204,7 @@ public class BukkitImageListener implements Listener { LocalSession session = fp.getSession(); BrushTool tool; try { - tool = session.getBrushTool(fp.getPlayer(), false); + tool = session.getBrushTool(fp, false); } catch (InvalidToolBindException e) { return; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index 1fc42dde9..ece1f4cd1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -1,7 +1,6 @@ package com.boydti.fawe.bukkit.listener; import com.boydti.fawe.command.CFICommands; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RunnableVal3; import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.comphenix.protocol.PacketType; @@ -16,28 +15,19 @@ import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.ChunkCoordIntPair; import com.comphenix.protocol.wrappers.EnumWrappers; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.event.platform.BlockInteractEvent; import com.sk89q.worldedit.event.platform.Interaction; import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.math.BlockVector3; - -import com.sk89q.worldedit.util.formatting.text.TextComponent.Builder; -import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.util.List; - import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; +import java.lang.reflect.InvocationTargetException; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.Plugin; /** @@ -243,7 +233,7 @@ public class CFIPacketListener implements Listener { private boolean sendBlockChange(Player plr, VirtualWorld gen, BlockVector3 pt, Interaction action) { PlatformManager platform = WorldEdit.getInstance().getPlatformManager(); - com.sk89q.worldedit.entity.Player actor = FawePlayer.wrap(plr).getPlayer(); + com.sk89q.worldedit.entity.Player actor = BukkitAdapter.adapt(plr); com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt.toVector3()); BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action); platform.handleBlockInteract(toCall); @@ -265,10 +255,10 @@ public class CFIPacketListener implements Listener { } private VirtualWorld getGenerator(Player player) { - FawePlayer fp = FawePlayer.wrap(player); - VirtualWorld vw = fp.getSession().getVirtualWorld(); + BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player); + VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld(); if (vw != null) return vw; - CFICommands.CFISettings settings = fp.getMeta("CFISettings"); + CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings"); if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) { return settings.getGenerator(); } 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 664734cd9..84d328400 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,6 +1,5 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; @@ -24,12 +23,11 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); - final Location location = player.getLocation(); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player player, MaskType type) { + final Location location = BukkitAdapter.adapt(player).getLocation(); Island island = ASkyBlockAPI.getInstance().getIslandAt(location); - if (island != null && isAllowed(player, island, type)) { + if (island != null && isAllowed(BukkitAdapter.adapt(player), island, type)) { Location center1 = island.getCenter(); MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ()); @@ -38,8 +36,8 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener { return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), island, type); + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(BukkitAdapter.adapt(player), island, type); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java index abd616603..95a31d98e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/BukkitMaskManager.java @@ -3,7 +3,7 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.regions.FaweMaskManager; import org.bukkit.entity.Player; -public abstract class BukkitMaskManager extends FaweMaskManager { +public abstract class BukkitMaskManager extends FaweMaskManager { public BukkitMaskManager(final String plugin) { super(plugin); 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 2b1fa2b62..042d315bf 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,6 +1,5 @@ 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; @@ -21,15 +20,15 @@ public class FactionsFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) { + final Player player = BukkitAdapter.adapt(p); final Location loc = player.getLocation(); final PS ps = PS.valueOf(loc); final Faction fac = BoardColl.get().getFactionAt(ps); if (fac != null) { if (type == MaskType.OWNER) { MPlayer leader = fac.getLeader(); - if (leader != null && fp.getUUID().equals(leader.getUuid())) { + if (leader != null && p.getUniqueId().equals(leader.getUuid())) { final Chunk chunk = loc.getChunk(); final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos2 = BlockVector3 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 656ebacf0..43ce11db1 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,6 +1,5 @@ package com.boydti.fawe.bukkit.regions; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.util.Permission; @@ -26,11 +25,10 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) { + final Player player = BukkitAdapter.adapt(p); final Chunk chunk = player.getLocation().getChunk(); - final boolean perm = Permission - .hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); + final boolean perm = Permission.hasPermission(p, "fawe.factions.wilderness"); final World world = player.getWorld(); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); 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 cccb32804..2e97337cd 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 @@ -1,7 +1,6 @@ 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.Permission; @@ -11,7 +10,6 @@ import com.massivecraft.factions.Faction; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; import org.bukkit.Chunk; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -26,11 +24,10 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) { + final Player player = BukkitAdapter.adapt(p); final Chunk chunk = player.getLocation().getChunk(); - final boolean perm = Permission - .hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness"); + final boolean perm = Permission.hasPermission(p, "fawe.factions.wilderness"); final World world = player.getWorld(); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); 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 0e07ae3f8..43c3cea03 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 @@ -2,22 +2,19 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncWorld; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMask; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import java.util.ArrayList; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.event.EventException; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.plugin.RegisteredListener; -import java.util.ArrayList; - public class FreeBuildRegion extends BukkitMaskManager { private final ArrayList listeners; @@ -38,7 +35,7 @@ public class FreeBuildRegion extends BukkitMaskManager { } @Override - public FaweMask getMask(FawePlayer player, MaskType type) { + public FaweMask getMask(com.sk89q.worldedit.entity.Player player, MaskType type) { if (type != MaskType.MEMBER) return null; ArrayList currRegList = new ArrayList<>(); for (RegisteredListener listener : this.listeners) { @@ -49,20 +46,20 @@ public class FreeBuildRegion extends BukkitMaskManager { if (currRegList.isEmpty()) return null; RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); - World bukkitWorld = BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()); + World bukkitWorld = BukkitAdapter.adapt(player.getWorld()); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld); BlockVector3 pos1 = BlockVector3.ZERO; BlockVector3 pos2 = BlockVector3.ZERO; AsyncBlock block = new AsyncBlock(asyncWorld, 0, 0, 0); - BlockBreakEvent event = new BlockBreakEvent(block, BukkitAdapter.adapt(player.toWorldEditPlayer())); + BlockBreakEvent event = new BlockBreakEvent(block, BukkitAdapter.adapt(player)); return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER; + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return bukkitWorld == BukkitAdapter.adapt(player.getWorld()) && type == MaskType.MEMBER; } @Override 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 15a22d1fe..2ba07cdaf 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,7 +1,6 @@ package com.boydti.fawe.bukkit.regions; 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; @@ -26,8 +25,8 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene } @Override - public FaweMask getMask(final FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player fp, MaskType type) { + final Player player = BukkitAdapter.adapt(fp); final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null); if (claim != null) { if (isAllowed(player, claim, type)) { @@ -37,7 +36,7 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer fp, MaskType type) { + public boolean isValid(com.sk89q.worldedit.entity.Player fp, MaskType type) { return isAllowed(player, claim, 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 a94b4a7f2..296e19524 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 @@ -1,11 +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.sk89q.worldedit.math.BlockVector3; - import java.util.List; import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; import net.sacredlabyrinth.Phaed.PreciousStones.field.Field; @@ -17,7 +14,7 @@ import org.bukkit.plugin.Plugin; public class PreciousStonesFeature extends BukkitMaskManager implements Listener { - public PreciousStonesFeature(Plugin preciousstonesPlugin, FaweBukkit p3) { + public PreciousStonesFeature(Plugin preciousstonesPlugin) { super(preciousstonesPlugin.getName()); } @@ -27,8 +24,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener } @Override - public FaweMask getMask(FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) { + final Player player = BukkitAdapter.adapt(fp); final Location location = player.getLocation(); final List fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location); if (fields.isEmpty()) { @@ -42,8 +39,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), myField, type, fp.hasPermission("fawe.preciousstones.member")); + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(BukkitAdapter.adapt(player), 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 3217ab4e1..1f988ad0e 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 @@ -4,7 +4,6 @@ import com.bekvon.bukkit.residence.Residence; 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; @@ -28,8 +27,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(final FawePlayer fp, final MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(final com.sk89q.worldedit.entity.Player fp, final MaskType type) { + final Player player = BukkitAdapter.adapt(fp); final Location location = player.getLocation(); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); if (residence != null) { @@ -44,8 +43,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener { final ClaimedResidence finalResidence = residence; return new FaweMask(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2)) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), finalResidence, type); + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(BukkitAdapter.adapt(player), 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 f7cc9dc27..db119ee9d 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 @@ -1,6 +1,5 @@ package com.boydti.fawe.bukkit.regions; -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; @@ -62,36 +61,33 @@ public class TownyFeature extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(FawePlayer fp) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(com.sk89q.worldedit.entity.Player fp) { + final Player player = BukkitAdapter.adapt(fp); final Location location = player.getLocation(); try { final PlayerCache cache = ((Towny) this.towny).getCache(player); final WorldCoord mycoord = cache.getLastTownBlock(); if (mycoord == null) { return null; - } else { - final TownBlock myplot = mycoord.getTownBlock(); - if (myplot == null) { - return null; - } else { - boolean isMember = isAllowed(player, myplot); - if (isMember) { - final Chunk chunk = location.getChunk(); - final BlockVector3 pos1 = BlockVector3 - .at(chunk.getX() * 16, 0, chunk.getZ() * 16); - final BlockVector3 pos2 = BlockVector3.at( - chunk.getX() * 16 + 15, 156, chunk.getZ() * 16 - + 15); - return new FaweMask(pos1, pos2) { - @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), - myplot); - } - }; + } + final TownBlock myplot = mycoord.getTownBlock(); + if (myplot == null) { + return null; + } + boolean isMember = isAllowed(player, myplot); + if (isMember) { + final Chunk chunk = location.getChunk(); + final BlockVector3 pos1 = BlockVector3 + .at(chunk.getX() * 16, 0, chunk.getZ() * 16); + final BlockVector3 pos2 = BlockVector3.at( + chunk.getX() * 16 + 15, 156, chunk.getZ() * 16 + + 15); + return new FaweMask(pos1, pos2) { + @Override + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(BukkitAdapter.adapt(player),myplot); } - } + }; } } catch (Exception ignored) { } 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 f9125bc0e..5f622fb0c 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,7 +1,6 @@ package com.boydti.fawe.bukkit.regions; 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; @@ -90,8 +89,8 @@ public class Worldguard extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) { + final Player player = BukkitAdapter.adapt(fp); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final Location location = player.getLocation(); final ProtectedRegion myregion = this.getRegion(localplayer, location); @@ -108,8 +107,8 @@ public class Worldguard extends BukkitMaskManager implements Listener { } else { return new FaweMask(adapt(myregion)) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion); } }; } @@ -117,8 +116,8 @@ public class Worldguard extends BukkitMaskManager implements Listener { return new FaweMask(pos1, pos2) { @Override - public boolean isValid(FawePlayer player, MaskType type) { - return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { + return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion); } }; } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java index 7992f769f..3c7ea4bf9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/WorldguardFlag.java @@ -1,7 +1,6 @@ package com.boydti.fawe.bukkit.regions; import com.boydti.fawe.bukkit.filter.WorldGuardFilter; -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; @@ -30,8 +29,8 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener { } @Override - public FaweMask getMask(FawePlayer fp, MaskType type) { - final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); + public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) { + final Player player = BukkitAdapter.adapt(fp); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final RegionContainer container = WorldGuard.getInstance().getPlatform() .getRegionContainer(); @@ -39,7 +38,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener { return new FaweMask(new ManagerRegion(manager, localplayer)) { @Override - public boolean isValid(FawePlayer player, MaskType type) { + public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) { // We rely on the region mask instead of this return true; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index ce24c1da4..465948668 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -28,17 +28,16 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; -import org.bukkit.Chunk; +import com.sk89q.worldedit.util.formatting.text.format.TextColor; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.BlockCommandSender; import org.jetbrains.annotations.NotNull; - -import java.util.UUID; - -import javax.annotation.Nullable; +import org.jetbrains.annotations.Nullable; public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable { @@ -72,21 +71,21 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @Override public void print(String msg) { for (String part : msg.split("\n")) { - sender.sendMessage("\u00A7d" + part); + print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); } } @Override public void printDebug(String msg) { for (String part : msg.split("\n")) { - sender.sendMessage("\u00A77" + part); + print(TextComponent.of(part, TextColor.GRAY)); } } @Override public void printError(String msg) { for (String part : msg.split("\n")) { - sender.sendMessage("\u00A7c" + part); + print(TextComponent.of(part, TextColor.RED)); } } @@ -156,10 +155,9 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @NotNull Block block = sender.getBlock(); @NotNull World world = block.getWorld(); if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4)) { - @NotNull Material type = block.getType(); - return type == Material.COMMAND_BLOCK - || type == Material.CHAIN_COMMAND_BLOCK - || type == Material.REPEATING_COMMAND_BLOCK; + return sender.getBlock().getType() == Material.COMMAND_BLOCK + || sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK + || sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK; } return false; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index d0549b087..324687745 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -23,16 +23,13 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; -import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; -import java.io.File; import java.util.UUID; import javax.annotation.Nullable; import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -44,12 +41,14 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { private static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be"); private CommandSender sender; + private WorldEditPlugin plugin; public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) { checkNotNull(plugin); checkNotNull(sender); checkArgument(!(sender instanceof Player), "Cannot wrap a player"); + this.plugin = plugin; this.sender = sender; } @@ -96,11 +95,6 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { TextAdapter.sendComponent(sender, component); } - @Override - public boolean canDestroyBedrock() { - return true; - } - @Override public String[] getGroups() { return new String[0]; @@ -122,25 +116,6 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { public void checkPermission(String permission) throws AuthorizationException { } - @Override - public boolean isPlayer() { - return false; - } - - @Override - public File openFileOpenDialog(String[] extensions) { - return null; - } - - @Override - public File openFileSaveDialog(String[] extensions) { - return null; - } - - @Override - public void dispatchCUIEvent(CUIEvent event) { - } - @Override public SessionKey getSessionKey() { return new SessionKey() { diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index cfcf9f44f..a403db0a1 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -51,6 +51,7 @@ import java.util.Map; import java.util.UUID; import javax.annotation.Nullable; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Item; @@ -69,6 +70,7 @@ public class BukkitPlayer extends AbstractPlayerActor { } public BukkitPlayer(WorldEditPlugin plugin, Player player) { + super(); this.plugin = plugin; this.player = player; } @@ -352,4 +354,11 @@ public class BukkitPlayer extends AbstractPlayerActor { } } } + + @Override + public void sendTitle(String title, String sub) { + player.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); + Bukkit.getServer().dispatchCommand(player, "title " + getName() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]"); + Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); + } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index e0b37df63..cd308904d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -508,7 +508,6 @@ public class BukkitWorld extends AbstractWorld { @Override public void sendChunk(int X, int Z, int mask) { - } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index 7097a9e8c..d7d97f8c0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; +import java.util.Optional; import org.bukkit.block.Block; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; @@ -36,15 +37,11 @@ import org.bukkit.event.player.PlayerCommandSendEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; -import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.MapBackedValueStore; -import java.util.Iterator; -import java.util.Optional; - /** * Handles all events thrown in relation to a Player */ @@ -73,23 +70,16 @@ public class WorldEditListener implements Listener { @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerCommandSend(PlayerCommandSendEvent event) { - // Command processing used to show up in timings + InjectedValueStore store = MapBackedValueStore.create(); + store.injectValue(Key.of(Actor.class), context -> + Optional.of(plugin.wrapCommandSender(event.getPlayer()))); CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager(); - InjectedValueStore store = null; - Iterator iter = event.getCommands().iterator(); - while (iter.hasNext()) { - String name = iter.next(); - Optional optional = commandManager.getCommand(name); - if (optional.isPresent()) { - if (store == null) { - store = MapBackedValueStore.create(); - store.injectValue(Key.of(Actor.class), context -> Optional.of(plugin.wrapCommandSender(event.getPlayer()))); - } - if (!optional.get().getCondition().satisfied(store)) { - iter.remove(); - } - } - } + event.getCommands().removeIf(name -> + // remove if in the manager and not satisfied + commandManager.getCommand(name) + .filter(command -> !command.getCondition().satisfied(store)) + .isPresent() + ); } /** diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index f735febb4..20a289528 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -19,14 +19,14 @@ package com.sk89q.worldedit.bukkit; -import com.bekvon.bukkit.residence.commands.message; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME; + import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; -import com.boydti.fawe.util.MainUtil; - import com.boydti.fawe.bukkit.adapter.mc1_14.Spigot_v1_14_R4; +import com.boydti.fawe.util.MainUtil; import com.google.common.base.Joiner; -import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.wepif.PermissionsResolverManager; import com.sk89q.worldedit.EditSession; @@ -42,6 +42,7 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; +import com.sk89q.worldedit.internal.anvil.ChunkDeleter; import com.sk89q.worldedit.internal.command.CommandUtil; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; @@ -51,32 +52,15 @@ import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.weather.WeatherTypes; import io.papermc.lib.PaperLib; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.block.Biome; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.plugin.java.JavaPluginLoader; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -86,6 +70,28 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.jar.JarFile; import java.util.logging.Level; import java.util.zip.ZipEntry; +import javax.annotation.Nullable; +import org.bstats.bukkit.Metrics; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.block.Biome; +import org.bukkit.command.BlockCommandSender; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.world.WorldInitEvent; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.java.JavaPluginLoader; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Plugin for Bukkit. @@ -171,9 +177,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // Setup platform server = new BukkitServerInterface(this, getServer()); worldEdit.getPlatformManager().register(server); - loadAdapter(); // Need an adapter to work with special blocks with NBT data - loadConfig(); // Load configuration + Path delChunks = Paths.get(getDataFolder().getPath(), DELCHUNKS_FILE_NAME); + if (Files.exists(delChunks)) { + ChunkDeleter.runFromFile(delChunks, true); + } + fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver"); } @@ -184,10 +193,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public void onEnable() { if (INSTANCE != null) return; onLoad(); - setupTags(); // these have to be done post-world since they rely on MC registries. the other ones just use Bukkit enums - //TODO: FAWE -- This needs to be moved to onLoad() - setupRegistries(); - WorldEdit.getInstance().loadMappings(); PermissionsResolverManager.initialize(this); // Setup permission resolver @@ -204,7 +209,20 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter getServer().getPluginManager().registerEvents(new AsyncTabCompleteListener(), this); } - WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); + initializeRegistries(); // this creates the objects matching Bukkit's enums - but doesn't fill them with data yet + if (Bukkit.getWorlds().isEmpty()) { + setupPreWorldData(); + // register this so we can load world-dependent data right as the first world is loading + getServer().getPluginManager().registerEvents(new WorldInitListener(), this); + } else { + getLogger().warning("Server reload detected. This may cause various issues with WorldEdit and dependent plugins."); + try { + setupPreWorldData(); + // since worlds are loaded already, we can do this now + setupWorldData(); + } catch (Throwable ignored) { + } + } // // Register 1.13 Material ids with LegacyMapper // LegacyMapper legacyMapper = LegacyMapper.getInstance(); @@ -213,11 +231,24 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter // legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState()); // } // } - + // Enable metrics + new Metrics(this); PaperLib.suggestPaper(this); } - private void setupRegistries() { + private void setupPreWorldData() { + loadAdapter(); + loadConfig(); + WorldEdit.getInstance().loadMappings(); + } + + private void setupWorldData() { + setupTags(); // datapacks aren't loaded until just before the world is, and bukkit has no event for this + // so the earliest we can do this is in WorldInit + WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); + } + + private void initializeRegistries() { // Biome for (Biome biome : Biome.values()) { String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT); @@ -323,13 +354,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter private void loadConfig() { createDefaultConfiguration("config-legacy.yml"); // Create the default configuration file - try { - config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); - config.load(); - } catch (Throwable e) { - getLogger().severe("Failed to load config.yml"); - e.printStackTrace(); - } + config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); + config.load(); // Create schematics folder WorldEdit worldEdit = WorldEdit.getInstance(); File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir); @@ -380,7 +406,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public void onDisable() { Fawe.get().onDisable(); WorldEdit worldEdit = WorldEdit.getInstance(); - worldEdit.getSessionManager().clear(); + worldEdit.getSessionManager().unload(); worldEdit.getPlatformManager().unregister(server); if (config != null) { config.unload(); @@ -537,7 +563,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter public Actor wrapCommandSender(CommandSender sender) { if (sender instanceof Player) { return wrapPlayer((Player) sender); - } else if (sender instanceof BlockCommandSender) { + } else if (config.commandBlockSupport && sender instanceof BlockCommandSender) { return new BukkitBlockCommandSender(this, (BlockCommandSender) sender); } @@ -577,6 +603,16 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter return bukkitAdapter; } + private class WorldInitListener implements Listener { + private boolean loaded = false; + @EventHandler(priority = EventPriority.LOWEST) + public void onWorldInit(@SuppressWarnings("unused") WorldInitEvent event) { + if (loaded) return; + loaded = true; + setupWorldData(); + } + } + private class AsyncTabCompleteListener implements Listener { AsyncTabCompleteListener() { } diff --git a/worldedit-bukkit/src/main/java/org/bstats/bukkit/MetricsLite.java b/worldedit-bukkit/src/main/java/org/bstats/bukkit/Metrics.java similarity index 97% rename from worldedit-bukkit/src/main/java/org/bstats/bukkit/MetricsLite.java rename to worldedit-bukkit/src/main/java/org/bstats/bukkit/Metrics.java index 20772b14b..e07b0aece 100644 --- a/worldedit-bukkit/src/main/java/org/bstats/bukkit/MetricsLite.java +++ b/worldedit-bukkit/src/main/java/org/bstats/bukkit/Metrics.java @@ -30,7 +30,7 @@ import java.util.zip.GZIPOutputStream; * Check out https://bStats.org/ to learn more about bStats! */ @SuppressWarnings({"WeakerAccess", "unused"}) -public class MetricsLite { +public class Metrics { static { // You can use the property to disable the check in your test environment @@ -40,7 +40,7 @@ public class MetricsLite { new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'}); final String examplePackage = defaultPackage; // We want to make sure nobody just copy & pastes the example and use the wrong package names - if (MetricsLite.class.getPackage().getName().equals(defaultPackage) || MetricsLite.class.getPackage().getName().equals(examplePackage)) { + if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); } } @@ -75,7 +75,7 @@ public class MetricsLite { * * @param plugin The plugin which stats should be submitted. */ - public MetricsLite(Plugin plugin) { + public Metrics(Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null!"); } @@ -129,7 +129,7 @@ public class MetricsLite { } catch (NoSuchFieldException ignored) { } } // Register our service - Bukkit.getServicesManager().register(MetricsLite.class, this, plugin, ServicePriority.Normal); + Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal); if (!found) { // We are the first! startSubmitting(); @@ -364,4 +364,4 @@ public class MetricsLite { return outputStream.toByteArray(); } -} \ No newline at end of file +} 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 183b07c37..7d9993d35 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -1,10 +1,8 @@ package com.boydti.fawe; import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.command.CFICommand; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.regions.general.plot.PlotSquaredFeature; import com.boydti.fawe.util.CachedTextureUtil; @@ -16,10 +14,11 @@ import com.boydti.fawe.util.RandomTextureUtil; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.WEManager; +import com.github.luben.zstd.util.Native; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.platform.Actor; -import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.session.request.Request; import java.io.BufferedReader; import java.io.File; @@ -192,8 +191,8 @@ public class Fawe { } catch (Throwable ignored) {} try { imp().startMetrics(); - } catch (Throwable ignored) { - debug(ignored.getMessage()); + } catch (Throwable e) { + debug(e.getMessage()); } }, 0); @@ -334,7 +333,7 @@ public class Fawe { */ if (!Settings.IMP.EXPERIMENTAL.DISABLE_NATIVES) { try { - com.github.luben.zstd.util.Native.load(); + Native.load(); } catch (Throwable e) { if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) { Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL); @@ -367,7 +366,6 @@ public class Fawe { if (x86OS != x86JVM) { debug("====== UPGRADE TO 64-BIT JAVA ======"); debug("You are running 32-bit Java on a 64-bit machine"); - debug(" - This is only a recommendation"); debug("===================================="); } } catch (Throwable ignore) {} @@ -402,9 +400,8 @@ public class Fawe { mp.setUsageThreshold(alert); } } - } catch (Throwable e) { + } catch (Throwable ignored) { debug("====== MEMORY LISTENER ERROR ======"); - e.printStackTrace(); debug("==================================="); debug("FAWE needs access to the JVM memory system:"); debug(" - Change your Java security settings"); @@ -435,29 +432,29 @@ public class Fawe { return this.thread = Thread.currentThread(); } - private ConcurrentHashMap players = new ConcurrentHashMap<>(8, 0.9f, 1); - private ConcurrentHashMap playersUUID = new ConcurrentHashMap<>(8, 0.9f, 1); + private ConcurrentHashMap players = new ConcurrentHashMap<>(8, 0.9f, 1); + private ConcurrentHashMap playersUUID = new ConcurrentHashMap<>(8, 0.9f, 1); - public void register(FawePlayer player) { + public void register(Player player) { players.put(player.getName(), player); - playersUUID.put(player.getUUID(), player); + playersUUID.put(player.getUniqueId(), player); } public void unregister(String name) { - FawePlayer player = players.remove(name); - if (player != null) playersUUID.remove(player.getUUID()); + Player player = players.remove(name); + if (player != null) playersUUID.remove(player.getUniqueId()); } - public FawePlayer getCachedPlayer(String name) { + public Player getCachedPlayer(String name) { return players.get(name); } - public FawePlayer getCachedPlayer(UUID uuid) { + public Player getCachedPlayer(UUID uuid) { return playersUUID.get(uuid); } - public Collection getCachedPlayers() { + public Collection getCachedPlayers() { return players.values(); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index 5b95666f4..4904f6e88 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -3,7 +3,6 @@ package com.boydti.fawe; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.exception.FaweException; @@ -16,16 +15,12 @@ import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.WEManager; import com.boydti.fawe.wrappers.WorldWrapper; - import com.google.common.collect.Sets; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.extension.factory.DefaultTransformParser; -import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser; -import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser; +import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -37,8 +32,6 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; - -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; @@ -48,6 +41,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; +import javax.annotation.Nullable; /** * The FaweAPI class offers a few useful functions.
@@ -149,21 +143,6 @@ public class FaweAPI { // PlatformCommandManager.getInstance().registerCommands(clazz, aliases); TODO NOT IMPLEMENTED } - /** - * Wrap some object into a FawePlayer
- * - org.bukkit.entity.Player - * - org.spongepowered.api.entity.living.player - * - com.sk89q.worldedit.entity.Player - * - String (name) - * - UUID (player UUID) - * - * @param obj - * @return - */ - public static FawePlayer wrapPlayer(Object obj) { - return FawePlayer.wrap(obj); - } - /** * You can either use a IQueueExtent or an EditSession to change blocks
* - The IQueueExtent skips a bit of overhead so it's marginally faster
@@ -241,7 +220,7 @@ public class FaweAPI { * @param player * @return */ - public static Region[] getRegions(FawePlayer player) { + public static Region[] getRegions(Player player) { return WEManager.IMP.getMask(player); } @@ -395,7 +374,7 @@ public class FaweAPI { * @param uuid * @param index * @return - * @see DiskStorageHistory#toEditSession(FawePlayer) + * @see DiskStorageHistory#toEditSession(Player) */ public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) { return new DiskStorageHistory(world, uuid, index); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index 40f40592f..6122e0f5d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -2,12 +2,11 @@ package com.boydti.fawe; import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; +import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.world.World; - import java.io.File; import java.util.Collection; import java.util.UUID; @@ -20,7 +19,7 @@ public interface IFawe { void setupCommand(final String label, final FaweCommand cmd); - FawePlayer wrap(final Object obj); + Player wrap(final Object obj); void setupVault(); @@ -32,7 +31,7 @@ public interface IFawe { void startMetrics(); - default ImageViewer getImageViewer(FawePlayer player) { + default ImageViewer getImageViewer(Player player) { return null; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java index 1999fdaf3..1579b3604 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommand.java @@ -2,10 +2,11 @@ package com.boydti.fawe.command; import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline; -import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.command.CFICommands.CFISettings; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.changeset.CFIChangeSet; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.io.IOException; import java.util.ArrayList; @@ -23,17 +24,17 @@ public class CFICommand extends CommandProcessor { @Override public List preprocess(InjectedValueAccess context, List args) { - FawePlayer fp = context.injectedValue(Key.of(FawePlayer.class)).orElseThrow(() -> new IllegalStateException("No player")); - CFICommands.CFISettings settings = CFICommands.getSettings(fp); - settings.popMessages(fp); - args = dispatch(fp, settings, args, context); + Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player")); + CFICommands.CFISettings settings = CFICommands.getSettings(player); + settings.popMessages(player); + args = dispatch(player, settings, args, context); HeightMapMCAGenerator gen = settings.getGenerator(); if (gen != null && gen.isModified()) { try { gen.update(); - CFIChangeSet set = new CFIChangeSet(gen, fp.getUUID()); - LocalSession session = fp.getSession(); - session.remember(fp.getPlayer(), gen, set, fp.getLimit()); + CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId()); + LocalSession session = player.getSession(); + session.remember(player, gen, set, player.getLimit()); } catch (IOException e) { throw new StopExecutionException(TextComponent.of(e.getMessage())); } @@ -46,7 +47,7 @@ public class CFICommand extends CommandProcessor { return result; } - private List dispatch(FawePlayer fp, CFICommands.CFISettings settings, List args, InjectedValueAccess context) { + private List dispatch(Player player, CFISettings settings, List args, InjectedValueAccess context) { if (!settings.hasGenerator()) { if (args.size() == 0) { String hmCmd = "/cfi "; @@ -62,25 +63,23 @@ public class CFICommand extends CommandProcessor { .append(newline()) .append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty") .append("- An empty map of a specific size").build(); - fp.toWorldEditPlayer().print(build); + player.print(build); } else { args = new ArrayList<>(args); switch (args.size()) { - case 1: { + case 1: args.add(0, "heightmap"); break; - } - case 2: { + case 2: args.add(0, "empty"); break; - } } return args; } } else { if (args.isEmpty()) { settings.setCategory(null); - CFICommands.mainMenu(fp); + CFICommands.mainMenu(player); return null; } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 8a65ec7b5..34207e391 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -8,7 +8,6 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.beta.SingleFilterBlock; import com.boydti.fawe.config.BBC; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; @@ -71,7 +70,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.IntStream; import javax.imageio.ImageIO; - import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; @@ -106,7 +104,7 @@ public class CFICommands { desc = "Start CFI with a height map as a base" ) @CommandPermissions("worldedit.anvil.cfi") - public void heightmap(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) { + public void heightmap(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) { if (yscale != 0) { int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData(); int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale))) @@ -128,7 +126,7 @@ public class CFICommands { desc = "Start CFI with an empty map as a base" ) @CommandPermissions("worldedit.anvil.cfi") - public void heightMap(FawePlayer fp, int width, int length) { + public void heightMap(Player fp, int width, int length) { HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName())); setup(generator, fp); } @@ -138,7 +136,7 @@ public class CFICommands { return df.format(new Date()); } - private void setup(HeightMapMCAGenerator generator, FawePlayer fp) { + private void setup(HeightMapMCAGenerator generator, Player fp) { CFISettings settings = getSettings(fp).remove(); generator.setPacketViewer(fp); settings.setGenerator(generator).bind(); @@ -152,9 +150,9 @@ public class CFICommands { desc = "Info about using brushes with CFI" ) @CommandPermissions("worldedit.anvil.cfi") - public void brush(FawePlayer fp) { - CFISettings settings = assertSettings(fp); - settings.popMessages(fp); + public void brush(Player player) { + CFISettings settings = assertSettings(player); + settings.popMessages(player); @NotNull Builder msg; if (settings.getGenerator().getImageViewer() != null) { msg = TextComponent.builder("CFI supports using brushes during creation").append(newline()) @@ -164,8 +162,8 @@ public class CFICommands { } else { msg = TextComponent.builder("This is not supported with your platform/version").append(newline()); } - //TODO msg.text("< [Back]").cmdTip(alias()).send(fp); - fp.toWorldEditPlayer().print(msg.build()); + //TODO msg.text("< [Back]").cmdTip(alias()).send(player); + player.print(msg.build()); } @Command( @@ -174,9 +172,9 @@ public class CFICommands { desc = "Cancel creation" ) @CommandPermissions("worldedit.anvil.cfi") - public void cancel(FawePlayer fp) { + public void cancel(Player fp) { getSettings(fp).remove(); - fp.sendMessage("Cancelled!"); + fp.print("Cancelled!"); } @Command( @@ -185,32 +183,32 @@ public class CFICommands { desc = "Create the world" ) @CommandPermissions("worldedit.anvil.cfi") - public void done(FawePlayer fp) { - CFISettings settings = assertSettings(fp); + public void done(Player player) { + CFISettings settings = assertSettings(player); HeightMapMCAGenerator generator = settings.getGenerator(); Function function = folder -> { if (folder != null) { try { generator.setFolder(folder); - fp.sendMessage("Generating " + folder); + player.print("Generating " + folder); generator.generate(); generator.setPacketViewer(null); generator.setImageViewer(null); settings.remove(); - fp.sendMessage("Done!"); + player.print("Done!"); return true; } catch (IOException e) { throw new RuntimeException(e); } } else { - fp.sendMessage("Unable to generate world... (see console)?"); + player.print("Unable to generate world... (see console)?"); } return false; }; try { - new PlotLoader().load(fp, settings, function); + new PlotLoader().load(player, settings, function); } catch (Throwable e) { e.printStackTrace(); function.apply(generator.getFolder().getParentFile()); @@ -220,17 +218,17 @@ public class CFICommands { if (folder != null) { World world = FaweAPI.getWorld(folder.getName()); if (world != null) { - if (fp.getWorld() != world) { + if (player.getWorld() != world) { TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { Location spawn = new Location(world, world.getSpawnPosition().toVector3()); - fp.getPlayer().setPosition(spawn); + player.setPosition(spawn); } }); } } else { - fp.sendMessage("Unable to import world (" + folder.getName() + ") please do so manually"); + player.print("Unable to import world (" + folder.getName() + ") please do so manually"); } } } @@ -240,7 +238,7 @@ public class CFICommands { desc = "Set the floor and main block" ) @CommandPermissions("worldedit.anvil.cfi") - public void column(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void column(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setColumn(load(image), patternArg, !disableWhiteOnly); @@ -249,7 +247,7 @@ public class CFICommands { } else { gen.setColumn(patternArg); } - fp.sendMessage("Set column!"); + fp.print("Set column!"); assertSettings(fp).resetComponent(); component(fp); } @@ -259,14 +257,14 @@ public class CFICommands { desc = "Set the floor (default: grass)" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void floorCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ floor(fp, patternArg, image, maskOpt, disableWhiteOnly); - fp.sendMessage("Set floor!"); + fp.print("Set floor!"); assertSettings(fp).resetComponent(); component(fp); } - private void floor(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) { + private void floor(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setFloor(load(image), patternArg, !disableWhiteOnly); @@ -282,14 +280,14 @@ public class CFICommands { desc = "Set the main block (default: stone)" ) @CommandPermissions("worldedit.anvil.cfi") - public void mainCmd(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void mainCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ main(fp, patternArg, image, maskOpt, disableWhiteOnly); - fp.sendMessage("Set main!"); + fp.print("Set main!"); assertSettings(fp).resetComponent(); component(fp); } - public void main(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void main(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setMain(load(image), patternArg, !disableWhiteOnly); @@ -308,7 +306,7 @@ public class CFICommands { "e.g. Tallgrass" ) @CommandPermissions("worldedit.anvil.cfi") - public void overlay(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void overlay(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setOverlay(load(image), patternArg, !disableWhiteOnly); @@ -317,7 +315,7 @@ public class CFICommands { } else { gen.setOverlay(patternArg); } - fp.sendMessage("Set overlay!"); + fp.print("Set overlay!"); component(fp); } @@ -330,13 +328,13 @@ public class CFICommands { " - A good value for radius and iterations would be 1 8." ) @CommandPermissions("worldedit.anvil.cfi") - public void smoothCmd(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void smoothCmd(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly); assertSettings(fp).resetComponent(); component(fp); } - private void smooth(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + private void smooth(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.smooth(load(image), !disableWhiteOnly, radius, iterations); @@ -350,12 +348,12 @@ public class CFICommands { desc = "Create some snow" ) @CommandPermissions("worldedit.anvil.cfi") - public void snow(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + public void snow(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly); smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly); - fp.toWorldEditPlayer().print(TextComponent.of("Added snow!")); + fp.print(TextComponent.of("Added snow!")); assertSettings(fp).resetComponent(); component(fp); } @@ -369,7 +367,7 @@ public class CFICommands { "Below 50 will prefer to color with blocks" ) @CommandPermissions("worldedit.anvil.cfi") - public void biomepriority(FawePlayer fp, int value) { + public void biomepriority(Player fp, int value) { assertSettings(fp).getGenerator().setBiomePriority(value); coloring(fp); } @@ -382,7 +380,7 @@ public class CFICommands { "`#clipboard` will only use the blocks present in your clipboard." ) @CommandPermissions("worldedit.anvil.cfi") - public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String argOpt) throws EmptyClipboardException, InputParseException, FileNotFoundException { + public void paletteblocks(Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String argOpt) throws EmptyClipboardException, InputParseException, FileNotFoundException { if (argOpt == null) { TextComponent build = TextComponent.builder("What blocks do you want to color with?") .append(newline()) @@ -405,14 +403,14 @@ public class CFICommands { .append(TextComponent.of("< [Back]").clickEvent(ClickEvent .runCommand("/cfi coloring"))) .build(); - fp.toWorldEditPlayer().print(build); + player.print(build); return; } - HeightMapMCAGenerator generator = assertSettings(fp).getGenerator(); + HeightMapMCAGenerator generator = assertSettings(player).getGenerator(); ParserContext context = new ParserContext(); - context.setActor(fp.getPlayer()); - context.setWorld(fp.getWorld()); - context.setSession(fp.getSession()); + context.setActor(player); + context.setWorld(player.getWorld()); + context.setSession(player.getSession()); context.setExtent(generator); Request.request().setExtent(generator); @@ -424,7 +422,7 @@ public class CFICommands { return; } case "#clipboard": { - ClipboardHolder holder = fp.getSession().getClipboard(); + ClipboardHolder holder = player.getSession().getClipboard(); Clipboard clipboard = holder.getClipboard(); boolean[] ids = new boolean[BlockTypes.size()]; for (BlockVector3 pt : clipboard.getRegion()) { @@ -460,7 +458,7 @@ public class CFICommands { } } generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks)); - coloring(fp); + coloring(player); } @Command( @@ -471,9 +469,9 @@ public class CFICommands { "Randomization will allow mixing biomes when coloring with biomes" ) @CommandPermissions("worldedit.anvil.cfi") - public void randomization(FawePlayer fp, boolean enabled) { - assertSettings(fp).getGenerator().setTextureRandomVariation(enabled); - coloring(fp); + public void randomization(Player player, boolean enabled) { + assertSettings(player).getGenerator().setTextureRandomVariation(enabled); + coloring(player); } @Command( @@ -485,14 +483,14 @@ public class CFICommands { "Using 0 73 for the min/max would use the simplest 73% of blocks for coloring, and is a reasonable value." ) @CommandPermissions("worldedit.anvil.cfi") - public void complexity(FawePlayer fp, int min, int max) throws FileNotFoundException { - HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); + public void complexity(Player player, int min, int max) throws FileNotFoundException { + HeightMapMCAGenerator gen = assertSettings(player).getGenerator(); if (min == 0 && max == 100) { gen.setTextureUtil(Fawe.get().getTextureUtil()); } else { gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max)); } - coloring(fp); + coloring(player); } @Command( @@ -504,11 +502,11 @@ public class CFICommands { " - The distance is the spacing between each schematic" ) @CommandPermissions("worldedit.anvil.cfi") - public void schem(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask") Mask mask, String schematic, int rarity, int distance, boolean rotate)throws IOException, WorldEditException { - HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); + public void schem(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask") Mask mask, String schematic, int rarity, int distance, boolean rotate)throws IOException, WorldEditException { + HeightMapMCAGenerator gen = assertSettings(player).getGenerator(); - World world = fp.getWorld(); - MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(fp.getPlayer(), schematic, null, true); + World world = player.getWorld(); + MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, schematic, null, true); if (multi == null) { return; } @@ -517,8 +515,8 @@ public class CFICommands { } else { gen.addSchems(load(imageMask), mask, multi.getHolders(), rarity, distance, rotate); } - fp.toWorldEditPlayer().print(TextComponent.of("Added schematics!")); - populate(fp); + player.print(TextComponent.of("Added schematics!")); + populate(player); } @Command( @@ -530,8 +528,8 @@ public class CFICommands { " - If a mask is used, the biome will be set anywhere the mask applies" ) @CommandPermissions("worldedit.anvil.cfi") - public void biome(FawePlayer fp, @Arg(name = "biome", desc = "Biome type") BiomeType biomeType, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ - HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); + public void biome(Player player, @Arg(name = "biome", desc = "Biome type") BiomeType biomeType, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ + HeightMapMCAGenerator gen = assertSettings(player).getGenerator(); if (image != null) { gen.setBiome(load(image), biomeType, !disableWhiteOnly); } else if (maskOpt != null) { @@ -539,9 +537,9 @@ public class CFICommands { } else { gen.setBiome(biomeType); } - fp.toWorldEditPlayer().print(TextComponent.of("Set biome!")); - assertSettings(fp).resetComponent(); - component(fp); + player.print(TextComponent.of("Set biome!")); + assertSettings(player).resetComponent(); + component(player); } @Command( @@ -549,9 +547,9 @@ public class CFICommands { desc = "Generate vanilla caves" ) @CommandPermissions("worldedit.anvil.cfi") - public void caves(FawePlayer fp) throws WorldEditException { + public void caves(Player fp) throws WorldEditException { assertSettings(fp).getGenerator().addCaves(); - fp.toWorldEditPlayer().print(TextComponent.of("Added caves!")); + fp.print(TextComponent.of("Added caves!")); populate(fp); } @@ -561,9 +559,9 @@ public class CFICommands { descFooter = "Use a specific pattern and settings to generate ore" ) @CommandPermissions("worldedit.anvil.cfi") - public void ore(FawePlayer fp, @Arg(name = "mask", desc = "Mask") Mask mask, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException { + public void ore(Player fp, @Arg(name = "mask", desc = "Mask") Mask mask, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException { assertSettings(fp).getGenerator().addOre(mask, patternArg, size, frequency, rariry, minY, maxY); - fp.toWorldEditPlayer().print(TextComponent.of("Added ore!")); + fp.print(TextComponent.of("Added ore!")); populate(fp); } @@ -572,9 +570,9 @@ public class CFICommands { desc = "Generate the vanilla ores" ) @CommandPermissions("worldedit.anvil.cfi") - public void ores(FawePlayer fp, @Arg(name = "mask", desc = "Mask") Mask mask) throws WorldEditException { + public void ores(Player fp, @Arg(name = "mask", desc = "Mask") Mask mask) throws WorldEditException { assertSettings(fp).getGenerator().addDefaultOres(mask); - fp.toWorldEditPlayer().print(TextComponent.of("Added ores!")); + fp.print(TextComponent.of("Added ores!")); populate(fp); } @@ -584,14 +582,14 @@ public class CFICommands { descFooter = "Set the terrain height either based on an image heightmap, or a numeric value." ) @CommandPermissions("worldedit.anvil.cfi") - public void height(FawePlayer fp, String imageStr) throws WorldEditException { + public void height(Player fp, String imageStr) throws WorldEditException { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (!MathMan.isInteger(imageStr)) { gen.setHeight(ImageUtil.getImage(imageStr)); } else { gen.setHeights(Integer.parseInt(imageStr)); } - fp.toWorldEditPlayer().print("Set Height!"); + fp.print("Set Height!"); component(fp); } @@ -600,11 +598,11 @@ public class CFICommands { desc = "Change the block used for water\ne.g. Lava" ) @CommandPermissions("worldedit.anvil.cfi") - public void waterId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { + public void waterId(Player fp, BlockStateHolder block) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setWaterId(block.getBlockType().getInternalId()); - fp.toWorldEditPlayer().print("Set water id!"); + fp.print("Set water id!"); settings.resetComponent(); component(fp); } @@ -615,10 +613,10 @@ public class CFICommands { desc = "Change the block used for the base\ne.g. Bedrock" ) @CommandPermissions("worldedit.anvil.cfi") - public void baseId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { + public void baseId(Player fp, BlockStateHolder block) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBedrockId(block.getBlockType().getInternalId()); - fp.toWorldEditPlayer().print(TextComponent.of("Set base id!")); + fp.print(TextComponent.of("Set base id!")); settings.resetComponent(); component(fp); } @@ -630,9 +628,9 @@ public class CFICommands { " - A value of 0 is the default and will not modify the height" ) @CommandPermissions("worldedit.anvil.cfi") - public void worldthickness(FawePlayer fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { + public void worldthickness(Player fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { assertSettings(fp).getGenerator().setWorldThickness(heightArg); - fp.toWorldEditPlayer().print(TextComponent.of("Set world thickness!")); + fp.print("Set world thickness!"); component(fp); } @@ -643,9 +641,9 @@ public class CFICommands { " - A value of 0 is the default and will only set the top block" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorthickness(FawePlayer fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { + public void floorthickness(Player fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { assertSettings(fp).getGenerator().setFloorThickness(heightArg); - fp.toWorldEditPlayer().print(TextComponent.of("Set floor thickness!")); + fp.print("Set floor thickness!"); component(fp); } @@ -655,9 +653,9 @@ public class CFICommands { desc = "Resend the CFI chunks" ) @CommandPermissions("worldedit.anvil.cfi") - public void update(FawePlayer fp) throws WorldEditException { + public void update(Player fp) throws WorldEditException { assertSettings(fp).getGenerator().update(); - fp.toWorldEditPlayer().print(TextComponent.of("Chunks refreshed!")); + fp.print("Chunks refreshed!"); mainMenu(fp); } @@ -667,14 +665,13 @@ public class CFICommands { desc = "Teleport to the CFI virtual world" ) @CommandPermissions("worldedit.anvil.cfi") - public void tp(FawePlayer fp) throws WorldEditException { - HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); - fp.toWorldEditPlayer().print(TextComponent.of("Teleporting...")); + public void tp(Player player) throws WorldEditException { + HeightMapMCAGenerator gen = assertSettings(player).getGenerator(); + player.print("Teleporting..."); Vector3 origin = gen.getOrigin(); - Player player = fp.getPlayer(); player.setPosition(origin.subtract(16, 0, 16)); player.findFreePosition(); - mainMenu(fp); + mainMenu(player); } @Command( @@ -685,9 +682,9 @@ public class CFICommands { " - By default water is disabled (with a value of 0)" ) @CommandPermissions("worldedit.anvil.cfi") - public void waterheight(FawePlayer fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { + public void waterheight(Player fp, @Arg(name = "height", desc = "brush height") int heightArg) throws WorldEditException { assertSettings(fp).getGenerator().setWaterHeight(heightArg); - fp.toWorldEditPlayer().print(TextComponent.of("Set water height!")); + fp.print("Set water height!"); component(fp); } @@ -698,10 +695,10 @@ public class CFICommands { ) // ![79,174,212,5:3,5:4,18,161,20] @CommandPermissions("worldedit.anvil.cfi") - public void glass(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void glass(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setColorWithGlass(load(image)); - fp.toWorldEditPlayer().print(TextComponent.of("Set color with glass!")); + fp.print("Set color with glass!"); settings.resetColoring(); mainMenu(fp); } @@ -715,7 +712,7 @@ public class CFICommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void color(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void color(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); HeightMapMCAGenerator gen = settings.getGenerator(); if (imageMask != null) { @@ -726,7 +723,7 @@ public class CFICommands { gen.setColor(load(image)); } settings.resetColoring(); - fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks!")); + fp.print("Set color with blocks!"); mainMenu(fp); } @@ -739,10 +736,10 @@ public class CFICommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void blockbiome(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void blockbiome(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBlockAndBiomeColor(load(image), maskOpt, load(imageMask), !disableWhiteOnly); - fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks and biomes!")); + fp.print(TextComponent.of("Set color with blocks and biomes!")); settings.resetColoring(); mainMenu(fp); } @@ -755,10 +752,10 @@ public class CFICommands { " - If you changed the block to something other than grass you will not see anything." ) @CommandPermissions("worldedit.anvil.cfi") - public void biomecolor(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { + public void biomecolor(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { CFISettings settings = assertSettings(fp); settings.getGenerator().setBiomeColor(load(image)); - fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!")); + fp.print(TextComponent.of("Set color with biomes!")); settings.resetColoring(); mainMenu(fp); } @@ -770,7 +767,7 @@ public class CFICommands { desc = "Color the world using an image" ) @CommandPermissions("worldedit.anvil.cfi") - public void coloring(FawePlayer fp) { + public void coloring(Player fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); settings.setCategory(this::coloring); @@ -847,7 +844,7 @@ public class CFICommands { .append("[None]");//.cmdTip("/cfi " + Commands.getAlias(Command.class, "image")).append(newline()); } builder.append("< [Back]");//.cmdTip(alias()).send(fp); - fp.toWorldEditPlayer().print(builder.build()); + fp.print(builder.build()); } @Command( @@ -855,7 +852,7 @@ public class CFICommands { desc = "Select a mask" ) @CommandPermissions("worldedit.anvil.cfi") - public void mask(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){ + public void mask(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){ CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -882,7 +879,7 @@ public class CFICommands { .append( TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(s2))) .clickEvent(ClickEvent.runCommand(s2))).build(); - fp.toWorldEditPlayer().print(build); + fp.print(build); } @Command( @@ -890,7 +887,7 @@ public class CFICommands { desc = "Select a pattern" ) @CommandPermissions("worldedit.anvil.cfi") - public void pattern(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern patternArg, InjectedValueAccess context)throws CommandException { + public void pattern(Player fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern patternArg, InjectedValueAccess context)throws CommandException { CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -912,7 +909,7 @@ public class CFICommands { .append(TextComponent.of("< [Back]") .hoverEvent(HoverEvent.showText(TextComponent.of(s1))) .clickEvent(ClickEvent.runCommand(s1))).build(); - fp.toWorldEditPlayer().print(build); + fp.print(build); } } @@ -921,15 +918,15 @@ public class CFICommands { desc = "Download the current image" ) @CommandPermissions("worldedit.anvil.cfi") - public void download(FawePlayer fp)throws IOException { - CFISettings settings = assertSettings(fp); + public void download(Player player)throws IOException { + CFISettings settings = assertSettings(player); BufferedImage image = settings.getGenerator().draw(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "jpg", baos); byte[] data = baos.toByteArray(); - fp.sendMessage("Please wait..."); + player.print("Please wait..."); URL url = ImgurUtility.uploadImage(data); - BBC.DOWNLOAD_LINK.send(fp, url); + BBC.DOWNLOAD_LINK.send(player, url); } @Command( @@ -937,7 +934,7 @@ public class CFICommands { desc = "Select an image" ) @CommandPermissions("worldedit.anvil.cfi") - public void image(FawePlayer fp, @Arg(desc = "image url or filename", def = "") ProvideBindings.ImageUri image, InjectedValueAccess context)throws CommandException { + public void image(Player fp, @Arg(desc = "image url or filename", def = "") ProvideBindings.ImageUri image, InjectedValueAccess context)throws CommandException { CFISettings settings = getSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; @@ -952,7 +949,7 @@ public class CFICommands { .append(newline()) .append("From a file: ").append(TextComponent.of("[Click Here]").clickEvent(ClickEvent.suggestCommand("/cfi image file://"))) .build(); - fp.toWorldEditPlayer().print(build); + fp.print(build); } else { if (settings.hasGenerator()) { coloring(fp); @@ -969,9 +966,9 @@ public class CFICommands { desc = "" ) @CommandPermissions("worldedit.anvil.cfi") - public void populate(FawePlayer fp) { - CFISettings settings = assertSettings(fp); - settings.popMessages(fp); + public void populate(Player player) { + CFISettings settings = assertSettings(player); + settings.popMessages(player); settings.setCategory(this::populate); TextComponent build = TextComponent.builder("What would you like to populate?") .append(newline()) @@ -980,7 +977,7 @@ public class CFICommands { .append(newline()) .append(TextComponent.of("< [Back]").clickEvent(ClickEvent.runCommand("/cfi"))) .build(); - fp.toWorldEditPlayer().print(build); + player.print(build); } @Command( @@ -989,9 +986,9 @@ public class CFICommands { desc = "Components menu" ) @CommandPermissions("worldedit.anvil.cfi") - public void component(FawePlayer fp) { - CFISettings settings = assertSettings(fp); - settings.popMessages(fp); + public void component(Player player) { + CFISettings settings = assertSettings(player); + settings.popMessages(player); settings.setCategory(this::component); String mask; @@ -1007,10 +1004,10 @@ public class CFICommands { StringBuilder maskArgs = new StringBuilder(); if (settings.imageMask != null) { - maskArgs.append(" " + settings.imageMaskArg); + maskArgs.append(" ").append(settings.imageMaskArg); } if (settings.mask != null) { - maskArgs.append(" " + settings.maskArg); + maskArgs.append(" ").append(settings.maskArg); } if (!settings.whiteOnly) { maskArgs.append(" -w"); @@ -1090,11 +1087,11 @@ public class CFICommands { msg.append(newline()) .append(TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi"))).clickEvent(ClickEvent.runCommand("/cfi"))); - fp.toWorldEditPlayer().print(msg.build()); + player.print(msg.build()); } - private static CFISettings assertSettings(FawePlayer fp) { - CFISettings settings = getSettings(fp); + private static CFISettings assertSettings(Player player) { + CFISettings settings = getSettings(player); if (!settings.hasGenerator()) { throw new StopExecutionException(TextComponent.of("Please use /cfi")); } @@ -1102,13 +1099,13 @@ public class CFICommands { } - protected static CFISettings getSettings(FawePlayer fp) { + protected static CFISettings getSettings(Player fp) { CFISettings settings = fp.getMeta("CFISettings"); return settings == null ? new CFISettings(fp) : settings; } public static class CFISettings { - private final FawePlayer fp; + private final Player player; private HeightMapMCAGenerator generator; @@ -1123,12 +1120,12 @@ public class CFICommands { protected Pattern pattern; protected String patternArg; - protected Consumer category; + protected Consumer category; private boolean bound; - public CFISettings(FawePlayer player) { - this.fp = player; + public CFISettings(Player player) { + this.player = player; } public boolean hasGenerator() { @@ -1174,47 +1171,47 @@ public class CFICommands { pattern = null; } - public Consumer getCategory() { + public Consumer getCategory() { return category; } - public void setCategory(Consumer methodRef) { + public void setCategory(Consumer methodRef) { this.category = category; } public CFISettings setGenerator(HeightMapMCAGenerator generator) { this.generator = generator; if (bound) { - fp.getSession().setVirtualWorld(generator); + player.getSession().setVirtualWorld(generator); } return this; } public CFISettings bind() { if (generator != null) { - fp.getSession().setVirtualWorld(generator); + player.getSession().setVirtualWorld(generator); } bound = true; - fp.setMeta("CFISettings", this); + player.setMeta("CFISettings", this); return this; } - public void popMessages(FawePlayer fp) { - ArrayDeque messages = fp.deleteMeta("CFIBufferedMessages"); + public void popMessages(Player player) { + ArrayDeque messages = player.deleteMeta("CFIBufferedMessages"); if (messages != null) { for (String message : messages) { - fp.sendMessage(message); + player.print(message); } } } public CFISettings remove() { - fp.deleteMeta("CFISettings"); + player.deleteMeta("CFISettings"); HeightMapMCAGenerator gen = this.generator; if (gen != null) { - fp.getSession().setVirtualWorld(null); + player.getSession().setVirtualWorld(null); } - popMessages(fp); + popMessages(player); bound = false; generator = null; image = null; @@ -1229,7 +1226,7 @@ public class CFICommands { } @SuppressWarnings("unused") - protected static void mainMenu(FawePlayer fp) { + protected static void mainMenu(Player player) { //TODO // msg("What do you want to do now?").append(newline()) // .cmdOptions("/cfi ", "", "Coloring", "Component", "Populate", "Brush") diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java index 4ce6f4507..ee1ee80ec 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/PlotLoader.java @@ -1,6 +1,6 @@ package com.boydti.fawe.command; -import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.command.CFICommands.CFISettings; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.PlotSquared; @@ -15,7 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; - +import com.sk89q.worldedit.entity.Player; import java.io.File; import java.io.IOException; import java.util.function.Function; @@ -36,15 +36,15 @@ public class PlotLoader { () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone)); } - public void load(FawePlayer fp, CFICommands.CFISettings settings, + public void load(Player fp, CFISettings settings, Function createTask) throws IOException { PlotAreaManager manager = PlotSquared.get().getPlotAreaManager(); if (manager instanceof SinglePlotAreaManager) { SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager; SinglePlotArea area = sManager.getArea(); - PlotPlayer player = PlotPlayer.wrap(fp.parent); + PlotPlayer player = PlotPlayer.get(fp.getName()); - fp.sendMessage("Claiming world"); + fp.print("Claiming world"); Plot plot = TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Plot o) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index 1043018c6..9beca2402 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -5,13 +5,14 @@ import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; -import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; @@ -27,7 +28,11 @@ public class Rollback extends FaweCommand { } @Override - public boolean execute(FawePlayer player, String... args) { + public boolean execute(Actor actor, String... args) { + if (!(actor.isPlayer() && actor instanceof Player)) { + return false; + } + Player player = (Player) actor; if (!Settings.IMP.HISTORY.USE_DATABASE) { BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); return false; @@ -58,13 +63,13 @@ public class Rollback extends FaweCommand { BBC.COMMAND_SYNTAX.send(player, "/frb u: r: t: