From 895de11a092e47b8d4ecfd04ddc0844344f0706a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 4 Aug 2016 19:46:38 +1000 Subject: [PATCH] Fix entity mask + More work on rollback --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 6 + core/src/main/java/com/boydti/fawe/Fawe.java | 2 + .../main/java/com/boydti/fawe/FaweCache.java | 13 ++ .../com/boydti/fawe/command/Rollback.java | 19 ++ .../main/java/com/boydti/fawe/config/BBC.java | 21 +- .../com/boydti/fawe/database/DBHandler.java | 2 + .../fawe/database/RollbackDatabase.java | 57 +++-- .../logging/rollback/RollbackDatabase.java | 4 - .../rollback/RollbackOptimizedHistory.java | 5 + .../fawe/object/brush/InspectBrush.java | 121 ++++++++-- .../object/change/MutableFullBlockChange.java | 49 ++++ .../change/MutablePlayerBlockChange.java | 16 -- .../object/changeset/FaweStreamChangeSet.java | 61 +++++ .../fawe/object/extent/ProcessedWEExtent.java | 11 +- .../java/com/boydti/fawe/util/WEManager.java | 6 +- .../worldedit/command/BrushCommands.java | 19 -- .../worldedit/command/HistoryCommands.java | 40 +++- .../sk89q/worldedit/command/ToolCommands.java | 215 ++++++++++++++++++ 18 files changed, 589 insertions(+), 78 deletions(-) delete mode 100644 core/src/main/java/com/boydti/fawe/logging/rollback/RollbackDatabase.java create mode 100644 core/src/main/java/com/boydti/fawe/object/change/MutableFullBlockChange.java delete mode 100644 core/src/main/java/com/boydti/fawe/object/change/MutablePlayerBlockChange.java create mode 100644 core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 669c5a1c..7825b78f 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -219,6 +219,12 @@ public class FaweBukkit implements IFawe, Listener { return world.getName(); } + @Override + public String getUserName(UUID uuid) { + String name = Bukkit.getOfflinePlayer(uuid).getName(); + return name != null ? name : uuid.toString(); + } + /** * A mask manager handles region restrictions e.g. PlotSquared plots / WorldGuard regions */ diff --git a/core/src/main/java/com/boydti/fawe/Fawe.java b/core/src/main/java/com/boydti/fawe/Fawe.java index b4996268..052ed2d1 100644 --- a/core/src/main/java/com/boydti/fawe/Fawe.java +++ b/core/src/main/java/com/boydti/fawe/Fawe.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.command.NavigationCommands; import com.sk89q.worldedit.command.RegionCommands; import com.sk89q.worldedit.command.SchematicCommands; import com.sk89q.worldedit.command.ScriptingCommands; +import com.sk89q.worldedit.command.ToolCommands; import com.sk89q.worldedit.command.composition.SelectionCommand; import com.sk89q.worldedit.command.tool.brush.GravityBrush; import com.sk89q.worldedit.event.extent.EditSessionEvent; @@ -277,6 +278,7 @@ public class Fawe { LocalSession.inject(); // Add remember order / queue flushing // Commands BrushCommands.inject(); // Translations + heightmap + ToolCommands.inject(); // Translations + inspect ClipboardCommands.inject(); // Translations + lazycopy + paste optimizations SchematicCommands.inject(); // Translations ScriptingCommands.inject(); // Translations diff --git a/core/src/main/java/com/boydti/fawe/FaweCache.java b/core/src/main/java/com/boydti/fawe/FaweCache.java index bc9b0116..153990e2 100644 --- a/core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/core/src/main/java/com/boydti/fawe/FaweCache.java @@ -16,6 +16,7 @@ import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.CuboidClipboard; import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.world.registry.BundledBlockData; import java.awt.Color; import java.lang.reflect.Field; import java.util.ArrayList; @@ -507,6 +508,18 @@ public class FaweCache { } } + public static String getMaterialName(int combined) { + return getMaterialName(getId(combined), getData(combined)); + } + + public static String getMaterialName(int id, int data) { + BundledBlockData.BlockEntry entry = BundledBlockData.getInstance().findById(id); + if (entry == null) { + return data != 0 ? id + ":" + data : id + ""; + } + return data != 0 ? entry.id.replace("minecraft:","") + ":" + data : entry.id.replace("minecraft:",""); + } + public static Map asMap(Object... pairs) { HashMap map = new HashMap(pairs.length >> 1); for (int i = 0; i < pairs.length; i+=2) { diff --git a/core/src/main/java/com/boydti/fawe/command/Rollback.java b/core/src/main/java/com/boydti/fawe/command/Rollback.java index f836b321..7d46fd37 100644 --- a/core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -3,6 +3,7 @@ package com.boydti.fawe.command; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; +import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FawePlayer; @@ -27,6 +28,24 @@ public class Rollback extends FaweCommand { @Override public boolean execute(final FawePlayer player, final String... args) { + if (!Settings.HISTORY.USE_DATABASE) { + BBC.SETTING_DISABLE.send(player, "history.use-database"); + return false; + } + if (args.length != 3) { + BBC.COMMAND_SYNTAX.send(player, "/frb u: r: t: