Various major

Add regen
Add //history [find|restore|rollback|summary|clear]
 - history commands are interactable
 - inspect brush info is interactable
Commands are now logged to a searchable database
Fix some cases of id/ordinal mismatch
This commit is contained in:
Jesse Boyd
2019-11-23 04:31:48 +00:00
parent edcaeb6cfe
commit 1844d4dba7
56 changed files with 1236 additions and 924 deletions

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.SimpleAsyncNotifyQueue;
import com.boydti.fawe.object.task.AsyncNotifyQueue;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.internal.cui.CUIEvent;
@ -65,7 +65,7 @@ public abstract class AbstractNonPlayerActor implements Actor {
// Queue for async tasks
private AtomicInteger runningCount = new AtomicInteger();
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue(
private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
(thread, throwable) -> {
while (throwable.getCause() != null) {
throwable = throwable.getCause();
@ -106,7 +106,7 @@ public abstract class AbstractNonPlayerActor implements Actor {
}
};
if (async) {
asyncNotifyQueue.queue(wrapped);
asyncNotifyQueue.run(wrapped);
} else {
TaskManager.IMP.taskNow(wrapped, false);
}

View File

@ -19,11 +19,12 @@
package com.sk89q.worldedit.extension.platform;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.object.task.AsyncNotifyQueue;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
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;
@ -94,7 +95,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
// Queue for async tasks
private AtomicInteger runningCount = new AtomicInteger();
private SimpleAsyncNotifyQueue asyncNotifyQueue = new SimpleAsyncNotifyQueue(
private AsyncNotifyQueue asyncNotifyQueue = new AsyncNotifyQueue(
(thread, throwable) -> {
while (throwable.getCause() != null) {
throwable = throwable.getCause();
@ -618,7 +619,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) {
throw new AuthorizationException();
throw new AuthorizationException(Caption.toString(TranslatableComponent.of("fawe.error.no.perm", permission)));
}
}
@ -675,7 +676,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
}
};
if (async) {
asyncNotifyQueue.queue(wrapped);
asyncNotifyQueue.run(wrapped);
} else {
TaskManager.IMP.taskNow(wrapped, false);
}

View File

@ -110,7 +110,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* @param component The component to print
*/
default void printError(Component component) {
print(TranslatableComponent.of("error", component));
print(TranslatableComponent.of("fawe.error", component));
}
/**
@ -119,7 +119,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* @param component The component to print
*/
default void printInfo(Component component) {
print(TranslatableComponent.of("info", component));
print(TranslatableComponent.of("fawe.info", component));
}
/**
@ -142,7 +142,7 @@ public interface Actor extends Identifiable, SessionOwner, Subject, MapMetadatab
* @param component The component to print
*/
default void printDebug(Component component) {
print(TranslatableComponent.of("debug", component));
print(TranslatableComponent.of("fawe.debug", component));
}
/**

View File

@ -25,6 +25,8 @@ import com.boydti.fawe.command.AnvilCommandsRegistration;
import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.command.HistorySubCommands;
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
@ -294,6 +296,7 @@ public final class PlatformCommandManager {
}
});
});
/*
globalInjectedValues.injectValue(Key.of(EditSession.class),
context -> {
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
@ -306,6 +309,7 @@ public final class PlatformCommandManager {
return editSession;
});
});
*/
globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class),
context -> context.injectedValue(Key.of(Actor.class))
.orElseThrow(() -> new IllegalStateException("No CFI Settings")).getMeta("CFISettings"));
@ -518,10 +522,18 @@ public final class PlatformCommandManager {
GenerationCommandsRegistration.builder(),
new GenerationCommands(worldEdit)
);
HistoryCommands history = new HistoryCommands(worldEdit);
this.registration.register(
commandManager,
HistoryCommandsRegistration.builder(),
new HistoryCommands(worldEdit)
commandManager,
HistoryCommandsRegistration.builder(),
history
);
registerSubCommands(
"/history",
ImmutableList.of(),
"Manage your history",
HistorySubCommandsRegistration.builder(),
new HistorySubCommands(history)
);
this.registration.register(
commandManager,
@ -739,7 +751,7 @@ public final class PlatformCommandManager {
} catch (UsageException e) {
ImmutableList<Command> cmd = e.getCommands();
if (!cmd.isEmpty()) {
actor.printError(TranslatableComponent.of("fawe.error.command.syntax", HelpGenerator.create(e.getCommandParseResult()).getUsage()));
actor.printError(TranslatableComponent.of("fawe.error.command.syntax", HelpGenerator.create(e.getCommandParseResult()).getFullHelp()));
}
actor.printError(e.getRichMessage());
} catch (CommandExecutionException e) {

View File

@ -1,5 +1,8 @@
package com.sk89q.worldedit.extension.platform.binding;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.image.ImageUtil;
import com.sk89q.worldedit.WorldEdit;
@ -14,12 +17,15 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.annotation.Time;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -36,6 +42,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
import java.util.Collection;
import java.util.UUID;
public class ConsumeBindings extends Bindings {
private final PlatformCommandManager manager;
@ -45,6 +52,12 @@ public class ConsumeBindings extends Bindings {
this.manager = manager;
}
@Time
@Binding
public Long time(Actor actor, String argument) {
return MainUtil.timeToSec(argument) * 1000;
}
@Binding
@Confirm
@Selection
@ -99,6 +112,30 @@ public class ConsumeBindings extends Bindings {
return radius;
}
@Binding
public UUID playerUUID(Actor actor, String argument) {
if (argument.equals("me")) {
return actor.getUniqueId();
}
if (argument.equals("*")) {
return Identifiable.EVERYONE;
}
if (argument.equalsIgnoreCase("console") || argument.equalsIgnoreCase("server")) {
return Identifiable.CONSOLE;
}
UUID uuid;
if (argument.length() > 16) {
uuid = UUID.fromString(argument);
} else {
uuid = Fawe.imp().getUUID(argument);
}
if (uuid == null) {
throw new InputParseException(Caption.toString(TranslatableComponent.of("fawe.error.player.not.found" , argument)));
}
return uuid;
}
@Binding
public ProvideBindings.ImageUri getImage(String argument) {
return new ProvideBindings.ImageUri(ImageUtil.getImageURI(argument));

View File

@ -1,19 +1,28 @@
package com.sk89q.worldedit.extension.platform.binding;
import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.logging.LoggingChangeSet;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.image.ImageUtil;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.annotation.AllowedRegion;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -57,8 +66,10 @@ public class ProvideBindings extends Bindings {
}
@Binding
public EditSession editSession(LocalSession localSession, Player player) {
EditSession editSession = localSession.createEditSession(player);
public EditSession editSession(LocalSession localSession, Player player, InjectedValueAccess context) {
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
String command = arguments == null ? null : arguments.get();
EditSession editSession = localSession.createEditSession(player, command);
editSession.enableStandardMode();
Request.request().setEditSession(editSession);
return editSession;
@ -70,6 +81,31 @@ public class ProvideBindings extends Bindings {
return localSession.getSelection(player.getWorld());
}
@Binding
public RollbackDatabase database(World world) {
return DBHandler.IMP.getDatabase(world);
}
@AllowedRegion(FaweMaskManager.MaskType.OWNER)
@Binding
public Region[] regionsOwner(Player player) {
return regions(player, FaweMaskManager.MaskType.OWNER);
}
@AllowedRegion(FaweMaskManager.MaskType.MEMBER)
@Binding
public Region[] regionsMember(Player player) {
return regions(player, FaweMaskManager.MaskType.MEMBER);
}
public Region[] regions(Player player, FaweMaskManager.MaskType type) {
Region[] regions = player.getCurrentRegions(type);
if (regions == null) {
throw new IllegalArgumentException(Caption.toString(TranslatableComponent.of("fawe.error.no.region")));
}
return regions;
}
@Binding
public TextureUtil getTexture(LocalSession session) {
return session.getTextureUtil();
@ -102,7 +138,7 @@ public class ProvideBindings extends Bindings {
return extent;
}
Player plr = getPlayer(actor);
EditSession editSession = editSession(getLocalSession(plr), plr);
EditSession editSession = editSession(getLocalSession(plr), plr, access);
if (access instanceof InjectedValueStore) {
InjectedValueStore store = (InjectedValueStore) access;
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));