Update some classes

This commit is contained in:
Jesse Boyd 2016-06-29 15:25:27 +10:00
parent b56a6d4b7c
commit af6c80901a
3 changed files with 23 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit.v0; package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.example.CharFaweChunk;
import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
@ -24,7 +25,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.Plugin;
public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener { public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener {
@ -37,7 +37,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
setupAdapter(null); setupAdapter(null);
if (!registered) { if (!registered) {
registered = true; registered = true;
Bukkit.getServer().getPluginManager().registerEvents(this, (Plugin) Fawe.imp()); Bukkit.getServer().getPluginManager().registerEvents(this, ((FaweBukkit) Fawe.imp()).getPlugin());
} }
} }

View File

@ -293,8 +293,10 @@ public class ClipboardCommands {
Operations.completeLegacy(operation); Operations.completeLegacy(operation);
if (selectPasted) { if (selectPasted) {
Vector max = to.add(region.getMaximumPoint().subtract(region.getMinimumPoint())); Vector clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), to, max); Vector realTo = to.add(holder.getTransform().apply(clipboardOffset));
Vector max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint())));
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max);
session.setRegionSelector(player.getWorld(), selector); session.setRegionSelector(player.getWorld(), selector);
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(player, session); selector.explainRegionAdjust(player, session);

View File

@ -142,7 +142,6 @@ public final class CommandManager {
builder.setAuthorizer(new ActorAuthorizer()); builder.setAuthorizer(new ActorAuthorizer());
builder.setDefaultCompleter(new UserCommandCompleter(platformManager)); builder.setDefaultCompleter(new UserCommandCompleter(platformManager));
builder.addBinding(new WorldEditBinding(worldEdit)); builder.addBinding(new WorldEditBinding(worldEdit));
builder.addExceptionConverter(exceptionConverter);
builder.addInvokeListener(new LegacyCommandsHandler()); builder.addInvokeListener(new LegacyCommandsHandler());
builder.addInvokeListener(new CommandLoggingHandler(worldEdit, commandLog)); builder.addInvokeListener(new CommandLoggingHandler(worldEdit, commandLog));
@ -260,7 +259,23 @@ public final class CommandManager {
locals.put("arguments", event.getArguments()); locals.put("arguments", event.getArguments());
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
try { try {
dispatcher.call(Joiner.on(" ").join(split), locals, new String[0]); // This is a bit of a hack, since the call method can only throw CommandExceptions
// everything needs to be wrapped at least once. Which means to handle all WorldEdit
// exceptions without writing a hook into every dispatcher, we need to unwrap these
// exceptions and rethrow their converted form, if their is one.
try {
dispatcher.call(Joiner.on(" ").join(split), locals, new String[0]);
} catch (Throwable t) {
// Use the exception converter to convert the exception if any of its causes
// can be converted, otherwise throw the original exception
Throwable next = t;
do {
exceptionConverter.convert(next);
next = next.getCause();
} while (next != null);
throw t;
}
} catch (CommandPermissionsException e) { } catch (CommandPermissionsException e) {
BBC.NO_PERM.send(actor, "worldedit.*"); BBC.NO_PERM.send(actor, "worldedit.*");
} catch (InvalidUsageException e) { } catch (InvalidUsageException e) {