mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Allow console to execute commands now that editsessions etc. accept actors
- Fixes #724 - Fixes #1044
This commit is contained in:
parent
fa2f50dea8
commit
0ed98729f8
@ -46,15 +46,15 @@ public class ProvideBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
public LocalSession getLocalSession(Player player) {
|
public LocalSession getLocalSession(Actor actor) {
|
||||||
return getWorldEdit().getSessionManager().get(player);
|
return getWorldEdit().getSessionManager().get(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
public EditSession editSession(LocalSession localSession, Player player, InjectedValueAccess context) {
|
public EditSession editSession(LocalSession localSession, Actor actor, InjectedValueAccess context) {
|
||||||
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
|
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
|
||||||
String command = arguments == null ? null : arguments.get();
|
String command = arguments == null ? null : arguments.get();
|
||||||
EditSession editSession = localSession.createEditSession(player, command);
|
EditSession editSession = localSession.createEditSession(actor, command);
|
||||||
editSession.enableStandardMode();
|
editSession.enableStandardMode();
|
||||||
Request.request().setEditSession(editSession);
|
Request.request().setEditSession(editSession);
|
||||||
return editSession;
|
return editSession;
|
||||||
@ -62,8 +62,8 @@ public class ProvideBindings extends Bindings {
|
|||||||
|
|
||||||
@Selection
|
@Selection
|
||||||
@Binding
|
@Binding
|
||||||
public Region selection(LocalSession localSession, Player player) {
|
public Region selection(LocalSession localSession) {
|
||||||
return localSession.getSelection(player.getWorld());
|
return localSession.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
@ -124,8 +124,7 @@ public class ProvideBindings extends Bindings {
|
|||||||
if (extent != null) {
|
if (extent != null) {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
Player plr = getPlayer(actor);
|
EditSession editSession = editSession(getLocalSession(actor), actor, access);
|
||||||
EditSession editSession = editSession(getLocalSession(plr), plr, access);
|
|
||||||
if (access instanceof InjectedValueStore) {
|
if (access instanceof InjectedValueStore) {
|
||||||
InjectedValueStore store = (InjectedValueStore) access;
|
InjectedValueStore store = (InjectedValueStore) access;
|
||||||
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
|
store.injectValue(Key.of(EditSession.class), ValueProvider.constant(editSession));
|
||||||
|
@ -6,27 +6,28 @@ import com.fastasyncworldedit.core.util.MemUtil;
|
|||||||
import com.fastasyncworldedit.core.util.Permission;
|
import com.fastasyncworldedit.core.util.Permission;
|
||||||
import com.fastasyncworldedit.core.util.WEManager;
|
import com.fastasyncworldedit.core.util.WEManager;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
public class MemoryCheckingExtent extends PassthroughExtent {
|
public class MemoryCheckingExtent extends PassthroughExtent {
|
||||||
|
|
||||||
private final Player player;
|
private final Actor actor;
|
||||||
|
|
||||||
public MemoryCheckingExtent(Player player, Extent extent) {
|
public MemoryCheckingExtent(Actor actor, Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.player = player;
|
this.actor = actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Extent getExtent() {
|
public Extent getExtent() {
|
||||||
if (MemUtil.isMemoryLimited()) {
|
if (MemUtil.isMemoryLimited()) {
|
||||||
if (this.player != null) {
|
if (this.actor != null) {
|
||||||
player.print(Caption.of(
|
actor.print(Caption.of(
|
||||||
"fawe.cancel.worldedit.cancel.reason",
|
"fawe.cancel.worldedit.cancel.reason",
|
||||||
Caption.of("fawe.cancel.worldedit.cancel.reason.low.memory")
|
Caption.of("fawe.cancel.worldedit.cancel.reason.low.memory")
|
||||||
));
|
));
|
||||||
if (Permission.hasPermission(this.player, "worldedit.fast")) {
|
if (Permission.hasPermission(this.actor, "worldedit.fast")) {
|
||||||
this.player.print(Caption.of("fawe.info.worldedit.oom.admin"));
|
this.actor.print(Caption.of("fawe.info.worldedit.oom.admin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);
|
WEManager.IMP.cancelEdit(this, FaweCache.LOW_MEMORY);
|
||||||
|
@ -13,7 +13,7 @@ import com.fastasyncworldedit.core.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.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -134,35 +134,35 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
enttFile.delete();
|
enttFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player player, Region[] regions) {
|
public void undo(Actor actor, Region[] regions) {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditSession session = toEditSession(player, regions);
|
EditSession session = toEditSession(actor, regions);
|
||||||
session.setBlocks(this, ChangeSetExecutor.Type.UNDO);
|
session.setBlocks(this, ChangeSetExecutor.Type.UNDO);
|
||||||
deleteFiles();
|
deleteFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player player) {
|
public void undo(Actor actor) {
|
||||||
undo(player, null);
|
undo(actor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redo(Player player, Region[] regions) {
|
public void redo(Actor actor, Region[] regions) {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditSession session = toEditSession(player, regions);
|
EditSession session = toEditSession(actor, regions);
|
||||||
session.setBlocks(this, ChangeSetExecutor.Type.REDO);
|
session.setBlocks(this, ChangeSetExecutor.Type.REDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redo(Player player) {
|
public void redo(Actor actor) {
|
||||||
redo(player, null);
|
redo(actor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
|
@ -16,7 +16,7 @@ import com.sk89q.jnbt.CompoundTag;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.EditSessionBuilder;
|
import com.sk89q.worldedit.EditSessionBuilder;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
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;
|
||||||
@ -251,12 +251,12 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
|||||||
|
|
||||||
public abstract Iterator<Change> getIterator(boolean redo);
|
public abstract Iterator<Change> getIterator(boolean redo);
|
||||||
|
|
||||||
public EditSession toEditSession(Player player) {
|
public EditSession toEditSession(Actor actor) {
|
||||||
return toEditSession(player, null);
|
return toEditSession(actor, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditSession toEditSession(Player player, Region[] regions) {
|
public EditSession toEditSession(Actor actor, Region[] regions) {
|
||||||
EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(getWorld()).actor(player).
|
EditSessionBuilder builder = WorldEdit.getInstance().newEditSessionBuilder().world(getWorld()).actor(actor).
|
||||||
fastMode(false).checkMemory(false).changeSet(this).limitUnlimited();
|
fastMode(false).checkMemory(false).changeSet(this).limitUnlimited();
|
||||||
if (regions != null) {
|
if (regions != null) {
|
||||||
builder.allowedRegions(regions);
|
builder.allowedRegions(regions);
|
||||||
|
@ -3,6 +3,7 @@ package com.fastasyncworldedit.core.history.changeset;
|
|||||||
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.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
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;
|
||||||
@ -84,13 +85,13 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession toEditSession(Player player) {
|
public EditSession toEditSession(Actor actor) {
|
||||||
return parent.toEditSession(player);
|
return parent.toEditSession(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession toEditSession(Player player, Region[] regions) {
|
public EditSession toEditSession(Actor actor, Region[] regions) {
|
||||||
return parent.toEditSession(player, regions);
|
return parent.toEditSession(actor, regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -328,17 +328,17 @@ public class ClipboardCommands {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.clipboard.download"})
|
@CommandPermissions({"worldedit.clipboard.download"})
|
||||||
public void download(
|
public void download(
|
||||||
final Player player,
|
final Actor actor,
|
||||||
final LocalSession session,
|
final LocalSession session,
|
||||||
@Arg(name = "format", desc = "String", def = "fast") final String formatName
|
@Arg(name = "format", desc = "String", def = "fast") final String formatName
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
actor.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(Caption.of("fawe.web.generating.link", formatName));
|
actor.print(Caption.of("fawe.web.generating.link", formatName));
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
@ -388,7 +388,7 @@ public class ClipboardCommands {
|
|||||||
// If we have a transform, bake it into the copy
|
// If we have a transform, bake it into the copy
|
||||||
if (!transform.isIdentity()) {
|
if (!transform.isIdentity()) {
|
||||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
||||||
target = new BlockArrayClipboard(result.getTransformedRegion(), player.getUniqueId());
|
target = new BlockArrayClipboard(result.getTransformedRegion(), actor.getUniqueId());
|
||||||
target.setOrigin(clipboard.getOrigin());
|
target.setOrigin(clipboard.getOrigin());
|
||||||
Operations.completeLegacy(result.copyTo(target));
|
Operations.completeLegacy(result.copyTo(target));
|
||||||
} else {
|
} else {
|
||||||
@ -407,17 +407,17 @@ public class ClipboardCommands {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings.IMP.WEB.URL.isEmpty()) {
|
if (Settings.IMP.WEB.URL.isEmpty()) {
|
||||||
player.print(Caption.of("fawe.error.setting.disable", "web.url"));
|
actor.print(Caption.of("fawe.error.setting.disable", "web.url"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
url = FaweAPI.upload(target, format);
|
url = FaweAPI.upload(target, format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
player.print(Caption.of("fawe.web.generating.link.failed"));
|
actor.print(Caption.of("fawe.web.generating.link.failed"));
|
||||||
} else {
|
} else {
|
||||||
String urlText = url.toString();
|
String urlText = url.toString();
|
||||||
player.print(Caption.of("fawe.web.download.link", urlText).clickEvent(ClickEvent.openUrl(urlText)));
|
actor.print(Caption.of("fawe.web.download.link", urlText).clickEvent(ClickEvent.openUrl(urlText)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ public class GeneralCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.global-texture")
|
@CommandPermissions("worldedit.global-texture")
|
||||||
public void gtexture(
|
public void gtexture(
|
||||||
Player player,
|
Actor actor,
|
||||||
World worldArg,
|
World worldArg,
|
||||||
LocalSession session,
|
LocalSession session,
|
||||||
EditSession editSession,
|
EditSession editSession,
|
||||||
@ -470,7 +470,7 @@ public class GeneralCommands {
|
|||||||
// TODO NOT IMPLEMENTED convert this to an ArgumentConverter
|
// TODO NOT IMPLEMENTED convert this to an ArgumentConverter
|
||||||
if (arguments.isEmpty()) {
|
if (arguments.isEmpty()) {
|
||||||
session.setTextureUtil(null);
|
session.setTextureUtil(null);
|
||||||
player.print(Caption.of("fawe.worldedit.general.texture.disabled"));
|
actor.print(Caption.of("fawe.worldedit.general.texture.disabled"));
|
||||||
} else {
|
} else {
|
||||||
String arg = arguments.get(0);
|
String arg = arguments.get(0);
|
||||||
String argLower = arg.toLowerCase(Locale.ROOT);
|
String argLower = arg.toLowerCase(Locale.ROOT);
|
||||||
@ -503,7 +503,7 @@ public class GeneralCommands {
|
|||||||
util = Fawe.get().getTextureUtil();
|
util = Fawe.get().getTextureUtil();
|
||||||
} else {
|
} else {
|
||||||
ParserContext parserContext = new ParserContext();
|
ParserContext parserContext = new ParserContext();
|
||||||
parserContext.setActor(player);
|
parserContext.setActor(actor);
|
||||||
parserContext.setWorld(worldArg);
|
parserContext.setWorld(worldArg);
|
||||||
parserContext.setSession(session);
|
parserContext.setSession(session);
|
||||||
parserContext.setExtent(editSession);
|
parserContext.setExtent(editSession);
|
||||||
@ -523,7 +523,7 @@ public class GeneralCommands {
|
|||||||
util = new CachedTextureUtil(util);
|
util = new CachedTextureUtil(util);
|
||||||
}
|
}
|
||||||
session.setTextureUtil(util);
|
session.setTextureUtil(util);
|
||||||
player.print(Caption.of("fawe.worldedit.general.texture.set", StringMan.join(arguments, " ")));
|
actor.print(Caption.of("fawe.worldedit.general.texture.set", StringMan.join(arguments, " ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,16 +535,16 @@ public class GeneralCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
|
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
|
||||||
public void gsmask(
|
public void gsmask(
|
||||||
Player player,
|
Actor actor,
|
||||||
LocalSession session,
|
LocalSession session,
|
||||||
EditSession editSession,
|
EditSession editSession,
|
||||||
@Arg(desc = "The mask to set", def = "") Mask maskOpt
|
@Arg(desc = "The mask to set", def = "") Mask maskOpt
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
session.setSourceMask(maskOpt);
|
session.setSourceMask(maskOpt);
|
||||||
if (maskOpt == null) {
|
if (maskOpt == null) {
|
||||||
player.print(Caption.of("fawe.worldedit.general.source.mask.disabled"));
|
actor.print(Caption.of("fawe.worldedit.general.source.mask.disabled"));
|
||||||
} else {
|
} else {
|
||||||
player.print(Caption.of("fawe.worldedit.general.source.mask"));
|
actor.print(Caption.of("fawe.worldedit.general.source.mask"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,16 +555,16 @@ public class GeneralCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.global-transform", "worldedit.transform.global"})
|
@CommandPermissions({"worldedit.global-transform", "worldedit.transform.global"})
|
||||||
public void gtransform(
|
public void gtransform(
|
||||||
Player player,
|
Actor actor,
|
||||||
EditSession editSession,
|
EditSession editSession,
|
||||||
LocalSession session,
|
LocalSession session,
|
||||||
@Arg(desc = "The transform to set", def = "") ResettableExtent transform
|
@Arg(desc = "The transform to set", def = "") ResettableExtent transform
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
session.setTransform(transform);
|
session.setTransform(transform);
|
||||||
if (transform == null) {
|
if (transform == null) {
|
||||||
player.print(Caption.of("fawe.worldedit.general.transform.disabled"));
|
actor.print(Caption.of("fawe.worldedit.general.transform.disabled"));
|
||||||
} else {
|
} else {
|
||||||
player.print(Caption.of("fawe.worldedit.general.transform"));
|
actor.print(Caption.of("fawe.worldedit.general.transform"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,11 +574,11 @@ public class GeneralCommands {
|
|||||||
desc = "Toggle FAWE tips"
|
desc = "Toggle FAWE tips"
|
||||||
)
|
)
|
||||||
@CommandPermissions("fawe.tips")
|
@CommandPermissions("fawe.tips")
|
||||||
public void tips(Player player, LocalSession session) throws WorldEditException {
|
public void tips(Actor actor, LocalSession session) throws WorldEditException {
|
||||||
if (player.togglePermission("fawe.tips")) {
|
if (actor.togglePermission("fawe.tips")) {
|
||||||
player.print(Caption.of("fawe.info.worldedit.toggle.tips.on"));
|
actor.print(Caption.of("fawe.info.worldedit.toggle.tips.on"));
|
||||||
} else {
|
} else {
|
||||||
player.print(Caption.of("fawe.info.worldedit.toggle.tips.off"));
|
actor.print(Caption.of("fawe.info.worldedit.toggle.tips.off"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,10 +140,10 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.test")
|
@CommandPermissions("worldedit.region.test")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void test(
|
public void test(
|
||||||
Player player, EditSession editSession,
|
Actor actor, EditSession editSession,
|
||||||
@Arg(desc = "test") double testValue
|
@Arg(desc = "test") double testValue
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
player.print(TextComponent.of(testValue));
|
actor.print(TextComponent.of(testValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -151,19 +151,9 @@ public class RegionCommands {
|
|||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.fix")
|
@CommandPermissions("worldedit.light.fix")
|
||||||
public void fixLighting(Player player) throws WorldEditException {
|
public void fixLighting(Actor actor, LocalSession session, @Selection Region selection) throws WorldEditException {
|
||||||
final Location loc = player.getLocation();
|
int count = FaweAPI.fixLighting(session.getSelectionWorld(), selection, null, RelightMode.ALL);
|
||||||
Region selection = player.getSelection();
|
actor.print(Caption.of("fawe.info.lighting.propagate.selection", count));
|
||||||
if (selection == null) {
|
|
||||||
final int cx = loc.getBlockX() >> 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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, RelightMode.ALL);
|
|
||||||
player.print(Caption.of("fawe.info.lighting.propagate.selection", count));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Command(
|
// @Command(
|
||||||
@ -184,18 +174,9 @@ public class RegionCommands {
|
|||||||
desc = "Removing lighting in a selection"
|
desc = "Removing lighting in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.remove")
|
@CommandPermissions("worldedit.light.remove")
|
||||||
public void removeLighting(Player player) {
|
public void removeLighting(Actor actor, LocalSession session, @Selection Region selection) {
|
||||||
Region selection = player.getSelection();
|
int count = FaweAPI.fixLighting(session.getSelectionWorld(), selection, null, RelightMode.NONE);
|
||||||
if (selection == null) {
|
actor.print(Caption.of("fawe.info.updated.lighting.selection", count));
|
||||||
final int cx = player.getLocation().getBlockX() >> 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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, RelightMode.NONE);
|
|
||||||
player.print(Caption.of("fawe.info.updated.lighting.selection", count));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -224,8 +205,8 @@ public class RegionCommands {
|
|||||||
desc = "Set block lighting in a selection"
|
desc = "Set block lighting in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.set")
|
@CommandPermissions("worldedit.light.set")
|
||||||
public void setlighting(Player player, EditSession editSession, @Selection Region region) {
|
public void setlighting(Actor actor, EditSession editSession, @Selection Region region) {
|
||||||
player.print(Caption.of("fawe.info.temporarily-not-working"));
|
actor.print(Caption.of("fawe.info.temporarily-not-working"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -233,8 +214,8 @@ public class RegionCommands {
|
|||||||
desc = "Set sky lighting in a selection"
|
desc = "Set sky lighting in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.set")
|
@CommandPermissions("worldedit.light.set")
|
||||||
public void setskylighting(Player player, @Selection Region region) {
|
public void setskylighting(Actor actor, @Selection Region region) {
|
||||||
player.print(Caption.of("fawe.info.temporarily-not-working"));
|
actor.print(Caption.of("fawe.info.temporarily-not-working"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -355,7 +336,7 @@ public class RegionCommands {
|
|||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void lay(
|
public void lay(
|
||||||
Player player,
|
Actor actor,
|
||||||
EditSession editSession,
|
EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg
|
@Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg
|
||||||
@ -380,7 +361,7 @@ public class RegionCommands {
|
|||||||
editSession.setBlock(x, y, z, patternArg);
|
editSession.setBlock(x, y, z, patternArg);
|
||||||
affected++;
|
affected++;
|
||||||
}
|
}
|
||||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -619,7 +600,7 @@ public class RegionCommands {
|
|||||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public void fall(
|
public void fall(
|
||||||
Player player, EditSession editSession, LocalSession session,
|
Actor actor, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "BlockStateHolder", def = "air")
|
@Arg(desc = "BlockStateHolder", def = "air")
|
||||||
BlockStateHolder replace,
|
BlockStateHolder replace,
|
||||||
@ -627,7 +608,7 @@ public class RegionCommands {
|
|||||||
boolean notFullHeight
|
boolean notFullHeight
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
int affected = editSession.fall(region, !notFullHeight, replace);
|
int affected = editSession.fall(region, !notFullHeight, replace);
|
||||||
player.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", affected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -148,7 +148,7 @@ public class SchematicCommands {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.web", "worldedit.schematic.load.asset"})
|
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.web", "worldedit.schematic.load.asset"})
|
||||||
public void loadall(
|
public void loadall(
|
||||||
Player player, LocalSession session,
|
Actor actor, LocalSession session,
|
||||||
@Arg(desc = "Format name.", def = "fast")
|
@Arg(desc = "Format name.", def = "fast")
|
||||||
String formatName,
|
String formatName,
|
||||||
@Arg(desc = "File name.")
|
@Arg(desc = "File name.")
|
||||||
@ -160,18 +160,18 @@ public class SchematicCommands {
|
|||||||
) throws FilenameException {
|
) throws FilenameException {
|
||||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
actor.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format", formatName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true);
|
MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(actor, filename, null, true);
|
||||||
if (all != null) {
|
if (all != null) {
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
session.setClipboard(all);
|
session.setClipboard(all);
|
||||||
} else {
|
} else {
|
||||||
session.addClipboard(all);
|
session.addClipboard(all);
|
||||||
}
|
}
|
||||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.loaded", filename));
|
actor.print(Caption.of("fawe.worldedit.schematic.schematic.loaded", filename));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -183,9 +183,9 @@ public class SchematicCommands {
|
|||||||
desc = "Clear your clipboard"
|
desc = "Clear your clipboard"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||||
public void clear(Player player, LocalSession session) throws WorldEditException {
|
public void clear(Actor actor, LocalSession session) throws WorldEditException {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.cleared"));
|
actor.print(Caption.of("fawe.worldedit.clipboard.clipboard.cleared"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -194,7 +194,7 @@ public class SchematicCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||||
public void unload(
|
public void unload(
|
||||||
Player player, LocalSession session,
|
Actor actor, LocalSession session,
|
||||||
@Arg(desc = "File name, requires extension.")
|
@Arg(desc = "File name, requires extension.")
|
||||||
String fileName
|
String fileName
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
@ -204,7 +204,7 @@ public class SchematicCommands {
|
|||||||
} else {
|
} else {
|
||||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||||
File working = this.worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
File working = this.worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||||
File root = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
File root = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working;
|
||||||
uri = new File(root, fileName).toURI();
|
uri = new File(root, fileName).toURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,11 +221,11 @@ public class SchematicCommands {
|
|||||||
} else {
|
} else {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
}
|
}
|
||||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.cleared"));
|
actor.print(Caption.of("fawe.worldedit.clipboard.clipboard.cleared"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found", fileName));
|
actor.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found", fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
@ -235,42 +235,42 @@ public class SchematicCommands {
|
|||||||
desc = "Move your loaded schematic"
|
desc = "Move your loaded schematic"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||||
public void move(Player player, LocalSession session, @Arg(desc = "Directory.") String directory) throws WorldEditException,
|
public void move(Actor actor, LocalSession session, @Arg(desc = "Directory.") String directory) throws WorldEditException,
|
||||||
IOException {
|
IOException {
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
File working = worldEdit.getWorkingDirectoryPath(config.saveDir).toFile();
|
||||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, actor.getUniqueId().toString()) : working;
|
||||||
File destDir = new File(dir, directory);
|
File destDir = new File(dir, directory);
|
||||||
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
||||||
player.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir))));
|
actor.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission(
|
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !actor.hasPermission(
|
||||||
"worldedit.schematic.move.other")) {
|
"worldedit.schematic.move.other")) {
|
||||||
player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other"));
|
actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ClipboardHolder clipboard = session.getClipboard();
|
ClipboardHolder clipboard = session.getClipboard();
|
||||||
List<File> sources = getFiles(clipboard);
|
List<File> sources = getFiles(clipboard);
|
||||||
if (sources.isEmpty()) {
|
if (sources.isEmpty()) {
|
||||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
|
actor.print(Caption.of("fawe.worldedit.schematic.schematic.none"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!destDir.exists() && !destDir.mkdirs()) {
|
if (!destDir.exists() && !destDir.mkdirs()) {
|
||||||
player.print(Caption.of("worldedit.schematic.file-perm-fail", TextComponent.of(String.valueOf(destDir))));
|
actor.print(Caption.of("worldedit.schematic.file-perm-fail", TextComponent.of(String.valueOf(destDir))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (File source : sources) {
|
for (File source : sources) {
|
||||||
File destFile = new File(destDir, source.getName());
|
File destFile = new File(destDir, source.getName());
|
||||||
if (destFile.exists()) {
|
if (destFile.exists()) {
|
||||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile));
|
actor.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists", destFile));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(
|
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(
|
||||||
dir,
|
dir,
|
||||||
destFile
|
destFile
|
||||||
) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
) || !MainUtil.isInSubDirectory(dir, source)) && !actor.hasPermission("worldedit.schematic.delete.other")) {
|
||||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
|
actor.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
|
||||||
Caption.of("fawe.error.no-perm", ("worldedit.schematic.move.other"))
|
Caption.of("fawe.error.no-perm", ("worldedit.schematic.move.other"))
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
@ -281,7 +281,7 @@ public class SchematicCommands {
|
|||||||
if (cached.exists()) {
|
if (cached.exists()) {
|
||||||
Files.move(cached.toPath(), destFile.toPath());
|
Files.move(cached.toPath(), destFile.toPath());
|
||||||
}
|
}
|
||||||
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success", source, destFile));
|
actor.print(Caption.of("fawe.worldedit.schematic.schematic.move.success", source, destFile));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class UtilityCommands {
|
|||||||
desc = "Generate or run a macro"
|
desc = "Generate or run a macro"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.macro")
|
@CommandPermissions("worldedit.macro")
|
||||||
public void macro(Player player, LocalSession session, String name, String argument) throws IOException {
|
public void macro(Actor actor, LocalSession session, String name, String argument) throws IOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,11 +130,11 @@ public class UtilityCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("fawe.admin")
|
@CommandPermissions("fawe.admin")
|
||||||
public void heightmapInterface(
|
public void heightmapInterface(
|
||||||
Player player,
|
Actor actor,
|
||||||
@Arg(name = "min", desc = "int", def = "100") int min,
|
@Arg(name = "min", desc = "int", def = "100") int min,
|
||||||
@Arg(name = "max", desc = "int", def = "200") int max
|
@Arg(name = "max", desc = "int", def = "200") int max
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
player.print(TextComponent.of("Please wait while we generate the minified heightmaps."));
|
actor.print(TextComponent.of("Please wait while we generate the minified heightmaps."));
|
||||||
File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP);
|
File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP);
|
||||||
|
|
||||||
File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap");
|
File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap");
|
||||||
@ -170,7 +170,7 @@ public class UtilityCommands {
|
|||||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
player.print(TextComponent.of(String.format("Writing %s", name)));
|
actor.print(TextComponent.of(String.format("Writing %s", name)));
|
||||||
File minFile = new File(minImages, name);
|
File minFile = new File(minImages, name);
|
||||||
File maxFile = new File(maxImages, name);
|
File maxFile = new File(maxImages, name);
|
||||||
minFile.getParentFile().mkdirs();
|
minFile.getParentFile().mkdirs();
|
||||||
@ -195,9 +195,9 @@ public class UtilityCommands {
|
|||||||
config.append("// The local source for the image (used in commands)\n");
|
config.append("// The local source for the image (used in commands)\n");
|
||||||
config.append("var src_local = \"file://\";\n");
|
config.append("var src_local = \"file://\";\n");
|
||||||
File configFile = new File(webSrc, "config.js");
|
File configFile = new File(webSrc, "config.js");
|
||||||
player.print(TextComponent.of(String.format("Writing %s", configFile)));
|
actor.print(TextComponent.of(String.format("Writing %s", configFile)));
|
||||||
Files.write(configFile.toPath(), config.toString().getBytes());
|
Files.write(configFile.toPath(), config.toString().getBytes());
|
||||||
player.print(TextComponent.of("Done! See: `FastAsyncWorldEdit/web/heightmap`"));
|
actor.print(TextComponent.of("Done! See: `FastAsyncWorldEdit/web/heightmap`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -206,9 +206,9 @@ public class UtilityCommands {
|
|||||||
desc = "Cancel your current command"
|
desc = "Cancel your current command"
|
||||||
)
|
)
|
||||||
@CommandPermissions(value = "fawe.cancel", queued = false)
|
@CommandPermissions(value = "fawe.cancel", queued = false)
|
||||||
public void cancel(Player player) {
|
public void cancel(Actor actor) {
|
||||||
int cancelled = player.cancel(false);
|
int cancelled = actor.cancel(false);
|
||||||
player.print(Caption.of("fawe.cancel.worldedit.cancel.count", cancelled));
|
actor.print(Caption.of("fawe.cancel.worldedit.cancel.count", cancelled));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -825,9 +825,9 @@ public class UtilityCommands {
|
|||||||
desc = "Confirm a command"
|
desc = "Confirm a command"
|
||||||
)
|
)
|
||||||
@CommandPermissions(value = "fawe.confirm", queued = false)
|
@CommandPermissions(value = "fawe.confirm", queued = false)
|
||||||
public void confirm(Player player) throws WorldEditException {
|
public void confirm(Actor actor) throws WorldEditException {
|
||||||
if (!player.confirm()) {
|
if (!actor.confirm()) {
|
||||||
player.print(Caption.of("fawe.worldedit.utility.nothing.confirmed"));
|
actor.print(Caption.of("fawe.worldedit.utility.nothing.confirmed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user