From fa7fc22398939cb3b168b45e66d5da1c24b7aa81 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 11 Aug 2018 15:06:02 +1000 Subject: [PATCH] Record source --- .../worldedit/command/SchematicCommands.java | 4 +++- .../sk89q/worldedit/event/extent/PasteEvent.java | 4 +++- .../event/extent/PlayerSaveClipboardEvent.java | 15 ++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 7dfb98b8..ca95ecfe 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -338,7 +338,9 @@ public class SchematicCommands extends MethodCommands { } else { target = clipboard; } - if (new PlayerSaveClipboardEvent(player, clipboard, f.toURI()).call()) { + URI uri = null; + if (holder instanceof URIClipboardHolder) uri = ((URIClipboardHolder) holder).getURI(clipboard); + if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) { try (ClipboardWriter writer = format.getWriter(fos)) { if (writer instanceof StructureFormat) { ((StructureFormat) writer).write(target, holder.getWorldData(), player.getName()); diff --git a/core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java b/core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java index 1d63c347..b612653f 100644 --- a/core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java +++ b/core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java @@ -21,11 +21,13 @@ package com.sk89q.worldedit.event.extent; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.event.Cancellable; +import com.sk89q.worldedit.event.Event; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; - import java.net.URI; + import static com.sk89q.worldedit.EditSession.Stage; public class PasteEvent extends FaweEvent { diff --git a/core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java b/core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java index 20c993b0..9b05cfd0 100644 --- a/core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java +++ b/core/src/main/java/com/sk89q/worldedit/event/extent/PlayerSaveClipboardEvent.java @@ -11,13 +11,14 @@ import java.net.URI; public class PlayerSaveClipboardEvent extends FaweEvent { private final Player player; private final Clipboard clipboard; - private final URI uri; + private final URI source, destination; private boolean cancelled; - public PlayerSaveClipboardEvent(Player player, Clipboard clipboard, URI destination) { + public PlayerSaveClipboardEvent(Player player, Clipboard clipboard, URI source, URI destination) { this.player = player; this.clipboard = clipboard; - this.uri = destination; + this.source = source; + this.destination = destination; } @Override @@ -30,8 +31,12 @@ public class PlayerSaveClipboardEvent extends FaweEvent { this.cancelled = cancelled; } - public URI getUri() { - return uri; + public URI getSourceURI() { + return source; + } + + public URI getDestinationURI() { + return destination; } public Clipboard getClipboard() {