Remove FawePlayer and API modifications

Dieser Commit ist enthalten in:
MattBDev 2019-09-13 23:05:16 -04:00
Ursprung c65e06cb1b
Commit 14ed3f1d9c
105 geänderte Dateien mit 1614 neuen und 2407 gelöschten Zeilen

Datei anzeigen

@ -1,12 +1,17 @@
package com.boydti.fawe.bukkit; package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweCommand; 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.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class BukkitCommand implements CommandExecutor { public class BukkitCommand implements CommandExecutor {
@ -19,7 +24,7 @@ public class BukkitCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, Command cmd, String label, String[] args) { 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()) { if (!sender.hasPermission(this.cmd.getPerm()) && !sender.isOp()) {
BBC.NO_PERM.send(plr, this.cmd.getPerm()); BBC.NO_PERM.send(plr, this.cmd.getPerm());
return true; return true;
@ -27,4 +32,24 @@ public class BukkitCommand implements CommandExecutor {
this.cmd.executeSafe(plr, args); this.cmd.executeSafe(plr, args);
return true; 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);
}
} }

Datei anzeigen

@ -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<Player> {
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);
}
}

Datei anzeigen

@ -6,25 +6,40 @@ import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler;
import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.listener.BukkitImageListener; 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.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.BukkitTaskMan;
import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.ItemUtil;
import com.boydti.fawe.bukkit.util.VaultUtil; import com.boydti.fawe.bukkit.util.VaultUtil;
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; 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.config.Settings;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.Jars; import com.boydti.fawe.util.Jars;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.World; 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.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
@ -38,14 +53,6 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; 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 { public class FaweBukkit implements IFawe, Listener {
// private final WorldEditPlugin plugin; // private final WorldEditPlugin plugin;
@ -74,14 +81,7 @@ public class FaweBukkit implements IFawe, Listener {
e.printStackTrace(); e.printStackTrace();
debug("==================================="); debug("===================================");
} }
if (Bukkit.getVersion().contains("git-Spigot")) { if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
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) {
new RenderListener(plugin); new RenderListener(plugin);
} }
} catch (final Throwable e) { } catch (final Throwable e) {
@ -122,7 +122,7 @@ public class FaweBukkit implements IFawe, Listener {
} }
@Override @Override
public synchronized ImageViewer getImageViewer(FawePlayer fp) { public synchronized ImageViewer getImageViewer(com.sk89q.worldedit.entity.Player fp) {
if (listeningImages && imageListener == null) return null; if (listeningImages && imageListener == null) return null;
try { try {
listeningImages = true; listeningImages = true;
@ -143,7 +143,7 @@ public class FaweBukkit implements IFawe, Listener {
fos.write(jarData); fos.write(jarData);
} }
} }
BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp.toWorldEditPlayer())); BukkitImageViewer viewer = new BukkitImageViewer(BukkitAdapter.adapt(fp));
if (imageListener == null) { if (imageListener == null) {
this.imageListener = new BukkitImageListener(plugin); this.imageListener = new BukkitImageListener(plugin);
} }
@ -195,34 +195,21 @@ public class FaweBukkit implements IFawe, Listener {
} }
@Override @Override
public FawePlayer<Player> wrap(final Object obj) { public com.sk89q.worldedit.entity.Player wrap(final Object obj) {
if (obj.getClass() == String.class) { if (obj.getClass() == String.class) {
String name = (String) obj; String name = (String) obj;
FawePlayer existing = Fawe.get().getCachedPlayer(name); com.sk89q.worldedit.entity.Player existing = Fawe.get().getCachedPlayer(name);
if (existing != null) { if (existing != null) {
return existing; return existing;
} }
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name);
return player != null ? new BukkitPlayer(player) : null; return player != null ? BukkitAdapter.adapt(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 null;
} }
@Override public void startMetrics() { @Override public void startMetrics() {
new MetricsLite(plugin); new Metrics(plugin);
} }
public ItemUtil getItemUtil() { public ItemUtil getItemUtil() {
@ -347,7 +334,7 @@ public class FaweBukkit implements IFawe, Listener {
final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) { if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) {
try { try {
managers.add(new PreciousStonesFeature(preciousStonesPlugin, this)); managers.add(new PreciousStonesFeature(preciousStonesPlugin));
Fawe.debug("Plugin 'PreciousStones' found. Using it now."); Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@ -399,9 +386,9 @@ public class FaweBukkit implements IFawe, Listener {
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String name = player.getName(); String name = player.getName();
FawePlayer fp = Fawe.get().getCachedPlayer(name); com.sk89q.worldedit.entity.Player wePlayer = Fawe.get().getCachedPlayer(name);
if (fp != null) { if (wePlayer != null) {
fp.unregister(); wePlayer.unregister();
Fawe.get().unregister(name); Fawe.get().unregister(name);
} }
} }

Datei anzeigen

@ -1,10 +1,11 @@
package com.boydti.fawe.bukkit.listener; 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.MovableTool;
import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.ResettableTool;
import com.boydti.fawe.object.brush.scroll.ScrollTool; import com.boydti.fawe.object.brush.scroll.ScrollTool;
import com.sk89q.worldedit.LocalSession; 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 com.sk89q.worldedit.command.tool.Tool;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -29,9 +30,8 @@ public class BrushListener implements Listener {
if (bukkitPlayer.isSneaking()) { if (bukkitPlayer.isSneaking()) {
return; return;
} }
FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); BukkitPlayer player = BukkitAdapter.adapt(bukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = player.getSession();
LocalSession session = fp.getSession();
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof ScrollTool) { if (tool instanceof ScrollTool) {
final int slot = event.getNewSlot(); final int slot = event.getNewSlot();
@ -55,9 +55,8 @@ public class BrushListener implements Listener {
Location to = event.getTo(); 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()) { 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(); Player bukkitPlayer = event.getPlayer();
FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = player.getSession();
LocalSession session = fp.getSession();
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool != null) { if (tool != null) {
if (tool instanceof MovableTool) { if (tool instanceof MovableTool) {
@ -74,9 +73,8 @@ public class BrushListener implements Listener {
if (event.getAction() == Action.PHYSICAL) { if (event.getAction() == Action.PHYSICAL) {
return; return;
} }
FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); com.sk89q.worldedit.entity.Player player = BukkitAdapter.adapt(bukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = player.getSession();
LocalSession session = fp.getSession();
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof ResettableTool) { if (tool instanceof ResettableTool) {
if (((ResettableTool) tool).reset()) { if (((ResettableTool) tool).reset()) {

Datei anzeigen

@ -3,9 +3,8 @@ package com.boydti.fawe.bukkit.listener;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
import com.boydti.fawe.command.CFICommands; 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.BrushSettings;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.TaskManager; 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.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException; 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.BrushTool;
import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; 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.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Rotation; import org.bukkit.Rotation;
@ -42,13 +49,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.plugin.Plugin; 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 { public class BukkitImageListener implements Listener {
private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0); private Location mutable = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
@ -63,7 +63,7 @@ public class BukkitImageListener implements Listener {
Iterator<Player> iter = recipients.iterator(); Iterator<Player> iter = recipients.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Player player = iter.next(); Player player = iter.next();
FawePlayer<Object> fp = FawePlayer.wrap(player); BukkitPlayer fp = BukkitAdapter.adapt(player);
CFICommands.CFISettings settings = fp.getMeta("CFISettings"); CFICommands.CFISettings settings = fp.getMeta("CFISettings");
if (player.equals(event.getPlayer()) || !fp.hasMeta() || settings == null || !settings.hasGenerator()) { if (player.equals(event.getPlayer()) || !fp.hasMeta() || settings == null || !settings.hasGenerator()) {
continue; continue;
@ -106,7 +106,7 @@ public class BukkitImageListener implements Listener {
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
FawePlayer<Object> fp = FawePlayer.wrap(player); BukkitPlayer fp = BukkitAdapter.adapt(player);
if (fp.getMeta("CFISettings") == null) { if (fp.getMeta("CFISettings") == null) {
return; return;
} }
@ -189,7 +189,7 @@ public class BukkitImageListener implements Listener {
} }
ItemFrame itemFrame = (ItemFrame) entity; ItemFrame itemFrame = (ItemFrame) entity;
FawePlayer<Object> fp = FawePlayer.wrap(player); BukkitPlayer fp = BukkitAdapter.adapt(player);
CFICommands.CFISettings settings = fp.getMeta("CFISettings"); CFICommands.CFISettings settings = fp.getMeta("CFISettings");
HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator(); HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
BukkitImageViewer viewer = get(generator); BukkitImageViewer viewer = get(generator);
@ -204,7 +204,7 @@ public class BukkitImageListener implements Listener {
LocalSession session = fp.getSession(); LocalSession session = fp.getSession();
BrushTool tool; BrushTool tool;
try { try {
tool = session.getBrushTool(fp.getPlayer(), false); tool = session.getBrushTool(fp, false);
} catch (InvalidToolBindException e) { } catch (InvalidToolBindException e) {
return; return;
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.listener; package com.boydti.fawe.bukkit.listener;
import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal3; import com.boydti.fawe.object.RunnableVal3;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.comphenix.protocol.PacketType; 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.ChunkCoordIntPair;
import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.EnumWrappers;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.bukkit.BukkitAdapter; 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.BlockInteractEvent;
import com.sk89q.worldedit.event.platform.Interaction; import com.sk89q.worldedit.event.platform.Interaction;
import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.math.BlockVector3; 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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import java.lang.reflect.InvocationTargetException;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.Plugin; 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) { private boolean sendBlockChange(Player plr, VirtualWorld gen, BlockVector3 pt, Interaction action) {
PlatformManager platform = WorldEdit.getInstance().getPlatformManager(); 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()); com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt.toVector3());
BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action); BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action);
platform.handleBlockInteract(toCall); platform.handleBlockInteract(toCall);
@ -265,10 +255,10 @@ public class CFIPacketListener implements Listener {
} }
private VirtualWorld getGenerator(Player player) { private VirtualWorld getGenerator(Player player) {
FawePlayer<Object> fp = FawePlayer.wrap(player); BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
VirtualWorld vw = fp.getSession().getVirtualWorld(); VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
if (vw != null) return vw; 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()) { if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
return settings.getGenerator(); return settings.getGenerator();
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -24,12 +23,11 @@ public class ASkyBlockHook extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player player, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Location location = BukkitAdapter.adapt(player).getLocation();
final Location location = player.getLocation();
Island island = ASkyBlockAPI.getInstance().getIslandAt(location); 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(); Location center1 = island.getCenter();
MutableBlockVector3 center = MutableBlockVector3.at(center1.getX(), center1.getY(), center1.getZ()); 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) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), island, type); return isAllowed(BukkitAdapter.adapt(player), island, type);
} }
}; };
} }

Datei anzeigen

@ -3,7 +3,7 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class BukkitMaskManager extends FaweMaskManager<Player> { public abstract class BukkitMaskManager extends FaweMaskManager {
public BukkitMaskManager(final String plugin) { public BukkitMaskManager(final String plugin) {
super(plugin); super(plugin);

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
@ -21,15 +20,15 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(p);
final Location loc = player.getLocation(); final Location loc = player.getLocation();
final PS ps = PS.valueOf(loc); final PS ps = PS.valueOf(loc);
final Faction fac = BoardColl.get().getFactionAt(ps); final Faction fac = BoardColl.get().getFactionAt(ps);
if (fac != null) { if (fac != null) {
if (type == MaskType.OWNER) { if (type == MaskType.OWNER) {
MPlayer leader = fac.getLeader(); 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 Chunk chunk = loc.getChunk();
final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16); final BlockVector3 pos1 = BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16);
final BlockVector3 pos2 = BlockVector3 final BlockVector3 pos2 = BlockVector3

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Permission; import com.boydti.fawe.util.Permission;
@ -26,11 +25,10 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(p);
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission final boolean perm = Permission.hasPermission(p, "fawe.factions.wilderness");
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
final World world = player.getWorld(); final World world = player.getWorld();
RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Permission; 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.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -26,11 +24,10 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player p, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(p);
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Permission final boolean perm = Permission.hasPermission(p, "fawe.factions.wilderness");
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
final World world = player.getWorld(); final World world = player.getWorld();
RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());

Datei anzeigen

@ -2,22 +2,19 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld; import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import java.util.ArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventException; import org.bukkit.event.EventException;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import java.util.ArrayList;
public class FreeBuildRegion extends BukkitMaskManager { public class FreeBuildRegion extends BukkitMaskManager {
private final ArrayList<RegisteredListener> listeners; private final ArrayList<RegisteredListener> listeners;
@ -38,7 +35,7 @@ public class FreeBuildRegion extends BukkitMaskManager {
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> player, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player player, MaskType type) {
if (type != MaskType.MEMBER) return null; if (type != MaskType.MEMBER) return null;
ArrayList<RegisteredListener> currRegList = new ArrayList<>(); ArrayList<RegisteredListener> currRegList = new ArrayList<>();
for (RegisteredListener listener : this.listeners) { for (RegisteredListener listener : this.listeners) {
@ -49,20 +46,20 @@ public class FreeBuildRegion extends BukkitMaskManager {
if (currRegList.isEmpty()) return null; if (currRegList.isEmpty()) return null;
RegisteredListener[] listeners = currRegList.toArray(new RegisteredListener[0]); 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); AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
BlockVector3 pos1 = BlockVector3.ZERO; BlockVector3 pos1 = BlockVector3.ZERO;
BlockVector3 pos2 = BlockVector3.ZERO; BlockVector3 pos2 = BlockVector3.ZERO;
AsyncBlock block = new AsyncBlock(asyncWorld, 0, 0, 0); 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) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return bukkitWorld == BukkitAdapter.adapt(player.toWorldEditPlayer().getWorld()) && type == MaskType.MEMBER; return bukkitWorld == BukkitAdapter.adapt(player.getWorld()) && type == MaskType.MEMBER;
} }
@Override @Override

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.filter.GriefPreventionFilter; import com.boydti.fawe.bukkit.filter.GriefPreventionFilter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -26,8 +25,8 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null); final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(BukkitAdapter.adapt(fp.getLocation()), true, null);
if (claim != null) { if (claim != null) {
if (isAllowed(player, claim, type)) { if (isAllowed(player, claim, type)) {
@ -37,7 +36,7 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
return new FaweMask(pos1, pos2) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer fp, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player fp, MaskType type) {
return isAllowed(player, claim, type); return isAllowed(player, claim, type);
} }
}; };

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.bukkit.regions; 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.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import java.util.List; import java.util.List;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
import net.sacredlabyrinth.Phaed.PreciousStones.field.Field; import net.sacredlabyrinth.Phaed.PreciousStones.field.Field;
@ -17,7 +14,7 @@ import org.bukkit.plugin.Plugin;
public class PreciousStonesFeature extends BukkitMaskManager implements Listener { public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
public PreciousStonesFeature(Plugin preciousstonesPlugin, FaweBukkit p3) { public PreciousStonesFeature(Plugin preciousstonesPlugin) {
super(preciousstonesPlugin.getName()); super(preciousstonesPlugin.getName());
} }
@ -27,8 +24,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final Location location = player.getLocation(); final Location location = player.getLocation();
final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location); final List<Field> fields = PreciousStones.API().getFieldsProtectingArea(FieldFlag.ALL, location);
if (fields.isEmpty()) { if (fields.isEmpty()) {
@ -42,8 +39,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz()); BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
return new FaweMask(pos1, pos2) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), myField, type, fp.hasPermission("fawe.preciousstones.member")); return isAllowed(BukkitAdapter.adapt(player), myField, type, fp.hasPermission("fawe.preciousstones.member"));
} }
}; };
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.protection.ClaimedResidence; import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.CuboidArea; import com.bekvon.bukkit.residence.protection.CuboidArea;
import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,8 +27,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(final FawePlayer<Player> fp, final MaskType type) { public FaweMask getMask(final com.sk89q.worldedit.entity.Player fp, final MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final Location location = player.getLocation(); final Location location = player.getLocation();
ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location); ClaimedResidence residence = Residence.getInstance().getResidenceManager().getByLoc(location);
if (residence != null) { if (residence != null) {
@ -44,8 +43,8 @@ public class ResidenceFeature extends BukkitMaskManager implements Listener {
final ClaimedResidence finalResidence = residence; final ClaimedResidence finalResidence = residence;
return new FaweMask(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2)) { return new FaweMask(BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2)) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed((Player) BukkitAdapter.adapt(player.toWorldEditPlayer()), finalResidence, type); return isAllowed(BukkitAdapter.adapt(player), finalResidence, type);
} }
}; };
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.palmergames.bukkit.towny.Towny; import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
@ -62,36 +61,33 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp) { public FaweMask getMask(com.sk89q.worldedit.entity.Player fp) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final Location location = player.getLocation(); final Location location = player.getLocation();
try { try {
final PlayerCache cache = ((Towny) this.towny).getCache(player); final PlayerCache cache = ((Towny) this.towny).getCache(player);
final WorldCoord mycoord = cache.getLastTownBlock(); final WorldCoord mycoord = cache.getLastTownBlock();
if (mycoord == null) { if (mycoord == null) {
return null; return null;
} else { }
final TownBlock myplot = mycoord.getTownBlock(); final TownBlock myplot = mycoord.getTownBlock();
if (myplot == null) { if (myplot == null) {
return null; return null;
} else { }
boolean isMember = isAllowed(player, myplot); boolean isMember = isAllowed(player, myplot);
if (isMember) { if (isMember) {
final Chunk chunk = location.getChunk(); final Chunk chunk = location.getChunk();
final BlockVector3 pos1 = BlockVector3 final BlockVector3 pos1 = BlockVector3
.at(chunk.getX() * 16, 0, chunk.getZ() * 16); .at(chunk.getX() * 16, 0, chunk.getZ() * 16);
final BlockVector3 pos2 = BlockVector3.at( final BlockVector3 pos2 = BlockVector3.at(
chunk.getX() * 16 + 15, 156, chunk.getZ() * 16 chunk.getX() * 16 + 15, 156, chunk.getZ() * 16
+ 15); + 15);
return new FaweMask(pos1, pos2) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(BukkitAdapter.adapt(player.toWorldEditPlayer()), return isAllowed(BukkitAdapter.adapt(player),myplot);
myplot);
}
};
} }
} };
} }
} catch (Exception ignored) { } catch (Exception ignored) {
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
@ -90,8 +89,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final Location location = player.getLocation(); final Location location = player.getLocation();
final ProtectedRegion myregion = this.getRegion(localplayer, location); final ProtectedRegion myregion = this.getRegion(localplayer, location);
@ -108,8 +107,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
} else { } else {
return new FaweMask(adapt(myregion)) { return new FaweMask(adapt(myregion)) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
} }
}; };
} }
@ -117,8 +116,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
return new FaweMask(pos1, pos2) { return new FaweMask(pos1, pos2) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player.toWorldEditPlayer())), myregion); return isAllowed(worldguard.wrapPlayer(BukkitAdapter.adapt(player)), myregion);
} }
}; };
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.regions; package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.bukkit.filter.WorldGuardFilter; import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -30,8 +29,8 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
} }
@Override @Override
public FaweMask getMask(FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(com.sk89q.worldedit.entity.Player fp, MaskType type) {
final Player player = BukkitAdapter.adapt(fp.toWorldEditPlayer()); final Player player = BukkitAdapter.adapt(fp);
final LocalPlayer localplayer = this.worldguard.wrapPlayer(player); final LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
final RegionContainer container = WorldGuard.getInstance().getPlatform() final RegionContainer container = WorldGuard.getInstance().getPlatform()
.getRegionContainer(); .getRegionContainer();
@ -39,7 +38,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
return new FaweMask(new ManagerRegion(manager, localplayer)) { return new FaweMask(new ManagerRegion(manager, localplayer)) {
@Override @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 // We rely on the region mask instead of this
return true; return true;
} }

Datei anzeigen

@ -28,17 +28,16 @@ import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component; 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 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.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.BlockCommandSender; import org.bukkit.command.BlockCommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
import javax.annotation.Nullable;
public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable { public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements Locatable {
@ -72,21 +71,21 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override @Override
public void print(String msg) { public void print(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
sender.sendMessage("\u00A7d" + part); print(TextComponent.of(part, TextColor.LIGHT_PURPLE));
} }
} }
@Override @Override
public void printDebug(String msg) { public void printDebug(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
sender.sendMessage("\u00A77" + part); print(TextComponent.of(part, TextColor.GRAY));
} }
} }
@Override @Override
public void printError(String msg) { public void printError(String msg) {
for (String part : msg.split("\n")) { 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 Block block = sender.getBlock();
@NotNull World world = block.getWorld(); @NotNull World world = block.getWorld();
if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4)) { if (world.isChunkLoaded(block.getX() >> 4, block.getZ() >> 4)) {
@NotNull Material type = block.getType(); return sender.getBlock().getType() == Material.COMMAND_BLOCK
return type == Material.COMMAND_BLOCK || sender.getBlock().getType() == Material.CHAIN_COMMAND_BLOCK
|| type == Material.CHAIN_COMMAND_BLOCK || sender.getBlock().getType() == Material.REPEATING_COMMAND_BLOCK;
|| type == Material.REPEATING_COMMAND_BLOCK;
} }
return false; return false;
} }

Datei anzeigen

@ -23,16 +23,13 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter; import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import java.io.File;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; 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 static final UUID DEFAULT_ID = UUID.fromString("a233eb4b-4cab-42cd-9fd9-7e7b9a3f74be");
private CommandSender sender; private CommandSender sender;
private WorldEditPlugin plugin;
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) { public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
checkNotNull(plugin); checkNotNull(plugin);
checkNotNull(sender); checkNotNull(sender);
checkArgument(!(sender instanceof Player), "Cannot wrap a player"); checkArgument(!(sender instanceof Player), "Cannot wrap a player");
this.plugin = plugin;
this.sender = sender; this.sender = sender;
} }
@ -96,11 +95,6 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
TextAdapter.sendComponent(sender, component); TextAdapter.sendComponent(sender, component);
} }
@Override
public boolean canDestroyBedrock() {
return true;
}
@Override @Override
public String[] getGroups() { public String[] getGroups() {
return new String[0]; return new String[0];
@ -122,25 +116,6 @@ public class BukkitCommandSender extends AbstractNonPlayerActor {
public void checkPermission(String permission) throws AuthorizationException { 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 @Override
public SessionKey getSessionKey() { public SessionKey getSessionKey() {
return new SessionKey() { return new SessionKey() {

Datei anzeigen

@ -51,6 +51,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
@ -69,6 +70,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
public BukkitPlayer(WorldEditPlugin plugin, Player player) { public BukkitPlayer(WorldEditPlugin plugin, Player player) {
super();
this.plugin = plugin; this.plugin = plugin;
this.player = player; 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\"}]");
}
} }

Datei anzeigen

@ -508,7 +508,6 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
public void sendChunk(int X, int Z, int mask) { public void sendChunk(int X, int Z, int mask) {
} }
@Override @Override

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.Optional;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Event.Result; import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler; 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.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.Key;
import org.enginehub.piston.inject.MapBackedValueStore; import org.enginehub.piston.inject.MapBackedValueStore;
import java.util.Iterator;
import java.util.Optional;
/** /**
* Handles all events thrown in relation to a Player * Handles all events thrown in relation to a Player
*/ */
@ -73,23 +70,16 @@ public class WorldEditListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerCommandSend(PlayerCommandSendEvent event) { 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(); CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
InjectedValueStore store = null; event.getCommands().removeIf(name ->
Iterator<String> iter = event.getCommands().iterator(); // remove if in the manager and not satisfied
while (iter.hasNext()) { commandManager.getCommand(name)
String name = iter.next(); .filter(command -> !command.getCondition().satisfied(store))
Optional<Command> optional = commandManager.getCommand(name); .isPresent()
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();
}
}
}
} }
/** /**

Datei anzeigen

@ -19,14 +19,14 @@
package com.sk89q.worldedit.bukkit; 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.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit; 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.bukkit.adapter.mc1_14.Spigot_v1_14_R4;
import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.wepif.PermissionsResolverManager; import com.sk89q.wepif.PermissionsResolverManager;
import com.sk89q.worldedit.EditSession; 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.Capability;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag; 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.internal.command.CommandUtil;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory; 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.item.ItemType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import io.papermc.lib.PaperLib; 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.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Field; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -86,6 +70,28 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.ZipEntry; 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. * Plugin for Bukkit.
@ -171,9 +177,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// Setup platform // Setup platform
server = new BukkitServerInterface(this, getServer()); server = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(server); 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"); fail(() -> PermissionsResolverManager.initialize(INSTANCE), "Failed to initialize permissions resolver");
} }
@ -184,10 +193,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public void onEnable() { public void onEnable() {
if (INSTANCE != null) return; if (INSTANCE != null) return;
onLoad(); 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 PermissionsResolverManager.initialize(this); // Setup permission resolver
@ -204,7 +209,20 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
getServer().getPluginManager().registerEvents(new AsyncTabCompleteListener(), this); 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 // // Register 1.13 Material ids with LegacyMapper
// LegacyMapper legacyMapper = LegacyMapper.getInstance(); // LegacyMapper legacyMapper = LegacyMapper.getInstance();
@ -213,11 +231,24 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState()); // legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
// } // }
// } // }
// Enable metrics
new Metrics(this);
PaperLib.suggestPaper(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 // Biome
for (Biome biome : Biome.values()) { for (Biome biome : Biome.values()) {
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT); String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
@ -323,13 +354,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private void loadConfig() { private void loadConfig() {
createDefaultConfiguration("config-legacy.yml"); // Create the default configuration file createDefaultConfiguration("config-legacy.yml"); // Create the default configuration file
try { config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this);
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); config.load();
config.load();
} catch (Throwable e) {
getLogger().severe("Failed to load config.yml");
e.printStackTrace();
}
// Create schematics folder // Create schematics folder
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEdit worldEdit = WorldEdit.getInstance();
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir); File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
@ -380,7 +406,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public void onDisable() { public void onDisable() {
Fawe.get().onDisable(); Fawe.get().onDisable();
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().clear(); worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(server); worldEdit.getPlatformManager().unregister(server);
if (config != null) { if (config != null) {
config.unload(); config.unload();
@ -537,7 +563,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public Actor wrapCommandSender(CommandSender sender) { public Actor wrapCommandSender(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof Player) {
return wrapPlayer((Player) sender); return wrapPlayer((Player) sender);
} else if (sender instanceof BlockCommandSender) { } else if (config.commandBlockSupport && sender instanceof BlockCommandSender) {
return new BukkitBlockCommandSender(this, (BlockCommandSender) sender); return new BukkitBlockCommandSender(this, (BlockCommandSender) sender);
} }
@ -577,6 +603,16 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
return bukkitAdapter; 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 { private class AsyncTabCompleteListener implements Listener {
AsyncTabCompleteListener() { AsyncTabCompleteListener() {
} }

Datei anzeigen

@ -30,7 +30,7 @@ import java.util.zip.GZIPOutputStream;
* Check out https://bStats.org/ to learn more about bStats! * Check out https://bStats.org/ to learn more about bStats!
*/ */
@SuppressWarnings({"WeakerAccess", "unused"}) @SuppressWarnings({"WeakerAccess", "unused"})
public class MetricsLite { public class Metrics {
static { static {
// You can use the property to disable the check in your test environment // 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'}); new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
final String examplePackage = defaultPackage; final String examplePackage = defaultPackage;
// We want to make sure nobody just copy & pastes the example and use the wrong package names // 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!"); 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. * @param plugin The plugin which stats should be submitted.
*/ */
public MetricsLite(Plugin plugin) { public Metrics(Plugin plugin) {
if (plugin == null) { if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!"); throw new IllegalArgumentException("Plugin cannot be null!");
} }
@ -129,7 +129,7 @@ public class MetricsLite {
} catch (NoSuchFieldException ignored) { } } catch (NoSuchFieldException ignored) { }
} }
// Register our service // Register our service
Bukkit.getServicesManager().register(MetricsLite.class, this, plugin, ServicePriority.Normal); Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
if (!found) { if (!found) {
// We are the first! // We are the first!
startSubmitting(); startSubmitting();

Datei anzeigen

@ -1,10 +1,8 @@
package com.boydti.fawe; package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.command.CFICommand;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.object.brush.visualization.VisualQueue;
import com.boydti.fawe.regions.general.plot.PlotSquaredFeature; import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
import com.boydti.fawe.util.CachedTextureUtil; 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.TaskManager;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.github.luben.zstd.util.Native;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -192,8 +191,8 @@ public class Fawe {
} catch (Throwable ignored) {} } catch (Throwable ignored) {}
try { try {
imp().startMetrics(); imp().startMetrics();
} catch (Throwable ignored) { } catch (Throwable e) {
debug(ignored.getMessage()); debug(e.getMessage());
} }
}, 0); }, 0);
@ -334,7 +333,7 @@ public class Fawe {
*/ */
if (!Settings.IMP.EXPERIMENTAL.DISABLE_NATIVES) { if (!Settings.IMP.EXPERIMENTAL.DISABLE_NATIVES) {
try { try {
com.github.luben.zstd.util.Native.load(); Native.load();
} catch (Throwable e) { } catch (Throwable e) {
if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL > 6 || Settings.IMP.HISTORY.COMPRESSION_LEVEL > 6) { 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); Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL = Math.min(6, Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL);
@ -367,7 +366,6 @@ public class Fawe {
if (x86OS != x86JVM) { if (x86OS != x86JVM) {
debug("====== UPGRADE TO 64-BIT JAVA ======"); debug("====== UPGRADE TO 64-BIT JAVA ======");
debug("You are running 32-bit Java on a 64-bit machine"); debug("You are running 32-bit Java on a 64-bit machine");
debug(" - This is only a recommendation");
debug("===================================="); debug("====================================");
} }
} catch (Throwable ignore) {} } catch (Throwable ignore) {}
@ -402,9 +400,8 @@ public class Fawe {
mp.setUsageThreshold(alert); mp.setUsageThreshold(alert);
} }
} }
} catch (Throwable e) { } catch (Throwable ignored) {
debug("====== MEMORY LISTENER ERROR ======"); debug("====== MEMORY LISTENER ERROR ======");
e.printStackTrace();
debug("==================================="); debug("===================================");
debug("FAWE needs access to the JVM memory system:"); debug("FAWE needs access to the JVM memory system:");
debug(" - Change your Java security settings"); debug(" - Change your Java security settings");
@ -435,29 +432,29 @@ public class Fawe {
return this.thread = Thread.currentThread(); return this.thread = Thread.currentThread();
} }
private ConcurrentHashMap<String, FawePlayer> players = new ConcurrentHashMap<>(8, 0.9f, 1); private ConcurrentHashMap<String, Player> players = new ConcurrentHashMap<>(8, 0.9f, 1);
private ConcurrentHashMap<UUID, FawePlayer> playersUUID = new ConcurrentHashMap<>(8, 0.9f, 1); private ConcurrentHashMap<UUID, Player> playersUUID = new ConcurrentHashMap<>(8, 0.9f, 1);
public <T> void register(FawePlayer<T> player) { public <T> void register(Player player) {
players.put(player.getName(), player); players.put(player.getName(), player);
playersUUID.put(player.getUUID(), player); playersUUID.put(player.getUniqueId(), player);
} }
public <T> void unregister(String name) { public <T> void unregister(String name) {
FawePlayer player = players.remove(name); Player player = players.remove(name);
if (player != null) playersUUID.remove(player.getUUID()); if (player != null) playersUUID.remove(player.getUniqueId());
} }
public FawePlayer getCachedPlayer(String name) { public Player getCachedPlayer(String name) {
return players.get(name); return players.get(name);
} }
public FawePlayer getCachedPlayer(UUID uuid) { public Player getCachedPlayer(UUID uuid) {
return playersUUID.get(uuid); return playersUUID.get(uuid);
} }
public Collection<FawePlayer> getCachedPlayers() { public Collection<Player> getCachedPlayers() {
return players.values(); return players.values();
} }
} }

Datei anzeigen

@ -3,7 +3,6 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.exception.FaweException; 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.TaskManager;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.wrappers.WorldWrapper; import com.boydti.fawe.wrappers.WorldWrapper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser;
import com.sk89q.worldedit.extension.platform.Capability; 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.extension.platform.Platform;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; 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.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -48,6 +41,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
/** /**
* The FaweAPI class offers a few useful functions.<br> * The FaweAPI class offers a few useful functions.<br>
@ -149,21 +143,6 @@ public class FaweAPI {
// PlatformCommandManager.getInstance().registerCommands(clazz, aliases); TODO NOT IMPLEMENTED // PlatformCommandManager.getInstance().registerCommands(clazz, aliases); TODO NOT IMPLEMENTED
} }
/**
* Wrap some object into a FawePlayer<br>
* - 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<br> * You can either use a IQueueExtent or an EditSession to change blocks<br>
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br> * - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
@ -241,7 +220,7 @@ public class FaweAPI {
* @param player * @param player
* @return * @return
*/ */
public static Region[] getRegions(FawePlayer player) { public static Region[] getRegions(Player player) {
return WEManager.IMP.getMask(player); return WEManager.IMP.getMask(player);
} }
@ -395,7 +374,7 @@ public class FaweAPI {
* @param uuid * @param uuid
* @param index * @param index
* @return * @return
* @see DiskStorageHistory#toEditSession(FawePlayer) * @see DiskStorageHistory#toEditSession(Player)
*/ */
public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) { public static DiskStorageHistory getChangeSetFromDisk(World world, UUID uuid, int index) {
return new DiskStorageHistory(world, uuid, index); return new DiskStorageHistory(world, uuid, index);

Datei anzeigen

@ -2,12 +2,11 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.io.File; import java.io.File;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@ -20,7 +19,7 @@ public interface IFawe {
void setupCommand(final String label, final FaweCommand cmd); void setupCommand(final String label, final FaweCommand cmd);
FawePlayer wrap(final Object obj); Player wrap(final Object obj);
void setupVault(); void setupVault();
@ -32,7 +31,7 @@ public interface IFawe {
void startMetrics(); void startMetrics();
default ImageViewer getImageViewer(FawePlayer player) { default ImageViewer getImageViewer(Player player) {
return null; return null;
} }

Datei anzeigen

@ -2,10 +2,11 @@ package com.boydti.fawe.command;
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline; 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.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.changeset.CFIChangeSet; import com.boydti.fawe.object.changeset.CFIChangeSet;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,17 +24,17 @@ public class CFICommand extends CommandProcessor<Object, Object> {
@Override @Override
public List<String> preprocess(InjectedValueAccess context, List<String> args) { public List<String> preprocess(InjectedValueAccess context, List<String> args) {
FawePlayer fp = context.injectedValue(Key.of(FawePlayer.class)).orElseThrow(() -> new IllegalStateException("No player")); Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
CFICommands.CFISettings settings = CFICommands.getSettings(fp); CFICommands.CFISettings settings = CFICommands.getSettings(player);
settings.popMessages(fp); settings.popMessages(player);
args = dispatch(fp, settings, args, context); args = dispatch(player, settings, args, context);
HeightMapMCAGenerator gen = settings.getGenerator(); HeightMapMCAGenerator gen = settings.getGenerator();
if (gen != null && gen.isModified()) { if (gen != null && gen.isModified()) {
try { try {
gen.update(); gen.update();
CFIChangeSet set = new CFIChangeSet(gen, fp.getUUID()); CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId());
LocalSession session = fp.getSession(); LocalSession session = player.getSession();
session.remember(fp.getPlayer(), gen, set, fp.getLimit()); session.remember(player, gen, set, player.getLimit());
} catch (IOException e) { } catch (IOException e) {
throw new StopExecutionException(TextComponent.of(e.getMessage())); throw new StopExecutionException(TextComponent.of(e.getMessage()));
} }
@ -46,7 +47,7 @@ public class CFICommand extends CommandProcessor<Object, Object> {
return result; return result;
} }
private List<String> dispatch(FawePlayer fp, CFICommands.CFISettings settings, List<String> args, InjectedValueAccess context) { private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {
if (!settings.hasGenerator()) { if (!settings.hasGenerator()) {
if (args.size() == 0) { if (args.size() == 0) {
String hmCmd = "/cfi "; String hmCmd = "/cfi ";
@ -62,25 +63,23 @@ public class CFICommand extends CommandProcessor<Object, Object> {
.append(newline()) .append(newline())
.append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty") .append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
.append("- An empty map of a specific size").build(); .append("- An empty map of a specific size").build();
fp.toWorldEditPlayer().print(build); player.print(build);
} else { } else {
args = new ArrayList<>(args); args = new ArrayList<>(args);
switch (args.size()) { switch (args.size()) {
case 1: { case 1:
args.add(0, "heightmap"); args.add(0, "heightmap");
break; break;
} case 2:
case 2: {
args.add(0, "empty"); args.add(0, "empty");
break; break;
}
} }
return args; return args;
} }
} else { } else {
if (args.isEmpty()) { if (args.isEmpty()) {
settings.setCategory(null); settings.setCategory(null);
CFICommands.mainMenu(fp); CFICommands.mainMenu(player);
return null; return null;
} }
} }

Datei anzeigen

@ -8,7 +8,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.SingleFilterBlock; import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -71,7 +70,6 @@ import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -106,7 +104,7 @@ public class CFICommands {
desc = "Start CFI with a height map as a base" desc = "Start CFI with a height map as a base"
) )
@CommandPermissions("worldedit.anvil.cfi") @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) { if (yscale != 0) {
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData(); int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale))) 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" desc = "Start CFI with an empty map as a base"
) )
@CommandPermissions("worldedit.anvil.cfi") @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())); HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName()));
setup(generator, fp); setup(generator, fp);
} }
@ -138,7 +136,7 @@ public class CFICommands {
return df.format(new Date()); return df.format(new Date());
} }
private void setup(HeightMapMCAGenerator generator, FawePlayer fp) { private void setup(HeightMapMCAGenerator generator, Player fp) {
CFISettings settings = getSettings(fp).remove(); CFISettings settings = getSettings(fp).remove();
generator.setPacketViewer(fp); generator.setPacketViewer(fp);
settings.setGenerator(generator).bind(); settings.setGenerator(generator).bind();
@ -152,9 +150,9 @@ public class CFICommands {
desc = "Info about using brushes with CFI" desc = "Info about using brushes with CFI"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void brush(FawePlayer fp) { public void brush(Player player) {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(player);
settings.popMessages(fp); settings.popMessages(player);
@NotNull Builder msg; @NotNull Builder msg;
if (settings.getGenerator().getImageViewer() != null) { if (settings.getGenerator().getImageViewer() != null) {
msg = TextComponent.builder("CFI supports using brushes during creation").append(newline()) msg = TextComponent.builder("CFI supports using brushes during creation").append(newline())
@ -164,8 +162,8 @@ public class CFICommands {
} else { } else {
msg = TextComponent.builder("This is not supported with your platform/version").append(newline()); msg = TextComponent.builder("This is not supported with your platform/version").append(newline());
} }
//TODO msg.text("< [Back]").cmdTip(alias()).send(fp); //TODO msg.text("< [Back]").cmdTip(alias()).send(player);
fp.toWorldEditPlayer().print(msg.build()); player.print(msg.build());
} }
@Command( @Command(
@ -174,9 +172,9 @@ public class CFICommands {
desc = "Cancel creation" desc = "Cancel creation"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void cancel(FawePlayer fp) { public void cancel(Player fp) {
getSettings(fp).remove(); getSettings(fp).remove();
fp.sendMessage("Cancelled!"); fp.print("Cancelled!");
} }
@Command( @Command(
@ -185,32 +183,32 @@ public class CFICommands {
desc = "Create the world" desc = "Create the world"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void done(FawePlayer fp) { public void done(Player player) {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(player);
HeightMapMCAGenerator generator = settings.getGenerator(); HeightMapMCAGenerator generator = settings.getGenerator();
Function<File, Boolean> function = folder -> { Function<File, Boolean> function = folder -> {
if (folder != null) { if (folder != null) {
try { try {
generator.setFolder(folder); generator.setFolder(folder);
fp.sendMessage("Generating " + folder); player.print("Generating " + folder);
generator.generate(); generator.generate();
generator.setPacketViewer(null); generator.setPacketViewer(null);
generator.setImageViewer(null); generator.setImageViewer(null);
settings.remove(); settings.remove();
fp.sendMessage("Done!"); player.print("Done!");
return true; return true;
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else { } else {
fp.sendMessage("Unable to generate world... (see console)?"); player.print("Unable to generate world... (see console)?");
} }
return false; return false;
}; };
try { try {
new PlotLoader().load(fp, settings, function); new PlotLoader().load(player, settings, function);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
function.apply(generator.getFolder().getParentFile()); function.apply(generator.getFolder().getParentFile());
@ -220,17 +218,17 @@ public class CFICommands {
if (folder != null) { if (folder != null) {
World world = FaweAPI.getWorld(folder.getName()); World world = FaweAPI.getWorld(folder.getName());
if (world != null) { if (world != null) {
if (fp.getWorld() != world) { if (player.getWorld() != world) {
TaskManager.IMP.sync(new RunnableVal<Object>() { TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override @Override
public void run(Object value) { public void run(Object value) {
Location spawn = new Location(world, world.getSpawnPosition().toVector3()); Location spawn = new Location(world, world.getSpawnPosition().toVector3());
fp.getPlayer().setPosition(spawn); player.setPosition(spawn);
} }
}); });
} }
} else { } 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" desc = "Set the floor and main block"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setColumn(load(image), patternArg, !disableWhiteOnly); gen.setColumn(load(image), patternArg, !disableWhiteOnly);
@ -249,7 +247,7 @@ public class CFICommands {
} else { } else {
gen.setColumn(patternArg); gen.setColumn(patternArg);
} }
fp.sendMessage("Set column!"); fp.print("Set column!");
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); component(fp);
} }
@ -259,14 +257,14 @@ public class CFICommands {
desc = "Set the floor (default: grass)" desc = "Set the floor (default: grass)"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); floor(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.sendMessage("Set floor!"); fp.print("Set floor!");
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setFloor(load(image), patternArg, !disableWhiteOnly); gen.setFloor(load(image), patternArg, !disableWhiteOnly);
@ -282,14 +280,14 @@ public class CFICommands {
desc = "Set the main block (default: stone)" desc = "Set the main block (default: stone)"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); main(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.sendMessage("Set main!"); fp.print("Set main!");
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setMain(load(image), patternArg, !disableWhiteOnly); gen.setMain(load(image), patternArg, !disableWhiteOnly);
@ -308,7 +306,7 @@ public class CFICommands {
"e.g. Tallgrass" "e.g. Tallgrass"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.setOverlay(load(image), patternArg, !disableWhiteOnly); gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
@ -317,7 +315,7 @@ public class CFICommands {
} else { } else {
gen.setOverlay(patternArg); gen.setOverlay(patternArg);
} }
fp.sendMessage("Set overlay!"); fp.print("Set overlay!");
component(fp); component(fp);
} }
@ -330,13 +328,13 @@ public class CFICommands {
" - A good value for radius and iterations would be 1 8." " - A good value for radius and iterations would be 1 8."
) )
@CommandPermissions("worldedit.anvil.cfi") @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); smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); 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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) { if (image != null) {
gen.smooth(load(image), !disableWhiteOnly, radius, iterations); gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
@ -350,12 +348,12 @@ public class CFICommands {
desc = "Create some snow" desc = "Create some snow"
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(fp, 1, 8, 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(); assertSettings(fp).resetComponent();
component(fp); component(fp);
} }
@ -369,7 +367,7 @@ public class CFICommands {
"Below 50 will prefer to color with blocks" "Below 50 will prefer to color with blocks"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void biomepriority(FawePlayer fp, int value) { public void biomepriority(Player fp, int value) {
assertSettings(fp).getGenerator().setBiomePriority(value); assertSettings(fp).getGenerator().setBiomePriority(value);
coloring(fp); coloring(fp);
} }
@ -382,7 +380,7 @@ public class CFICommands {
"`#clipboard` will only use the blocks present in your clipboard." "`#clipboard` will only use the blocks present in your clipboard."
) )
@CommandPermissions("worldedit.anvil.cfi") @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) { if (argOpt == null) {
TextComponent build = TextComponent.builder("What blocks do you want to color with?") TextComponent build = TextComponent.builder("What blocks do you want to color with?")
.append(newline()) .append(newline())
@ -405,14 +403,14 @@ public class CFICommands {
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent .append(TextComponent.of("< [Back]").clickEvent(ClickEvent
.runCommand("/cfi coloring"))) .runCommand("/cfi coloring")))
.build(); .build();
fp.toWorldEditPlayer().print(build); player.print(build);
return; return;
} }
HeightMapMCAGenerator generator = assertSettings(fp).getGenerator(); HeightMapMCAGenerator generator = assertSettings(player).getGenerator();
ParserContext context = new ParserContext(); ParserContext context = new ParserContext();
context.setActor(fp.getPlayer()); context.setActor(player);
context.setWorld(fp.getWorld()); context.setWorld(player.getWorld());
context.setSession(fp.getSession()); context.setSession(player.getSession());
context.setExtent(generator); context.setExtent(generator);
Request.request().setExtent(generator); Request.request().setExtent(generator);
@ -424,7 +422,7 @@ public class CFICommands {
return; return;
} }
case "#clipboard": { case "#clipboard": {
ClipboardHolder holder = fp.getSession().getClipboard(); ClipboardHolder holder = player.getSession().getClipboard();
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
boolean[] ids = new boolean[BlockTypes.size()]; boolean[] ids = new boolean[BlockTypes.size()];
for (BlockVector3 pt : clipboard.getRegion()) { for (BlockVector3 pt : clipboard.getRegion()) {
@ -460,7 +458,7 @@ public class CFICommands {
} }
} }
generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks)); generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks));
coloring(fp); coloring(player);
} }
@Command( @Command(
@ -471,9 +469,9 @@ public class CFICommands {
"Randomization will allow mixing biomes when coloring with biomes" "Randomization will allow mixing biomes when coloring with biomes"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void randomization(FawePlayer fp, boolean enabled) { public void randomization(Player player, boolean enabled) {
assertSettings(fp).getGenerator().setTextureRandomVariation(enabled); assertSettings(player).getGenerator().setTextureRandomVariation(enabled);
coloring(fp); coloring(player);
} }
@Command( @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." "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") @CommandPermissions("worldedit.anvil.cfi")
public void complexity(FawePlayer fp, int min, int max) throws FileNotFoundException { public void complexity(Player player, int min, int max) throws FileNotFoundException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (min == 0 && max == 100) { if (min == 0 && max == 100) {
gen.setTextureUtil(Fawe.get().getTextureUtil()); gen.setTextureUtil(Fawe.get().getTextureUtil());
} else { } else {
gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max)); gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
} }
coloring(fp); coloring(player);
} }
@Command( @Command(
@ -504,11 +502,11 @@ public class CFICommands {
" - The distance is the spacing between each schematic" " - The distance is the spacing between each schematic"
) )
@CommandPermissions("worldedit.anvil.cfi") @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 { 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(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
World world = fp.getWorld(); World world = player.getWorld();
MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(fp.getPlayer(), schematic, null, true); MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, schematic, null, true);
if (multi == null) { if (multi == null) {
return; return;
} }
@ -517,8 +515,8 @@ public class CFICommands {
} else { } else {
gen.addSchems(load(imageMask), mask, multi.getHolders(), rarity, distance, rotate); gen.addSchems(load(imageMask), mask, multi.getHolders(), rarity, distance, rotate);
} }
fp.toWorldEditPlayer().print(TextComponent.of("Added schematics!")); player.print(TextComponent.of("Added schematics!"));
populate(fp); populate(player);
} }
@Command( @Command(
@ -530,8 +528,8 @@ public class CFICommands {
" - If a mask is used, the biome will be set anywhere the mask applies" " - If a mask is used, the biome will be set anywhere the mask applies"
) )
@CommandPermissions("worldedit.anvil.cfi") @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){ 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(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
if (image != null) { if (image != null) {
gen.setBiome(load(image), biomeType, !disableWhiteOnly); gen.setBiome(load(image), biomeType, !disableWhiteOnly);
} else if (maskOpt != null) { } else if (maskOpt != null) {
@ -539,9 +537,9 @@ public class CFICommands {
} else { } else {
gen.setBiome(biomeType); gen.setBiome(biomeType);
} }
fp.toWorldEditPlayer().print(TextComponent.of("Set biome!")); player.print(TextComponent.of("Set biome!"));
assertSettings(fp).resetComponent(); assertSettings(player).resetComponent();
component(fp); component(player);
} }
@Command( @Command(
@ -549,9 +547,9 @@ public class CFICommands {
desc = "Generate vanilla caves" desc = "Generate vanilla caves"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void caves(FawePlayer fp) throws WorldEditException { public void caves(Player fp) throws WorldEditException {
assertSettings(fp).getGenerator().addCaves(); assertSettings(fp).getGenerator().addCaves();
fp.toWorldEditPlayer().print(TextComponent.of("Added caves!")); fp.print(TextComponent.of("Added caves!"));
populate(fp); populate(fp);
} }
@ -561,9 +559,9 @@ public class CFICommands {
descFooter = "Use a specific pattern and settings to generate ore" descFooter = "Use a specific pattern and settings to generate ore"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); 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); populate(fp);
} }
@ -572,9 +570,9 @@ public class CFICommands {
desc = "Generate the vanilla ores" desc = "Generate the vanilla ores"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().addDefaultOres(mask);
fp.toWorldEditPlayer().print(TextComponent.of("Added ores!")); fp.print(TextComponent.of("Added ores!"));
populate(fp); populate(fp);
} }
@ -584,14 +582,14 @@ public class CFICommands {
descFooter = "Set the terrain height either based on an image heightmap, or a numeric value." descFooter = "Set the terrain height either based on an image heightmap, or a numeric value."
) )
@CommandPermissions("worldedit.anvil.cfi") @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(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (!MathMan.isInteger(imageStr)) { if (!MathMan.isInteger(imageStr)) {
gen.setHeight(ImageUtil.getImage(imageStr)); gen.setHeight(ImageUtil.getImage(imageStr));
} else { } else {
gen.setHeights(Integer.parseInt(imageStr)); gen.setHeights(Integer.parseInt(imageStr));
} }
fp.toWorldEditPlayer().print("Set Height!"); fp.print("Set Height!");
component(fp); component(fp);
} }
@ -600,11 +598,11 @@ public class CFICommands {
desc = "Change the block used for water\ne.g. Lava" desc = "Change the block used for water\ne.g. Lava"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setWaterId(block.getBlockType().getInternalId()); settings.getGenerator().setWaterId(block.getBlockType().getInternalId());
fp.toWorldEditPlayer().print("Set water id!"); fp.print("Set water id!");
settings.resetComponent(); settings.resetComponent();
component(fp); component(fp);
} }
@ -615,10 +613,10 @@ public class CFICommands {
desc = "Change the block used for the base\ne.g. Bedrock" desc = "Change the block used for the base\ne.g. Bedrock"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBedrockId(block.getBlockType().getInternalId()); settings.getGenerator().setBedrockId(block.getBlockType().getInternalId());
fp.toWorldEditPlayer().print(TextComponent.of("Set base id!")); fp.print(TextComponent.of("Set base id!"));
settings.resetComponent(); settings.resetComponent();
component(fp); component(fp);
} }
@ -630,9 +628,9 @@ public class CFICommands {
" - A value of 0 is the default and will not modify the height" " - A value of 0 is the default and will not modify the height"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().setWorldThickness(heightArg);
fp.toWorldEditPlayer().print(TextComponent.of("Set world thickness!")); fp.print("Set world thickness!");
component(fp); component(fp);
} }
@ -643,9 +641,9 @@ public class CFICommands {
" - A value of 0 is the default and will only set the top block" " - A value of 0 is the default and will only set the top block"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().setFloorThickness(heightArg);
fp.toWorldEditPlayer().print(TextComponent.of("Set floor thickness!")); fp.print("Set floor thickness!");
component(fp); component(fp);
} }
@ -655,9 +653,9 @@ public class CFICommands {
desc = "Resend the CFI chunks" desc = "Resend the CFI chunks"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void update(FawePlayer fp) throws WorldEditException { public void update(Player fp) throws WorldEditException {
assertSettings(fp).getGenerator().update(); assertSettings(fp).getGenerator().update();
fp.toWorldEditPlayer().print(TextComponent.of("Chunks refreshed!")); fp.print("Chunks refreshed!");
mainMenu(fp); mainMenu(fp);
} }
@ -667,14 +665,13 @@ public class CFICommands {
desc = "Teleport to the CFI virtual world" desc = "Teleport to the CFI virtual world"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void tp(FawePlayer fp) throws WorldEditException { public void tp(Player player) throws WorldEditException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
fp.toWorldEditPlayer().print(TextComponent.of("Teleporting...")); player.print("Teleporting...");
Vector3 origin = gen.getOrigin(); Vector3 origin = gen.getOrigin();
Player player = fp.getPlayer();
player.setPosition(origin.subtract(16, 0, 16)); player.setPosition(origin.subtract(16, 0, 16));
player.findFreePosition(); player.findFreePosition();
mainMenu(fp); mainMenu(player);
} }
@Command( @Command(
@ -685,9 +682,9 @@ public class CFICommands {
" - By default water is disabled (with a value of 0)" " - By default water is disabled (with a value of 0)"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); assertSettings(fp).getGenerator().setWaterHeight(heightArg);
fp.toWorldEditPlayer().print(TextComponent.of("Set water height!")); fp.print("Set water height!");
component(fp); component(fp);
} }
@ -698,10 +695,10 @@ public class CFICommands {
) )
// ![79,174,212,5:3,5:4,18,161,20] // ![79,174,212,5:3,5:4,18,161,20]
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setColorWithGlass(load(image)); settings.getGenerator().setColorWithGlass(load(image));
fp.toWorldEditPlayer().print(TextComponent.of("Set color with glass!")); fp.print("Set color with glass!");
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -715,7 +712,7 @@ public class CFICommands {
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator gen = settings.getGenerator(); HeightMapMCAGenerator gen = settings.getGenerator();
if (imageMask != null) { if (imageMask != null) {
@ -726,7 +723,7 @@ public class CFICommands {
gen.setColor(load(image)); gen.setColor(load(image));
} }
settings.resetColoring(); settings.resetColoring();
fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks!")); fp.print("Set color with blocks!");
mainMenu(fp); mainMenu(fp);
} }
@ -739,10 +736,10 @@ public class CFICommands {
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBlockAndBiomeColor(load(image), maskOpt, load(imageMask), !disableWhiteOnly); 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(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -755,10 +752,10 @@ public class CFICommands {
" - If you changed the block to something other than grass you will not see anything." " - If you changed the block to something other than grass you will not see anything."
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBiomeColor(load(image)); settings.getGenerator().setBiomeColor(load(image));
fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!")); fp.print(TextComponent.of("Set color with biomes!"));
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -770,7 +767,7 @@ public class CFICommands {
desc = "Color the world using an image" desc = "Color the world using an image"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void coloring(FawePlayer fp) { public void coloring(Player fp) {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.popMessages(fp); settings.popMessages(fp);
settings.setCategory(this::coloring); settings.setCategory(this::coloring);
@ -847,7 +844,7 @@ public class CFICommands {
.append("[None]");//.cmdTip("/cfi " + Commands.getAlias(Command.class, "image")).append(newline()); .append("[None]");//.cmdTip("/cfi " + Commands.getAlias(Command.class, "image")).append(newline());
} }
builder.append("< [Back]");//.cmdTip(alias()).send(fp); builder.append("< [Back]");//.cmdTip(alias()).send(fp);
fp.toWorldEditPlayer().print(builder.build()); fp.print(builder.build());
} }
@Command( @Command(
@ -855,7 +852,7 @@ public class CFICommands {
desc = "Select a mask" desc = "Select a mask"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
String[] split = getArguments(context).split(" "); String[] split = getArguments(context).split(" ");
int index = 2; int index = 2;
@ -882,7 +879,7 @@ public class CFICommands {
.append( .append(
TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(s2))) TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(s2)))
.clickEvent(ClickEvent.runCommand(s2))).build(); .clickEvent(ClickEvent.runCommand(s2))).build();
fp.toWorldEditPlayer().print(build); fp.print(build);
} }
@Command( @Command(
@ -890,7 +887,7 @@ public class CFICommands {
desc = "Select a pattern" desc = "Select a pattern"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = assertSettings(fp);
String[] split = getArguments(context).split(" "); String[] split = getArguments(context).split(" ");
int index = 2; int index = 2;
@ -912,7 +909,7 @@ public class CFICommands {
.append(TextComponent.of("< [Back]") .append(TextComponent.of("< [Back]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s1))) .hoverEvent(HoverEvent.showText(TextComponent.of(s1)))
.clickEvent(ClickEvent.runCommand(s1))).build(); .clickEvent(ClickEvent.runCommand(s1))).build();
fp.toWorldEditPlayer().print(build); fp.print(build);
} }
} }
@ -921,15 +918,15 @@ public class CFICommands {
desc = "Download the current image" desc = "Download the current image"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void download(FawePlayer fp)throws IOException { public void download(Player player)throws IOException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(player);
BufferedImage image = settings.getGenerator().draw(); BufferedImage image = settings.getGenerator().draw();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos); ImageIO.write(image, "jpg", baos);
byte[] data = baos.toByteArray(); byte[] data = baos.toByteArray();
fp.sendMessage("Please wait..."); player.print("Please wait...");
URL url = ImgurUtility.uploadImage(data); URL url = ImgurUtility.uploadImage(data);
BBC.DOWNLOAD_LINK.send(fp, url); BBC.DOWNLOAD_LINK.send(player, url);
} }
@Command( @Command(
@ -937,7 +934,7 @@ public class CFICommands {
desc = "Select an image" desc = "Select an image"
) )
@CommandPermissions("worldedit.anvil.cfi") @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); CFISettings settings = getSettings(fp);
String[] split = getArguments(context).split(" "); String[] split = getArguments(context).split(" ");
int index = 2; int index = 2;
@ -952,7 +949,7 @@ public class CFICommands {
.append(newline()) .append(newline())
.append("From a file: ").append(TextComponent.of("[Click Here]").clickEvent(ClickEvent.suggestCommand("/cfi image file://"))) .append("From a file: ").append(TextComponent.of("[Click Here]").clickEvent(ClickEvent.suggestCommand("/cfi image file://")))
.build(); .build();
fp.toWorldEditPlayer().print(build); fp.print(build);
} else { } else {
if (settings.hasGenerator()) { if (settings.hasGenerator()) {
coloring(fp); coloring(fp);
@ -969,9 +966,9 @@ public class CFICommands {
desc = "" desc = ""
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void populate(FawePlayer fp) { public void populate(Player player) {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(player);
settings.popMessages(fp); settings.popMessages(player);
settings.setCategory(this::populate); settings.setCategory(this::populate);
TextComponent build = TextComponent.builder("What would you like to populate?") TextComponent build = TextComponent.builder("What would you like to populate?")
.append(newline()) .append(newline())
@ -980,7 +977,7 @@ public class CFICommands {
.append(newline()) .append(newline())
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent.runCommand("/cfi"))) .append(TextComponent.of("< [Back]").clickEvent(ClickEvent.runCommand("/cfi")))
.build(); .build();
fp.toWorldEditPlayer().print(build); player.print(build);
} }
@Command( @Command(
@ -989,9 +986,9 @@ public class CFICommands {
desc = "Components menu" desc = "Components menu"
) )
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void component(FawePlayer fp) { public void component(Player player) {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(player);
settings.popMessages(fp); settings.popMessages(player);
settings.setCategory(this::component); settings.setCategory(this::component);
String mask; String mask;
@ -1007,10 +1004,10 @@ public class CFICommands {
StringBuilder maskArgs = new StringBuilder(); StringBuilder maskArgs = new StringBuilder();
if (settings.imageMask != null) { if (settings.imageMask != null) {
maskArgs.append(" " + settings.imageMaskArg); maskArgs.append(" ").append(settings.imageMaskArg);
} }
if (settings.mask != null) { if (settings.mask != null) {
maskArgs.append(" " + settings.maskArg); maskArgs.append(" ").append(settings.maskArg);
} }
if (!settings.whiteOnly) { if (!settings.whiteOnly) {
maskArgs.append(" -w"); maskArgs.append(" -w");
@ -1090,11 +1087,11 @@ public class CFICommands {
msg.append(newline()) msg.append(newline())
.append(TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi"))).clickEvent(ClickEvent.runCommand("/cfi"))); .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) { private static CFISettings assertSettings(Player player) {
CFISettings settings = getSettings(fp); CFISettings settings = getSettings(player);
if (!settings.hasGenerator()) { if (!settings.hasGenerator()) {
throw new StopExecutionException(TextComponent.of("Please use /cfi")); 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"); CFISettings settings = fp.getMeta("CFISettings");
return settings == null ? new CFISettings(fp) : settings; return settings == null ? new CFISettings(fp) : settings;
} }
public static class CFISettings { public static class CFISettings {
private final FawePlayer fp; private final Player player;
private HeightMapMCAGenerator generator; private HeightMapMCAGenerator generator;
@ -1123,12 +1120,12 @@ public class CFICommands {
protected Pattern pattern; protected Pattern pattern;
protected String patternArg; protected String patternArg;
protected Consumer<FawePlayer> category; protected Consumer<Player> category;
private boolean bound; private boolean bound;
public CFISettings(FawePlayer player) { public CFISettings(Player player) {
this.fp = player; this.player = player;
} }
public boolean hasGenerator() { public boolean hasGenerator() {
@ -1174,47 +1171,47 @@ public class CFICommands {
pattern = null; pattern = null;
} }
public Consumer<FawePlayer> getCategory() { public Consumer<Player> getCategory() {
return category; return category;
} }
public void setCategory(Consumer<FawePlayer> methodRef) { public void setCategory(Consumer<Player> methodRef) {
this.category = category; this.category = category;
} }
public CFISettings setGenerator(HeightMapMCAGenerator generator) { public CFISettings setGenerator(HeightMapMCAGenerator generator) {
this.generator = generator; this.generator = generator;
if (bound) { if (bound) {
fp.getSession().setVirtualWorld(generator); player.getSession().setVirtualWorld(generator);
} }
return this; return this;
} }
public CFISettings bind() { public CFISettings bind() {
if (generator != null) { if (generator != null) {
fp.getSession().setVirtualWorld(generator); player.getSession().setVirtualWorld(generator);
} }
bound = true; bound = true;
fp.setMeta("CFISettings", this); player.setMeta("CFISettings", this);
return this; return this;
} }
public void popMessages(FawePlayer fp) { public void popMessages(Player player) {
ArrayDeque<String> messages = fp.deleteMeta("CFIBufferedMessages"); ArrayDeque<String> messages = player.deleteMeta("CFIBufferedMessages");
if (messages != null) { if (messages != null) {
for (String message : messages) { for (String message : messages) {
fp.sendMessage(message); player.print(message);
} }
} }
} }
public CFISettings remove() { public CFISettings remove() {
fp.deleteMeta("CFISettings"); player.deleteMeta("CFISettings");
HeightMapMCAGenerator gen = this.generator; HeightMapMCAGenerator gen = this.generator;
if (gen != null) { if (gen != null) {
fp.getSession().setVirtualWorld(null); player.getSession().setVirtualWorld(null);
} }
popMessages(fp); popMessages(player);
bound = false; bound = false;
generator = null; generator = null;
image = null; image = null;
@ -1229,7 +1226,7 @@ public class CFICommands {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected static void mainMenu(FawePlayer fp) { protected static void mainMenu(Player player) {
//TODO //TODO
// msg("What do you want to do now?").append(newline()) // msg("What do you want to do now?").append(newline())
// .cmdOptions("/cfi ", "", "Coloring", "Component", "Populate", "Brush") // .cmdOptions("/cfi ", "", "Coloring", "Component", "Populate", "Brush")

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.command; 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.object.RunnableVal;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; 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.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.sk89q.worldedit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.function.Function; import java.util.function.Function;
@ -36,15 +36,15 @@ public class PlotLoader {
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone)); () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
} }
public void load(FawePlayer fp, CFICommands.CFISettings settings, public void load(Player fp, CFISettings settings,
Function<File, Boolean> createTask) throws IOException { Function<File, Boolean> createTask) throws IOException {
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager(); PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) { if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager; SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
SinglePlotArea area = sManager.getArea(); 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<Plot>() { Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
@Override @Override
public void run(Plot o) { public void run(Plot o) {

Datei anzeigen

@ -5,13 +5,14 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.EditSession; 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.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -27,7 +28,11 @@ public class Rollback extends FaweCommand {
} }
@Override @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) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
return false; return false;
@ -58,13 +63,13 @@ public class Rollback extends FaweCommand {
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>"); BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
return false; return false;
} }
player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); player.deleteMeta(Player.METADATA_KEYS.ROLLBACK);
Location origin = player.getPlayer().getLocation(); Location origin = player.getLocation();
rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() { rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() {
@Override @Override
public void run(List<DiskStorageHistory> edits) { public void run(List<DiskStorageHistory> edits) {
long total = 0; long total = 0;
player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |="); player.print("&d=| Username | Bounds | Distance | Changes | Age |=");
for (DiskStorageHistory edit : edits) { for (DiskStorageHistory edit : edits) {
DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getBlockX(), origin.getBlockX(), origin.getBlockZ(), origin.getBlockZ()), !player.hasPermission("fawe.rollback.deep")); DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getBlockX(), origin.getBlockX(), origin.getBlockZ(), origin.getBlockZ()), !player.hasPermission("fawe.rollback.deep"));
RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ); RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ);
@ -82,14 +87,14 @@ public class Rollback extends FaweCommand {
percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName); percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName);
prefix = ", "; prefix = ", ";
} }
player.sendMessage("&c" + name + " | " + region + " | " + distance + "m | " + size + " | " + MainUtil.secToTime(seconds)); player.print("&c" + name + " | " + region + " | " + distance + "m | " + size + " | " + MainUtil.secToTime(seconds));
player.sendMessage("&8 - &7(" + percentString + ")"); player.print("&8 - &7(" + percentString + ")");
} }
player.sendMessage("&d=================================================="); player.print("&d==================================================");
player.sendMessage("&dSize: " + (double) (total / 1024) / 1000 + "MB"); player.print("&dSize: " + (double) (total / 1024) / 1000 + "MB");
player.sendMessage("&dTo rollback: /frb undo"); player.print("&dTo rollback: /frb undo");
player.sendMessage("&d=================================================="); player.print("&d==================================================");
player.setMeta(FawePlayer.METADATA_KEYS.ROLLBACK, edits); player.setMeta(Player.METADATA_KEYS.ROLLBACK, edits);
} }
}); });
break; break;
@ -99,20 +104,20 @@ public class Rollback extends FaweCommand {
BBC.NO_PERM.send(player, "fawe.rollback.perform"); BBC.NO_PERM.send(player, "fawe.rollback.perform");
return false; return false;
} }
final List<DiskStorageHistory> edits = player.getMeta(FawePlayer.METADATA_KEYS.ROLLBACK); final List<DiskStorageHistory> edits = player.getMeta(Player.METADATA_KEYS.ROLLBACK);
player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); player.deleteMeta(Player.METADATA_KEYS.ROLLBACK);
if (edits == null) { if (edits == null) {
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>");
return false; return false;
} }
for (DiskStorageHistory edit : edits) { for (DiskStorageHistory edit : edits) {
player.sendMessage("&d" + edit.getBDFile()); player.print("&d" + edit.getBDFile());
EditSession session = edit.toEditSession(null); EditSession session = edit.toEditSession(null);
session.undo(session); session.undo(session);
edit.deleteFiles(); edit.deleteFiles();
session.flushQueue(); session.flushQueue();
} }
player.sendMessage("Rollback complete!"); player.print("Rollback complete!");
default: default:
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>"); BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>");
return false; return false;
@ -120,7 +125,7 @@ public class Rollback extends FaweCommand {
return true; return true;
} }
public void rollback(FawePlayer player, boolean shallow, String[] args, RunnableVal<List<DiskStorageHistory>> result) { public void rollback(Player player, boolean shallow, String[] args, RunnableVal<List<DiskStorageHistory>> result) {
UUID user = null; UUID user = null;
int radius = Integer.MAX_VALUE; int radius = Integer.MAX_VALUE;
long time = Long.MAX_VALUE; long time = Long.MAX_VALUE;
@ -143,14 +148,14 @@ public class Rollback extends FaweCommand {
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
if (user == null) { if (user == null) {
player.sendMessage("&dInvalid user: " + split[1]); player.print("&dInvalid user: " + split[1]);
return; return;
} }
break; break;
case "r": case "r":
case "radius": case "radius":
if (!MathMan.isInteger(split[1])) { if (!MathMan.isInteger(split[1])) {
player.sendMessage("&dInvalid radius: " + split[1]); player.print("&dInvalid radius: " + split[1]);
return; return;
} }
radius = Integer.parseInt(split[1]); radius = Integer.parseInt(split[1]);
@ -167,11 +172,11 @@ public class Rollback extends FaweCommand {
Location origin = player.getLocation(); Location origin = player.getLocation();
List<DiskStorageHistory> edits = FaweAPI.getBDFiles(origin, user, radius, time, shallow); List<DiskStorageHistory> edits = FaweAPI.getBDFiles(origin, user, radius, time, shallow);
if (edits == null) { if (edits == null) {
player.sendMessage("&cToo broad, try refining your search!"); player.print("&cToo broad, try refining your search!");
return; return;
} }
if (edits.size() == 0) { if (edits.size() == 0) {
player.sendMessage("&cNo edits found!"); player.print("&cNo edits found!");
return; return;
} }
result.run(edits); result.run(edits);

Datei anzeigen

@ -3,7 +3,6 @@ package com.boydti.fawe.config;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection; import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration; import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -497,16 +496,6 @@ public enum BBC {
} }
} }
public void send(FawePlayer<?> player, Object... args) {
if (isEmpty()) {
return;
}
if (player == null) {
Fawe.debug(this.format(args));
} else {
player.sendMessage(this.format(args));
}
}
public void send(Actor player, Object... args) { public void send(Actor player, Object... args) {
if (isEmpty()) { if (isEmpty()) {
return; return;

Datei anzeigen

@ -1,9 +1,12 @@
package com.boydti.fawe.config; package com.boydti.fawe.config;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.entity.Player;
import java.io.File; import java.io.File;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public class Settings extends Config { public class Settings extends Config {
@Ignore @Ignore
@ -463,7 +466,7 @@ public class Settings extends Config {
save(file); save(file);
} }
public FaweLimit getLimit(FawePlayer player) { public FaweLimit getLimit(Player player) {
FaweLimit limit; FaweLimit limit;
if (player.hasPermission("fawe.limit.*") || player.hasPermission("fawe.bypass")) { if (player.hasPermission("fawe.limit.*") || player.hasPermission("fawe.bypass")) {
limit = FaweLimit.MAX.copy(); limit = FaweLimit.MAX.copy();
@ -475,7 +478,7 @@ public class Settings extends Config {
boolean limitFound = false; boolean limitFound = false;
for (String key : keys) { for (String key : keys) {
if ((player != null && player.hasPermission("fawe.limit." + key)) || (!limitFound && key.equals("default"))) { if (player.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) {
limitFound = true; limitFound = true;
LIMITS newLimit = LIMITS.get(key); LIMITS newLimit = LIMITS.get(key);
limit.MAX_ACTIONS = Math.max(limit.MAX_ACTIONS, newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE); limit.MAX_ACTIONS = Math.max(limit.MAX_ACTIONS, newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE);

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.logging; package com.boydti.fawe.logging;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet; import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
import java.lang.reflect.Constructor; import com.sk89q.worldedit.entity.Player;
//import org.primesoft.blockshub.IBlocksHubApi; //import org.primesoft.blockshub.IBlocksHubApi;
//import org.primesoft.blockshub.api.IPlayer; //import org.primesoft.blockshub.api.IPlayer;
//import org.primesoft.blockshub.api.IWorld; //import org.primesoft.blockshub.api.IWorld;
@ -14,7 +11,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
private static boolean initialized = false; private static boolean initialized = false;
public static FaweChangeSet wrap(FawePlayer player, FaweChangeSet parent) { public static FaweChangeSet wrap(Player player, FaweChangeSet parent) {
if (!initialized) { if (!initialized) {
initialized = true; initialized = true;
// api = (IBlocksHubApi) Fawe.imp().getBlocksHubApi(); // api = (IBlocksHubApi) Fawe.imp().getBlocksHubApi();
@ -33,7 +30,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
// private final MutableBlockData oldBlock; // private final MutableBlockData oldBlock;
// private final MutableBlockData newBlock; // private final MutableBlockData newBlock;
private LoggingChangeSet(FawePlayer player, FaweChangeSet parent) { private LoggingChangeSet(Player player, FaweChangeSet parent) {
super(parent); super(parent);
// String world = player.getLocation().world; // String world = player.getLocation().world;
// try { // try {

Datei anzeigen

@ -2,6 +2,8 @@ package com.boydti.fawe.object;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
public abstract class FaweCommand<T> { public abstract class FaweCommand<T> {
public final String perm; public final String perm;
@ -20,7 +22,7 @@ public abstract class FaweCommand<T> {
return this.perm; return this.perm;
} }
public boolean executeSafe(final FawePlayer<T> player, final String... args) { public boolean executeSafe(final Actor player, final String... args) {
try { try {
if (!safe) { if (!safe) {
execute(player, args); execute(player, args);
@ -40,5 +42,5 @@ public abstract class FaweCommand<T> {
return false; return false;
} }
public abstract boolean execute(final FawePlayer<T> player, final String... args); public abstract boolean execute(final Actor actor, final String... args);
} }

Datei anzeigen

@ -1,643 +0,0 @@
package com.boydti.fawe.object;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.extension.platform.PlayerProxy;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.lang.reflect.Field;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull;
public abstract class FawePlayer<T> extends Metadatable {
public final T parent;
private LocalSession session;
public static final class METADATA_KEYS {
public static final String ANVIL_CLIPBOARD = "anvil-clipboard";
public static final String ROLLBACK = "rollback";
}
/**
* Wrap some object into a FawePlayer<br>
* - org.bukkit.entity.Player
* - org.spongepowered.api.entity.living.player
* - com.sk89q.worldedit.entity.Player
* - String (name)
* - UUID (player UUID)
*
* @param obj
* @param <V>
* @return
*/
public static <V> FawePlayer<V> wrap(Object obj) {
if (obj instanceof FawePlayer) {
return (FawePlayer<V>) obj;
}
if (obj instanceof Player) {
Player actor = LocationMaskedPlayerWrapper.unwrap((Player) obj);
if (obj instanceof PlayerProxy) {
Player player = ((PlayerProxy) obj).getBasePlayer();
FawePlayer<Object> result = wrap(player);
return (FawePlayer<V>) (result == null ? wrap(player.getName()) : result);
} else if (obj instanceof PlayerWrapper) {
return wrap(((PlayerWrapper) obj).getParent());
} else {
try {
Field fieldPlayer = actor.getClass().getDeclaredField("player");
fieldPlayer.setAccessible(true);
return wrap(fieldPlayer.get(actor));
} catch (Throwable ignore) {
}
}
}
if (obj instanceof Actor) {
Actor actor = (Actor) obj;
FawePlayer existing = Fawe.get().getCachedPlayer(actor.getName());
if (existing != null) {
return existing;
}
}
obj.getClass().getName();
return Fawe.imp().wrap(obj);
}
@Deprecated
public FawePlayer(T parent) {
this.parent = parent;
Fawe.get().register(this);
if (Settings.IMP.CLIPBOARD.USE_DISK) {
loadClipboardFromDisk();
}
}
public int cancel(boolean close) {
// Collection<IQueueExtent> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
int cancelled = 0;
// clearActions();
// for (IQueueExtent queue : queues) {
// Collection<EditSession> sessions = queue.getEditSessions();
// for (EditSession session : sessions) {
// FawePlayer currentPlayer = session.getPlayer();
// if (currentPlayer == this) {
// if (session.cancel()) {
// cancelled++;
// }
// }
// }
// }
// VirtualWorld world = getSession().getVirtualWorld();
// if (world != null) {
// if (close) {
// try {
// world.close(false);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// else world.clear();
// }
return cancelled;
}
private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, @NotNull String command) {
CommandEvent event = new CommandEvent(getPlayer(), command);
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run();
return null;
}, context, getSession(), event);
setMeta("cmdConfirm", newTask);
}
public void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (times > limit) {
setConfirmTask(task, context, command);
String volume = "<unspecified>";
throw new RegionOperationException(
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.format(0, times, command, volume));
}
}
task.run();
}
public void checkConfirmationRadius(@NotNull Runnable task, String command, int radius, InjectedValueAccess context) throws RegionOperationException {
if (command != null && !getMeta("cmdConfirmRunning", false)) {
if (radius > 0) {
if (radius > 448) {
setConfirmTask(task, context, command);
long volume = (long) (Math.PI * ((double) radius * radius));
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(0, radius, command,
NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
public void checkConfirmationStack(@NotNull Runnable task, @NotNull String command, Region region, int times, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
long area = (long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
if (area > 2 << 18) {
setConfirmTask(task, context, command);
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(min, max, command, NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
public void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command, Region region, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
if (area > 2 << 18) {
setConfirmTask(task, context, command);
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
long volume = (long) base.getX() * base.getZ() * base.getY();
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(min, max, command, NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
public synchronized boolean confirm() {
Runnable confirm = deleteMeta("cmdConfirm");
if (confirm == null) {
return false;
}
queueAction(() -> {
setMeta("cmdConfirmRunning", true);
try {
confirm.run();
} finally {
setMeta("cmdConfirmRunning", false);
}
});
return true;
}
public void checkAllowedRegion(Region wrappedSelection) {
Region[] allowed = WEManager.IMP.getMask(this, FaweMaskManager.MaskType.OWNER);
HashSet<Region> allowedSet = new HashSet<>(Arrays.asList(allowed));
if (allowed.length == 0) {
throw FaweException.NO_REGION;
} else if (!WEManager.IMP.regionContains(wrappedSelection, allowedSet)) {
throw FaweException.OUTSIDE_REGION;
}
}
/**
* Queue an action to run async
* @param run
*/
public void queueAction(Runnable run) {
runAction(run, false, true);
}
public void clearActions() {
asyncNotifyQueue.clear();
}
public boolean runAsyncIfFree(Runnable r) {
return runAction(r, true, true);
}
public boolean runIfFree(Runnable r) {
return runAction(r, true, false);
}
// Queue for async tasks
private AtomicInteger runningCount = new AtomicInteger();
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue((thread, throwable) -> {
while (throwable.getCause() != null) {
throwable = throwable.getCause();
}
if (throwable instanceof WorldEditException) {
sendMessage(throwable.getLocalizedMessage());
} else {
FaweException fe = FaweException.get(throwable);
if (fe != null) {
sendMessage(fe.getMessage());
} else {
throwable.printStackTrace();
}
}
});
/**
* Run a task either async, or on the current thread
* @param ifFree
* @param checkFree Whether to first check if a task is running
* @param async
* @return false if the task was ran or queued
*/
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
if (checkFree) {
if (runningCount.get() != 0) return false;
}
Runnable wrapped = () -> {
try {
runningCount.addAndGet(1);
ifFree.run();
} finally {
runningCount.decrementAndGet();
}
};
if (async) {
asyncNotifyQueue.queue(wrapped);
} else {
TaskManager.IMP.taskNow(wrapped, false);
}
return true;
}
public boolean checkAction() {
long time = getMeta("faweActionTick", Long.MIN_VALUE);
long tick = Fawe.get().getTimer().getTick();
setMeta("faweActionTick", tick);
return tick > time;
}
/**
* Loads any history items from disk:
* - Should already be called if history on disk is enabled
*/
public void loadClipboardFromDisk() {
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + getUUID() + ".bd");
try {
if (file.exists() && file.length() > 5) {
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
Player player = toWorldEditPlayer();
LocalSession session = getSession();
try {
if (session.getClipboard() != null) {
return;
}
} catch (EmptyClipboardException ignored) {
}
if (player != null) {
Clipboard clip = doc.toClipboard();
ClipboardHolder holder = new ClipboardHolder(clip);
getSession().setClipboard(holder);
}
}
} catch (Exception event) {
Fawe.debug("====== INVALID CLIPBOARD ======");
event.printStackTrace();
Fawe.debug("===============---=============");
Fawe.debug("This shouldn't result in any failure");
Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
Fawe.debug("===============---=============");
}
}
/**
* Get the current World
*
* @return
*/
public World getWorld() {
return getPlayer().getWorld();
}
/**
* Load all the undo EditSession's from disk for a world <br>
* - Usually already called when necessary
*
* @param world
*/
public void loadSessionsFromDisk(World world) {
if (world == null) {
return;
}
getSession().loadSessionHistoryFromDisk(getUUID(), world);
}
/**
* Send a title
*
* @param head
* @param sub
*/
public abstract void sendTitle(String head, String sub);
/**
* Remove the title
*/
public abstract void resetTitle();
/**
* Get the player's limit
*
* @return
*/
public FaweLimit getLimit() {
return Settings.IMP.getLimit(this);
}
/**
* Get the player's name
*
* @return
*/
public abstract String getName();
/**
* Get the player's UUID
*
* @return
*/
public abstract UUID getUUID();
public boolean isSneaking() {
return false;
}
/**
* Check the player's permission
*
* @param perm
* @return
*/
public abstract boolean hasPermission(String perm);
/**
* Send a message to the player
*
* @param message
*/
public abstract void sendMessage(String message);
/**
* Print a WorldEdit error.
*
* @param msg The error message text
*/
public abstract void printError(String msg);
/**
* Have the player execute a command
*
* @param substring
*/
public abstract void executeCommand(String substring);
/**
* Get the player's location
*
* @return
*/
public Location getLocation() {
return getPlayer().getLocation();
}
/**
* Get the WorldEdit player object
*
* @return
*/
public abstract Player toWorldEditPlayer();
private Player cachedWorldEditPlayer;
public Player getPlayer() {
if (cachedWorldEditPlayer == null) {
cachedWorldEditPlayer = toWorldEditPlayer();
}
return cachedWorldEditPlayer;
}
/**
* Get the player's current selection (or null)
*
* @return
*/
public Region getSelection() {
try {
return this.getSession().getSelection(this.getPlayer().getWorld());
} catch (IncompleteRegionException e) {
return null;
}
}
/**
* Get the player's current LocalSession
*
* @return
*/
public LocalSession getSession() {
if (this.session != null || this.getPlayer() == null || Fawe.get() == null) return this.session;
else return session = Fawe.get().getWorldEdit().getSessionManager().get(this.getPlayer());
}
/**
* Get the player's current allowed WorldEdit regions
*
* @return
*/
@Deprecated
public Region[] getCurrentRegions() {
return WEManager.IMP.getMask(this);
}
@Deprecated
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
return WEManager.IMP.getMask(this, type);
}
/**
* Set the player's WorldEdit selection to the following CuboidRegion
*
* @param region
*/
@Deprecated
public void setSelection(RegionWrapper region) {
final Player player = this.getPlayer();
BlockVector3 top = region.getMaximumPoint();
top.withY(getWorld().getMaxY());
final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getMinimumPoint(), top);
this.getSession().setRegionSelector(player.getWorld(), selector);
}
public void setSelection(Region region) {
RegionSelector selector;
if (region instanceof ConvexPolyhedralRegion) {
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
} else if (region instanceof CylinderRegion) {
selector = new CylinderRegionSelector((CylinderRegion) region);
} else if (region instanceof Polygonal2DRegion) {
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
} else {
selector = new CuboidRegionSelector(null, region.getMinimumPoint(), region.getMaximumPoint());
}
selector.setWorld(region.getWorld());
final Player player = this.getPlayer();
this.getSession().setRegionSelector(player.getWorld(), selector);
}
/**
* Set the player's WorldEdit selection
*
* @param selector
*/
public void setSelection(RegionSelector selector) {
this.getSession().setRegionSelector(toWorldEditPlayer().getWorld(), selector);
}
/**
* Get the largest region in the player's allowed WorldEdit region
*
* @return
*/
public Region getLargestRegion() {
int area = 0;
Region max = null;
for (Region region : this.getCurrentRegions()) {
final int tmp = region.getArea();
if (tmp > area) {
area = tmp;
max = region;
}
}
return max;
}
@Override
public String toString() {
return this.getName();
}
/**
* Check if the player has WorldEdit bypass enabled
*
* @return
*/
public boolean hasWorldEditBypass() {
return this.hasPermission("fawe.bypass");
}
/**
* Unregister this player (deletes all metadata etc)
* - Usually called on logout
*/
public void unregister() {
cancel(true);
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
session = getSession();
session.setClipboard(null);
session.clearHistory();
session.unregisterTools(getPlayer());
}
Fawe.get().unregister(getName());
}
/**
* Get a new EditSession from this player
*/
public EditSession getNewEditSession() {
return new EditSessionBuilder(getWorld()).player(this).build();
}
public void setVirtualWorld(VirtualWorld world) {
getSession().setVirtualWorld(world);
}
/**
* Get the World the player is editing in (may not match the world they are in)<br/>
* - e.g. If they are editing a CFI world.<br/>
* @return Editing world
*/
public World getWorldForEditing() {
VirtualWorld virtual = getSession().getVirtualWorld();
if (virtual != null) {
return virtual;
}
// CFICommands.CFISettings cfi = getMeta("CFISettings");
// if (cfi != null && cfi.hasGenerator() && cfi.getGenerator().hasPacketViewer()) {
// return cfi.getGenerator();
// }
return WorldEdit.getInstance().getPlatformManager().getWorldForEditing(getWorld());
}
public PlayerProxy createProxy() {
Player player = getPlayer();
World world = getWorldForEditing();
PlatformManager platformManager = WorldEdit.getInstance().getPlatformManager();
Player permActor = platformManager.queryCapability(Capability.PERMISSIONS).matchPlayer(player);
if (permActor == null) {
permActor = player;
}
Player cuiActor = platformManager.queryCapability(Capability.WORLDEDIT_CUI).matchPlayer(player);
if (cuiActor == null) {
cuiActor = player;
}
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
if (world instanceof VirtualWorld) {
proxy.setOffset(Vector3.ZERO.subtract(((VirtualWorld) world).getOrigin()));
}
return proxy;
}
}

Datei anzeigen

@ -2,17 +2,14 @@ package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -49,7 +46,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
return; return;
} }
} else if (this.direction) { } else if (this.direction) {
Location loc = editSession.getPlayer().getPlayer().getLocation(); Location loc = editSession.getPlayer().getLocation();
Vector3 facing = loc.getDirection().normalize(); Vector3 facing = loc.getDirection().normalize();
BlockVector3 midpoint = pos1.add(pos2).divide(2); BlockVector3 midpoint = pos1.add(pos2).divide(2);
BlockVector3 offset = midpoint.subtract(vertex); BlockVector3 offset = midpoint.subtract(vertex);

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
@ -14,7 +13,7 @@ public class CircleBrush implements Brush {
private final Player player; private final Player player;
public CircleBrush(Player player) { public CircleBrush(Player player) {
this.player = LocationMaskedPlayerWrapper.unwrap(player); this.player = player;
} }
@Override @Override

Datei anzeigen

@ -1,10 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
import com.boydti.fawe.wrappers.SilentPlayerWrapper;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
@ -35,19 +31,17 @@ public class CommandBrush implements Brush {
.replace("{world}", editSession.getWorld().getName()) .replace("{world}", editSession.getWorld().getName())
.replace("{size}", Integer.toString(radius)); .replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer(); Player player = editSession.getPlayer();
Player player = fp.getPlayer();
Location face = player.getBlockTraceFace(256, true); Location face = player.getBlockTraceFace(256, true);
if (face == null) { if (face == null) {
position = position.add(0, 1, 1); position = position.add(0, 1, 1);
} else { } else {
position = position.add(face.getDirection().toBlockPoint()); position = position.add(face.getDirection().toBlockPoint());
} }
fp.setSelection(selector); player.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position.toVector3())));
List<String> cmds = StringMan.split(replaced, ';'); List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) { for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
} }
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder; import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
import com.boydti.fawe.object.function.NullRegionFunction; import com.boydti.fawe.object.function.NullRegionFunction;
@ -49,7 +48,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
@Override @Override
public void build(final EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { public void build(final EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
FawePlayer fp = editSession.getPlayer(); Player fp = editSession.getPlayer();
ClipboardHolder clipboard = session.getExistingClipboard(); ClipboardHolder clipboard = session.getExistingClipboard();
if (clipboard == null) { if (clipboard == null) {
if (editSession.getExtent() instanceof VisualExtent) { if (editSession.getExtent() instanceof VisualExtent) {
@ -96,7 +95,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
} }
if (autoRotate) { if (autoRotate) {
if (transform == null) transform = new AffineTransform(); if (transform == null) transform = new AffineTransform();
Location loc = editSession.getPlayer().toWorldEditPlayer().getLocation(); Location loc = fp.getLocation();
float yaw = loc.getYaw(); float yaw = loc.getYaw();
float pitch = loc.getPitch(); float pitch = loc.getPitch();
transform = transform.rotateY((-yaw) % 360); transform = transform.rotateY((-yaw) % 360);

Datei anzeigen

@ -81,7 +81,7 @@ public class ImageBrush implements Brush {
double scale = Math.max(width, height) / sizeDouble; double scale = Math.max(width, height) / sizeDouble;
Location loc = editSession.getPlayer().getPlayer().getLocation(); Location loc = editSession.getPlayer().getLocation();
float yaw = loc.getYaw(); float yaw = loc.getYaw();
float pitch = loc.getPitch(); float pitch = loc.getPitch();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse();

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.change.MutableFullBlockChange; import com.boydti.fawe.object.change.MutableFullBlockChange;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
@ -23,7 +22,6 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
@ -72,8 +70,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
final int y = target.getBlockY(); final int y = target.getBlockY();
final int z = target.getBlockZ(); final int z = target.getBlockZ();
World world = player.getWorld(); World world = player.getWorld();
final FawePlayer fp = FawePlayer.wrap(player); EditSessionBuilder editSession = new EditSessionBuilder(world).player(player);
EditSessionBuilder editSession = new EditSessionBuilder(world).player(fp);
RollbackDatabase db = DBHandler.IMP.getDatabase(world); RollbackDatabase db = DBHandler.IMP.getDatabase(world);
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
db.getPotentialEdits(null, 0, target, target, new RunnableVal<DiskStorageHistory>() { db.getPotentialEdits(null, 0, target, target, new RunnableVal<DiskStorageHistory>() {
@ -93,7 +90,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
int index = value.getIndex(); int index = value.getIndex();
long age = System.currentTimeMillis() - value.getBDFile().lastModified(); long age = System.currentTimeMillis() - value.getBDFile().lastModified();
String ageFormatted = MainUtil.secToTime(age / 1000); String ageFormatted = MainUtil.secToTime(age / 1000);
BBC.TOOL_INSPECT_INFO.send(fp, name, BlockState.getFromInternalId(from).getAsString(), BlockState.getFromInternalId(to).getAsString(), ageFormatted); BBC.TOOL_INSPECT_INFO.send(player, name, BlockState.getFromInternalId(from).getAsString(), BlockState.getFromInternalId(to).getAsString(), ageFormatted);
count.incrementAndGet(); count.incrementAndGet();
return; return;
} }
@ -104,7 +101,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
}, new Runnable() { }, new Runnable() {
@Override @Override
public void run() { public void run() {
BBC.TOOL_INSPECT_INFO_FOOTER.send(fp, count); BBC.TOOL_INSPECT_INFO_FOOTER.send(player, count);
} }
}, false, false); }, false, false);
return true; return true;

Datei anzeigen

@ -1,11 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
import com.boydti.fawe.wrappers.SilentPlayerWrapper;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
@ -14,7 +10,6 @@ import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.util.Location;
import java.util.List; import java.util.List;
public class ScatterCommand extends ScatterBrush { public class ScatterCommand extends ScatterBrush {
@ -35,13 +30,11 @@ public class ScatterCommand extends ScatterBrush {
.replace("{world}", editSession.getWorld().getName()) .replace("{world}", editSession.getWorld().getName())
.replace("{size}", Integer.toString(radius)); .replace("{size}", Integer.toString(radius));
FawePlayer fp = editSession.getPlayer(); Player player = editSession.getPlayer();
Player player = fp.getPlayer(); player.setSelection(selector);
fp.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position.toVector3())));
List<String> cmds = StringMan.split(replaced, ';'); List<String> cmds = StringMan.split(replaced, ';');
for (String cmd : cmds) { for (String cmd : cmds) {
CommandEvent event = new CommandEvent(wePlayer, cmd); CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event); PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks; import com.sk89q.worldedit.function.mask.Masks;
@ -19,7 +18,6 @@ import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -53,13 +51,11 @@ public class StencilBrush extends HeightBrush {
final SolidBlockMask solid = new SolidBlockMask(editSession); final SolidBlockMask solid = new SolidBlockMask(editSession);
final AdjacentAnyMask adjacent = new AdjacentAnyMask(Masks.negate(solid)); final AdjacentAnyMask adjacent = new AdjacentAnyMask(Masks.negate(solid));
Player player = editSession.getPlayer().getPlayer();
// BlockVector3 pos = player.getLocation(); // BlockVector3 pos = player.getLocation();
Location loc = editSession.getPlayer().getPlayer().getLocation(); Location loc = editSession.getPlayer().getLocation();
float yaw = loc.getYaw(); float yaw = loc.getYaw();
float pitch = loc.getPitch(); float pitch = loc.getPitch();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse();

Datei anzeigen

@ -36,7 +36,7 @@ public class SurfaceSpline implements Brush {
if (max == -1) return; if (max == -1) return;
// pos.mutY(max); // pos.mutY(max);
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ()));
editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_PRIMARY_2.s()); editSession.getPlayer().print(BBC.BRUSH_SPLINE_PRIMARY_2.s());
if (!vis) return; if (!vis) return;
} }
LocalBlockVectorSet vset = new LocalBlockVectorSet(); LocalBlockVectorSet vset = new LocalBlockVectorSet();
@ -90,6 +90,6 @@ public class SurfaceSpline implements Brush {
editSession.setBlocks(newSet, pattern); editSession.setBlocks(newSet, pattern);
if (!vis) path.clear(); if (!vis) path.clear();
} }
editSession.getPlayer().sendMessage(BBC.BRUSH_SPLINE_SECONDARY.s()); editSession.getPlayer().print(BBC.BRUSH_SPLINE_SECONDARY.s());
} }
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.brush.sweep; package com.boydti.fawe.object.brush.sweep;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.ResettableTool;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -10,6 +9,7 @@ import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -47,7 +47,7 @@ public class SweepBrush implements Brush, ResettableTool {
boolean newPos = !position.equals(this.position); boolean newPos = !position.equals(this.position);
this.position = position; this.position = position;
FawePlayer player = editSession.getPlayer(); Player player = editSession.getPlayer();
if (newPos) { if (newPos) {
BBC.BRUSH_SPLINE_PRIMARY_2.send(player); BBC.BRUSH_SPLINE_PRIMARY_2.send(player);
positions.add(position); positions.add(position);

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.brush.visualization; package com.boydti.fawe.object.brush.visualization;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.BlockInteractEvent; import com.sk89q.worldedit.event.platform.BlockInteractEvent;
@ -28,7 +27,7 @@ public interface VirtualWorld extends SimpleWorld, Closeable {
@Override @Override
boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException; boolean setBlock(BlockVector3 pt, BlockStateHolder block) throws WorldEditException;
FawePlayer getPlayer(); Player getPlayer();
void update(); void update();

Datei anzeigen

@ -1,28 +1,18 @@
package com.boydti.fawe.object.brush.visualization; package com.boydti.fawe.object.brush.visualization;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.concurrent.Future;
public class VisualExtent extends AbstractDelegateExtent { public class VisualExtent extends AbstractDelegateExtent {
public static final BlockType VISUALIZE_BLOCK_DEFAULT = BlockTypes.BLACK_STAINED_GLASS; public static final BlockType VISUALIZE_BLOCK_DEFAULT = BlockTypes.BLACK_STAINED_GLASS;

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.brush.visualization; package com.boydti.fawe.object.brush.visualization;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.task.SingleThreadIntervalQueue; import com.boydti.fawe.object.task.SingleThreadIntervalQueue;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -8,24 +7,23 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> { public class VisualQueue extends SingleThreadIntervalQueue<Player> {
public VisualQueue(int interval) { public VisualQueue(int interval) {
super(interval); super(interval);
} }
@Override @Override
public void operate(FawePlayer fp) { public void operate(Player fp) {
LocalSession session = fp.getSession(); LocalSession session = fp.getSession();
Player player = fp.getPlayer(); Tool tool = session.getTool(fp);
Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool brushTool = (BrushTool) tool; BrushTool brushTool = (BrushTool) tool;
if (brushTool.getVisualMode() != VisualMode.NONE) { if (brushTool.getVisualMode() != VisualMode.NONE) {
try { try {
brushTool.visualize(BrushTool.BrushAction.PRIMARY, player); brushTool.visualize(BrushTool.BrushAction.PRIMARY, fp);
} catch (Throwable e) { } catch (Throwable e) {
WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player); WorldEdit.getInstance().getPlatformManager().handleThrowable(e, fp);
} }
} }
} }

Datei anzeigen

@ -3,11 +3,9 @@ package com.boydti.fawe.object.brush.visualization.cfi;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.FallbackChunkGet; import com.boydti.fawe.beta.implementation.FallbackChunkGet;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.Metadatable; import com.boydti.fawe.object.Metadatable;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.change.StreamChange; import com.boydti.fawe.object.change.StreamChange;
@ -29,6 +27,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
@ -52,8 +51,6 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -64,6 +61,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nullable;
// TODO FIXME // TODO FIXME
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld { public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
@ -208,7 +206,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
// Used for visualizing the world by sending chunk packets // Used for visualizing the world by sending chunk packets
// These three variables should be set together // These three variables should be set together
// private IQueueExtent packetQueue; // private IQueueExtent packetQueue;
private FawePlayer player; private Player player;
private BlockVector2 chunkOffset = BlockVector2.ZERO; private BlockVector2 chunkOffset = BlockVector2.ZERO;
private EditSession editSession; private EditSession editSession;
// end // end
@ -246,7 +244,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return player != null; return player != null;
} }
public void setPacketViewer(FawePlayer player) { public void setPacketViewer(Player player) {
this.player = player; this.player = player;
if (player != null) { if (player != null) {
Location pos = player.getLocation(); Location pos = player.getLocation();
@ -254,7 +252,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
} }
public FawePlayer getOwner() { public Player getOwner() {
return player; return player;
} }
@ -690,7 +688,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
@Override @Override
public FawePlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -834,8 +832,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
if (curES != null && isModified()) { if (curES != null && isModified()) {
try { try {
update(); update();
FawePlayer esPlayer = curES.getPlayer(); Player esPlayer = curES.getPlayer();
UUID uuid = esPlayer != null ? esPlayer.getUUID() : EditSession.CONSOLE; UUID uuid = esPlayer != null ? esPlayer.getUniqueId() : EditSession.CONSOLE;
try { try {
curES.setRawChangeSet(new CFIChangeSet(this, uuid)); curES.setRawChangeSet(new CFIChangeSet(this, uuid));
} catch (IOException e) { } catch (IOException e) {

Datei anzeigen

@ -1,22 +1,18 @@
package com.boydti.fawe.object.changeset; package com.boydti.fawe.object.changeset;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.beta.IQueueExtent;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.history.change.BlockChange; import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.history.change.EntityCreate; import com.sk89q.worldedit.history.change.EntityCreate;
import com.sk89q.worldedit.history.change.EntityRemove; import com.sk89q.worldedit.history.change.EntityRemove;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future; import java.util.concurrent.Future;
@ -131,12 +127,12 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
} }
@Override @Override
public EditSession toEditSession(FawePlayer player) { public EditSession toEditSession(Player player) {
return parent.toEditSession(player); return parent.toEditSession(player);
} }
@Override @Override
public EditSession toEditSession(FawePlayer player, Region[] regions) { public EditSession toEditSession(Player player, Region[] regions) {
return parent.toEditSession(player, regions); return parent.toEditSession(player, regions);
} }

Datei anzeigen

@ -6,13 +6,13 @@ import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.IntegerPair; import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -139,22 +139,22 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
enttFile.delete(); enttFile.delete();
} }
public void undo(FawePlayer fp, Region[] regions) { public void undo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions); EditSession session = toEditSession(fp, regions);
session.undo(session); session.undo(session);
deleteFiles(); deleteFiles();
} }
public void undo(FawePlayer fp) { public void undo(Player fp) {
undo(fp, null); undo(fp, null);
} }
public void redo(FawePlayer fp, Region[] regions) { public void redo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions); EditSession session = toEditSession(fp, regions);
session.redo(session); session.redo(session);
} }
public void redo(FawePlayer fp) { public void redo(Player fp) {
undo(fp, null); undo(fp, null);
} }

Datei anzeigen

@ -5,13 +5,13 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.history.change.BlockChange; import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
@ -143,11 +143,11 @@ public abstract class FaweChangeSet implements ChangeSet {
public void delete() { public void delete() {
} }
public EditSession toEditSession(FawePlayer player) { public EditSession toEditSession(Player player) {
return toEditSession(player, null); return toEditSession(player, null);
} }
public EditSession toEditSession(FawePlayer player, Region[] regions) { public EditSession toEditSession(Player player, Region[] regions) {
EditSessionBuilder builder = new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false).checkMemory(false).changeSet(this).limitUnlimited(); EditSessionBuilder builder = new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false).checkMemory(false).changeSet(this).limitUnlimited();
if (regions != null) { if (regions != null) {
builder.allowedRegions(regions); builder.allowedRegions(regions);

Datei anzeigen

@ -1,22 +1,18 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.Permission; import com.boydti.fawe.util.Permission;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class MemoryCheckingExtent extends PassthroughExtent { public class MemoryCheckingExtent extends PassthroughExtent {
private final FawePlayer<?> player; private final Player player;
public MemoryCheckingExtent(final FawePlayer<?> player, final Extent extent) { public MemoryCheckingExtent(final Player player, final Extent extent) {
super(extent); super(extent);
this.player = player; this.player = player;
} }
@ -25,8 +21,8 @@ public class MemoryCheckingExtent extends PassthroughExtent {
public Extent getExtent() { public Extent getExtent() {
if (MemUtil.isMemoryLimited()) { if (MemUtil.isMemoryLimited()) {
if (this.player != null) { if (this.player != null) {
player.sendMessage(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s())); player.print(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s()));
if (Permission.hasPermission(this.player.toWorldEditPlayer(), "worldedit.fast")) { if (Permission.hasPermission(this.player, "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(this.player); BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
} }
} }

Datei anzeigen

@ -1,10 +1,10 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.util.FaweTimer; import com.boydti.fawe.util.FaweTimer;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
@ -20,10 +20,10 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
protected final Pattern pattern; protected final Pattern pattern;
protected final UUID uuid; protected final UUID uuid;
public BufferedPattern(FawePlayer fp, Pattern parent) { public BufferedPattern(Actor actor, Pattern parent) {
this.uuid = fp.getUUID(); this.uuid = actor.getUniqueId();
long[] tmp = fp.getMeta("lastActionTime"); long[] tmp = actor.getMeta("lastActionTime");
if (tmp == null) fp.setMeta("lastActionTime", tmp = new long[2]); if (tmp == null) actor.setMeta("lastActionTime", tmp = new long[2]);
actionTime = tmp; actionTime = tmp;
this.pattern = parent; this.pattern = parent;
this.timer = Fawe.get().getTimer(); this.timer = Fawe.get().getTimer();

Datei anzeigen

@ -1,12 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
public class BufferedPattern2D extends BufferedPattern { public class BufferedPattern2D extends BufferedPattern {
public BufferedPattern2D(FawePlayer fp, Pattern parent) { public BufferedPattern2D(Actor fp, Pattern parent) {
super(fp, parent); super(fp, parent);
} }

Datei anzeigen

@ -1,15 +1,15 @@
package com.boydti.fawe.object.progress; package com.boydti.fawe.object.progress;
import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.entity.Player;
public class ChatProgressTracker extends DefaultProgressTracker { public class ChatProgressTracker extends DefaultProgressTracker {
public ChatProgressTracker(FawePlayer player) { public ChatProgressTracker(Player player) {
super(player); super(player);
setInterval(getDelay() / 50); setInterval(getDelay() / 50);
} }
@Override @Override
public void sendTile(String title, String sub) { public void sendTile(String title, String sub) {
getPlayer().sendMessage(title + sub); getPlayer().print(title + sub);
} }
} }

Datei anzeigen

@ -2,10 +2,10 @@ package com.boydti.fawe.object.progress;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.entity.Player;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
/** /**
@ -13,12 +13,12 @@ import java.util.function.BiConsumer;
*/ */
public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker.ProgressType, Integer> { public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker.ProgressType, Integer> {
private final FawePlayer player; private final Player player;
private final long start; private final long start;
private int delay = Settings.IMP.QUEUE.PROGRESS.DELAY; private int delay = Settings.IMP.QUEUE.PROGRESS.DELAY;
private int interval = Settings.IMP.QUEUE.PROGRESS.INTERVAL; private int interval = Settings.IMP.QUEUE.PROGRESS.INTERVAL;
public DefaultProgressTracker(FawePlayer player) { public DefaultProgressTracker(Player player) {
this.start = System.currentTimeMillis(); this.start = System.currentTimeMillis();
this.player = player; this.player = player;
} }
@ -39,7 +39,7 @@ public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker
return delay; return delay;
} }
public FawePlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.regions.selector; package com.boydti.fawe.object.regions.selector;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.regions.FuzzyRegion; import com.boydti.fawe.object.regions.FuzzyRegion;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ExtentTraverser;
@ -11,7 +10,6 @@ import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -33,7 +31,7 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
public FuzzyRegionSelector(Player player, @Nullable World world, Mask mask) { public FuzzyRegionSelector(Player player, @Nullable World world, Mask mask) {
super(new EditSessionBuilder(world) super(new EditSessionBuilder(world)
.player(FawePlayer.wrap(player)) .player(player)
.changeSetNull() .changeSetNull()
.checkMemory(false) .checkMemory(false)
.autoQueue(false) .autoQueue(false)
@ -53,7 +51,7 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
@Override @Override
public void setWorld(@Nullable World world) { public void setWorld(@Nullable World world) {
EditSession extent = new EditSessionBuilder(world) EditSession extent = new EditSessionBuilder(world)
.player(FawePlayer.wrap(player)) .player(player)
.changeSetNull() .changeSetNull()
.checkMemory(false) .checkMemory(false)
.autoQueue(true) .autoQueue(true)

Datei anzeigen

@ -5,10 +5,11 @@ import com.boydti.fawe.util.TaskManager;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
public abstract class SingleThreadIntervalQueue<T> { public abstract class SingleThreadIntervalQueue<T> {
private final ConcurrentHashMap<T, Long> objMap = new ConcurrentHashMap<>(); private final ConcurrentMap<T, Long> objMap = new ConcurrentHashMap<>();
private final Runnable task; private final Runnable task;
private AtomicBoolean queued = new AtomicBoolean(); private AtomicBoolean queued = new AtomicBoolean();

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.regions; package com.boydti.fawe.regions;
import com.boydti.fawe.object.FawePlayer; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.IDelegateRegion; import com.sk89q.worldedit.regions.IDelegateRegion;
@ -23,7 +23,7 @@ public class FaweMask implements IDelegateRegion {
return region; return region;
} }
public boolean isValid(FawePlayer player, FaweMaskManager.MaskType type) { public boolean isValid(Player player, FaweMaskManager.MaskType type) {
return false; return false;
} }

Datei anzeigen

@ -1,10 +1,10 @@
package com.boydti.fawe.regions; package com.boydti.fawe.regions;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.general.RegionFilter; import com.boydti.fawe.regions.general.RegionFilter;
import com.sk89q.worldedit.entity.Player;
public abstract class FaweMaskManager<T> { public abstract class FaweMaskManager {
public enum MaskType { public enum MaskType {
OWNER, OWNER,
@ -37,11 +37,11 @@ public abstract class FaweMaskManager<T> {
} }
@Deprecated @Deprecated
public FaweMask getMask(final FawePlayer<T> player) { public FaweMask getMask(final Player player) {
return getMask(player, MaskType.getDefaultMaskType()); return getMask(player, MaskType.getDefaultMaskType());
} }
public FaweMask getMask(final FawePlayer<T> player, MaskType type) { public FaweMask getMask(final Player player, MaskType type) {
return getMask(player); return getMask(player);
} }
@ -53,8 +53,8 @@ public abstract class FaweMaskManager<T> {
return null; return null;
} }
private boolean hasMemberPermission(FawePlayer fp) { private boolean hasMemberPermission(Player player) {
return fp.hasPermission("fawe." + getKey() + ".member"); return player.hasPermission("fawe." + getKey() + ".member");
} }
public boolean isExclusive() { public boolean isExclusive() {

Datei anzeigen

@ -1,16 +0,0 @@
package com.boydti.fawe.regions.general;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
public class RedProtectFeature extends FaweMaskManager {
public RedProtectFeature(String plugin) {
super(plugin);
}
@Override
public FaweMask getMask(FawePlayer player) {
return null;
}
}

Datei anzeigen

@ -1,6 +1,6 @@
package com.boydti.fawe.regions.general.plot; package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
@ -79,7 +79,7 @@ public class PlotSetBiome extends Command {
.autoQueue(false) .autoQueue(false)
.checkMemory(false) .checkMemory(false)
.allowedRegionsEverywhere() .allowedRegionsEverywhere()
.player(FawePlayer.wrap(player.getName())) .player(Fawe.imp().wrap(player.getName()))
.limitUnlimited() .limitUnlimited()
.build(); .build();
long seed = ThreadLocalRandom.current().nextLong(); long seed = ThreadLocalRandom.current().nextLong();

Datei anzeigen

@ -2,7 +2,6 @@ package com.boydti.fawe.regions.general.plot;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.SimpleRegion; import com.boydti.fawe.regions.SimpleRegion;
@ -23,6 +22,7 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
@ -89,17 +89,17 @@ public class PlotSquaredFeature extends FaweMaskManager {
} }
} }
public boolean isAllowed(FawePlayer fp, Plot plot, MaskType type) { public boolean isAllowed(com.sk89q.worldedit.entity.Player player, Plot plot, MaskType type) {
if (plot == null) { if (plot == null) {
return false; return false;
} }
UUID uid = fp.getUUID(); UUID uid = player.getUniqueId();
return !Flags.NO_WORLDEDIT.isTrue(plot) && ((plot.isOwner(uid) || (type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE) || ((plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && fp.hasPermission("fawe.plotsquared.member"))))) || fp.hasPermission("fawe.plotsquared.admin")); return !Flags.NO_WORLDEDIT.isTrue(plot) && ((plot.isOwner(uid) || (type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE) || ((plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player.hasPermission("fawe.plotsquared.member"))))) || player.hasPermission("fawe.plotsquared.admin"));
} }
@Override @Override
public FaweMask getMask(FawePlayer fp, MaskType type) { public FaweMask getMask(Player fp, MaskType type) {
final PlotPlayer pp = PlotPlayer.wrap(fp.parent); final PlotPlayer pp = PlotPlayer.wrap(fp);
final HashSet<RegionWrapper> regions; final HashSet<RegionWrapper> regions;
Plot plot = pp.getCurrentPlot(); Plot plot = pp.getCurrentPlot();
if (isAllowed(fp, plot, type)) { if (isAllowed(fp, plot, type)) {
@ -151,7 +151,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
return new FaweMask(maskedRegion) { return new FaweMask(maskedRegion) {
@Override @Override
public boolean isValid(FawePlayer player, MaskType type) { public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) { if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) {
return false; return false;
} }

Datei anzeigen

@ -8,7 +8,6 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.HistoryExtent; import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.NullChangeSet; import com.boydti.fawe.object.NullChangeSet;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -19,6 +18,7 @@ import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.NullExtent; import com.boydti.fawe.object.extent.NullExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -34,7 +34,7 @@ public class EditSessionBuilder {
private World world; private World world;
private String worldName; private String worldName;
private Extent extent; private Extent extent;
private FawePlayer player; private Player player;
private FaweLimit limit; private FaweLimit limit;
private FaweChangeSet changeSet; private FaweChangeSet changeSet;
private Region[] allowedRegions; private Region[] allowedRegions;
@ -81,7 +81,7 @@ public class EditSessionBuilder {
this.world = FaweAPI.getWorld(worldName); this.world = FaweAPI.getWorld(worldName);
} }
public EditSessionBuilder player(@Nullable FawePlayer player) { public EditSessionBuilder player(@Nullable Player player) {
this.player = player; this.player = player;
return this; return this;
} }
@ -95,7 +95,7 @@ public class EditSessionBuilder {
return limit(FaweLimit.MAX.copy()); return limit(FaweLimit.MAX.copy());
} }
public EditSessionBuilder limitUnprocessed(@Nonnull FawePlayer fp) { public EditSessionBuilder limitUnprocessed(@Nonnull Player fp) {
checkNotNull(fp); checkNotNull(fp);
limitUnlimited(); limitUnlimited();
FaweLimit tmp = fp.getLimit(); FaweLimit tmp = fp.getLimit();
@ -266,10 +266,10 @@ public class EditSessionBuilder {
eventBus = WorldEdit.getInstance().getEventBus(); eventBus = WorldEdit.getInstance().getEventBus();
} }
if (event == null) { if (event == null) {
event = new EditSessionEvent(world, player == null ? null : (player.getPlayer()), -1, null); event = new EditSessionEvent(world, player, -1, null);
} }
if (player == null && event.getActor() != null) { if (player == null && event.getActor() != null) {
player = FawePlayer.wrap(event.getActor()); player = (Player) event.getActor();
} }
if (limit == null) { if (limit == null) {
if (player == null) { if (player == null) {
@ -293,7 +293,7 @@ public class EditSessionBuilder {
} }
if (checkMemory) { if (checkMemory) {
if (MemUtil.isMemoryLimitedSlow()) { if (MemUtil.isMemoryLimitedSlow()) {
if (Permission.hasPermission(player.toWorldEditPlayer(), "worldedit.fast")) { if (Permission.hasPermission(player, "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(player); BBC.WORLDEDIT_OOM_ADMIN.send(player);
} }
throw FaweException.LOW_MEMORY; throw FaweException.LOW_MEMORY;
@ -450,7 +450,7 @@ public class EditSessionBuilder {
return limit; return limit;
} }
public FawePlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }

Datei anzeigen

@ -7,7 +7,6 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.RunnableVal2; import com.boydti.fawe.object.RunnableVal2;
@ -87,22 +86,11 @@ import net.jpountz.lz4.LZ4InputStream;
import net.jpountz.lz4.LZ4Utils; import net.jpountz.lz4.LZ4Utils;
public class MainUtil { public class MainUtil {
/*
* Generic non plugin related utils
* e.g. sending messages
*/
public static void sendMessage(final FawePlayer<?> player, String message) {
if (player == null) {
Fawe.debug(message);
} else {
player.sendMessage(message);
}
}
public static void sendAdmin(final String s) { public static void sendAdmin(final String s) {
for (final FawePlayer<?> player : Fawe.get().getCachedPlayers()) { for (final Player player : Fawe.get().getCachedPlayers()) {
if (player.hasPermission("fawe.admin")) { if (player.hasPermission("fawe.admin")) {
player.sendMessage(s); player.print(s);
} }
} }
Fawe.debug(s); Fawe.debug(s);

Datei anzeigen

@ -1,22 +1,24 @@
package com.boydti.fawe.util; package com.boydti.fawe.util;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.NullExtent; import com.boydti.fawe.object.extent.NullExtent;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class WEManager { public class WEManager {
@ -63,7 +65,7 @@ public class WEManager {
} }
@Deprecated @Deprecated
public Region[] getMask(FawePlayer<?> player) { public Region[] getMask(Player player) {
return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType()); return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType());
} }
@ -77,7 +79,7 @@ public class WEManager {
* @param player * @param player
* @return * @return
*/ */
public Region[] getMask(FawePlayer<?> player, FaweMaskManager.MaskType type) { public Region[] getMask(Player player, FaweMaskManager.MaskType type) {
if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) { if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) {
return new Region[]{RegionWrapper.GLOBAL()}; return new Region[]{RegionWrapper.GLOBAL()};
} }

Datei anzeigen

@ -1,41 +0,0 @@
package com.boydti.fawe.wrappers;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
public class LocationMaskedPlayerWrapper extends PlayerWrapper {
private final boolean allowTeleport;
private Location position;
public LocationMaskedPlayerWrapper(Player parent, Location position) {
this(parent, position, false);
}
public LocationMaskedPlayerWrapper(Player parent, Location position, boolean allowTeleport) {
super(parent);
this.position = position;
this.allowTeleport = allowTeleport;
}
public static Player unwrap(Player object) {
if (object instanceof LocationMaskedPlayerWrapper) {
return ((LocationMaskedPlayerWrapper) object).getParent();
} else {
return object;
}
}
@Override
public Location getLocation() {
return position;
}
@Override
public void setPosition(Vector3 pos, float pitch, float yaw) {
this.position = new Location(position.getExtent(), pos, pitch, yaw);
if (allowTeleport) {
super.setPosition(pos, pitch, yaw);
}
}
}

Datei anzeigen

@ -1,424 +0,0 @@
package com.boydti.fawe.wrappers;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import javax.annotation.Nullable;
import java.io.File;
import java.util.UUID;
public class PlayerWrapper extends AbstractPlayerActor {
private final Player parent;
public PlayerWrapper(Player parent) {
this.parent = parent;
}
public static PlayerWrapper wrap(Player parent) {
if (parent instanceof PlayerWrapper) {
return (PlayerWrapper) parent;
}
return new PlayerWrapper(parent);
}
public Player getParent() {
return parent;
}
@Override
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
return parent.getBlockInHand(handSide);
}
@Override
public UUID getUniqueId() {
return parent.getUniqueId();
}
@Override
public BaseItemStack getItemInHand(HandSide handSide) {
return parent.getItemInHand(handSide);
}
@Override
public void giveItem(BaseItemStack itemStack) {
parent.giveItem(itemStack);
}
@Override
public BlockBag getInventoryBlockBag() {
return parent.getInventoryBlockBag();
}
@Override
public String getName() {
return parent.getName();
}
@Override
public BaseEntity getState() {
throw new UnsupportedOperationException("Can't withPropertyId() on a player");
}
@Override
public Location getLocation() {
return this.parent.getLocation();
}
@Override
public void setPosition(Vector3 pos, float pitch, float yaw) {
parent.setPosition(pos, pitch, yaw);
}
@Override
public World getWorld() {
return WorldWrapper.wrap(parent.getWorld());
}
@Override
public void printRaw(String msg) {
parent.printRaw(msg);
}
@Override
public void printDebug(String msg) {
parent.printDebug(msg);
}
@Override
public void print(String msg) {
parent.print(msg);
}
@Override
public void printError(String msg) {
parent.printError(msg);
}
@Override public void print(Component component) {
parent.print(component);
}
@Override
public String[] getGroups() {
return parent.getGroups();
}
@Override
public boolean hasPermission(String perm) {
return parent.hasPermission(perm);
}
@Override public boolean togglePermission(String permission) {
return parent.togglePermission(permission);
}
@Override public void setPermission(String permission, boolean value) {
parent.setPermission(permission, value);
}
@Override
public void dispatchCUIEvent(CUIEvent event) {
parent.dispatchCUIEvent(event);
}
@Nullable
@Override
public <T> T getFacet(Class<? extends T> cls) {
return parent.getFacet(cls);
}
@Override
public SessionKey getSessionKey() {
return parent.getSessionKey();
}
@Override
public GameMode getGameMode() {
return parent.getGameMode();
}
@Override
public void setGameMode(GameMode gameMode) {
parent.setGameMode(gameMode);
}
@Override
public void findFreePosition(Location searchPos) {
TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
PlayerWrapper.super.findFreePosition(searchPos);
}
});
}
@Override
public void setOnGround(Location searchPos) {
TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
PlayerWrapper.super.setOnGround(searchPos);
}
});
}
@Override
public void findFreePosition() {
TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
parent.findFreePosition();
}
});
}
@Override
public boolean ascendLevel() {
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
this.value = parent.ascendLevel();
}
});
}
@Override
public boolean descendLevel() {
return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override
public void run(Boolean value) {
this.value = parent.descendLevel();
}
});
}
@Override
public boolean ascendToCeiling(int clearance) {
return ascendToCeiling(clearance, true);
}
@Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
Location pos = getBlockIn();
int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2);
int z = pos.getBlockZ();
Extent world = getLocation().getExtent();
// No free space above
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) {
return false;
}
while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling!
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
}
++y;
}
return false;
}
@Override
public boolean ascendUpwards(int distance) {
return ascendUpwards(distance, true);
}
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Location pos = getBlockIn();
final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
final int z = pos.getBlockZ();
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
final Extent world = getLocation().getExtent();
while (y <= world.getMaximumPoint().getY() + 2) {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
break; // Hit something
} else if (y > maxY + 1) {
break;
} else if (y == maxY + 1) {
floatAt(x, y - 1, z, alwaysGlass);
return true;
}
++y;
}
return false;
}
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
RuntimeException caught = null;
try {
EditSession edit = new EditSessionBuilder(parent.getWorld()).player(FawePlayer.wrap(this)).build();
edit.setBlock(BlockVector3.at(x, y - 1, z), BlockTypes.GLASS);
edit.flushQueue();
LocalSession session = Fawe.get().getWorldEdit().getSessionManager().get(this);
if (session != null) {
session.remember(edit, true, FawePlayer.wrap(this).getLimit().MAX_HISTORY);
}
} catch (RuntimeException e) {
caught = e;
}
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
}
});
if (caught != null) {
throw caught;
}
}
@Override
public Location getBlockTrace(int range, boolean useLastBlock) {
return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override
public void run(Location value) {
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
this.value = useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock();
}
});
}
@Override
public Location getBlockTraceFace(int range, boolean useLastBlock) {
return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override
public void run(Location value) {
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
this.value = useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace();
}
});
}
@Override
public Location getSolidBlockTrace(int range) {
return TaskManager.IMP.sync(new RunnableVal<Location>() {
@Override
public void run(Location value) {
TargetBlock tb = new TargetBlock(PlayerWrapper.this, range, 0.2D);
this.value = tb.getSolidTargetBlock();
}
});
}
@Override
public Direction getCardinalDirection() {
return parent.getCardinalDirection();
}
@Override
public boolean passThroughForwardWall(int range) {
return TaskManager.IMP.sync(() -> {
int searchDist = 0;
TargetBlock hitBlox = new TargetBlock(PlayerWrapper.this, range, 0.2);
Extent world = getLocation().getExtent();
Location block;
boolean firstBlock = true;
int freeToFind = 2;
boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) {
boolean free = !world.getBlock(BlockVector3.at(block.getBlockX(), block.getBlockY(), block.getBlockZ())).getBlockType().getMaterial().isMovementBlocker();
if (firstBlock) {
firstBlock = false;
if (!free) {
--freeToFind;
continue;
}
}
++searchDist;
if (searchDist > 20) {
return false;
}
if (inFree != free) {
if (free) {
--freeToFind;
}
}
if (freeToFind == 0) {
setOnGround(block);
return true;
}
inFree = free;
}
return false;
});
}
@Override
public boolean remove() {
return parent.remove();
}
@Override
public boolean canDestroyBedrock() {
return parent.canDestroyBedrock();
}
@Override
public boolean isPlayer() {
return parent.isPlayer();
}
@Override
public File openFileOpenDialog(String[] extensions) {
return parent.openFileOpenDialog(extensions);
}
@Override
public File openFileSaveDialog(String[] extensions) {
return parent.openFileSaveDialog(extensions);
}
@Override
public boolean setLocation(Location location) {
return parent.setLocation(location);
}
}

Datei anzeigen

@ -1,24 +0,0 @@
package com.boydti.fawe.wrappers;
import com.sk89q.worldedit.entity.Player;
/**
* Still prints error messages
*/
public class SilentPlayerWrapper extends PlayerWrapper {
public SilentPlayerWrapper(Player parent) {
super(parent);
}
@Override
public void print(String msg) {
}
@Override
public void printDebug(String msg) {
}
@Override
public void printRaw(String msg) {
}
}

Datei anzeigen

@ -48,7 +48,7 @@ public class CompoundTag extends Tag {
* @return true if the tag contains the given key * @return true if the tag contains the given key
*/ */
public boolean containsKey(String key) { public boolean containsKey(String key) {
return getValue().containsKey(key); return value.containsKey(key);
} }
@Override @Override
@ -85,7 +85,7 @@ public class CompoundTag extends Tag {
* @return a byte array * @return a byte array
*/ */
public byte[] getByteArray(String key) { public byte[] getByteArray(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ByteArrayTag) { if (tag instanceof ByteArrayTag) {
return ((ByteArrayTag) tag).getValue(); return ((ByteArrayTag) tag).getValue();
} else { } else {
@ -103,7 +103,7 @@ public class CompoundTag extends Tag {
* @return a byte * @return a byte
*/ */
public byte getByte(String key) { public byte getByte(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ByteTag) { if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue(); return ((ByteTag) tag).getValue();
} else { } else {
@ -121,7 +121,7 @@ public class CompoundTag extends Tag {
* @return a double * @return a double
*/ */
public double getDouble(String key) { public double getDouble(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof DoubleTag) { if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue(); return ((DoubleTag) tag).getValue();
} else { } else {
@ -140,7 +140,7 @@ public class CompoundTag extends Tag {
* @return a double * @return a double
*/ */
public double asDouble(String key) { public double asDouble(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ByteTag) { if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue(); return ((ByteTag) tag).getValue();
@ -174,7 +174,7 @@ public class CompoundTag extends Tag {
* @return a float * @return a float
*/ */
public float getFloat(String key) { public float getFloat(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof FloatTag) { if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue(); return ((FloatTag) tag).getValue();
} else { } else {
@ -192,7 +192,7 @@ public class CompoundTag extends Tag {
* @return an int array * @return an int array
*/ */
public int[] getIntArray(String key) { public int[] getIntArray(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof IntArrayTag) { if (tag instanceof IntArrayTag) {
return ((IntArrayTag) tag).getValue(); return ((IntArrayTag) tag).getValue();
} else { } else {
@ -210,7 +210,7 @@ public class CompoundTag extends Tag {
* @return an int * @return an int
*/ */
public int getInt(String key) { public int getInt(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof IntTag) { if (tag instanceof IntTag) {
return ((IntTag) tag).getValue(); return ((IntTag) tag).getValue();
} else { } else {
@ -229,7 +229,7 @@ public class CompoundTag extends Tag {
* @return an int * @return an int
*/ */
public int asInt(String key) { public int asInt(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ByteTag) { if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue(); return ((ByteTag) tag).getValue();
@ -263,7 +263,7 @@ public class CompoundTag extends Tag {
* @return a list of tags * @return a list of tags
*/ */
public List<Tag> getList(String key) { public List<Tag> getList(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ListTag) { if (tag instanceof ListTag) {
return ((ListTag) tag).getValue(); return ((ListTag) tag).getValue();
} else { } else {
@ -281,7 +281,7 @@ public class CompoundTag extends Tag {
* @return a tag list instance * @return a tag list instance
*/ */
public ListTag getListTag(String key) { public ListTag getListTag(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ListTag) { if (tag instanceof ListTag) {
return (ListTag) tag; return (ListTag) tag;
} else { } else {
@ -304,7 +304,7 @@ public class CompoundTag extends Tag {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Tag> List<T> getList(String key, Class<T> listType) { public <T extends Tag> List<T> getList(String key, Class<T> listType) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ListTag) { if (tag instanceof ListTag) {
ListTag listTag = (ListTag) tag; ListTag listTag = (ListTag) tag;
if (listTag.getType().equals(listType)) { if (listTag.getType().equals(listType)) {
@ -327,7 +327,7 @@ public class CompoundTag extends Tag {
* @return an int array * @return an int array
*/ */
public long[] getLongArray(String key) { public long[] getLongArray(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof LongArrayTag) { if (tag instanceof LongArrayTag) {
return ((LongArrayTag) tag).getValue(); return ((LongArrayTag) tag).getValue();
} else { } else {
@ -345,7 +345,7 @@ public class CompoundTag extends Tag {
* @return a long * @return a long
*/ */
public long getLong(String key) { public long getLong(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof LongTag) { if (tag instanceof LongTag) {
return ((LongTag) tag).getValue(); return ((LongTag) tag).getValue();
} else { } else {
@ -364,7 +364,7 @@ public class CompoundTag extends Tag {
* @return a long * @return a long
*/ */
public long asLong(String key) { public long asLong(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ByteTag) { if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue(); return ((ByteTag) tag).getValue();
@ -398,7 +398,7 @@ public class CompoundTag extends Tag {
* @return a short * @return a short
*/ */
public short getShort(String key) { public short getShort(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof ShortTag) { if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue(); return ((ShortTag) tag).getValue();
} else { } else {
@ -416,7 +416,7 @@ public class CompoundTag extends Tag {
* @return a string * @return a string
*/ */
public String getString(String key) { public String getString(String key) {
Tag tag = getValue().get(key); Tag tag = value.get(key);
if (tag instanceof StringTag) { if (tag instanceof StringTag) {
return ((StringTag) tag).getValue(); return ((StringTag) tag).getValue();
} else { } else {
@ -437,8 +437,8 @@ public class CompoundTag extends Tag {
@Override @Override
public String toString() { public String toString() {
StringBuilder bldr = new StringBuilder(); StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(": ").append(getValue().size()).append(" entries\r\n{\r\n"); bldr.append("TAG_Compound").append(": ").append(value.size()).append(" entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : getValue().entrySet()) { for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
} }
bldr.append("}"); bldr.append("}");

Datei anzeigen

@ -28,7 +28,6 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.HistoryExtent; import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
@ -49,11 +48,9 @@ import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.google.common.base.Supplier;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent; import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.ChangeSetExtent; import com.sk89q.worldedit.extent.ChangeSetExtent;
@ -65,10 +62,12 @@ import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent; import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
import com.sk89q.worldedit.function.GroundFunction; import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.ForestGenerator; import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.BoundedHeightMask; import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
@ -95,7 +94,6 @@ import com.sk89q.worldedit.function.visitor.NonRisingVisitor;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
@ -125,10 +123,8 @@ import com.sk89q.worldedit.regions.shape.RegionShape;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.SimpleWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -138,8 +134,6 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -209,7 +203,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
private AbstractDelegateExtent bypassAll; private AbstractDelegateExtent bypassAll;
private final FaweLimit originalLimit; private final FaweLimit originalLimit;
private final FaweLimit limit; private final FaweLimit limit;
private final FawePlayer player; private final Player player;
private FaweChangeSet changeTask; private FaweChangeSet changeTask;
private final MutableBlockVector3 mutablebv = new MutableBlockVector3(); private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
@ -222,11 +216,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7"); public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
@Deprecated @Deprecated
public EditSession(@Nonnull World world, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { public EditSession(@Nonnull World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event); this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
} }
public EditSession(@Nullable String worldName, @Nullable World world, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { public EditSession(@Nullable String worldName, @Nullable World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event)); this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event));
} }
@ -332,7 +326,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return * @return
*/ */
@Nullable @Nullable
public FawePlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -794,18 +788,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return getExtent().getFullBlock(position); return getExtent().getFullBlock(position);
} }
/**
* Get a block type at the given position.
*
* @param position the position
* @return the block type
* @deprecated Use {@link #getBlock(BlockVector3)} or {@link #getBlock(BlockVector3)}
*/
@Deprecated
public BlockType getBlockType(final BlockVector3 position) {
return getBlockType(position.getBlockX(), position.getBlockY(), position.getBlockZ());
}
/** /**
* Returns the highest solid 'terrain' block. * Returns the highest solid 'terrain' block.
* *
@ -842,6 +824,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return y; return y;
} }
} }
return minY; return minY;
} }
@ -980,56 +963,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return changes; return changes;
} }
/**
* Set a block (only if a previous block was not there) if {@link Math#random()}
* returns a number less than the given probability.
*
* @param position the position
* @param block the block
* @param probability a probability between 0 and 1, inclusive
* @return Whether the block changed -- not entirely dependable
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public boolean setChanceBlockIfAir(final BlockVector3 position, final BaseBlock block, final double probability) throws MaxChangedBlocksException {
return (ThreadLocalRandom.current().nextInt(65536) <= (probability * 65536)) && this.setBlockIfAir(position, block);
}
/**
* Set a block only if there's no block already there.
*
* @param position the position
* @param block the block to set
* @return if block was changed
* @throws MaxChangedBlocksException thrown if too many blocks are changed
* @deprecated Use your own method
*/
@Deprecated
public boolean setBlockIfAir(final BlockVector3 position, final BlockStateHolder block) throws MaxChangedBlocksException {
return this.getBlock(position).getBlockType().getMaterial().isAir() && this.setBlock(position, block);
}
@Override @Override
@Nullable @Nullable
public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) { public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
return getExtent().createEntity(location, entity); return getExtent().createEntity(location, entity);
} }
/**
* Insert a contrived block change into the history.
*
* @param position the position
* @param existing the previous block at that position
* @param block the new block
* @deprecated Get the change set with {@link #getChangeSet()} and add the change with that
*/
@Deprecated
public void rememberChange(final BlockVector3 position, final BaseBlock existing, final BaseBlock block) {
ChangeSet changeSet = getChangeSet();
if (changeSet != null) {
changeSet.add(new BlockChange(position, existing, block));
}
}
/** /**
* Restores all blocks to their initial state. * Restores all blocks to their initial state.
* *
@ -1393,10 +1332,90 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
getWorld(), // Causes clamping of Y range getWorld(), // Causes clamping of Y range
position.add(adjustment.multiply(-1)), position.add(adjustment.multiply(-1)),
position.add(adjustment)); position.add(adjustment));
Pattern pattern = BlockTypes.AIR.getDefaultState(); return replaceBlocks(region, mask, BlockTypes.AIR.getDefaultState());
}
/**
* Sets all the blocks inside a region to a given block type.
*
* @param region the region
* @param block the block
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
return setBlocks(region, (Pattern) block);
}
/**
* Sets all the blocks inside a region to a given pattern.
*
* @param region the region
* @param pattern the pattern that provides the replacement block
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern);
RegionVisitor visitor = new RegionVisitor(region, replace);
Operations.completeLegacy(visitor);
return visitor.getAffected();
}
/**
* Replaces all the blocks matching a given filter, within a given region, to a block
* returned by a given pattern.
*
* @param region the region to replace the blocks within
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
* @param replacement the replacement block
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return replaceBlocks(region, filter, (Pattern) replacement);
}
/**
* Replaces all the blocks matching a given filter, within a given region, to a block
* returned by a given pattern.
*
* @param region the region to replace the blocks within
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
* @param pattern the pattern that provides the new blocks
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMask(this, filter);
return replaceBlocks(region, mask, pattern); return replaceBlocks(region, mask, pattern);
} }
/**
* Replaces all the blocks matching a given mask, within a given region, to a block
* returned by a given pattern.
*
* @param region the region to replace the blocks within
* @param mask the mask that blocks must match
* @param pattern the pattern that provides the new blocks
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(mask);
checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, pattern);
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
RegionVisitor visitor = new RegionVisitor(region, filter);
Operations.completeLegacy(visitor);
return visitor.getAffected();
}
/** /**
* Sets the blocks at the center of the given region to the given pattern. * Sets the blocks at the center of the given region to the given pattern.
* If the center sits between two blocks on a certain axis, then two blocks * If the center sits between two blocks on a certain axis, then two blocks
@ -1413,10 +1432,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
Vector3 center = region.getCenter(); Vector3 center = region.getCenter();
Region centerRegion = new CuboidRegion( Region centerRegion = new CuboidRegion(
getWorld(), // Causes clamping of Y range getWorld(), // Causes clamping of Y range
BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())), BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
BlockVector3.at(MathUtils.roundHalfUp(center.getX()), BlockVector3.at(
center.getY(), MathUtils.roundHalfUp(center.getZ()))); MathUtils.roundHalfUp(center.getX()),
MathUtils.roundHalfUp(center.getY()),
MathUtils.roundHalfUp(center.getZ())));
return setBlocks(centerRegion, pattern); return setBlocks(centerRegion, pattern);
} }
@ -1481,7 +1502,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException { public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException {
return makeCuboidWalls(region, block); return makeCuboidWalls(region, (Pattern) block);
} }
/** /**
@ -1528,6 +1549,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) { if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
return true; return true;
} }
return false; return false;
} }
}, pattern); }, pattern);
@ -1546,7 +1568,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
*/ */
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException { public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block); checkNotNull(block);
return overlayCuboidBlocks(region, block);
return overlayCuboidBlocks(region, (Pattern) block);
} }
/** /**
@ -1591,7 +1614,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
/** /**
* Stack a cuboid region. * Stack a cuboid region. For compatibility, entities are copied but biomes are not.
* Use {@link #stackCuboidRegion(Region, BlockVector3, int, boolean, boolean, Mask)} to fine tune.
* *
* @param region the region to stack * @param region the region to stack
* @param dir the direction to stack * @param dir the direction to stack
@ -1636,10 +1660,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return number of blocks moved * @return number of blocks moved
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, boolean copyEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException { public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir,
boolean moveEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException {
checkNotNull(region); checkNotNull(region);
checkNotNull(dir); checkNotNull(dir);
checkArgument(distance >= 1, "distance >= 1 required"); checkArgument(distance >= 1, "distance >= 1 required");
checkArgument(!copyBiomes || region instanceof FlatRegion, "can't copy biomes from non-flat region");
BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance)); BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
final BlockVector3 displace = dir.multiply(distance); final BlockVector3 displace = dir.multiply(distance);
@ -1656,10 +1683,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState(); if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement); BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
copy.setCopyingBiomes(copyBiomes);
copy.setCopyingEntities(copyEntities);
copy.setSourceFunction(remove); // Remove copy.setSourceFunction(remove); // Remove
copy.setRemovingEntities(true);
copy.setCopyingEntities(moveEntities);
copy.setRemovingEntities(moveEntities);
copy.setCopyingBiomes(copyBiomes);
copy.setRepetitions(1); copy.setRepetitions(1);
Mask sourceMask = getSourceMask(); Mask sourceMask = getSourceMask();
if (sourceMask != null) { if (sourceMask != null) {
@ -1670,6 +1698,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (!copyAir) { if (!copyAir) {
copy.setSourceMask(new ExistingBlockMask(this)); copy.setSourceMask(new ExistingBlockMask(this));
} }
Operations.completeBlindly(copy); Operations.completeBlindly(copy);
return this.changes = copy.getAffected(); return this.changes = copy.getAffected();
} }
@ -1851,6 +1880,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
final int ceilRadiusX = (int) Math.ceil(radiusX); final int ceilRadiusX = (int) Math.ceil(radiusX);
final int ceilRadiusZ = (int) Math.ceil(radiusZ); final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double xSqr, zSqr; double xSqr, zSqr;
double distanceSq; double distanceSq;
double nextXn = 0; double nextXn = 0;
@ -2044,6 +2074,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException { public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
int affected = 0;
radiusX += 0.5; radiusX += 0.5;
radiusY += 0.5; radiusY += 0.5;
radiusZ += 0.5; radiusZ += 0.5;
@ -2629,7 +2661,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit); final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
// transform // transform
expression.evaluateTimeout(timeout, scaled.getX(), scaled.getY(), scaled.getZ()); expression.evaluate(new double[]{scaled.getX(), scaled.getY(), scaled.getZ()}, timeout);
int xv = (int) (x.getValue() * unit.getX() + zero2.getX()); int xv = (int) (x.getValue() * unit.getX() + zero2.getX());
int yv = (int) (y.getValue() * unit.getY() + zero2.getY()); int yv = (int) (y.getValue() * unit.getY() + zero2.getY());
int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ()); int zv = (int) (z.getValue() * unit.getZ() + zero2.getZ());

Datei anzeigen

@ -26,7 +26,6 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.FaweChangeSet;
@ -373,7 +372,7 @@ public class LocalSession implements TextureHolder {
public void remember(EditSession editSession) { public void remember(EditSession editSession) {
checkNotNull(editSession); checkNotNull(editSession);
FawePlayer fp = editSession.getPlayer(); Player fp = editSession.getPlayer();
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY; int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
remember(editSession, true, limit); remember(editSession, true, limit);
} }
@ -457,9 +456,9 @@ public class LocalSession implements TextureHolder {
return; return;
} }
FawePlayer fp = editSession.getPlayer(); Player fp = editSession.getPlayer();
if (fp != null) { if (fp != null) {
loadSessionHistoryFromDisk(fp.getUUID(), editSession.getWorld()); loadSessionHistoryFromDisk(fp.getUniqueId(), editSession.getWorld());
} }
// Destroy any sessions after this undo point // Destroy any sessions after this undo point
if (append) { if (append) {
@ -509,8 +508,7 @@ public class LocalSession implements TextureHolder {
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) { public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor); checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer //TODO This method needs to be modified to use actors instead of FAWEPlayer
FawePlayer fp = FawePlayer.wrap((Player)actor); loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing());
if (getHistoryNegativeIndex() < history.size()) { if (getHistoryNegativeIndex() < history.size()) {
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex())); FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld()) try (EditSession newEditSession = new EditSessionBuilder(changeSet.getWorld())
@ -518,8 +516,8 @@ public class LocalSession implements TextureHolder {
.checkMemory(false) .checkMemory(false)
.changeSetNull() .changeSetNull()
.fastmode(false) .fastmode(false)
.limitUnprocessed(fp) .limitUnprocessed((Player)actor)
.player(fp) .player((Player)actor)
.blockBag(getBlockBag((Player)actor)) .blockBag(getBlockBag((Player)actor))
.build()) { .build()) {
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO); newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.UNDO);
@ -547,8 +545,7 @@ public class LocalSession implements TextureHolder {
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) { public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor); checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer //TODO This method needs to be modified to use actors instead of FAWEPlayer
FawePlayer fp = FawePlayer.wrap((Player)actor); loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
loadSessionHistoryFromDisk(actor.getUniqueId(), fp.getWorldForEditing());
if (getHistoryNegativeIndex() > 0) { if (getHistoryNegativeIndex() > 0) {
setDirty(); setDirty();
historyNegativeIndex--; historyNegativeIndex--;
@ -558,8 +555,8 @@ public class LocalSession implements TextureHolder {
.checkMemory(false) .checkMemory(false)
.changeSetNull() .changeSetNull()
.fastmode(false) .fastmode(false)
.limitUnprocessed(fp) .limitUnprocessed((Player)actor)
.player(fp) .player((Player)actor)
.blockBag(getBlockBag((Player)actor)) .blockBag(getBlockBag((Player)actor))
.build()) { .build()) {
newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO); newEditSession.setBlocks(changeSet, ChangeSetExecutor.Type.REDO);
@ -578,6 +575,7 @@ public class LocalSession implements TextureHolder {
public World getWorldOverride() { public World getWorldOverride() {
return this.worldOverride; return this.worldOverride;
} }
public void setWorldOverride(@Nullable World worldOverride) { public void setWorldOverride(@Nullable World worldOverride) {
this.worldOverride = worldOverride; this.worldOverride = worldOverride;
} }
@ -904,7 +902,7 @@ public class LocalSession implements TextureHolder {
@Nullable @Nullable
public BlockBag getBlockBag(Player player) { public BlockBag getBlockBag(Player player) {
checkNotNull(player); checkNotNull(player);
if (!useInventory && FawePlayer.wrap(player).getLimit().INVENTORY_MODE == 0) { if (!useInventory && player.getLimit().INVENTORY_MODE == 0) {
return null; return null;
} }
return player.getInventoryBlockBag(); return player.getInventoryBlockBag();
@ -955,7 +953,6 @@ public class LocalSession implements TextureHolder {
* @return the tool, which may be {@code null} * @return the tool, which may be {@code null}
*/ */
@Nullable @Nullable
@Deprecated
public Tool getTool(ItemType item) { public Tool getTool(ItemType item) {
return tools[item.getInternalId()]; return tools[item.getInternalId()];
} }
@ -1364,7 +1361,7 @@ public class LocalSession implements TextureHolder {
world = (World) ((Locatable) actor).getExtent(); world = (World) ((Locatable) actor).getExtent();
} }
EditSessionBuilder builder = new EditSessionBuilder(world); EditSessionBuilder builder = new EditSessionBuilder(world);
if (actor.isPlayer() && actor instanceof Player) builder.player(FawePlayer.wrap(actor)); if (actor.isPlayer() && actor instanceof Player) builder.player((Player) actor);
builder.blockBag(blockBag); builder.blockBag(blockBag);
builder.fastmode(fastMode); builder.fastmode(fastMode);

Datei anzeigen

@ -109,7 +109,7 @@ public class BiomeCommands {
descFooter = "By default, uses all blocks in your selection." descFooter = "By default, uses all blocks in your selection."
) )
@CommandPermissions("worldedit.biome.info") @CommandPermissions("worldedit.biome.info")
public void biomeInfo(Player player, LocalSession session, EditSession editSession, public void biomeInfo(Player player, LocalSession session,
@Switch(name = 't', desc = "Use the block you are looking at.") @Switch(name = 't', desc = "Use the block you are looking at.")
boolean useLineOfSight, boolean useLineOfSight,
@Switch(name = 'p', desc = "Use the block you are currently in.") @Switch(name = 'p', desc = "Use the block you are currently in.")

Datei anzeigen

@ -25,7 +25,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.BlendBall; import com.boydti.fawe.object.brush.BlendBall;
import com.boydti.fawe.object.brush.BlobBrush; import com.boydti.fawe.object.brush.BlobBrush;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
@ -127,7 +126,6 @@ import java.net.URI;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.util.List; import java.util.List;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -647,8 +645,7 @@ public class BrushCommands {
Mask maskOpt, InjectedValueAccess context) throws WorldEditException { Mask maskOpt, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
FawePlayer fp = FawePlayer.wrap(player); FaweLimit limit = Settings.IMP.getLimit(player);
FaweLimit limit = Settings.IMP.getLimit(fp);
iterations = Math.min(limit.MAX_ITERATIONS, iterations); iterations = Math.min(limit.MAX_ITERATIONS, iterations);
set(session, context, set(session, context,

Datei anzeigen

@ -27,7 +27,6 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
@ -116,7 +115,7 @@ public class ClipboardCommands {
desc = "Copy the selection to the clipboard" desc = "Copy the selection to the clipboard"
) )
@CommandPermissions("worldedit.clipboard.copy") @CommandPermissions("worldedit.clipboard.copy")
public void copy(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void copy(Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
@Switch(name = 'e', desc = "Skip copy entities") @Switch(name = 'e', desc = "Skip copy entities")
boolean skipEntities, boolean skipEntities,
@ -129,11 +128,11 @@ public class ClipboardCommands {
long volume = long volume =
((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1);
FaweLimit limit = FawePlayer.wrap(player).getLimit(); FaweLimit limit = player.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweException.MAX_CHECKS;
} }
fp.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
session.setClipboard(null); session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
@ -178,7 +177,7 @@ public class ClipboardCommands {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit(); FaweLimit limit = player.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
} }
@ -210,7 +209,7 @@ public class ClipboardCommands {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit(); FaweLimit limit = player.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweException.MAX_CHECKS;
} }
@ -234,7 +233,7 @@ public class ClipboardCommands {
) )
@CommandPermissions("worldedit.clipboard.cut") @CommandPermissions("worldedit.clipboard.cut")
@Logging(REGION) @Logging(REGION)
public void cut(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void cut(Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "Pattern to leave in place of the selection", def = "air") @Arg(desc = "Pattern to leave in place of the selection", def = "air")
Pattern leavePattern, Pattern leavePattern,
@ -249,14 +248,14 @@ public class ClipboardCommands {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(player).getLimit(); FaweLimit limit = player.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweException.MAX_CHECKS;
} }
if (volume >= limit.MAX_CHANGES) { if (volume >= limit.MAX_CHANGES) {
throw FaweException.MAX_CHANGES; throw FaweException.MAX_CHANGES;
} }
fp.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
session.setClipboard(null); session.setClipboard(null);
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());

Datei anzeigen

@ -28,7 +28,6 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgum
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
@ -92,7 +91,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.caves") @CommandPermissions("worldedit.generation.caves")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void caves(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, public void caves(Player fp, LocalSession session, EditSession editSession, @Selection Region region,
@Arg(name = "size", desc = "TODO", def = "8") int sizeOpt, @Arg(name = "size", desc = "TODO", def = "8") int sizeOpt,
@Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt, @Arg(name = "frequency", desc = "TODO", def = "40") int frequencyOpt,
@Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt, @Arg(name = "rarity", desc = "TODO", def = "7") int rarityOpt,
@ -117,7 +116,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.ore") @CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void ores(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException { public void ores(Player fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
editSession.addOres(region, mask); editSession.addOres(region, mask);
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
@ -171,7 +170,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.ore") @CommandPermissions("worldedit.generation.ore")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void ore(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Arg(name="size", desc="Ore vein size") @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException { public void ore(Player fp, LocalSession session, EditSession editSession, @Selection Region region, Mask mask, Pattern material, @Arg(name="size", desc="Ore vein size") @Range(min = 0) int size, int freq, @Range(min = 0, max = 100) int rarity, @Range(min = 0, max = 255) int minY, @Range(min = 0, max = 255) int maxY, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount()); BBC.VISITOR_BLOCK.send(fp, editSession.getBlockChangeCount());
@ -184,7 +183,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hcyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void hcyl(Player fp, Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
BlockVector2 radius, BlockVector2 radius,
@ -206,7 +205,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.cylinder") @CommandPermissions("worldedit.generation.cylinder")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void cyl(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void cyl(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
BlockVector2 radius, BlockVector2 radius,
@ -217,9 +216,9 @@ public class GenerationCommands {
double max = Math.max(radius.getBlockX(), radius.getBlockZ()); double max = Math.max(radius.getBlockX(), radius.getBlockZ());
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
fp.checkConfirmationRadius(() -> { player.checkConfirmationRadius(() -> {
int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow); int affected = editSession.makeCylinder(pos, pattern, radius.getX(), radius.getZ(), Math.min(256, height), !hollow);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, "/cyl", (int) max, context); }, "/cyl", (int) max, context);
} }
@ -229,14 +228,14 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void hsphere(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W") BlockVector3 radii, @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W") BlockVector3 radii,
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position") @Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised, boolean raised,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
sphere(fp, player, session, editSession, pattern, radii, raised, true, context); sphere(player, session, editSession, pattern, radii, raised, true, context);
} }
@Command( @Command(
@ -245,7 +244,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.sphere") @CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void sphere(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate") @Arg(desc = "The pattern of blocks to generate")
Pattern pattern, Pattern pattern,
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W") @Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
@ -258,10 +257,10 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(max); worldEdit.checkMaxRadius(max);
BlockVector3 pos = session.getPlacementPosition(player); BlockVector3 pos = session.getPlacementPosition(player);
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos; BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
fp.checkConfirmationRadius(() -> { player.checkConfirmationRadius(() -> {
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow); int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, "sphere", (int) max, context); }, "sphere", (int) max, context);
} }
@ -310,7 +309,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void hollowPyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void hollowPyramid(Player fp, Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Arg(desc = "The size of the pyramid") @Arg(desc = "The size of the pyramid")
@ -324,7 +323,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.pyramid") @CommandPermissions("worldedit.generation.pyramid")
@Logging(PLACEMENT) @Logging(PLACEMENT)
public void pyramid(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void pyramid(Player fp, Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@Arg(desc = "The size of the pyramid") @Arg(desc = "The size of the pyramid")
@ -349,7 +348,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.shape") @CommandPermissions("worldedit.generation.shape")
@Logging(ALL) @Logging(ALL)
public void generate(FawePlayer fp, Player player, LocalSession session, EditSession editSession, public void generate(Player fp, Player player, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern pattern, Pattern pattern,
@ -415,7 +414,7 @@ public class GenerationCommands {
) )
@CommandPermissions("worldedit.generation.shape.biome") @CommandPermissions("worldedit.generation.shape.biome")
@Logging(ALL) @Logging(ALL)
public void generateBiome(FawePlayer fp, LocalSession session, EditSession editSession, public void generateBiome(Player fp, LocalSession session, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "The biome type to set") @Arg(desc = "The biome type to set")
BiomeType target, BiomeType target,
@ -437,7 +436,7 @@ public class GenerationCommands {
zero = Vector3.ZERO; zero = Vector3.ZERO;
unit = Vector3.ONE; unit = Vector3.ONE;
} else if (offset) { } else if (offset) {
zero = session.getPlacementPosition(fp.toWorldEditPlayer()).toVector3(); zero = session.getPlacementPosition(fp).toVector3();
unit = Vector3.ONE; unit = Vector3.ONE;
} else if (offsetCenter) { } else if (offsetCenter) {
final Vector3 min = region.getMinimumPoint().toVector3(); final Vector3 min = region.getMinimumPoint().toVector3();

Datei anzeigen

@ -20,7 +20,6 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.MethodCommands.getArguments;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
@ -29,7 +28,6 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
@ -146,8 +144,8 @@ public class HistoryCommands {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
DiskStorageHistory file = new DiskStorageHistory(world, uuid, index); DiskStorageHistory file = new DiskStorageHistory(world, uuid, index);
if (file.getBDFile().exists()) { if (file.getBDFile().exists()) {
if (restore) file.redo(FawePlayer.wrap(player)); if (restore) file.redo(player);
else file.undo(FawePlayer.wrap(player)); else file.undo(player);
BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index); BBC.ROLLBACK_ELEMENT.send(player, world.getName() + "/" + user + "-" + index);
} else { } else {
BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0); BBC.TOOL_INSPECT_INFO_FOOTER.send(player, 0);
@ -177,11 +175,10 @@ public class HistoryCommands {
bot = bot.withY(Math.min(255, top.getY())); bot = bot.withY(Math.min(255, top.getY()));
RollbackDatabase database = DBHandler.IMP.getDatabase(world); RollbackDatabase database = DBHandler.IMP.getDatabase(world);
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
final FawePlayer fp = FawePlayer.wrap(player);
Region[] allowedRegions = fp.getCurrentRegions(FaweMaskManager.MaskType.OWNER); Region[] allowedRegions = player.getCurrentRegions(FaweMaskManager.MaskType.OWNER);
if (allowedRegions == null) { if (allowedRegions == null) {
BBC.NO_REGION.send(fp); BBC.NO_REGION.send(player);
return; return;
} }
// TODO mask the regions bot / top to the bottom and top coord in the allowedRegions // TODO mask the regions bot / top to the bottom and top coord in the allowedRegions
@ -194,7 +191,7 @@ public class HistoryCommands {
database.getPotentialEdits(other, System.currentTimeMillis() - timeDiff, bot, top, new RunnableVal<DiskStorageHistory>() { database.getPotentialEdits(other, System.currentTimeMillis() - timeDiff, bot, top, new RunnableVal<DiskStorageHistory>() {
@Override @Override
public void run(DiskStorageHistory edit) { public void run(DiskStorageHistory edit) {
edit.undo(fp, allowedRegions); edit.undo(player, allowedRegions);
BBC.ROLLBACK_ELEMENT.send(player, edit.getWorld().getName() + "/" + user + "-" + edit.getIndex()); BBC.ROLLBACK_ELEMENT.send(player, edit.getWorld().getName() + "/" + user + "-" + edit.getIndex());
count.incrementAndGet(); count.incrementAndGet();
} }
@ -242,7 +239,7 @@ public class HistoryCommands {
undoSession = session; undoSession = session;
} }
int finalTimes = times; int finalTimes = times;
FawePlayer.wrap(player).checkConfirmation(() -> { player.checkConfirmation(() -> {
EditSession undone = null; EditSession undone = null;
int i = 0; int i = 0;
for (; i < finalTimes; ++i) { for (; i < finalTimes; ++i) {

Datei anzeigen

@ -1,16 +1,41 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.object.DataAnglePattern; import com.boydti.fawe.object.DataAnglePattern;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.collection.RandomCollection;
import com.boydti.fawe.object.pattern.*; import com.boydti.fawe.object.pattern.AngleColorPattern;
import com.boydti.fawe.object.pattern.AverageColorPattern;
import com.boydti.fawe.object.pattern.BiomePattern;
import com.boydti.fawe.object.pattern.BufferedPattern;
import com.boydti.fawe.object.pattern.BufferedPattern2D;
import com.boydti.fawe.object.pattern.DataPattern;
import com.boydti.fawe.object.pattern.DesaturatePattern;
import com.boydti.fawe.object.pattern.ExistingPattern;
import com.boydti.fawe.object.pattern.ExpressionPattern;
import com.boydti.fawe.object.pattern.FullClipboardPattern;
import com.boydti.fawe.object.pattern.IdDataMaskPattern;
import com.boydti.fawe.object.pattern.IdPattern;
import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
import com.boydti.fawe.object.pattern.LinearBlockPattern;
import com.boydti.fawe.object.pattern.MaskedPattern;
import com.boydti.fawe.object.pattern.NoXPattern;
import com.boydti.fawe.object.pattern.NoYPattern;
import com.boydti.fawe.object.pattern.NoZPattern;
import com.boydti.fawe.object.pattern.OffsetPattern;
import com.boydti.fawe.object.pattern.PropertyPattern;
import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
import com.boydti.fawe.object.pattern.RandomOffsetPattern;
import com.boydti.fawe.object.pattern.RelativePattern;
import com.boydti.fawe.object.pattern.SaturatePattern;
import com.boydti.fawe.object.pattern.ShadePattern;
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
import com.boydti.fawe.object.random.SimplexRandom; import com.boydti.fawe.object.random.SimplexRandom;
import com.boydti.fawe.util.ColorUtil; import com.boydti.fawe.util.ColorUtil;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.EmptyClipboardException;
import org.enginehub.piston.annotation.Command; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -21,21 +46,21 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.ClipboardPattern; import com.sk89q.worldedit.function.pattern.ClipboardPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import java.awt.Color; import java.awt.Color;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
//@Command(aliases = {"patterns"}, //@Command(aliases = {"patterns"},
// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)", // desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
@ -184,7 +209,7 @@ public class PatternCommands {
"Use with a brush when you don't want to apply to the same spot twice" "Use with a brush when you don't want to apply to the same spot twice"
) )
public Pattern buffer(Actor actor, Pattern pattern) { public Pattern buffer(Actor actor, Pattern pattern) {
return new BufferedPattern(FawePlayer.wrap(actor), pattern); return new BufferedPattern(actor, pattern);
} }
@Command( @Command(
@ -192,7 +217,7 @@ public class PatternCommands {
desc = "Only place a block once in a column while a pattern is in use" desc = "Only place a block once in a column while a pattern is in use"
) )
public Pattern buffer2d(Actor actor, Pattern pattern) { public Pattern buffer2d(Actor actor, Pattern pattern) {
return new BufferedPattern2D(FawePlayer.wrap(actor), pattern); return new BufferedPattern2D(actor, pattern);
} }
@Command( @Command(

Datei anzeigen

@ -32,7 +32,6 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -108,7 +107,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.set") @CommandPermissions("worldedit.region.set")
@Logging(REGION) @Logging(REGION)
public void set(FawePlayer fp, EditSession editSession, public void set(Player fp, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException { Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
@ -128,16 +127,15 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.light.fix") @CommandPermissions("worldedit.light.fix")
public void fixLighting(Player player) throws WorldEditException { public void fixLighting(Player player) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player);
final Location loc = player.getLocation(); final Location loc = player.getLocation();
Region selection = fp.getSelection(); Region selection = player.getSelection();
if (selection == null) { if (selection == null) {
final int cx = loc.getBlockX() >> 4; final int cx = loc.getBlockX() >> 4;
final int cz = loc.getBlockZ() >> 4; final int cz = loc.getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection,null); int count = FaweAPI.fixLighting(player.getWorld(), selection,null);
BBC.LIGHTING_PROPAGATE_SELECTION.send(fp, count); BBC.LIGHTING_PROPAGATE_SELECTION.send(player, count);
} }
@Command( @Command(
@ -146,11 +144,10 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.light.fix") @CommandPermissions("worldedit.light.fix")
public void getLighting(Player player, EditSession editSession) throws WorldEditException { public void getLighting(Player player, EditSession editSession) throws WorldEditException {
FawePlayer fp = FawePlayer.wrap(player);
final Location loc = player.getLocation(); final Location loc = player.getLocation();
int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
fp.sendMessage("Light: " + block + " | " + sky); player.print("Light: " + block + " | " + sky);
} }
@Command( @Command(
@ -159,15 +156,14 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.light.remove") @CommandPermissions("worldedit.light.remove")
public void removeLighting(Player player) { public void removeLighting(Player player) {
FawePlayer fp = FawePlayer.wrap(player); Region selection = player.getSelection();
Region selection = fp.getSelection();
if (selection == null) { if (selection == null) {
final int cx = player.getLocation().getBlockX() >> 4; final int cx = player.getLocation().getBlockX() >> 4;
final int cz = player.getLocation().getBlockZ() >> 4; final int cz = player.getLocation().getBlockZ() >> 4;
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection, null); int count = FaweAPI.fixLighting(player.getWorld(), selection, null);
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count); BBC.UPDATED_LIGHTING_SELECTION.send(player, count);
} }
@Command( @Command(
@ -244,7 +240,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.curve") @CommandPermissions("worldedit.region.curve")
@Logging(REGION) @Logging(REGION)
public void curve(FawePlayer fp, EditSession editSession, public void curve(Player fp, EditSession editSession,
@Selection Region region, @Selection Region region,
@Arg(desc = "The pattern of blocks to place") @Arg(desc = "The pattern of blocks to place")
Pattern patternArg, Pattern patternArg,
@ -275,7 +271,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.replace") @CommandPermissions("worldedit.region.replace")
@Logging(REGION) @Logging(REGION)
public void replace(FawePlayer fp, EditSession editSession, @Selection Region region, public void replace(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "The mask representing blocks to replace", def = "") @Arg(desc = "The mask representing blocks to replace", def = "")
Mask from, Mask from,
@Arg(desc = "The pattern of blocks to replace with") @Arg(desc = "The pattern of blocks to replace with")
@ -302,7 +298,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.overlay") @CommandPermissions("worldedit.region.overlay")
@Logging(REGION) @Logging(REGION)
public void overlay(FawePlayer fp, EditSession editSession, @Selection Region region, public void overlay(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to overlay") @Arg(desc = "The pattern of blocks to overlay")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException { Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
@ -317,7 +313,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.overlay") @CommandPermissions("worldedit.region.overlay")
@Logging(REGION) @Logging(REGION)
public void lay(FawePlayer fp, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg, InjectedValueAccess context) throws WorldEditException { public void lay(Player fp, EditSession editSession, @Selection Region region, @Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
int maxY = max.getBlockY(); int maxY = max.getBlockY();
@ -357,7 +353,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.naturalize") @CommandPermissions("worldedit.region.naturalize")
@Logging(REGION) @Logging(REGION)
public void naturalize(FawePlayer fp, EditSession editSession, @Selection Region region, InjectedValueAccess context) throws WorldEditException { public void naturalize(Player fp, EditSession editSession, @Selection Region region, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
int affected = editSession.naturalizeCuboidBlocks(region); int affected = editSession.naturalizeCuboidBlocks(region);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(fp, affected);
@ -370,7 +366,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.walls") @CommandPermissions("worldedit.region.walls")
@Logging(REGION) @Logging(REGION)
public void walls(FawePlayer fp, EditSession editSession, @Selection Region region, public void walls(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException { Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
@ -386,7 +382,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.faces") @CommandPermissions("worldedit.region.faces")
@Logging(REGION) @Logging(REGION)
public void faces(FawePlayer fp, EditSession editSession, @Selection Region region, public void faces(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set") @Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException { Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { fp.checkConfirmationRegion(() -> {
@ -402,7 +398,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.smooth") @CommandPermissions("worldedit.region.smooth")
@Logging(REGION) @Logging(REGION)
public void smooth(FawePlayer fp, EditSession editSession, @Selection Region region, public void smooth(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "# of iterations to perform", def = "1") @Arg(desc = "# of iterations to perform", def = "1")
int iterations, int iterations,
@Arg(desc = "The mask of blocks to use as the height map", def = "") @Arg(desc = "The mask of blocks to use as the height map", def = "")
@ -411,7 +407,7 @@ public class RegionCommands {
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = FawePlayer.wrap(fp).getLimit(); FaweLimit limit = fp.getLimit();
if (volume >= limit.MAX_CHECKS) { if (volume >= limit.MAX_CHECKS) {
throw FaweException.MAX_CHECKS; throw FaweException.MAX_CHECKS;
} }
@ -449,7 +445,7 @@ public class RegionCommands {
descFooter = "Select your current allowed region" descFooter = "Select your current allowed region"
) )
@CommandPermissions("fawe.worldeditregion") @CommandPermissions("fawe.worldeditregion")
public void wer(FawePlayer fp) throws WorldEditException { public void wer(Player fp) throws WorldEditException {
final Region region = fp.getLargestRegion(); final Region region = fp.getLargestRegion();
if (region == null) { if (region == null) {
BBC.NO_REGION.send(fp); BBC.NO_REGION.send(fp);
@ -466,7 +462,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.move") @CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
public void move(FawePlayer fp, World world, EditSession editSession, LocalSession session, public void move(Player player, World world, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(desc = "# of blocks to move", def = "1") @Arg(desc = "# of blocks to move", def = "1")
int count, int count,
@ -485,7 +481,7 @@ public class RegionCommands {
boolean skipEntities, boolean skipEntities,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1"); checkCommandArgument(count >= 1, "Count must be >= 1");
fp.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes, replace); int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes, replace);
if (moveSelection) { if (moveSelection) {
@ -493,13 +489,13 @@ public class RegionCommands {
region.shift(direction.multiply(count)); region.shift(direction.multiply(count));
session.getRegionSelector(world).learnChanges(); session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(fp.getPlayer(), session); session.getRegionSelector(world).explainRegionAdjust(player, session);
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
fp.printError(e.getMessage()); player.printError(e.getMessage());
} }
} }
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
@ -511,14 +507,14 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.fall") @CommandPermissions("worldedit.region.fall")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
public void fall(FawePlayer fp, EditSession editSession, LocalSession session, public void fall(Player player, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(name = "replace", desc = "BlockStateHolder", def = "air") BlockStateHolder replace, @Arg(name = "replace", desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
@Switch(name = 'm', desc = "TODO") boolean notFullHeight, @Switch(name = 'm', desc = "TODO") boolean notFullHeight,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
int affected = editSession.fall(region, !notFullHeight, replace); int affected = editSession.fall(region, !notFullHeight, replace);
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region, context); }, getArguments(context), region, context);
} }
@ -528,7 +524,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.stack") @CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION) @Logging(ORIENTATION_REGION)
public void stack(FawePlayer fp, EditSession editSession, LocalSession session, public void stack(Player player, EditSession editSession, LocalSession session,
@Selection Region region, @Selection Region region,
@Arg(desc = "# of copies to stack", def = "1") @Arg(desc = "# of copies to stack", def = "1")
int count, int count,
@ -546,7 +542,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Source mask") @ArgFlag(name = 'm', desc = "Source mask")
Mask sourceMask, Mask sourceMask,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationStack(() -> { player.checkConfirmationStack(() -> {
if (sourceMask != null) { if (sourceMask != null) {
editSession.addSourceMask(sourceMask); editSession.addSourceMask(sourceMask);
} }
@ -559,14 +555,14 @@ public class RegionCommands {
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint(); final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
region.shift(shiftVector); region.shift(shiftVector);
session.getRegionSelector(fp.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(fp.getWorld()).explainRegionAdjust(fp.getPlayer(), session); session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
} catch (RegionOperationException e) { } catch (RegionOperationException e) {
fp.toWorldEditPlayer().printError(e.getMessage()); player.printError(e.getMessage());
} }
} }
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
}, getArguments(context), region, count, context); }, getArguments(context), region, count, context);
} }
@ -579,7 +575,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.deform") @CommandPermissions("worldedit.region.deform")
@Logging(ALL) @Logging(ALL)
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession, InjectedValueAccess context, public void deform(Player player, LocalSession session, EditSession editSession, InjectedValueAccess context,
@Selection Region region, @Selection Region region,
@Arg(desc = "The expression to use", variable = true) @Arg(desc = "The expression to use", variable = true)
List<String> expression, List<String> expression,
@ -609,11 +605,11 @@ public class RegionCommands {
} }
final Vector3 unit1 = unit; final Vector3 unit1 = unit;
fp.checkConfirmationRegion(() -> { player.checkConfirmationRegion(() -> {
try { try {
final int affected = editSession.deformRegion(region, zero, unit1, String.join(" ", expression), session.getTimeout()); final int affected = editSession.deformRegion(region, zero, unit1, String.join(" ", expression), session.getTimeout());
player.findFreePosition(); player.findFreePosition();
BBC.VISITOR_BLOCK.send(fp, affected); BBC.VISITOR_BLOCK.send(player, affected);
} catch (ExpressionException e) { } catch (ExpressionException e) {
player.printError(e.getMessage()); player.printError(e.getMessage());
} }
@ -630,7 +626,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.regen") @CommandPermissions("worldedit.regen")
@Logging(REGION) @Logging(REGION)
public void regenerateChunk(FawePlayer fp, LocalSession session, EditSession editSession, @Selection Region region, public void regenerateChunk(Player fp, LocalSession session, EditSession editSession, @Selection Region region,
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome, @Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
@Arg(def = "", desc = "Regenerate with seed") Long seed, @Arg(def = "", desc = "Regenerate with seed") Long seed,
InjectedValueAccess context) throws WorldEditException { InjectedValueAccess context) throws WorldEditException {
@ -667,7 +663,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.hollow") @CommandPermissions("worldedit.region.hollow")
@Logging(REGION) @Logging(REGION)
public void hollow(FawePlayer fp, EditSession editSession, public void hollow(Player fp, EditSession editSession,
@Selection Region region, @Selection Region region,
@Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0") @Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness, int thickness,
@ -706,7 +702,7 @@ public class RegionCommands {
) )
@CommandPermissions("worldedit.region.flora") @CommandPermissions("worldedit.region.flora")
@Logging(REGION) @Logging(REGION)
public void flora(FawePlayer fp, EditSession editSession, @Selection Region region, public void flora(Player fp, EditSession editSession, @Selection Region region,
@Arg(desc = "The density of the forest", def = "5") @Arg(desc = "The density of the forest", def = "5")
double density, InjectedValueAccess context) throws WorldEditException { double density, InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]"); checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");

Datei anzeigen

@ -19,16 +19,17 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper; import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.schematic.MinecraftStructure; import com.boydti.fawe.object.schematic.MinecraftStructure;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.google.common.collect.Multimap;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -51,9 +52,11 @@ import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat; import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.component.SchematicPaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.Closer;
import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.util.io.file.FilenameException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@ -83,7 +86,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.exception.StopExecutionException;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -570,7 +572,7 @@ public class SchematicCommands {
descFooter = "Note: Format is not fully verified until loading." descFooter = "Note: Format is not fully verified until loading."
) )
@CommandPermissions("worldedit.schematic.list") @CommandPermissions("worldedit.schematic.list")
public void list(FawePlayer fp, Actor actor, InjectedValueAccess args, public void list(Actor actor,
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") @ArgFlag(name = 'p', desc = "Page to view.", def = "1")
int page, int page,
@Switch(name = 'd', desc = "Sort by date, oldest first") @Switch(name = 'd', desc = "Sort by date, oldest first")
@ -796,4 +798,46 @@ public class SchematicCommands {
} }
return false; return false;
} }
private static class SchematicPaginationBox extends PaginationBox {
private final String prefix;
private final File[] files;
SchematicPaginationBox(String rootDir, File[] files, String pageCommand) {
super("Available schematics", pageCommand);
this.prefix = rootDir == null ? "" : rootDir;
this.files = files;
}
@Override
public Component getComponent(int number) {
checkArgument(number < files.length && number >= 0);
File file = files[number];
Multimap<String, ClipboardFormat> exts = ClipboardFormats.getFileExtensionMap();
String format = exts.get(com.google.common.io.Files.getFileExtension(file.getName()))
.stream().findFirst().map(ClipboardFormat::getName).orElse("Unknown");
boolean inRoot = file.getParentFile().getName().equals(prefix);
String path = inRoot ? file.getName() : file.getPath().split(Pattern.quote(prefix + File.separator))[1];
return TextComponent.builder()
.content("")
.append(TextComponent.of("[L]")
.color(TextColor.GOLD)
.clickEvent(ClickEvent
.of(ClickEvent.Action.RUN_COMMAND, "/schem load \"" + path + "\""))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to load"))))
.append(TextComponent.space())
.append(TextComponent.of(path)
.color(TextColor.DARK_GREEN)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(format))))
.build();
}
@Override
public int getComponentsSize() {
return files.length;
}
}
} }

Datei anzeigen

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -32,29 +30,14 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.scripting.CraftScriptContext;
import com.sk89q.worldedit.scripting.CraftScriptEngine;
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
import java.io.DataInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.Nullable;
import javax.script.ScriptException;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
import org.mozilla.javascript.NativeJavaObject; import org.enginehub.piston.inject.InjectedValueAccess;
/** /**
@ -80,7 +63,7 @@ public class ScriptingCommands {
desc = "" desc = ""
) )
@CommandPermissions("fawe.setupdispatcher") @CommandPermissions("fawe.setupdispatcher")
public void setupdispatcher(Player player, LocalSession session, final InjectedValueAccess args) throws WorldEditException { public void setupdispatcher(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
PlatformCommandManager.getInstance().registerAllCommands(); PlatformCommandManager.getInstance().registerAllCommands();
} }
@ -96,7 +79,7 @@ public class ScriptingCommands {
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true) @Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
List<String> commandStr) throws WorldEditException { List<String> commandStr) throws WorldEditException {
if (!player.hasPermission("worldedit.scripting.execute." + filename)) { if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
BBC.SCRIPTING_NO_PERM.send(player); player.printError(BBC.SCRIPTING_NO_PERM.s());
return; return;
} }
@ -122,12 +105,12 @@ public class ScriptingCommands {
String lastScript = session.getLastScript(); String lastScript = session.getLastScript();
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) { if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
BBC.SCRIPTING_NO_PERM.send(player); player.printError(BBC.SCRIPTING_NO_PERM.s());
return; return;
} }
if (lastScript == null) { if (lastScript == null) {
BBC.SCRIPTING_CS.send(player); player.printError(BBC.SCRIPTING_CS.s());
return; return;
} }

Datei anzeigen

@ -26,7 +26,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer; import com.boydti.fawe.object.DelegateConsumer;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal3; import com.boydti.fawe.object.RunnableVal3;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -41,7 +40,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions; import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.CommandQueued; import com.sk89q.worldedit.command.util.CommandQueued;
import com.sk89q.worldedit.command.util.CommandQueuedConditionGenerator;
import com.sk89q.worldedit.command.util.CreatureButcher; import com.sk89q.worldedit.command.util.CreatureButcher;
import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.command.util.Logging;
@ -50,8 +48,6 @@ import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; 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.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.EntityFunction; import com.sk89q.worldedit.function.EntityFunction;
@ -92,7 +88,6 @@ import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
@ -180,7 +175,7 @@ public class UtilityCommands {
) )
@CommandPermissions("fawe.cancel") @CommandPermissions("fawe.cancel")
@CommandQueued(false) @CommandQueued(false)
public void cancel(FawePlayer fp) { public void cancel(Player fp) {
int cancelled = fp.cancel(false); int cancelled = fp.cancel(false);
BBC.WORLDEDIT_CANCEL_COUNT.send(fp, cancelled); BBC.WORLDEDIT_CANCEL_COUNT.send(fp, cancelled);
} }
@ -679,7 +674,7 @@ public class UtilityCommands {
desc = "Confirm a command" desc = "Confirm a command"
) )
@CommandPermissions("fawe.confirm") @CommandPermissions("fawe.confirm")
public void confirm(FawePlayer fp) throws WorldEditException { public void confirm(Player fp) throws WorldEditException {
if (!fp.confirm()) { if (!fp.confirm()) {
BBC.NOTHING_CONFIRMED.send(fp); BBC.NOTHING_CONFIRMED.send(fp);
} }
@ -697,7 +692,8 @@ public class UtilityCommands {
int page, int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true) @Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> commandStr) throws WorldEditException { List<String> commandStr) throws WorldEditException {
PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor); PrintCommandHelp.help(commandStr, page, listSubCommands,
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help");
} }
public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) { public static void list(File dir, Actor actor, List<String> args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) {

Datei anzeigen

@ -108,7 +108,7 @@ public class WorldEditCommands {
} }
} }
actor.printDebug(""); actor.printDebug("");
actor.printDebug("Wiki: " + "https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki"); actor.printDebug("Wiki: https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/wiki");
} }
@Command( @Command(
@ -197,6 +197,7 @@ public class WorldEditCommands {
int page, int page,
@Arg(desc = "The command to retrieve help for", def = "", variable = true) @Arg(desc = "The command to retrieve help for", def = "", variable = true)
List<String> commandStr) throws WorldEditException { List<String> commandStr) throws WorldEditException {
PrintCommandHelp.help(commandStr, page, listSubCommands, we, actor); PrintCommandHelp.help(commandStr, page, listSubCommands,
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "/worldedit help");
} }
} }

Datei anzeigen

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.MovableTool;
@ -584,7 +583,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
this.visualMode = visualMode; this.visualMode = visualMode;
if (visualMode != VisualMode.NONE) { if (visualMode != VisualMode.NONE) {
try { try {
queueVisualization(FawePlayer.wrap(player)); queueVisualization(player);
} catch (Throwable e) { } catch (Throwable e) {
WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player); WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player);
} }
@ -614,7 +613,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (tmp.increment(player, amount)) { if (tmp.increment(player, amount)) {
if (visualMode != VisualMode.NONE) { if (visualMode != VisualMode.NONE) {
try { try {
queueVisualization(FawePlayer.wrap(player)); queueVisualization(player);
} catch (Throwable e) { } catch (Throwable e) {
WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player); WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player);
} }
@ -628,7 +627,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
return false; return false;
} }
public void queueVisualization(FawePlayer fp) { public void queueVisualization(Player fp) {
Fawe.get().getVisualQueue().queue(fp); Fawe.get().getVisualQueue().queue(fp);
} }
@ -641,9 +640,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
BrushSettings current = getContext(); BrushSettings current = getContext();
Brush brush = current.getBrush(); Brush brush = current.getBrush();
if (brush == null) return; if (brush == null) return;
FawePlayer<Object> fp = FawePlayer.wrap(player);
EditSessionBuilder builder = new EditSessionBuilder(player.getWorld()) EditSessionBuilder builder = new EditSessionBuilder(player.getWorld())
.player(fp) .player(player)
.allowedRegionsEverywhere() .allowedRegionsEverywhere()
.autoQueue(false) .autoQueue(false)
.blockBag(null) .blockBag(null)
@ -674,8 +672,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
} }
public void clear(Player player) { public void clear(Player player) {
FawePlayer<Object> fp = FawePlayer.wrap(player); Fawe.get().getVisualQueue().dequeue(player);
Fawe.get().getVisualQueue().dequeue(fp);
if (visualExtent != null) { if (visualExtent != null) {
visualExtent.clear(); visualExtent.clear();
} }
@ -684,7 +681,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
@Override @Override
public boolean move(Player player) { public boolean move(Player player) {
if (visualMode != VisualMode.NONE) { if (visualMode != VisualMode.NONE) {
queueVisualization(FawePlayer.wrap(player)); queueVisualization(player);
return true; return true;
} }
return false; return false;

Datei anzeigen

@ -82,7 +82,7 @@ public class FloatingTreeRemover implements BlockTool {
try { try {
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint()); final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
if (blockSet == null) { if (blockSet == null) {
BBC.TOOL_DELTREE_FLOATING_ERROR.send(player); player.printError(BBC.TOOL_DELTREE_FLOATING_ERROR.s());
return true; return true;
} }

Datei anzeigen

@ -23,7 +23,6 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -36,20 +35,19 @@ public class GravityBrush implements Brush {
} }
@Override @Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
int size = (int) sizeDouble; double endY = position.getY() + size;
int endY = position.getBlockY() + size; double startPerformY = Math.max(0, position.getY() - size);
int startPerformY = Math.max(0, position.getBlockY() - size); double startCheckY = fullHeight ? 0 : startPerformY;
int startCheckY = fullHeight ? 0 : startPerformY; for (double x = position.getX() + size; x > position.getX() - size; --x) {
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) { for (double z = position.getZ() + size; z > position.getZ() - size; --z) {
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) { double freeSpot = startCheckY;
int freeSpot = startCheckY; for (double y = startCheckY; y <= endY; y++) {
for (int y = startCheckY; y <= endY; y++) { BlockStateHolder block = editSession.getBlock((int)x, (int)y, (int)z);
BlockStateHolder block = editSession.getBlock(x, y, z);
if (!block.getBlockType().getMaterial().isAir()) { if (!block.getBlockType().getMaterial().isAir()) {
if (y != freeSpot) { if (y != freeSpot) {
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); editSession.setBlock((int)x, (int)y, (int)z, BlockTypes.AIR.getDefaultState());
editSession.setBlock(x, freeSpot, z, block); editSession.setBlock((int)x, (int)freeSpot, (int)z, block);
} }
freeSpot = y + 1; freeSpot = y + 1;
} }

Datei anzeigen

@ -19,26 +19,25 @@
package com.sk89q.worldedit.command.util; package com.sk89q.worldedit.command.util;
import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName;
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import static com.sk89q.worldedit.internal.command.CommandUtil.byCleanName;
import static com.sk89q.worldedit.internal.command.CommandUtil.getSubCommands;
import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox; import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException; import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
import static java.util.stream.Collectors.toList;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
/** /**
* Implementation of the //help command. * Implementation of the //help command.
@ -66,11 +65,11 @@ public class PrintCommandHelp {
return mapping.orElse(null); return mapping.orElse(null);
} }
public static void help(List<String> commandPath, int page, boolean listSubCommands, WorldEdit we, Actor actor) throws InvalidComponentException { public static void help(List<String> commandPath, int page, boolean listSubCommands,
CommandManager manager = we.getPlatformManager().getPlatformCommandManager().getCommandManager(); CommandManager manager, Actor actor, String helpRootCommand) throws InvalidComponentException {
if (commandPath.isEmpty()) { if (commandPath.isEmpty()) {
printCommands(page, manager.getAllCommands(), actor, ImmutableList.of()); printCommands(page, manager.getAllCommands(), actor, ImmutableList.of(), helpRootCommand);
return; return;
} }
@ -92,7 +91,7 @@ public class PrintCommandHelp {
toCommandString(visited), subCommand)); toCommandString(visited), subCommand));
// full help for single command // full help for single command
CommandUsageBox box = new CommandUsageBox(visited, visited.stream() CommandUsageBox box = new CommandUsageBox(visited, visited.stream()
.map(Command::getName).collect(Collectors.joining(" "))); .map(Command::getName).collect(Collectors.joining(" ")), helpRootCommand);
actor.print(box.create()); actor.print(box.create());
return; return;
} }
@ -104,7 +103,7 @@ public class PrintCommandHelp {
actor.printError(String.format("The sub-command '%s' under '%s' could not be found.", actor.printError(String.format("The sub-command '%s' under '%s' could not be found.",
subCommand, toCommandString(visited))); subCommand, toCommandString(visited)));
// list subcommands for currentCommand // list subcommands for currentCommand
printCommands(page, getSubCommands(Iterables.getLast(visited)).values().stream(), actor, visited); printCommands(page, getSubCommands(Iterables.getLast(visited)).values().stream(), actor, visited, helpRootCommand);
return; return;
} }
} }
@ -113,10 +112,10 @@ public class PrintCommandHelp {
if (subCommands.isEmpty() || !listSubCommands) { if (subCommands.isEmpty() || !listSubCommands) {
// Create the message // Create the message
CommandUsageBox box = new CommandUsageBox(visited, toCommandString(visited)); CommandUsageBox box = new CommandUsageBox(visited, toCommandString(visited), helpRootCommand);
actor.print(box.create()); actor.print(box.create());
} else { } else {
printCommands(page, subCommands.values().stream(), actor, visited); printCommands(page, subCommands.values().stream(), actor, visited, helpRootCommand);
} }
} }
@ -125,7 +124,7 @@ public class PrintCommandHelp {
} }
private static void printCommands(int page, Stream<Command> commandStream, Actor actor, private static void printCommands(int page, Stream<Command> commandStream, Actor actor,
List<Command> commandList) throws InvalidComponentException { List<Command> commandList, String helpRootCommand) throws InvalidComponentException {
// Get a list of aliases // Get a list of aliases
List<Command> commands = commandStream List<Command> commands = commandStream
.sorted(byCleanName()) .sorted(byCleanName())
@ -134,7 +133,8 @@ public class PrintCommandHelp {
String used = commandList.isEmpty() ? null : toCommandString(commandList); String used = commandList.isEmpty() ? null : toCommandString(commandList);
CommandListBox box = new CommandListBox( CommandListBox box = new CommandListBox(
(used == null ? "Help" : "Subcommands: " + used), (used == null ? "Help" : "Subcommands: " + used),
"//help -s -p %page%" + (used == null ? "" : " " + used)); helpRootCommand + " -s -p %page%" + (used == null ? "" : " " + used),
helpRootCommand);
if (!actor.isPlayer()) { if (!actor.isPlayer()) {
box.formatForConsole(); box.formatForConsole();
} }

Datei anzeigen

@ -0,0 +1,53 @@
package com.sk89q.worldedit.entity;
public interface Metadatable {
/**
* Set some session only metadata for the player
*
* @param key
* @param value
* @return previous value
*/
void setMeta(String key, Object value);
<T> T getAndSetMeta(String key, T value);
boolean hasMeta();
/**
* Get the metadata for a key.
*
* @param <V>
* @param key
* @return
*/
<V> V getMeta(String key);
/**
* Get the metadata for a specific key (or return the default provided)
*
* @param key
* @param def
* @param <V>
* @return
*/
default <V> V getMeta(String key, V def) {
V value = (V) getMeta(key);
return value == null ? def : value; }
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key
*/
<V> V deleteMeta(String key);
final class METADATA_KEYS {
public static final String ANVIL_CLIPBOARD = "anvil-clipboard";
public static final String ROLLBACK = "rollback";
}
}

Datei anzeigen

@ -19,13 +19,30 @@
package com.sk89q.worldedit.entity; package com.sk89q.worldedit.entity;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -33,8 +50,11 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import java.io.File;
import java.text.NumberFormat;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull;
/** /**
* Represents a player * Represents a player
@ -290,6 +310,7 @@ public interface Player extends Entity, Actor {
* *
* @param pos where to move them * @param pos where to move them
*/ */
@Override
void setPosition(Vector3 pos); void setPosition(Vector3 pos);
/** /**
@ -303,4 +324,184 @@ public interface Player extends Entity, Actor {
* @param block The block to send, null to reset * @param block The block to send, null to reset
*/ */
<B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block); <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block);
default FaweLimit getLimit() {
return Settings.IMP.getLimit(this);
}
void checkConfirmationStack(@NotNull Runnable task, @NotNull String command,
Region region, int times, InjectedValueAccess context) throws RegionOperationException;
void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command,
Region region, InjectedValueAccess context) throws RegionOperationException;
void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context,
@NotNull String command);
public Region[] getCurrentRegions();
Region[] getCurrentRegions(FaweMaskManager.MaskType type);
Region getLargestRegion();
void setSelection(Region region);
/**
* Get the player's current selection (or null)
*
* @return
*/
default Region getSelection() {
try {
return getSession().getSelection(getWorld());
} catch (IncompleteRegionException e) {
return null;
}
}
/**
* Set the player's WorldEdit selection
*
* @param selector
*/
default void setSelection(RegionSelector selector) {
getSession().setRegionSelector(getWorld(), selector);
}
/**
* Get the World the player is editing in (may not match the world they are in)<br/> - e.g. If
* they are editing a CFI world.<br/>
*
* @return Editing world
*/
default World getWorldForEditing() {
VirtualWorld virtual = getSession().getVirtualWorld();
if (virtual != null) {
return virtual;
}
// CFICommands.CFISettings cfi = getMeta("CFISettings");
// if (cfi != null && cfi.hasGenerator() && cfi.getGenerator().hasPacketViewer()) {
// return cfi.getGenerator();
// }
return WorldEdit.getInstance().getPlatformManager().getWorldForEditing(getWorld());
}
void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times,
int limit, InjectedValueAccess context) throws RegionOperationException;
default void checkConfirmationRadius(@NotNull Runnable task, String command, int radius,
InjectedValueAccess context) throws RegionOperationException {
if (command != null && !getMeta("cmdConfirmRunning", false)) {
if (radius > 0) {
if (radius > 448) {
setConfirmTask(task, context, command);
long volume = (long) (Math.PI * ((double) radius * radius));
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(0, radius, command,
NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
boolean confirm();
/**
* Queue an action to run async
*
* @param run
*/
default void queueAction(Runnable run) {
runAction(run, false, true);
}
default boolean runAsyncIfFree(Runnable r) {
return runAction(r, true, true);
}
default boolean runIfFree(Runnable r) {
return runAction(r, true, false);
}
default boolean checkAction() {
long time = getMeta("faweActionTick", Long.MIN_VALUE);
long tick = Fawe.get().getTimer().getTick();
setMeta("faweActionTick", tick);
return tick > time;
}
/**
* Unregister this player (deletes all metadata etc) - Usually called on logout
*/
default void unregister() {
cancel(true);
if (Settings.IMP.HISTORY.DELETE_ON_LOGOUT) {
getSession().setClipboard(null);
getSession().clearHistory();
getSession().unregisterTools(this);
}
Fawe.get().unregister(getName());
}
default int cancel(boolean close) {
// Collection<IQueueExtent> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
// int cancelled = 0;
// clearActions();
// for (IQueueExtent queue : queues) {
// Collection<EditSession> sessions = queue.getEditSessions();
// for (EditSession session : sessions) {
// FawePlayer currentPlayer = session.getPlayer();
// if (currentPlayer == this) {
// if (session.cancel()) {
// cancelled++;
// }
// }
// }
// }
// VirtualWorld world = getSession().getVirtualWorld();
// if (world != null) {
// if (close) {
// try {
// world.close(false);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// else world.clear();
// }
return 0;
}
void sendTitle(String title, String sub);
/**
* Loads any history items from disk: - Should already be called if history on disk is enabled
*/
default void loadClipboardFromDisk() {
File file = MainUtil.getFile(Fawe.imp().getDirectory(),
Settings.IMP.PATHS.CLIPBOARD + File.separator + getUniqueId() + ".bd");
try {
if (file.exists() && file.length() > 5) {
DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
LocalSession session = getSession();
try {
if (session.getClipboard() != null) {
return;
}
} catch (EmptyClipboardException ignored) {
}
Clipboard clip = doc.toClipboard();
ClipboardHolder holder = new ClipboardHolder(clip);
getSession().setClipboard(holder);
}
} catch (Exception event) {
Fawe.debug("====== INVALID CLIPBOARD ======");
event.printStackTrace();
Fawe.debug("===============---=============");
Fawe.debug("This shouldn't result in any failure");
Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
Fawe.debug("===============---=============");
}
}
} }

Datei anzeigen

@ -30,7 +30,6 @@ import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.session.SessionOwner; import com.sk89q.worldedit.session.SessionOwner;
import com.sk89q.worldedit.session.request.RequestExtent;
import java.util.function.IntSupplier; import java.util.function.IntSupplier;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -62,7 +61,7 @@ public class ExpressionMaskParser extends InputParser<Mask> {
exp.setEnvironment(env); exp.setEnvironment(env);
if (context.getActor() != null) { if (context.getActor() != null) {
SessionOwner owner = context.getActor(); SessionOwner owner = context.getActor();
int timeout = WorldEdit.getInstance().getSessionManager().get(owner).getTimeout(); IntSupplier timeout = () -> WorldEdit.getInstance().getSessionManager().get(owner).getTimeout();
return new ExpressionMask(exp, timeout); return new ExpressionMask(exp, timeout);
} }
return new ExpressionMask(exp); return new ExpressionMask(exp);

Datei anzeigen

@ -19,12 +19,39 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import java.io.File; import java.io.File;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class AbstractNonPlayerActor implements Actor { public abstract class AbstractNonPlayerActor implements Actor {
private final ConcurrentHashMap<String, Object> meta = new ConcurrentHashMap<>();
// Queue for async tasks
private AtomicInteger runningCount = new AtomicInteger();
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue(
(thread, throwable) -> {
while (throwable.getCause() != null) {
throwable = throwable.getCause();
}
if (throwable instanceof WorldEditException) {
printError(throwable.getLocalizedMessage());
} else {
FaweException fe = FaweException.get(throwable);
if (fe != null) {
printError(fe.getMessage());
} else {
throwable.printStackTrace();
}
}
});
@Override @Override
public boolean canDestroyBedrock() { public boolean canDestroyBedrock() {
return true; return true;
@ -48,4 +75,77 @@ public abstract class AbstractNonPlayerActor implements Actor {
@Override @Override
public void dispatchCUIEvent(CUIEvent event) { public void dispatchCUIEvent(CUIEvent event) {
} }
/**
* Run a task either async, or on the current thread
*
* @param ifFree
* @param checkFree Whether to first check if a task is running
* @param async
* @return false if the task was ran or queued
*/
@Override
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
if (checkFree) {
if (runningCount.get() != 0) {
return false;
}
}
Runnable wrapped = () -> {
try {
runningCount.addAndGet(1);
ifFree.run();
} finally {
runningCount.decrementAndGet();
}
};
if (async) {
asyncNotifyQueue.queue(wrapped);
} else {
TaskManager.IMP.taskNow(wrapped, false);
}
return true;
}
/**
* Set some session only metadata for the player
*
* @param key
* @param value
* @return previous value
*/
public final void setMeta(String key, Object value) {
this.meta.put(key, value);
}
public final <T> T getAndSetMeta(String key, T value) {
return (T) this.meta.put(key, value);
}
public final boolean hasMeta() {
return !meta.isEmpty();
}
/**
* Get the metadata for a key.
*
* @param <V>
* @param key
* @return
*/
public final <V> V getMeta(String key) {
return (V) this.meta.get(key);
}
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key
*/
public final <V> V deleteMeta(String key) {
return (V) this.meta.remove(key);
}
} }

Datei anzeigen

@ -19,18 +19,36 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -49,7 +67,12 @@ import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.io.File; import java.io.File;
import java.text.NumberFormat;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull;
/** /**
* An abstract implementation of both a {@link Actor} and a {@link Player} * An abstract implementation of both a {@link Actor} and a {@link Player}
@ -58,6 +81,34 @@ import javax.annotation.Nullable;
*/ */
public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
private final ConcurrentHashMap<String, Object> meta = new ConcurrentHashMap<>();
// Queue for async tasks
private AtomicInteger runningCount = new AtomicInteger();
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue(
(thread, throwable) -> {
while (throwable.getCause() != null) {
throwable = throwable.getCause();
}
if (throwable instanceof WorldEditException) {
printError(throwable.getLocalizedMessage());
} else {
FaweException fe = FaweException.get(throwable);
if (fe != null) {
printError(fe.getMessage());
} else {
throwable.printStackTrace();
}
}
});
public AbstractPlayerActor() {
Fawe.get().register(this);
if (Settings.IMP.CLIPBOARD.USE_DISK) {
loadClipboardFromDisk();
}
}
@Override @Override
public final Extent getExtent() { public final Extent getExtent() {
return getWorld(); return getWorld();
@ -601,4 +652,207 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) { public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
} }
/**
* Set some session only metadata for the player
*
* @param key
* @param value
* @return previous value
*/
public final void setMeta(String key, Object value) {
this.meta.put(key, value);
}
public final <T> T getAndSetMeta(String key, T value) {
return (T) this.meta.put(key, value);
}
public final boolean hasMeta() {
return !meta.isEmpty();
}
/**
* Get the metadata for a key.
*
* @param <V>
* @param key
* @return
*/
public final <V> V getMeta(String key) {
return (V) this.meta.get(key);
}
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key
*/
public final <V> V deleteMeta(String key) {
return (V) this.meta.remove(key);
}
/**
* Run a task either async, or on the current thread
*
* @param ifFree
* @param checkFree Whether to first check if a task is running
* @param async
* @return false if the task was ran or queued
*/
public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
if (checkFree) {
if (runningCount.get() != 0) {
return false;
}
}
Runnable wrapped = () -> {
try {
runningCount.addAndGet(1);
ifFree.run();
} finally {
runningCount.decrementAndGet();
}
};
if (async) {
asyncNotifyQueue.queue(wrapped);
} else {
TaskManager.IMP.taskNow(wrapped, false);
}
return true;
}
public void checkConfirmationStack(@NotNull Runnable task, @NotNull String command,
Region region, int times, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
long area =
(long) ((max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1)) * times;
if (area > 2 << 18) {
setConfirmTask(task, context, command);
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
long volume = (long) base.getX() * base.getZ() * base.getY() * times;
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(min, max, command,
NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
public void checkConfirmationRegion(@NotNull Runnable task, @NotNull String command,
Region region, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (region != null) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
long area = (max.getX() - min.getX()) * (max.getZ() - min.getZ() + 1);
if (area > 2 << 18) {
setConfirmTask(task, context, command);
BlockVector3 base = max.subtract(min).add(BlockVector3.ONE);
long volume = (long) base.getX() * base.getZ() * base.getY();
throw new RegionOperationException(BBC.WORLDEDIT_CANCEL_REASON_CONFIRM
.format(min, max, command,
NumberFormat.getNumberInstance().format(volume)));
}
}
}
task.run();
}
public void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context,
@NotNull String command) {
CommandEvent event = new CommandEvent(this, command);
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run();
return null;
}, context, getSession(), event);
setMeta("cmdConfirm", newTask);
}
/**
* Get the player's current allowed WorldEdit regions
*
* @return an array of allowed regions
*/
@Deprecated
public Region[] getCurrentRegions() {
return WEManager.IMP.getMask(this);
}
@Deprecated
public Region[] getCurrentRegions(FaweMaskManager.MaskType type) {
return WEManager.IMP.getMask(this, type);
}
/**
* Get the largest region in the player's allowed WorldEdit region
*
* @return
*/
public Region getLargestRegion() {
int area = 0;
Region max = null;
for (Region region : this.getCurrentRegions()) {
final int tmp = region.getArea();
if (tmp > area) {
area = tmp;
max = region;
}
}
return max;
}
public void setSelection(Region region) {
RegionSelector selector;
if (region instanceof ConvexPolyhedralRegion) {
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
} else if (region instanceof CylinderRegion) {
selector = new CylinderRegionSelector((CylinderRegion) region);
} else if (region instanceof Polygonal2DRegion) {
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
} else {
selector = new CuboidRegionSelector(null, region.getMinimumPoint(),
region.getMaximumPoint());
}
selector.setWorld(region.getWorld());
getSession().setRegionSelector(getWorld(), selector);
}
public void checkConfirmation(@NotNull Runnable task, @NotNull String command, int times,
int limit, InjectedValueAccess context) throws RegionOperationException {
if (!getMeta("cmdConfirmRunning", false)) {
if (times > limit) {
setConfirmTask(task, context, command);
String volume = "<unspecified>";
throw new RegionOperationException(
BBC.WORLDEDIT_CANCEL_REASON_CONFIRM.format(0, times, command, volume));
}
}
task.run();
}
public synchronized boolean confirm() {
Runnable confirm = deleteMeta("cmdConfirm");
if (confirm == null) {
return false;
}
queueAction(() -> {
setMeta("cmdConfirmRunning", true);
try {
confirm.run();
} finally {
setMeta("cmdConfirmRunning", false);
}
});
return true;
}
} }

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.entity.Metadatable;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionOwner; import com.sk89q.worldedit.session.SessionOwner;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
@ -30,7 +31,7 @@ import java.io.File;
/** /**
* An object that can perform actions in WorldEdit. * An object that can perform actions in WorldEdit.
*/ */
public interface Actor extends Identifiable, SessionOwner, Subject { public interface Actor extends Identifiable, SessionOwner, Subject, Metadatable {
/** /**
* Get the name of the actor. * Get the name of the actor.
@ -120,4 +121,6 @@ public interface Actor extends Identifiable, SessionOwner, Subject {
*/ */
void dispatchCUIEvent(CUIEvent event); void dispatchCUIEvent(CUIEvent event);
boolean runAction(Runnable ifFree, boolean checkFree, boolean async);
} }

Datei anzeigen

@ -28,11 +28,9 @@ import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration; import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.task.ThrowableSupplier; import com.boydti.fawe.object.task.ThrowableSupplier;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -104,7 +102,6 @@ import com.sk89q.worldedit.command.argument.RegistryConverter;
import com.sk89q.worldedit.command.argument.VectorConverter; import com.sk89q.worldedit.command.argument.VectorConverter;
import com.sk89q.worldedit.command.argument.WorldConverter; import com.sk89q.worldedit.command.argument.WorldConverter;
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter; import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandQueuedCondition; import com.sk89q.worldedit.command.util.CommandQueuedCondition;
import com.sk89q.worldedit.command.util.PermissionCondition; import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition; import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
@ -119,12 +116,10 @@ import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
import com.sk89q.worldedit.internal.command.exception.ExceptionConverter; import com.sk89q.worldedit.internal.command.exception.ExceptionConverter;
import com.sk89q.worldedit.internal.command.exception.WorldEditExceptionConverter; import com.sk89q.worldedit.internal.command.exception.WorldEditExceptionConverter;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.internal.util.Substring;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
@ -134,14 +129,11 @@ import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
@ -570,50 +562,11 @@ public final class PlatformCommandManager {
return def; return def;
} }
private Actor wrapActor(Actor actor, InjectedValueStore context) {
if (actor instanceof Player) {
final Set<String> failedPermissions = new LinkedHashSet<>();
Player player = (Player) actor;
Player unwrapped = LocationMaskedPlayerWrapper.unwrap(player);
actor = new LocationMaskedPlayerWrapper(unwrapped, player.getLocation(), true) {
@Override
public boolean hasPermission(String permission) {
if (!super.hasPermission(permission)) {
failedPermissions.add(permission);
return false;
}
return true;
}
@Override
public void checkPermission(String permission) throws AuthorizationException {
try {
super.checkPermission(permission);
} catch (AuthorizationException e) {
failedPermissions.add(permission);
throw e;
}
}
};
context.injectValue(Key.of(CommandPermissions.class), i -> Optional.of(new CommandPermissions() {
@Override
public Class<? extends Annotation> annotationType() {
return CommandPermissions.class;
}
@Override
public String[] value() {
return failedPermissions.toArray(new String[0]);
}
}));
}
return actor;
}
@Subscribe @Subscribe
public void handleCommand(CommandEvent event) { public void handleCommand(CommandEvent event) {
Request.reset(); Request.reset();
Actor actor = event.getActor(); Actor actor = event.getActor();
String args = event.getArguments(); String args = event.getArguments();
final FawePlayer<Object> fp = FawePlayer.wrap(actor);
System.out.println(1); System.out.println(1);
TaskManager.IMP.taskNow(() -> { TaskManager.IMP.taskNow(() -> {
int space0 = args.indexOf(' '); int space0 = args.indexOf(' ');
@ -747,10 +700,9 @@ public final class PlatformCommandManager {
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor) { private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor) {
InjectedValueStore store = MapBackedValueStore.create(); InjectedValueStore store = MapBackedValueStore.create();
Actor finalActor = wrapActor(actor, store); store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
store.injectValue(Key.of(Actor.class), ValueProvider.constant(finalActor)); if (actor instanceof Player) {
if (finalActor instanceof Player) { store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) finalActor));
} else { } else {
store.injectValue(Key.of(Player.class), context -> { store.injectValue(Key.of(Player.class), context -> {
throw new CommandException(TextComponent.of("This command must be used with a player."), ImmutableList.of()); throw new CommandException(TextComponent.of("This command must be used with a player."), ImmutableList.of());
@ -759,8 +711,8 @@ public final class PlatformCommandManager {
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments)); store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
store.injectValue(Key.of(LocalSession.class), store.injectValue(Key.of(LocalSession.class),
context -> { context -> {
LocalSession localSession = worldEdit.getSessionManager().get(finalActor); LocalSession localSession = worldEdit.getSessionManager().get(actor);
localSession.tellVersion(finalActor); localSession.tellVersion(actor);
return Optional.of(localSession); return Optional.of(localSession);
}); });

Datei anzeigen

@ -22,12 +22,9 @@ package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.brush.visualization.VirtualWorld;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.pattern.PatternTraverser; import com.boydti.fawe.object.pattern.PatternTraverser;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
import com.boydti.fawe.wrappers.WorldWrapper; import com.boydti.fawe.wrappers.WorldWrapper;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -73,7 +70,7 @@ public class PlatformManager {
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private PlatformCommandManager platformCommandManager; private final PlatformCommandManager platformCommandManager;
private final List<Platform> platforms = new ArrayList<>(); private final List<Platform> platforms = new ArrayList<>();
private final Map<Capability, Platform> preferences = new EnumMap<>(Capability.class); private final Map<Capability, Platform> preferences = new EnumMap<>(Capability.class);
@ -89,6 +86,7 @@ public class PlatformManager {
public PlatformManager(WorldEdit worldEdit) { public PlatformManager(WorldEdit worldEdit) {
checkNotNull(worldEdit); checkNotNull(worldEdit);
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
this.platformCommandManager = new PlatformCommandManager(worldEdit, this);
// Register this instance for events // Register this instance for events
worldEdit.getEventBus().register(this); worldEdit.getEventBus().register(this);
@ -119,9 +117,6 @@ public class PlatformManager {
firstSeenVersion = platform.getVersion(); firstSeenVersion = platform.getVersion();
} }
if (this.platformCommandManager == null) {
this.platformCommandManager = new PlatformCommandManager(worldEdit, this);
}
} }
/** /**
@ -265,8 +260,17 @@ public class PlatformManager {
if (base instanceof Player) { if (base instanceof Player) {
Player player = (Player) base; Player player = (Player) base;
FawePlayer fp = FawePlayer.wrap(player); Player permActor = queryCapability(Capability.PERMISSIONS).matchPlayer(player);
return (T) fp.createProxy(); if (permActor == null) {
permActor = player;
}
Player cuiActor = queryCapability(Capability.WORLDEDIT_CUI).matchPlayer(player);
if (cuiActor == null) {
cuiActor = player;
}
return (T) new PlayerProxy(player, permActor, cuiActor, getWorldForEditing(player.getWorld()));
} else { } else {
return base; return base;
} }
@ -341,9 +345,7 @@ public class PlatformManager {
if (session.hasSuperPickAxe()) { if (session.hasSuperPickAxe()) {
final BlockTool superPickaxe = session.getSuperPickaxe(); final BlockTool superPickaxe = session.getSuperPickaxe();
if (superPickaxe != null && superPickaxe.canUse(player) && player.isHoldingPickAxe()) { if (superPickaxe != null && superPickaxe.canUse(player) && player.isHoldingPickAxe()) {
FawePlayer<?> fp = FawePlayer.wrap(player); player.runAction(() -> reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location), false, true);
final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(() -> reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location), false, true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -351,9 +353,7 @@ public class PlatformManager {
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) { if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); player.runAction(() -> reset(((DoubleActionBlockTool) tool)).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location), false, true);
final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(() -> reset(((DoubleActionBlockTool) tool)).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location), false, true);
event.setCancelled(true); event.setCancelled(true);
} }
break; break;
@ -362,14 +362,12 @@ public class PlatformManager {
case OPEN: { case OPEN: {
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof BlockTool && tool.canUse(player)) { if (tool instanceof BlockTool && tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); if (player.checkAction()) {
if (fp.checkAction()) { player.runAction(() -> {
final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(() -> {
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location); ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
} else { } else {
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location); reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
} }
}, false, true); }, false, true);
event.setCancelled(true); event.setCancelled(true);
@ -400,8 +398,7 @@ public class PlatformManager {
public void handlePlayerInput(PlayerInputEvent event) { public void handlePlayerInput(PlayerInputEvent event) {
// Create a proxy actor with a potentially different world for // Create a proxy actor with a potentially different world for
// making changes to the world // making changes to the world
Player actor = createProxyActor(event.getPlayer()); Player player = createProxyActor(event.getPlayer());
Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap(actor), actor.getLocation(), true);
LocalSession session = worldEdit.getSessionManager().get(player); LocalSession session = worldEdit.getSessionManager().get(player);
VirtualWorld virtual = session.getVirtualWorld(); VirtualWorld virtual = session.getVirtualWorld();
@ -430,8 +427,7 @@ public class PlatformManager {
} }
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) { if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session));
fp.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session));
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -454,9 +450,8 @@ public class PlatformManager {
} }
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof TraceTool && tool.canUse(player)) { if (tool instanceof TraceTool && tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player);
//todo this needs to be fixed so the event is canceled after actPrimary is used and returns true //todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
fp.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session), false, true); player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session), false, true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.sk89q.worldedit.extension.platform.binding; package com.sk89q.worldedit.extension.platform.binding;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.image.ImageUtil; import com.boydti.fawe.util.image.ImageUtil;
@ -32,17 +31,15 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import java.awt.image.BufferedImage;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.Key;
import org.enginehub.piston.util.ValueProvider; import org.enginehub.piston.util.ValueProvider;
import java.awt.image.BufferedImage;
import java.lang.annotation.Annotation;
import java.net.URI;
import java.util.Collection;
import java.util.Optional;
public class ProvideBindings extends Bindings { public class ProvideBindings extends Bindings {
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
@ -112,17 +109,6 @@ public class ProvideBindings extends Bindings {
return editSession; return editSession;
} }
/**
* Gets an {@link com.boydti.fawe.object.FawePlayer} from a {@link ArgumentStack}.
*
* @param context the context
* @return a FawePlayer
* @throws ParameterException on other error
*/
public FawePlayer getFawePlayer(Actor actor) throws InputParseException {
return FawePlayer.wrap(actor);
}
/* /*
Parsed Parsed
*/ */

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
@ -40,7 +39,7 @@ import java.util.function.IntSupplier;
public class ExpressionMask extends AbstractMask { public class ExpressionMask extends AbstractMask {
private final Expression expression; private final Expression expression;
private final int timeout; private final IntSupplier timeout;
/** /**
* Create a new instance. * Create a new instance.
@ -58,10 +57,10 @@ public class ExpressionMask extends AbstractMask {
* @param expression the expression * @param expression the expression
*/ */
public ExpressionMask(Expression expression) { public ExpressionMask(Expression expression) {
this(expression, WorldEdit.getInstance().getConfiguration().calculationTimeout); this(expression, null);
} }
public ExpressionMask(Expression expression, int timeout) { public ExpressionMask(Expression expression, @Nullable IntSupplier timeout) {
checkNotNull(expression); checkNotNull(expression);
this.expression = expression; this.expression = expression;
this.timeout = timeout; this.timeout = timeout;
@ -73,7 +72,12 @@ public class ExpressionMask extends AbstractMask {
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) { if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3()); ((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
} }
return expression.evaluateTimeout(timeout, vector.getX(), vector.getY(), vector.getZ()) > 0; if (timeout == null) {
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
} else {
return expression.evaluate(new double[]{vector.getX(), vector.getY(), vector.getZ()},
timeout.getAsInt()) > 0;
}
} catch (EvaluationException e) { } catch (EvaluationException e) {
return false; return false;
} }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen