geforkt von Mirrors/FastAsyncWorldEdit
Remove FAWE-Piston
Disables a lot of previous functionality in FAWE until replacements can be made. This commit was untested and may cause major issues.
Dieser Commit ist enthalten in:
Ursprung
3452fd5a63
Commit
75653087b9
@ -8,18 +8,6 @@ plugins {
|
|||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
// maven {
|
|
||||||
// name = "Forge Maven"
|
|
||||||
// url = uri("https://files.minecraftforge.net/maven")
|
|
||||||
// }
|
|
||||||
// maven {
|
|
||||||
// name = "Fabric"
|
|
||||||
// url = uri("https://maven.fabricmc.net/")
|
|
||||||
// }
|
|
||||||
// maven {
|
|
||||||
// name = "sponge"
|
|
||||||
// url = uri("https://repo.spongepowered.org/maven")
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
@ -43,15 +31,10 @@ val mixinVersion: String = properties.getProperty("mixin.version")
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(gradleApi())
|
implementation(gradleApi())
|
||||||
// implementation("gradle.plugin.net.minecrell:licenser:0.4.1")
|
|
||||||
implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1")
|
implementation("org.ajoberstar.grgit:grgit-gradle:3.1.1")
|
||||||
implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0")
|
implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0")
|
||||||
implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21")
|
implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21")
|
||||||
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
|
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
|
||||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
|
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
|
||||||
// implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0")
|
|
||||||
// implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
|
|
||||||
// implementation("net.fabricmc:fabric-loom:$loomVersion")
|
|
||||||
// implementation("net.fabricmc:sponge-mixin:$mixinVersion")
|
|
||||||
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
|
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ fun Project.applyCommonConfiguration() {
|
|||||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
||||||
maven { url = uri("http://empcraft.com/maven2") }
|
maven { url = uri("http://empcraft.com/maven2") }
|
||||||
maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") }
|
maven { url = uri("https://repo.destroystokyo.com/repository/maven-public") }
|
||||||
maven { url = uri("https://ci.athion.net/job/FAWE-Piston/ws/") }
|
|
||||||
ivy { url = uri("https://ci.athion.net/job")
|
ivy { url = uri("https://ci.athion.net/job")
|
||||||
patternLayout {
|
patternLayout {
|
||||||
artifact("/[organisation]/[revision]/artifact/[module].[ext]")
|
artifact("/[organisation]/[revision]/artifact/[module].[ext]")
|
||||||
|
@ -3,7 +3,7 @@ import org.gradle.api.Project
|
|||||||
object Versions {
|
object Versions {
|
||||||
const val TEXT = "3.0.1"
|
const val TEXT = "3.0.1"
|
||||||
const val TEXT_EXTRAS = "3.0.2"
|
const val TEXT_EXTRAS = "3.0.2"
|
||||||
const val PISTON = "0.5.3-SNAPSHOT"
|
const val PISTON = "0.5.2"
|
||||||
const val AUTO_VALUE = "1.6.5"
|
const val AUTO_VALUE = "1.6.5"
|
||||||
const val JUNIT = "5.5.0"
|
const val JUNIT = "5.5.0"
|
||||||
const val MOCKITO = "3.0.0"
|
const val MOCKITO = "3.0.0"
|
||||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.bukkit.listener;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||||
import com.boydti.fawe.command.CFICommands;
|
|
||||||
import com.boydti.fawe.object.brush.BrushSettings;
|
import com.boydti.fawe.object.brush.BrushSettings;
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
@ -57,31 +56,32 @@ public class BukkitImageListener implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
//TODO Fix along with CFI code 2020-02-04
|
||||||
public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
// @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
Set<Player> recipients = event.getRecipients();
|
// public void onPlayerInteractEntity(AsyncPlayerChatEvent event) {
|
||||||
Iterator<Player> iter = recipients.iterator();
|
// Set<Player> recipients = event.getRecipients();
|
||||||
while (iter.hasNext()) {
|
// Iterator<Player> iter = recipients.iterator();
|
||||||
Player player = iter.next();
|
// while (iter.hasNext()) {
|
||||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
// Player player = iter.next();
|
||||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
continue;
|
// if (player.equals(event.getPlayer()) || !bukkitPlayer.hasMeta() || settings == null || !settings.hasGenerator()) {
|
||||||
}
|
// continue;
|
||||||
|
// }
|
||||||
String name = player.getName().toLowerCase();
|
//
|
||||||
if (!event.getMessage().toLowerCase().contains(name)) {
|
// String name = player.getName().toLowerCase();
|
||||||
ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
// if (!event.getMessage().toLowerCase().contains(name)) {
|
||||||
if (buffered == null) {
|
// ArrayDeque<String> buffered = bukkitPlayer.getMeta("CFIBufferedMessages");
|
||||||
bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
// if (buffered == null) {
|
||||||
}
|
// bukkitPlayer.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||||
String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
// }
|
||||||
event.getMessage());
|
// String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(),
|
||||||
buffered.add(full);
|
// event.getMessage());
|
||||||
iter.remove();
|
// buffered.add(full);
|
||||||
}
|
// iter.remove();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
public void onHangingBreakByEntity(HangingBreakByEntityEvent event) {
|
||||||
@ -184,126 +184,127 @@ public class BukkitImageListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleInteract(Event event, Player player, Entity entity, boolean primary) {
|
private void handleInteract(Event event, Player player, Entity entity, boolean primary) {
|
||||||
if (!(entity instanceof ItemFrame)) {
|
//todo fix with cfi code 2020-02-04
|
||||||
return;
|
// if (!(entity instanceof ItemFrame)) {
|
||||||
}
|
// return;
|
||||||
ItemFrame itemFrame = (ItemFrame) entity;
|
// }
|
||||||
|
// ItemFrame itemFrame = (ItemFrame) entity;
|
||||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
//
|
||||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
// BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
BukkitImageViewer viewer = get(generator);
|
// HeightMapMCAGenerator generator = settings == null ? null : settings.getGenerator();
|
||||||
if (viewer == null) {
|
// BukkitImageViewer viewer = get(generator);
|
||||||
return;
|
// if (viewer == null) {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
if (itemFrame.getRotation() != Rotation.NONE) {
|
//
|
||||||
itemFrame.setRotation(Rotation.NONE);
|
// if (itemFrame.getRotation() != Rotation.NONE) {
|
||||||
}
|
// itemFrame.setRotation(Rotation.NONE);
|
||||||
|
// }
|
||||||
LocalSession session = bukkitPlayer.getSession();
|
//
|
||||||
BrushTool tool;
|
// LocalSession session = bukkitPlayer.getSession();
|
||||||
try {
|
// BrushTool tool;
|
||||||
tool = session.getBrushTool(bukkitPlayer, false);
|
// try {
|
||||||
} catch (InvalidToolBindException e) {
|
// tool = session.getBrushTool(bukkitPlayer, false);
|
||||||
return;
|
// } catch (InvalidToolBindException e) {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
ItemFrame[][] frames = viewer.getItemFrames();
|
//
|
||||||
if (frames == null || tool == null) {
|
// ItemFrame[][] frames = viewer.getItemFrames();
|
||||||
viewer.selectFrame(itemFrame);
|
// if (frames == null || tool == null) {
|
||||||
player.updateInventory();
|
// viewer.selectFrame(itemFrame);
|
||||||
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
// player.updateInventory();
|
||||||
return;
|
// TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
//
|
||||||
Brush brush = context.getBrush();
|
// BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
|
||||||
if (brush == null) {
|
// Brush brush = context.getBrush();
|
||||||
return;
|
// if (brush == null) {
|
||||||
}
|
// return;
|
||||||
tool.setContext(context);
|
// }
|
||||||
|
// tool.setContext(context);
|
||||||
if (event instanceof Cancellable) {
|
//
|
||||||
((Cancellable) event).setCancelled(true);
|
// if (event instanceof Cancellable) {
|
||||||
}
|
// ((Cancellable) event).setCancelled(true);
|
||||||
|
// }
|
||||||
Location target = itemFrame.getLocation();
|
//
|
||||||
Location source = player.getLocation();
|
// Location target = itemFrame.getLocation();
|
||||||
|
// Location source = player.getLocation();
|
||||||
double yawRad = Math.toRadians(source.getYaw() + 90d);
|
//
|
||||||
double pitchRad = Math.toRadians(-source.getPitch());
|
// double yawRad = Math.toRadians(source.getYaw() + 90d);
|
||||||
|
// double pitchRad = Math.toRadians(-source.getPitch());
|
||||||
double a = Math.cos(pitchRad);
|
//
|
||||||
double xRat = Math.cos(yawRad) * a;
|
// double a = Math.cos(pitchRad);
|
||||||
double zRat = Math.sin(yawRad) * a;
|
// double xRat = Math.cos(yawRad) * a;
|
||||||
|
// double zRat = Math.sin(yawRad) * a;
|
||||||
BlockFace facing = itemFrame.getFacing();
|
//
|
||||||
double thickness = 1 / 32D + 1 / 128D;
|
// BlockFace facing = itemFrame.getFacing();
|
||||||
double modX = facing.getModX();
|
// double thickness = 1 / 32D + 1 / 128D;
|
||||||
double modZ = facing.getModZ();
|
// double modX = facing.getModX();
|
||||||
double dx = source.getX() - target.getX() - modX * thickness;
|
// double modZ = facing.getModZ();
|
||||||
double dy = source.getY() + player.getEyeHeight() - target.getY();
|
// double dx = source.getX() - target.getX() - modX * thickness;
|
||||||
double dz = source.getZ() - target.getZ() - modZ * thickness;
|
// double dy = source.getY() + player.getEyeHeight() - target.getY();
|
||||||
|
// double dz = source.getZ() - target.getZ() - modZ * thickness;
|
||||||
double offset;
|
//
|
||||||
double localX;
|
// double offset;
|
||||||
if (modX != 0) {
|
// double localX;
|
||||||
offset = dx / xRat;
|
// if (modX != 0) {
|
||||||
localX = (-modX) * (dz - offset * zRat);
|
// offset = dx / xRat;
|
||||||
} else {
|
// localX = (-modX) * (dz - offset * zRat);
|
||||||
offset = dz / zRat;
|
// } else {
|
||||||
localX = (modZ) * (dx - offset * xRat);
|
// offset = dz / zRat;
|
||||||
}
|
// localX = (modZ) * (dx - offset * xRat);
|
||||||
double localY = dy - offset * Math.sin(pitchRad);
|
// }
|
||||||
int localPixelX = (int) ((localX + 0.5) * 128);
|
// double localY = dy - offset * Math.sin(pitchRad);
|
||||||
int localPixelY = (int) ((localY + 0.5) * 128);
|
// int localPixelX = (int) ((localX + 0.5) * 128);
|
||||||
|
// int localPixelY = (int) ((localY + 0.5) * 128);
|
||||||
UUID uuid = itemFrame.getUniqueId();
|
//
|
||||||
for (int blockX = 0; blockX < frames.length; blockX++) {
|
// UUID uuid = itemFrame.getUniqueId();
|
||||||
for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
// for (int blockX = 0; blockX < frames.length; blockX++) {
|
||||||
if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
// for (int blockY = 0; blockY < frames[0].length; blockY++) {
|
||||||
int pixelX = localPixelX + blockX * 128;
|
// if (uuid.equals(frames[blockX][blockY].getUniqueId())) {
|
||||||
int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
// int pixelX = localPixelX + blockX * 128;
|
||||||
|
// int pixelY = (128 * frames[0].length) - (localPixelY + blockY * 128 + 1);
|
||||||
int width = generator.getWidth();
|
//
|
||||||
int length = generator.getLength();
|
// int width = generator.getWidth();
|
||||||
int worldX = (int) (pixelX * width / (frames.length * 128d));
|
// int length = generator.getLength();
|
||||||
int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
// int worldX = (int) (pixelX * width / (frames.length * 128d));
|
||||||
|
// int worldZ = (int) (pixelY * length / (frames[0].length * 128d));
|
||||||
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
//
|
||||||
return;
|
// if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
bukkitPlayer.runAction(() -> {
|
//
|
||||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
// bukkitPlayer.runAction(() -> {
|
||||||
viewer.refresh();
|
// BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||||
int topY = generator
|
// viewer.refresh();
|
||||||
.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
// int topY = generator
|
||||||
0, 255);
|
// .getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255,
|
||||||
wPos = wPos.withY(topY);
|
// 0, 255);
|
||||||
|
// wPos = wPos.withY(topY);
|
||||||
EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
//
|
||||||
.combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
// EditSession es = new EditSessionBuilder(bukkitPlayer.getWorld()).player(bukkitPlayer)
|
||||||
.build();
|
// .combineStages(false).autoQueue(false).blockBag(null).limitUnlimited()
|
||||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
// .build();
|
||||||
Extent extent = last.get();
|
// ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||||
if (extent instanceof IQueueExtent) {
|
// Extent extent = last.get();
|
||||||
last = last.previous();
|
// if (extent instanceof IQueueExtent) {
|
||||||
}
|
// last = last.previous();
|
||||||
last.setNext(generator);
|
// }
|
||||||
try {
|
// last.setNext(generator);
|
||||||
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
// try {
|
||||||
} catch (WorldEditException e) {
|
// brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||||
e.printStackTrace();
|
// } catch (WorldEditException e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
es.flushQueue();
|
// }
|
||||||
viewer.view(generator);
|
// es.flushQueue();
|
||||||
}, true, true);
|
// viewer.view(generator);
|
||||||
|
// }, true, true);
|
||||||
return;
|
//
|
||||||
}
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe.bukkit.listener;
|
package com.boydti.fawe.bukkit.listener;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.command.CFICommands;
|
|
||||||
import com.boydti.fawe.object.RunnableVal3;
|
import com.boydti.fawe.object.RunnableVal3;
|
||||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
@ -262,10 +261,10 @@ public class CFIPacketListener implements Listener {
|
|||||||
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
BukkitPlayer bukkitPlayer = BukkitAdapter.adapt(player);
|
||||||
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
VirtualWorld vw = bukkitPlayer.getSession().getVirtualWorld();
|
||||||
if (vw != null) return vw;
|
if (vw != null) return vw;
|
||||||
CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
// CFICommands.CFISettings settings = bukkitPlayer.getMeta("CFISettings");
|
||||||
if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
// if (settings != null && settings.hasGenerator() && settings.getGenerator().hasPacketViewer()) {
|
||||||
return settings.getGenerator();
|
// return settings.getGenerator();
|
||||||
}
|
// }
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import com.boydti.fawe.util.TextureUtil;
|
|||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.github.luben.zstd.util.Native;
|
import com.github.luben.zstd.util.Native;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
import com.sk89q.worldedit.session.request.Request;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -92,7 +91,8 @@ public class Fawe {
|
|||||||
private FaweVersion version;
|
private FaweVersion version;
|
||||||
private VisualQueue visualQueue;
|
private VisualQueue visualQueue;
|
||||||
private TextureUtil textures;
|
private TextureUtil textures;
|
||||||
private DefaultTransformParser transformParser;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
// private DefaultTransformParser transformParser;
|
||||||
|
|
||||||
private QueueHandler queueHandler;
|
private QueueHandler queueHandler;
|
||||||
|
|
||||||
@ -184,7 +184,8 @@ public class Fawe {
|
|||||||
// Delayed worldedit setup
|
// Delayed worldedit setup
|
||||||
TaskManager.IMP.later(() -> {
|
TaskManager.IMP.later(() -> {
|
||||||
try {
|
try {
|
||||||
transformParser = new DefaultTransformParser(getWorldEdit());
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
// transformParser = new DefaultTransformParser(getWorldEdit());
|
||||||
visualQueue = new VisualQueue(3);
|
visualQueue = new VisualQueue(3);
|
||||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||||
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
||||||
@ -209,9 +210,10 @@ public class Fawe {
|
|||||||
return queueHandler;
|
return queueHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultTransformParser getTransformParser() {
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
return transformParser;
|
// public DefaultTransformParser getTransformParser() {
|
||||||
}
|
// return transformParser;
|
||||||
|
// }
|
||||||
|
|
||||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||||
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
||||||
|
@ -1,88 +1,89 @@
|
|||||||
package com.boydti.fawe.command;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.boydti.fawe.command;
|
||||||
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
//
|
||||||
|
//import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
||||||
import com.boydti.fawe.command.CFICommands.CFISettings;
|
//
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
//import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
//import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
//import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
//import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
//import com.sk89q.worldedit.entity.Player;
|
||||||
import java.io.IOException;
|
//import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import java.util.ArrayList;
|
//import java.io.IOException;
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
import org.enginehub.piston.CommandManager;
|
//import java.util.List;
|
||||||
import org.enginehub.piston.exception.StopExecutionException;
|
//import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
//import org.enginehub.piston.exception.StopExecutionException;
|
||||||
import org.enginehub.piston.inject.Key;
|
//import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
|
//import org.enginehub.piston.inject.Key;
|
||||||
public class CFICommand extends CommandProcessor<Object, Object> {
|
//
|
||||||
|
//public class CFICommand extends CommandProcessor<Object, Object> {
|
||||||
public CFICommand(CommandManager manager) {
|
//
|
||||||
super(manager);
|
// public CFICommand(CommandManager manager) {
|
||||||
}
|
// super(manager);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public List<String> preprocess(InjectedValueAccess context, List<String> args) {
|
// @Override
|
||||||
Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
// public List<String> preprocess(InjectedValueAccess context, List<String> args) {
|
||||||
CFICommands.CFISettings settings = CFICommands.getSettings(player);
|
// Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||||
settings.popMessages(player);
|
// CFICommands.CFISettings settings = CFICommands.getSettings(player);
|
||||||
args = dispatch(player, settings, args, context);
|
// settings.popMessages(player);
|
||||||
HeightMapMCAGenerator gen = settings.getGenerator();
|
// args = dispatch(player, settings, args, context);
|
||||||
if (gen != null && gen.isModified()) {
|
// HeightMapMCAGenerator gen = settings.getGenerator();
|
||||||
try {
|
// if (gen != null && gen.isModified()) {
|
||||||
gen.update();
|
// try {
|
||||||
CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId());
|
// gen.update();
|
||||||
LocalSession session = player.getSession();
|
// CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId());
|
||||||
session.remember(player, gen, set, player.getLimit());
|
// LocalSession session = player.getSession();
|
||||||
} catch (IOException e) {
|
// session.remember(player, gen, set, player.getLimit());
|
||||||
throw new StopExecutionException(TextComponent.of(e.getMessage()));
|
// } catch (IOException e) {
|
||||||
}
|
// throw new StopExecutionException(TextComponent.of(e.getMessage()));
|
||||||
}
|
// }
|
||||||
return args;
|
// }
|
||||||
}
|
// return args;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public Object process(InjectedValueAccess context, List<String> args, Object result) {
|
// @Override
|
||||||
return result;
|
// public Object process(InjectedValueAccess context, List<String> args, Object result) {
|
||||||
}
|
// return result;
|
||||||
|
// }
|
||||||
private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {
|
//
|
||||||
if (!settings.hasGenerator()) {
|
// private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {
|
||||||
if (args.size() == 0) {
|
// if (!settings.hasGenerator()) {
|
||||||
String hmCmd = "/cfi ";
|
// if (args.size() == 0) {
|
||||||
if (settings.image == null) {
|
// String hmCmd = "/cfi ";
|
||||||
hmCmd += "image";
|
// if (settings.image == null) {
|
||||||
} else {
|
// hmCmd += "image";
|
||||||
hmCmd = "heightmap" + " " + settings.imageArg;
|
// } else {
|
||||||
}
|
// hmCmd = "heightmap" + " " + settings.imageArg;
|
||||||
TextComponent build = TextComponent.builder("What do you want to use as the base?")
|
// }
|
||||||
.append(newline())
|
// TextComponent build = TextComponent.builder("What do you want to use as the base?")
|
||||||
.append("[HeightMap]")/* TODO .cmdTip(hmCmd).*/.append(" - A heightmap like ")
|
// .append(newline())
|
||||||
.append("[this]")//TODO .linkTip("http://i.imgur.com/qCd30MR.jpg")
|
// .append("[HeightMap]")/* TODO .cmdTip(hmCmd).*/.append(" - A heightmap like ")
|
||||||
.append(newline())
|
// .append("[this]")//TODO .linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||||
.append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
|
// .append(newline())
|
||||||
.append("- An empty map of a specific size").build();
|
// .append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
|
||||||
player.print(build);
|
// .append("- An empty map of a specific size").build();
|
||||||
} else {
|
// player.print(build);
|
||||||
args = new ArrayList<>(args);
|
// } else {
|
||||||
switch (args.size()) {
|
// args = new ArrayList<>(args);
|
||||||
case 1:
|
// switch (args.size()) {
|
||||||
args.add(0, "heightmap");
|
// case 1:
|
||||||
break;
|
// args.add(0, "heightmap");
|
||||||
case 2:
|
// break;
|
||||||
args.add(0, "empty");
|
// case 2:
|
||||||
break;
|
// args.add(0, "empty");
|
||||||
}
|
// break;
|
||||||
return args;
|
// }
|
||||||
}
|
// return args;
|
||||||
} else {
|
// }
|
||||||
if (args.isEmpty()) {
|
// } else {
|
||||||
settings.setCategory(null);
|
// if (args.isEmpty()) {
|
||||||
CFICommands.mainMenu(player);
|
// settings.setCategory(null);
|
||||||
return null;
|
// CFICommands.mainMenu(player);
|
||||||
}
|
// return null;
|
||||||
}
|
// }
|
||||||
return args;
|
// }
|
||||||
}
|
// return args;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,93 +0,0 @@
|
|||||||
package com.boydti.fawe.command;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import org.enginehub.piston.Command;
|
|
||||||
import org.enginehub.piston.CommandManager;
|
|
||||||
import org.enginehub.piston.CommandParseResult;
|
|
||||||
import org.enginehub.piston.converter.ArgumentConverter;
|
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
|
||||||
import org.enginehub.piston.inject.Key;
|
|
||||||
import org.enginehub.piston.suggestion.Suggestion;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public abstract class CommandProcessor<I, O> implements CommandManager {
|
|
||||||
private final CommandManager parent;
|
|
||||||
|
|
||||||
public CommandProcessor(CommandManager parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Command.Builder newCommand(String s) {
|
|
||||||
return parent.newCommand(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void register(Command command) {
|
|
||||||
parent.register(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void register(String name, Consumer<Command.Builder> registrationProcess) {
|
|
||||||
parent.register(name, registrationProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void registerManager(CommandManager manager) {
|
|
||||||
parent.registerManager(manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Stream<Command> getAllCommands() {
|
|
||||||
return parent.getAllCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final boolean containsCommand(String name) {
|
|
||||||
return parent.containsCommand(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Optional<Command> getCommand(String s) {
|
|
||||||
return parent.getCommand(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final ImmutableSet<Suggestion> getSuggestions(InjectedValueAccess injectedValueAccess, List<String> list) {
|
|
||||||
return parent.getSuggestions(injectedValueAccess, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final CommandParseResult parse(InjectedValueAccess injectedValueAccess, List<String> list) {
|
|
||||||
return parent.parse(injectedValueAccess, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Object execute(InjectedValueAccess context, List<String> args) {
|
|
||||||
args = preprocess(context, args);
|
|
||||||
if (args != null) {
|
|
||||||
Object result = parent.execute(context, args);
|
|
||||||
return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston)
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final <T> void registerConverter(Key<T> key, ArgumentConverter<T> argumentConverter) {
|
|
||||||
parent.registerConverter(key, argumentConverter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final <T> Optional<ArgumentConverter<T>> getConverter(Key<T> key) {
|
|
||||||
return parent.getConverter(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract List<String> preprocess(InjectedValueAccess context, List<String> args);
|
|
||||||
|
|
||||||
public abstract Object process(InjectedValueAccess context, List<String> args, Object result);
|
|
||||||
}
|
|
@ -1,113 +1,114 @@
|
|||||||
package com.boydti.fawe.command;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.boydti.fawe.command;
|
||||||
import com.boydti.fawe.util.StringMan;
|
//
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
//import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
//import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
//import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
//import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
|
//import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
import java.util.*;
|
//
|
||||||
|
//import java.util.*;
|
||||||
public abstract class FaweParser<T> extends InputParser<T> {
|
//
|
||||||
|
//public abstract class FaweParser<T> extends InputParser<T> {
|
||||||
private final String prefix;
|
//
|
||||||
|
// private final String prefix;
|
||||||
protected FaweParser(WorldEdit worldEdit, String prefix) {
|
//
|
||||||
super(worldEdit);
|
// protected FaweParser(WorldEdit worldEdit, String prefix) {
|
||||||
this.prefix = prefix;
|
// super(worldEdit);
|
||||||
}
|
// this.prefix = prefix;
|
||||||
|
// }
|
||||||
public PlatformCommandManager getPlatform() {
|
//
|
||||||
return PlatformCommandManager.getInstance();
|
// public PlatformCommandManager getPlatform() {
|
||||||
}
|
// return PlatformCommandManager.getInstance();
|
||||||
|
// }
|
||||||
public T parse(String input, ParserContext context) {
|
//
|
||||||
input = prefix + " " + input;
|
// public T parse(String input, ParserContext context) {
|
||||||
InjectedValueAccess injected = context.getInjected();
|
// input = prefix + " " + input;
|
||||||
if (injected != null) {
|
// InjectedValueAccess injected = context.getInjected();
|
||||||
return getPlatform().parseCommand(input, injected);
|
// if (injected != null) {
|
||||||
} else {
|
// return getPlatform().parseCommand(input, injected);
|
||||||
return getPlatform().parseCommand(input, context.getActor());
|
// } else {
|
||||||
}
|
// return getPlatform().parseCommand(input, context.getActor());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
public T catchSuggestion(String currentInput, String nextInput, ParserContext context) throws InputParseException {
|
//
|
||||||
try {
|
// public T catchSuggestion(String currentInput, String nextInput, ParserContext context) throws InputParseException {
|
||||||
return parseFromInput(nextInput, context);
|
// try {
|
||||||
} catch (SuggestInputParseException e) {
|
// return parseFromInput(nextInput, context);
|
||||||
e.prepend(currentInput.substring(0, currentInput.length() - nextInput.length()));
|
// } catch (SuggestInputParseException e) {
|
||||||
throw e;
|
// e.prepend(currentInput.substring(0, currentInput.length() - nextInput.length()));
|
||||||
}
|
// throw e;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
protected static class ParseEntry {
|
//
|
||||||
public boolean and;
|
// protected static class ParseEntry {
|
||||||
public String input;
|
// public boolean and;
|
||||||
public String full;
|
// public String input;
|
||||||
|
// public String full;
|
||||||
public ParseEntry(String full, String input, boolean type) {
|
//
|
||||||
this.full = full;
|
// public ParseEntry(String full, String input, boolean type) {
|
||||||
this.input = input;
|
// this.full = full;
|
||||||
this.and = type;
|
// this.input = input;
|
||||||
}
|
// this.and = type;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public String toString() {
|
// @Override
|
||||||
return input + " | " + and;
|
// public String toString() {
|
||||||
}
|
// return input + " | " + and;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
public static List<Map.Entry<ParseEntry, List<String>>> parse(String toParse) throws InputParseException {
|
//
|
||||||
List<Map.Entry<ParseEntry, List<String>>> keys = new ArrayList<>();
|
// public static List<Map.Entry<ParseEntry, List<String>>> parse(String toParse) throws InputParseException {
|
||||||
List<String> inputs = new ArrayList<>();
|
// List<Map.Entry<ParseEntry, List<String>>> keys = new ArrayList<>();
|
||||||
List<Boolean> and = new ArrayList<>();
|
// List<String> inputs = new ArrayList<>();
|
||||||
int last = 0;
|
// List<Boolean> and = new ArrayList<>();
|
||||||
outer:
|
// int last = 0;
|
||||||
for (int i = 0; i < toParse.length(); i++) {
|
// outer:
|
||||||
char c = toParse.charAt(i);
|
// for (int i = 0; i < toParse.length(); i++) {
|
||||||
switch (c) {
|
// char c = toParse.charAt(i);
|
||||||
case ',':
|
// switch (c) {
|
||||||
case '&':
|
// case ',':
|
||||||
String result = toParse.substring(last, i);
|
// case '&':
|
||||||
if (!result.isEmpty()) {
|
// String result = toParse.substring(last, i);
|
||||||
inputs.add(result);
|
// if (!result.isEmpty()) {
|
||||||
and.add(c == '&');
|
// inputs.add(result);
|
||||||
} else {
|
// and.add(c == '&');
|
||||||
throw new InputParseException("Invalid dangling character " + c);
|
// } else {
|
||||||
}
|
// throw new InputParseException("Invalid dangling character " + c);
|
||||||
last = i + 1;
|
// }
|
||||||
continue outer;
|
// last = i + 1;
|
||||||
default:
|
// continue outer;
|
||||||
if (c == '[' && StringMan.getMatchingBracket(c) != c) {
|
// default:
|
||||||
int next = StringMan.findMatchingBracket(toParse, i);
|
// if (c == '[' && StringMan.getMatchingBracket(c) != c) {
|
||||||
if (next != -1) {
|
// int next = StringMan.findMatchingBracket(toParse, i);
|
||||||
i = next;
|
// if (next != -1) {
|
||||||
} else {
|
// i = next;
|
||||||
toParse += "]";
|
// } else {
|
||||||
i = toParse.length();
|
// toParse += "]";
|
||||||
}
|
// i = toParse.length();
|
||||||
continue outer;
|
// }
|
||||||
}
|
// continue outer;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
inputs.add(toParse.substring(last));
|
// }
|
||||||
for (int i = 0; i < inputs.size(); i++) {
|
// inputs.add(toParse.substring(last));
|
||||||
String full = inputs.get(i);
|
// for (int i = 0; i < inputs.size(); i++) {
|
||||||
String command = full;
|
// String full = inputs.get(i);
|
||||||
List<String> args = new ArrayList<>();
|
// String command = full;
|
||||||
while (!command.isEmpty() && command.charAt(command.length() - 1) == ']') {
|
// List<String> args = new ArrayList<>();
|
||||||
int startPos = StringMan.findMatchingBracket(command, command.length() - 1);
|
// while (!command.isEmpty() && command.charAt(command.length() - 1) == ']') {
|
||||||
if (startPos == -1) break;
|
// int startPos = StringMan.findMatchingBracket(command, command.length() - 1);
|
||||||
String arg = command.substring(startPos + 1, command.length() - 1);
|
// if (startPos == -1) break;
|
||||||
args.add(arg);
|
// String arg = command.substring(startPos + 1, command.length() - 1);
|
||||||
command = full.substring(0, startPos);
|
// args.add(arg);
|
||||||
}
|
// command = full.substring(0, startPos);
|
||||||
Collections.reverse(args);
|
// }
|
||||||
ParseEntry entry = new ParseEntry(full, command, i > 0 ? and.get(i - 1) : false);
|
// Collections.reverse(args);
|
||||||
keys.add(new AbstractMap.SimpleEntry<>(entry, args));
|
// ParseEntry entry = new ParseEntry(full, command, i > 0 ? and.get(i - 1) : false);
|
||||||
}
|
// keys.add(new AbstractMap.SimpleEntry<>(entry, args));
|
||||||
return keys;
|
// }
|
||||||
}
|
// return keys;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
@ -1,82 +1,83 @@
|
|||||||
package com.boydti.fawe.command;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.boydti.fawe.command;
|
||||||
import com.boydti.fawe.command.CFICommands.CFISettings;
|
//
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
//import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
//import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
//import com.boydti.fawe.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
//import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
//import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
//import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
//import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
//import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
//import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
//import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
//import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
//import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
//import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
//import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
||||||
import java.io.File;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import java.io.IOException;
|
//import java.io.File;
|
||||||
import java.util.function.Function;
|
//import java.io.IOException;
|
||||||
|
//import java.util.function.Function;
|
||||||
public class PlotLoader {
|
//
|
||||||
|
//public class PlotLoader {
|
||||||
@Deprecated
|
//
|
||||||
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start,
|
// @Deprecated
|
||||||
com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
// public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start,
|
||||||
final Plot plot = area.getNextFreePlot(player, start);
|
// com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
||||||
if (plot == null) {
|
// final Plot plot = area.getNextFreePlot(player, start);
|
||||||
whenDone.run(null);
|
// if (plot == null) {
|
||||||
return;
|
// whenDone.run(null);
|
||||||
}
|
// return;
|
||||||
whenDone.value = plot;
|
// }
|
||||||
plot.owner = player.getUUID();
|
// whenDone.value = plot;
|
||||||
DBFunc.createPlotSafe(plot, whenDone,
|
// plot.owner = player.getUUID();
|
||||||
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
// DBFunc.createPlotSafe(plot, whenDone,
|
||||||
}
|
// () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||||
|
// }
|
||||||
public void load(Actor actor, CFISettings settings, Function<File, Boolean> createTask) throws IOException {
|
//
|
||||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
// public void load(Actor actor, CFISettings settings, Function<File, Boolean> createTask) throws IOException {
|
||||||
if (manager instanceof SinglePlotAreaManager) {
|
// PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||||
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
// if (manager instanceof SinglePlotAreaManager) {
|
||||||
SinglePlotArea area = sManager.getArea();
|
// SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
||||||
PlotPlayer player = PlotPlayer.get(actor.getName());
|
// SinglePlotArea area = sManager.getArea();
|
||||||
|
// PlotPlayer player = PlotPlayer.get(actor.getName());
|
||||||
actor.print("Claiming world");
|
//
|
||||||
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
// actor.print("Claiming world");
|
||||||
@Override
|
// Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||||
public void run(Plot o) {
|
// @Override
|
||||||
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount()
|
// public void run(Plot o) {
|
||||||
: player.getPlotCount(area.worldname);
|
// int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount()
|
||||||
int diff = player.getAllowedPlots() - currentPlots;
|
// : player.getPlotCount(area.worldname);
|
||||||
if (diff < 1) {
|
// int diff = player.getAllowedPlots() - currentPlots;
|
||||||
Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
// if (diff < 1) {
|
||||||
return;
|
// Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
if (area.getMeta("lastPlot") == null) {
|
//
|
||||||
area.setMeta("lastPlot", new PlotId(0, 0));
|
// if (area.getMeta("lastPlot") == null) {
|
||||||
}
|
// area.setMeta("lastPlot", new PlotId(0, 0));
|
||||||
PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
// }
|
||||||
do {
|
// PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
||||||
lastId = Auto.getNextPlotId(lastId, 1);
|
// do {
|
||||||
} while (!area.canClaim(player, lastId, lastId));
|
// lastId = Auto.getNextPlotId(lastId, 1);
|
||||||
area.setMeta("lastPlot", lastId);
|
// } while (!area.canClaim(player, lastId, lastId));
|
||||||
this.value = area.getPlot(lastId);
|
// area.setMeta("lastPlot", lastId);
|
||||||
this.value.setOwner(player.getUUID());
|
// this.value = area.getPlot(lastId);
|
||||||
}
|
// this.value.setOwner(player.getUUID());
|
||||||
});
|
// }
|
||||||
if (plot != null) {
|
// });
|
||||||
|
// if (plot != null) {
|
||||||
File folder = CFICommands.getFolder(plot.getWorldName());
|
//
|
||||||
Boolean result = createTask.apply(folder);
|
// File folder = CFICommands.getFolder(plot.getWorldName());
|
||||||
if (result == Boolean.TRUE) {
|
// Boolean result = createTask.apply(folder);
|
||||||
TaskManager.IMP.sync(() -> plot.teleportPlayer(player));
|
// if (result == Boolean.TRUE) {
|
||||||
}
|
// TaskManager.IMP.sync(() -> plot.teleportPlayer(player));
|
||||||
return;
|
// }
|
||||||
}
|
// return;
|
||||||
}
|
// }
|
||||||
createTask.apply(null);
|
// }
|
||||||
}
|
// createTask.apply(null);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
@ -58,65 +58,66 @@ public class BrushSettings {
|
|||||||
this.constructor.put(SettingType.PERMISSIONS, permissions);
|
this.constructor.put(SettingType.PERMISSIONS, permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
// public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
|
||||||
String constructor = (String) settings.get(SettingType.BRUSH.name());
|
// PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
||||||
if (constructor == null) {
|
// String constructor = (String) settings.get(SettingType.BRUSH.name());
|
||||||
return new BrushSettings();
|
// if (constructor == null) {
|
||||||
}
|
// return new BrushSettings();
|
||||||
BrushSettings bs = manager.parseCommand(constructor, player);
|
// }
|
||||||
bs.constructor.put(SettingType.BRUSH, constructor);
|
// BrushSettings bs = manager.parseCommand(constructor, player);
|
||||||
if (settings.containsKey(SettingType.PERMISSIONS.name())) {
|
// bs.constructor.put(SettingType.BRUSH, constructor);
|
||||||
bs.permissions.addAll((Collection<? extends String>) settings.get(SettingType.PERMISSIONS.name()));
|
// if (settings.containsKey(SettingType.PERMISSIONS.name())) {
|
||||||
}
|
// bs.permissions.addAll((Collection<? extends String>) settings.get(SettingType.PERMISSIONS.name()));
|
||||||
if (settings.containsKey(SettingType.SIZE.name())) {
|
// }
|
||||||
try {
|
// if (settings.containsKey(SettingType.SIZE.name())) {
|
||||||
bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1));
|
// try {
|
||||||
bs.size.optimize();
|
// bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1));
|
||||||
} catch (ExpressionException e) {
|
// bs.size.optimize();
|
||||||
throw new RuntimeException(e);
|
// } catch (ExpressionException e) {
|
||||||
}
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
ParserContext parserContext = new ParserContext();
|
//
|
||||||
parserContext.setActor(player);
|
// ParserContext parserContext = new ParserContext();
|
||||||
parserContext.setWorld(player.getWorld());
|
// parserContext.setActor(player);
|
||||||
parserContext.setSession(session);
|
// parserContext.setWorld(player.getWorld());
|
||||||
|
// parserContext.setSession(session);
|
||||||
if (settings.containsKey(SettingType.MASK.name())) {
|
//
|
||||||
String maskArgs = (String) settings.get(SettingType.MASK.name());
|
// if (settings.containsKey(SettingType.MASK.name())) {
|
||||||
Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
// String maskArgs = (String) settings.get(SettingType.MASK.name());
|
||||||
bs.setMask(mask);
|
// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||||
bs.constructor.put(SettingType.MASK, maskArgs);
|
// bs.setMask(mask);
|
||||||
}
|
// bs.constructor.put(SettingType.MASK, maskArgs);
|
||||||
if (settings.containsKey(SettingType.SOURCE_MASK.name())) {
|
// }
|
||||||
String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name());
|
// if (settings.containsKey(SettingType.SOURCE_MASK.name())) {
|
||||||
Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
// String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name());
|
||||||
bs.setSourceMask(mask);
|
// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||||
bs.constructor.put(SettingType.SOURCE_MASK, maskArgs);
|
// bs.setSourceMask(mask);
|
||||||
}
|
// bs.constructor.put(SettingType.SOURCE_MASK, maskArgs);
|
||||||
if (settings.containsKey(SettingType.TRANSFORM.name())) {
|
// }
|
||||||
String transformArgs = (String) settings.get(SettingType.TRANSFORM.name());
|
// if (settings.containsKey(SettingType.TRANSFORM.name())) {
|
||||||
ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext);
|
// String transformArgs = (String) settings.get(SettingType.TRANSFORM.name());
|
||||||
bs.setTransform(extent);
|
// ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext);
|
||||||
bs.constructor.put(SettingType.TRANSFORM, transformArgs);
|
// bs.setTransform(extent);
|
||||||
}
|
// bs.constructor.put(SettingType.TRANSFORM, transformArgs);
|
||||||
if (settings.containsKey(SettingType.FILL.name())) {
|
// }
|
||||||
String fillArgs = (String) settings.get(SettingType.FILL.name());
|
// if (settings.containsKey(SettingType.FILL.name())) {
|
||||||
Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext);
|
// String fillArgs = (String) settings.get(SettingType.FILL.name());
|
||||||
bs.setFill(pattern);
|
// Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext);
|
||||||
bs.constructor.put(SettingType.FILL, fillArgs);
|
// bs.setFill(pattern);
|
||||||
}
|
// bs.constructor.put(SettingType.FILL, fillArgs);
|
||||||
if (settings.containsKey(SettingType.SCROLL_ACTION.name())) {
|
// }
|
||||||
String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name());
|
// if (settings.containsKey(SettingType.SCROLL_ACTION.name())) {
|
||||||
Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false);
|
// String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name());
|
||||||
if (action != null) {
|
// Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false);
|
||||||
bs.setScrollAction(action);
|
// if (action != null) {
|
||||||
bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs);
|
// bs.setScrollAction(action);
|
||||||
}
|
// bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs);
|
||||||
}
|
// }
|
||||||
return bs;
|
// }
|
||||||
}
|
// return bs;
|
||||||
|
// }
|
||||||
|
|
||||||
public BrushSettings setBrush(Brush brush) {
|
public BrushSettings setBrush(Brush brush) {
|
||||||
Brush tmp = this.brush;
|
Brush tmp = this.brush;
|
||||||
|
@ -41,23 +41,24 @@ public final class BrushCache {
|
|||||||
CompoundTag nbt = item.getNbtData();
|
CompoundTag nbt = item.getNbtData();
|
||||||
if (nbt == null) return null;
|
if (nbt == null) return null;
|
||||||
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
|
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
|
||||||
if (json != null) {
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
try {
|
// if (json != null) {
|
||||||
if (RECURSION.get() != null) return null;
|
// try {
|
||||||
RECURSION.set(true);
|
// if (RECURSION.get() != null) return null;
|
||||||
|
// RECURSION.set(true);
|
||||||
BrushTool tool = BrushTool.fromString(player, session, json.getValue());
|
//
|
||||||
tool.setHolder(item);
|
// BrushTool tool = BrushTool.fromString(player, session, json.getValue());
|
||||||
brushCache.put(key, tool);
|
// tool.setHolder(item);
|
||||||
return tool;
|
// brushCache.put(key, tool);
|
||||||
} catch (Exception throwable) {
|
// return tool;
|
||||||
getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
|
// } catch (Exception throwable) {
|
||||||
item.setNbtData(null);
|
// getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
|
||||||
brushCache.remove(key);
|
// item.setNbtData(null);
|
||||||
} finally {
|
// brushCache.remove(key);
|
||||||
RECURSION.remove();
|
// } finally {
|
||||||
}
|
// RECURSION.remove();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +155,15 @@ public class BrushCommands {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "none",
|
||||||
|
aliases = "unbind",
|
||||||
|
desc = "Unbind a bound brush from your current item"
|
||||||
|
)
|
||||||
|
void none(Player player, LocalSession session) throws WorldEditException {
|
||||||
|
ToolCommands.setToolNone(player, session, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "blendball",
|
name = "blendball",
|
||||||
aliases = {"bb", "blend"},
|
aliases = {"bb", "blend"},
|
||||||
@ -984,38 +993,39 @@ public class BrushCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
name = "loadbrush",
|
// @Command(
|
||||||
aliases = {"load"},
|
// name = "loadbrush",
|
||||||
desc = "Load a brush"
|
// aliases = {"load"},
|
||||||
)
|
// desc = "Load a brush"
|
||||||
@CommandPermissions("worldedit.brush.load")
|
// )
|
||||||
public void loadBrush(Player player, LocalSession session, @Arg(desc = "String name") String name)
|
// @CommandPermissions("worldedit.brush.load")
|
||||||
throws WorldEditException, IOException {
|
// public void loadBrush(Player player, LocalSession session, @Arg(desc = "String name") String name)
|
||||||
name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
// throws WorldEditException, IOException {
|
||||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
// name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
||||||
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
// File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||||
File file = new File(folder, player.getUniqueId() + File.separator + name);
|
// name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
||||||
if (!file.exists()) {
|
// File file = new File(folder, player.getUniqueId() + File.separator + name);
|
||||||
file = new File(folder, name);
|
// if (!file.exists()) {
|
||||||
}
|
// file = new File(folder, name);
|
||||||
if (!file.exists()) {
|
// }
|
||||||
File[] files = folder.listFiles(pathname -> false);
|
// if (!file.exists()) {
|
||||||
player.print(Caption.of("fawe.error.brush.not.found" , name));
|
// File[] files = folder.listFiles(pathname -> false);
|
||||||
return;
|
// player.print(Caption.of("fawe.error.brush.not.found" , name));
|
||||||
}
|
// return;
|
||||||
try (DataInputStream in = new DataInputStream(
|
// }
|
||||||
new GZIPInputStream(new FileInputStream(file)))) {
|
// try (DataInputStream in = new DataInputStream(
|
||||||
String json = in.readUTF();
|
// new GZIPInputStream(new FileInputStream(file)))) {
|
||||||
BrushTool tool = BrushTool.fromString(player, session, json);
|
// String json = in.readUTF();
|
||||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
// BrushTool tool = BrushTool.fromString(player, session, json);
|
||||||
session.setTool(item, tool, player);
|
// BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||||
player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , name));
|
// session.setTool(item, tool, player);
|
||||||
} catch (Throwable e) {
|
// player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , name));
|
||||||
e.printStackTrace();
|
// } catch (Throwable e) {
|
||||||
player.printError(TranslatableComponent.of("fawe.error.brush.incompatible"));
|
// e.printStackTrace();
|
||||||
}
|
// player.printError(TranslatableComponent.of("fawe.error.brush.incompatible"));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/listbrush",
|
name = "/listbrush",
|
||||||
|
@ -1,448 +1,449 @@
|
|||||||
package com.sk89q.worldedit.command;
|
// TODO: Ping @MattBDev to reimplement (or remove because this class is stupid) 2020-02-04
|
||||||
|
//package com.sk89q.worldedit.command;
|
||||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
//
|
||||||
import com.boydti.fawe.object.mask.AdjacentMask;
|
//import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||||
import com.boydti.fawe.object.mask.AngleMask;
|
//import com.boydti.fawe.object.mask.AdjacentMask;
|
||||||
import com.boydti.fawe.object.mask.BiomeMask;
|
//import com.boydti.fawe.object.mask.AngleMask;
|
||||||
import com.boydti.fawe.object.mask.BlockLightMask;
|
//import com.boydti.fawe.object.mask.BiomeMask;
|
||||||
import com.boydti.fawe.object.mask.BrightnessMask;
|
//import com.boydti.fawe.object.mask.BlockLightMask;
|
||||||
import com.boydti.fawe.object.mask.DataMask;
|
//import com.boydti.fawe.object.mask.BrightnessMask;
|
||||||
import com.boydti.fawe.object.mask.ExtremaMask;
|
//import com.boydti.fawe.object.mask.DataMask;
|
||||||
import com.boydti.fawe.object.mask.IdDataMask;
|
//import com.boydti.fawe.object.mask.ExtremaMask;
|
||||||
import com.boydti.fawe.object.mask.IdMask;
|
//import com.boydti.fawe.object.mask.IdDataMask;
|
||||||
import com.boydti.fawe.object.mask.LightMask;
|
//import com.boydti.fawe.object.mask.IdMask;
|
||||||
import com.boydti.fawe.object.mask.OpacityMask;
|
//import com.boydti.fawe.object.mask.LightMask;
|
||||||
import com.boydti.fawe.object.mask.ROCAngleMask;
|
//import com.boydti.fawe.object.mask.OpacityMask;
|
||||||
import com.boydti.fawe.object.mask.RadiusMask;
|
//import com.boydti.fawe.object.mask.ROCAngleMask;
|
||||||
import com.boydti.fawe.object.mask.RandomMask;
|
//import com.boydti.fawe.object.mask.RadiusMask;
|
||||||
import com.boydti.fawe.object.mask.SimplexMask;
|
//import com.boydti.fawe.object.mask.RandomMask;
|
||||||
import com.boydti.fawe.object.mask.SkyLightMask;
|
//import com.boydti.fawe.object.mask.SimplexMask;
|
||||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
//import com.boydti.fawe.object.mask.SkyLightMask;
|
||||||
import com.boydti.fawe.object.mask.WallMask;
|
//import com.boydti.fawe.object.mask.SurfaceMask;
|
||||||
import com.boydti.fawe.object.mask.XAxisMask;
|
//import com.boydti.fawe.object.mask.WallMask;
|
||||||
import com.boydti.fawe.object.mask.YAxisMask;
|
//import com.boydti.fawe.object.mask.XAxisMask;
|
||||||
import com.boydti.fawe.object.mask.ZAxisMask;
|
//import com.boydti.fawe.object.mask.YAxisMask;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
//import com.boydti.fawe.object.mask.ZAxisMask;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
//import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
//import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
//import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
//import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
//import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||||
import com.sk89q.worldedit.function.mask.ExpressionMask;
|
//import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
//import com.sk89q.worldedit.function.mask.ExpressionMask;
|
||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
//import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
//import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
//import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
//import com.sk89q.worldedit.function.mask.RegionMask;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
//import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionEnvironment;
|
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
//import com.sk89q.worldedit.internal.expression.ExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
//import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
//import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.session.request.RequestSelection;
|
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
//import com.sk89q.worldedit.session.request.RequestSelection;
|
||||||
import org.enginehub.piston.annotation.Command;
|
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
//import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
//import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
//import org.enginehub.piston.annotation.param.Arg;
|
||||||
|
//import org.enginehub.piston.annotation.param.Switch;
|
||||||
//@Command(aliases = {"masks"},
|
//
|
||||||
// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
////@Command(aliases = {"masks"},
|
||||||
// descFooter = "Masks determine if a block can be placed\n" +
|
//// desc = "Help for the various masks. [More Info](https://git.io/v9r4K)",
|
||||||
// " - Use [brackets] for arguments\n" +
|
//// descFooter = "Masks determine if a block can be placed\n" +
|
||||||
// " - Use , to OR multiple\n" +
|
//// " - Use [brackets] for arguments\n" +
|
||||||
// " - Use & to AND multiple\n" +
|
//// " - Use , to OR multiple\n" +
|
||||||
// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
//// " - Use & to AND multiple\n" +
|
||||||
// "More Info: https://git.io/v9r4K"
|
//// "e.g. >[stone,dirt],#light[0][5],$jungle\n" +
|
||||||
|
//// "More Info: https://git.io/v9r4K"
|
||||||
|
////)
|
||||||
|
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
|
//public class MaskCommands {
|
||||||
|
// private final WorldEdit worldEdit;
|
||||||
|
//
|
||||||
|
// public MaskCommands(WorldEdit worldEdit) {
|
||||||
|
// this.worldEdit = worldEdit;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#simplex",
|
||||||
|
// desc = "Use simplex noise as the mask"
|
||||||
|
// )
|
||||||
|
// public Mask simplex(@Arg(desc = "double scale") double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// scale = 1d / Math.max(1, scale);
|
||||||
|
// minInt = (minInt - 50) / 50;
|
||||||
|
// maxInt = (maxInt - 50) / 50;
|
||||||
|
// return new SimplexMask(scale, minInt, maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#light",
|
||||||
|
// desc = "Restrict to specific light levels"
|
||||||
|
// )
|
||||||
|
// public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// return new LightMask(extent, (int) minInt, (int) maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#false",
|
||||||
|
// desc = "Always false"
|
||||||
|
// )
|
||||||
|
// public Mask falseMask(Extent extent) {
|
||||||
|
// return Masks.alwaysFalse();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#true",
|
||||||
|
// desc = "Always true"
|
||||||
|
// )
|
||||||
|
// public Mask trueMask(Extent extent) {
|
||||||
|
// return Masks.alwaysTrue();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#skylight",
|
||||||
|
// desc = "Restrict to specific sky light levels"
|
||||||
|
// )
|
||||||
|
// public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#blocklight",
|
||||||
|
// aliases = {"#emittedlight"},
|
||||||
|
// desc = "Restrict to specific block light levels"
|
||||||
|
// )
|
||||||
|
// public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#opacity",
|
||||||
|
// desc = "Restrict to specific opacity levels"
|
||||||
|
// )
|
||||||
|
// public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#brightness",
|
||||||
|
// desc = "Restrict to specific block brightness"
|
||||||
|
// )
|
||||||
|
// public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
||||||
|
// return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#offset",
|
||||||
|
// desc = "Offset a mask"
|
||||||
|
// )
|
||||||
|
// public Mask offset(@Arg(desc = "double x") double x, @Arg(desc = "double y") double y, @Arg(desc = "double z") double z, @Arg(desc = "Mask") Mask mask) {
|
||||||
|
// return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#haslight",
|
||||||
|
// desc = "Restricts to blocks with light (sky or emitted)"
|
||||||
|
// )
|
||||||
|
// public Mask haslight(Extent extent) {
|
||||||
|
// return new LightMask(extent, 1, Integer.MAX_VALUE);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#nolight",
|
||||||
|
// desc = "Restrict to blocks without light (sky or emitted)"
|
||||||
|
// )
|
||||||
|
// public Mask nolight(Extent extent) {
|
||||||
|
// return new LightMask(extent, 0, 0);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#existing",
|
||||||
|
// desc = "If there is a non air block"
|
||||||
|
// )
|
||||||
|
// public Mask existing(Extent extent) {
|
||||||
|
// return new ExistingBlockMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#solid",
|
||||||
|
// desc = "If there is a solid block"
|
||||||
|
// )
|
||||||
|
// public Mask solid(Extent extent) {
|
||||||
|
// return new SolidBlockMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#liquid",
|
||||||
|
// desc = "If there is a solid block"
|
||||||
|
// )
|
||||||
|
// public Mask liquid(Extent extent) {
|
||||||
|
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#dregion",
|
||||||
|
// aliases = {"#dselection", "#dsel"},
|
||||||
|
// desc = "inside the player's selection"
|
||||||
|
// )
|
||||||
|
// public Mask dregion() {
|
||||||
|
// return new RegionMask(new RequestSelection());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#region",
|
||||||
|
// aliases = {"#selection", "#sel"},
|
||||||
|
// desc = "inside the provided selection"
|
||||||
|
// )
|
||||||
|
// public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
||||||
|
// return new RegionMask(session.getSelection(player.getWorld()).clone());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#xaxis",
|
||||||
|
// desc = "Restrict to initial x axis"
|
||||||
|
// )
|
||||||
|
// public Mask xaxis() {
|
||||||
|
// return new XAxisMask();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#yaxis",
|
||||||
|
// desc = "Restrict to initial y axis"
|
||||||
|
// )
|
||||||
|
// public Mask yaxis() {
|
||||||
|
// return new YAxisMask();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#zaxis",
|
||||||
|
// desc = "Restrict to initial z axis"
|
||||||
|
// )
|
||||||
|
// public Mask zaxis() {
|
||||||
|
// return new ZAxisMask();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#id",
|
||||||
|
// desc = "Restrict to initial id"
|
||||||
|
// )
|
||||||
|
// public Mask id(Extent extent) {
|
||||||
|
// return new IdMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#data",
|
||||||
|
// desc = "Restrict to initial data"
|
||||||
|
// )
|
||||||
|
// public Mask data(Extent extent) {
|
||||||
|
// return new DataMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#iddata",
|
||||||
|
// desc = "Restrict to initial block id and data"
|
||||||
|
// )
|
||||||
|
// public Mask iddata(Extent extent) {
|
||||||
|
// return new IdDataMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#air",
|
||||||
|
// desc = "Restrict to types of air"
|
||||||
|
// )
|
||||||
|
// public Mask air(Extent extent) {
|
||||||
|
// return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#wall",
|
||||||
|
// desc = "Restrict to walls (any block n,e,s,w of air)"
|
||||||
|
// )
|
||||||
|
// public Mask wall(Extent extent) {
|
||||||
|
// Mask blockMask = air(extent);
|
||||||
|
// return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#surface",
|
||||||
|
// desc = "Restrict to surfaces (any solid block touching air)"
|
||||||
|
// )
|
||||||
|
// public Mask surface(Extent extent) {
|
||||||
|
// return new SurfaceMask(extent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "\\",
|
||||||
|
// aliases = {"/", "#angle", "#\\", "#/"},
|
||||||
|
// desc = "Restrict to specific terrain angle",
|
||||||
|
// descFooter = "Restrict to specific terrain angle\n" +
|
||||||
|
// "The -o flag will only overlay\n" +
|
||||||
|
// "Example: /[0d][45d]\n" +
|
||||||
|
// "Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
||||||
|
// "Example: /[3][20]\n" +
|
||||||
|
// "Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
||||||
//)
|
//)
|
||||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
// public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
||||||
public class MaskCommands {
|
// double y1, y2;
|
||||||
private final WorldEdit worldEdit;
|
// boolean override;
|
||||||
|
// if (maxStr.endsWith("d")) {
|
||||||
public MaskCommands(WorldEdit worldEdit) {
|
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||||
this.worldEdit = worldEdit;
|
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||||
}
|
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||||
|
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||||
@Command(
|
// } else {
|
||||||
name = "#simplex",
|
// y1 = Expression.compile(minStr).evaluate();
|
||||||
desc = "Use simplex noise as the mask"
|
// y2 = Expression.compile(maxStr).evaluate();
|
||||||
)
|
// }
|
||||||
public Mask simplex(@Arg(desc = "double scale") double scale, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
// return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||||
scale = 1d / Math.max(1, scale);
|
// }
|
||||||
minInt = (minInt - 50) / 50;
|
//
|
||||||
maxInt = (maxInt - 50) / 50;
|
// @Command(
|
||||||
return new SimplexMask(scale, minInt, maxInt);
|
// name = "(",
|
||||||
}
|
// aliases = {")", "#roc", "#(", "#)"},
|
||||||
|
// desc = "Restrict to near specific terrain slope rate of change",
|
||||||
@Command(
|
// descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
||||||
name = "#light",
|
// "The -o flag will only overlay\n" +
|
||||||
desc = "Restrict to specific light levels"
|
// "Example: ([0d][45d][5]\n" +
|
||||||
)
|
// "Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
||||||
public Mask light(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
// "Note: Use negatives for decreasing slope"
|
||||||
return new LightMask(extent, (int) minInt, (int) maxInt);
|
//)
|
||||||
}
|
// public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||||
|
// double y1, y2;
|
||||||
@Command(
|
// boolean override;
|
||||||
name = "#false",
|
// if (maxStr.endsWith("d")) {
|
||||||
desc = "Always false"
|
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||||
)
|
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||||
public Mask falseMask(Extent extent) {
|
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||||
return Masks.alwaysFalse();
|
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||||
}
|
// } else {
|
||||||
|
// y1 = Expression.compile(minStr).evaluate();
|
||||||
@Command(
|
// y2 = Expression.compile(maxStr).evaluate();
|
||||||
name = "#true",
|
// }
|
||||||
desc = "Always true"
|
// return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
||||||
)
|
// }
|
||||||
public Mask trueMask(Extent extent) {
|
//
|
||||||
return Masks.alwaysTrue();
|
// @Command(
|
||||||
}
|
// name = "^",
|
||||||
|
// aliases = {"#extrema", "#^"},
|
||||||
@Command(
|
// desc = "Restrict to near specific terrain extrema",
|
||||||
name = "#skylight",
|
// descFooter = "Restrict to near specific terrain extrema\n" +
|
||||||
desc = "Restrict to specific sky light levels"
|
// "The -o flag will only overlay\n" +
|
||||||
)
|
// "Example: ([0d][45d][5]\n" +
|
||||||
public Mask skylight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
// "Explanation: Restrict to near 45 degrees of local maxima\n" +
|
||||||
return new SkyLightMask(extent, (int) minInt, (int) maxInt);
|
// "Note: Use negatives for local minima"
|
||||||
}
|
//)
|
||||||
|
// public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
||||||
@Command(
|
// double y1, y2;
|
||||||
name = "#blocklight",
|
// boolean override;
|
||||||
aliases = {"#emittedlight"},
|
// if (maxStr.endsWith("d")) {
|
||||||
desc = "Restrict to specific block light levels"
|
// double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
||||||
)
|
// double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
||||||
public Mask blocklight(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
// y1 = Math.tan(y1d * (Math.PI / 180));
|
||||||
return new BlockLightMask(extent, (int) minInt, (int) maxInt);
|
// y2 = Math.tan(y2d * (Math.PI / 180));
|
||||||
}
|
// } else {
|
||||||
|
// y1 = Expression.compile(minStr).evaluate();
|
||||||
@Command(
|
// y2 = Expression.compile(maxStr).evaluate();
|
||||||
name = "#opacity",
|
// }
|
||||||
desc = "Restrict to specific opacity levels"
|
// return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
||||||
)
|
// }
|
||||||
public Mask opacity(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
//
|
||||||
return new OpacityMask(extent, (int) minInt, (int) maxInt);
|
// @Command(
|
||||||
}
|
// name = "{",
|
||||||
|
// aliases = {"#{"},
|
||||||
@Command(
|
// desc = "Restricts blocks to within a specific radius range of the initial block"
|
||||||
name = "#brightness",
|
//)
|
||||||
desc = "Restrict to specific block brightness"
|
// public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||||
)
|
// return new RadiusMask((int) minInt, (int) maxInt);
|
||||||
public Mask brightness(Extent extent, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) {
|
// }
|
||||||
return new BrightnessMask(extent, (int) minInt, (int) maxInt);
|
//
|
||||||
}
|
// @Command(
|
||||||
|
// name = "|",
|
||||||
@Command(
|
// aliases = {"#|", "#side"},
|
||||||
name = "#offset",
|
// desc = "sides with a specific number of other blocks"
|
||||||
desc = "Offset a mask"
|
//)
|
||||||
)
|
// public Mask wall(@Arg(desc = "Mask") Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
||||||
public Mask offset(@Arg(desc = "double x") double x, @Arg(desc = "double y") double y, @Arg(desc = "double z") double z, @Arg(desc = "Mask") Mask mask) {
|
// return new WallMask(mask, (int) minInt, (int) maxInt);
|
||||||
return new OffsetMask(mask, BlockVector3.at(x, y, z));
|
// }
|
||||||
}
|
//
|
||||||
|
// @Command(
|
||||||
@Command(
|
// name = "~",
|
||||||
name = "#haslight",
|
// aliases = {"#~", "#adjacent"},
|
||||||
desc = "Restricts to blocks with light (sky or emitted)"
|
// desc = "Adjacent to a specific number of other blocks"
|
||||||
)
|
//)
|
||||||
public Mask haslight(Extent extent) {
|
// public Mask adjacent(@Arg(desc = "Mask") Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
||||||
return new LightMask(extent, 1, Integer.MAX_VALUE);
|
// if (min == -1 && max == -1) {
|
||||||
}
|
// min = 1;
|
||||||
|
// max = 8;
|
||||||
@Command(
|
// } else if (max == -1) max = min;
|
||||||
name = "#nolight",
|
// if (max >= 8 && min == 1) {
|
||||||
desc = "Restrict to blocks without light (sky or emitted)"
|
// return new AdjacentAnyMask(mask);
|
||||||
)
|
// }
|
||||||
public Mask nolight(Extent extent) {
|
// return new AdjacentMask(mask, (int) min, (int) max);
|
||||||
return new LightMask(extent, 0, 0);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Command(
|
||||||
@Command(
|
// name = "<",
|
||||||
name = "#existing",
|
// aliases = {"#<", "#below"},
|
||||||
desc = "If there is a non air block"
|
// desc = "below a specific block"
|
||||||
)
|
//)
|
||||||
public Mask existing(Extent extent) {
|
// public Mask below(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
||||||
return new ExistingBlockMask(extent);
|
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
||||||
}
|
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#solid",
|
// @Command(
|
||||||
desc = "If there is a solid block"
|
// name = ">",
|
||||||
)
|
// aliases = {"#>", "#above"},
|
||||||
public Mask solid(Extent extent) {
|
// desc = "above a specific block"
|
||||||
return new SolidBlockMask(extent);
|
//)
|
||||||
}
|
// public Mask above(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
||||||
|
// OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
||||||
@Command(
|
// return new MaskIntersection(offsetMask, Masks.negate(mask));
|
||||||
name = "#liquid",
|
// }
|
||||||
desc = "If there is a solid block"
|
//
|
||||||
)
|
// @Command(
|
||||||
public Mask liquid(Extent extent) {
|
// name = "$",
|
||||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isLiquid()).build(extent);
|
// aliases = {"#biome", "#$"},
|
||||||
}
|
// desc = "in a specific biome",
|
||||||
|
// descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
||||||
@Command(
|
//)
|
||||||
name = "#dregion",
|
// public Mask biome(Extent extent, @Arg(desc = "BiomeType") BiomeType biome) throws ExpressionException {
|
||||||
aliases = {"#dselection", "#dsel"},
|
// return new BiomeMask(extent, biome);
|
||||||
desc = "inside the player's selection"
|
// }
|
||||||
)
|
//
|
||||||
public Mask dregion() {
|
// @Command(
|
||||||
return new RegionMask(new RequestSelection());
|
// name = "%",
|
||||||
}
|
// aliases = {"#%", "#percent"},
|
||||||
|
// desc = "percentage chance"
|
||||||
@Command(
|
//)
|
||||||
name = "#region",
|
// public Mask random(@Arg(desc = "double chance") double chance) throws ExpressionException {
|
||||||
aliases = {"#selection", "#sel"},
|
// chance = chance / 100;
|
||||||
desc = "inside the provided selection"
|
// return new RandomMask(chance);
|
||||||
)
|
// }
|
||||||
public Mask selection(Player player, LocalSession session) throws IncompleteRegionException {
|
//
|
||||||
return new RegionMask(session.getSelection(player.getWorld()).clone());
|
// @Command(
|
||||||
}
|
// name = "=",
|
||||||
|
// aliases = {"#=", "#expression"},
|
||||||
@Command(
|
// desc = "expression mask"
|
||||||
name = "#xaxis",
|
//)
|
||||||
desc = "Restrict to initial x axis"
|
// public Mask expression(Extent extent, @Arg(desc = "String expression") String input) throws ExpressionException {
|
||||||
)
|
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||||
public Mask xaxis() {
|
// ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||||
return new XAxisMask();
|
// exp.setEnvironment(env);
|
||||||
}
|
// return new ExpressionMask(exp);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#yaxis",
|
// @Command(
|
||||||
desc = "Restrict to initial y axis"
|
// name = "!",
|
||||||
)
|
// aliases = {"#not", "#negate", "#!"},
|
||||||
public Mask yaxis() {
|
// desc = "Negate another mask"
|
||||||
return new YAxisMask();
|
//)
|
||||||
}
|
// public Mask negate(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
||||||
|
// return Masks.negate(mask);
|
||||||
@Command(
|
// }
|
||||||
name = "#zaxis",
|
//}
|
||||||
desc = "Restrict to initial z axis"
|
|
||||||
)
|
|
||||||
public Mask zaxis() {
|
|
||||||
return new ZAxisMask();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#id",
|
|
||||||
desc = "Restrict to initial id"
|
|
||||||
)
|
|
||||||
public Mask id(Extent extent) {
|
|
||||||
return new IdMask(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#data",
|
|
||||||
desc = "Restrict to initial data"
|
|
||||||
)
|
|
||||||
public Mask data(Extent extent) {
|
|
||||||
return new DataMask(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#iddata",
|
|
||||||
desc = "Restrict to initial block id and data"
|
|
||||||
)
|
|
||||||
public Mask iddata(Extent extent) {
|
|
||||||
return new IdDataMask(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#air",
|
|
||||||
desc = "Restrict to types of air"
|
|
||||||
)
|
|
||||||
public Mask air(Extent extent) {
|
|
||||||
return new BlockMaskBuilder().addAll(b -> b.getMaterial().isAir()).build(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#wall",
|
|
||||||
desc = "Restrict to walls (any block n,e,s,w of air)"
|
|
||||||
)
|
|
||||||
public Mask wall(Extent extent) {
|
|
||||||
Mask blockMask = air(extent);
|
|
||||||
return new MaskUnion(new ExistingBlockMask(extent), new WallMask(blockMask, 1, 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "#surface",
|
|
||||||
desc = "Restrict to surfaces (any solid block touching air)"
|
|
||||||
)
|
|
||||||
public Mask surface(Extent extent) {
|
|
||||||
return new SurfaceMask(extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "\\",
|
|
||||||
aliases = {"/", "#angle", "#\\", "#/"},
|
|
||||||
desc = "Restrict to specific terrain angle",
|
|
||||||
descFooter = "Restrict to specific terrain angle\n" +
|
|
||||||
"The -o flag will only overlay\n" +
|
|
||||||
"Example: /[0d][45d]\n" +
|
|
||||||
"Explanation: Allows any block where the adjacent block is between 0 and 45 degrees.\n" +
|
|
||||||
"Example: /[3][20]\n" +
|
|
||||||
"Explanation: Allows any block where the adjacent block is between 3 and 20 blocks below"
|
|
||||||
)
|
|
||||||
public Mask angle(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "1") int distanceOpt) throws ExpressionException {
|
|
||||||
double y1, y2;
|
|
||||||
boolean override;
|
|
||||||
if (maxStr.endsWith("d")) {
|
|
||||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
|
||||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
|
||||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
|
||||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
|
||||||
} else {
|
|
||||||
y1 = Expression.compile(minStr).evaluate();
|
|
||||||
y2 = Expression.compile(maxStr).evaluate();
|
|
||||||
}
|
|
||||||
return new AngleMask(extent, y1, y2, overlay, distanceOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "(",
|
|
||||||
aliases = {")", "#roc", "#(", "#)"},
|
|
||||||
desc = "Restrict to near specific terrain slope rate of change",
|
|
||||||
descFooter = "Restrict to near specific terrain slope rate of change\n" +
|
|
||||||
"The -o flag will only overlay\n" +
|
|
||||||
"Example: ([0d][45d][5]\n" +
|
|
||||||
"Explanation: Restrict near where the angle changes between 0-45 degrees within 5 blocks\n" +
|
|
||||||
"Note: Use negatives for decreasing slope"
|
|
||||||
)
|
|
||||||
public Mask roc(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
|
||||||
double y1, y2;
|
|
||||||
boolean override;
|
|
||||||
if (maxStr.endsWith("d")) {
|
|
||||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
|
||||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
|
||||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
|
||||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
|
||||||
} else {
|
|
||||||
y1 = Expression.compile(minStr).evaluate();
|
|
||||||
y2 = Expression.compile(maxStr).evaluate();
|
|
||||||
}
|
|
||||||
return new ROCAngleMask(extent, y1, y2, overlay, distanceOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "^",
|
|
||||||
aliases = {"#extrema", "#^"},
|
|
||||||
desc = "Restrict to near specific terrain extrema",
|
|
||||||
descFooter = "Restrict to near specific terrain extrema\n" +
|
|
||||||
"The -o flag will only overlay\n" +
|
|
||||||
"Example: ([0d][45d][5]\n" +
|
|
||||||
"Explanation: Restrict to near 45 degrees of local maxima\n" +
|
|
||||||
"Note: Use negatives for local minima"
|
|
||||||
)
|
|
||||||
public Mask extrema(Extent extent, @Arg(name="min", desc = "min angle") String minStr, @Arg(name="max", desc = "max angle") String maxStr, @Switch(name = 'o', desc = "TODO") boolean overlay, @Arg(name = "distance", desc = "int", def = "4") int distanceOpt) throws ExpressionException {
|
|
||||||
double y1, y2;
|
|
||||||
boolean override;
|
|
||||||
if (maxStr.endsWith("d")) {
|
|
||||||
double y1d = Expression.compile(minStr.substring(0, minStr.length() - 1)).evaluate();
|
|
||||||
double y2d = Expression.compile(maxStr.substring(0, maxStr.length() - 1)).evaluate();
|
|
||||||
y1 = Math.tan(y1d * (Math.PI / 180));
|
|
||||||
y2 = Math.tan(y2d * (Math.PI / 180));
|
|
||||||
} else {
|
|
||||||
y1 = Expression.compile(minStr).evaluate();
|
|
||||||
y2 = Expression.compile(maxStr).evaluate();
|
|
||||||
}
|
|
||||||
return new ExtremaMask(extent, y1, y2, overlay, distanceOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "{",
|
|
||||||
aliases = {"#{"},
|
|
||||||
desc = "Restricts blocks to within a specific radius range of the initial block"
|
|
||||||
)
|
|
||||||
public Mask radius(@Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
|
||||||
return new RadiusMask((int) minInt, (int) maxInt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "|",
|
|
||||||
aliases = {"#|", "#side"},
|
|
||||||
desc = "sides with a specific number of other blocks"
|
|
||||||
)
|
|
||||||
public Mask wall(@Arg(desc = "Mask") Mask mask, @Arg(name="mine", desc = "min light") double minInt, @Arg(name="mine", desc = "max light") double maxInt) throws ExpressionException {
|
|
||||||
return new WallMask(mask, (int) minInt, (int) maxInt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "~",
|
|
||||||
aliases = {"#~", "#adjacent"},
|
|
||||||
desc = "Adjacent to a specific number of other blocks"
|
|
||||||
)
|
|
||||||
public Mask adjacent(@Arg(desc = "Mask") Mask mask, @Arg(name = "min", desc = "double", def = "-1") double min, @Arg(name = "max", desc = "double", def = "-1") double max) throws ExpressionException {
|
|
||||||
if (min == -1 && max == -1) {
|
|
||||||
min = 1;
|
|
||||||
max = 8;
|
|
||||||
} else if (max == -1) max = min;
|
|
||||||
if (max >= 8 && min == 1) {
|
|
||||||
return new AdjacentAnyMask(mask);
|
|
||||||
}
|
|
||||||
return new AdjacentMask(mask, (int) min, (int) max);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "<",
|
|
||||||
aliases = {"#<", "#below"},
|
|
||||||
desc = "below a specific block"
|
|
||||||
)
|
|
||||||
public Mask below(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
|
||||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, 1, 0));
|
|
||||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = ">",
|
|
||||||
aliases = {"#>", "#above"},
|
|
||||||
desc = "above a specific block"
|
|
||||||
)
|
|
||||||
public Mask above(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
|
||||||
OffsetMask offsetMask = new OffsetMask(mask, BlockVector3.at(0, -1, 0));
|
|
||||||
return new MaskIntersection(offsetMask, Masks.negate(mask));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "$",
|
|
||||||
aliases = {"#biome", "#$"},
|
|
||||||
desc = "in a specific biome",
|
|
||||||
descFooter = "in a specific biome. For a list of biomes use //biomelist"
|
|
||||||
)
|
|
||||||
public Mask biome(Extent extent, @Arg(desc = "BiomeType") BiomeType biome) throws ExpressionException {
|
|
||||||
return new BiomeMask(extent, biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "%",
|
|
||||||
aliases = {"#%", "#percent"},
|
|
||||||
desc = "percentage chance"
|
|
||||||
)
|
|
||||||
public Mask random(@Arg(desc = "double chance") double chance) throws ExpressionException {
|
|
||||||
chance = chance / 100;
|
|
||||||
return new RandomMask(chance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "=",
|
|
||||||
aliases = {"#=", "#expression"},
|
|
||||||
desc = "expression mask"
|
|
||||||
)
|
|
||||||
public Mask expression(Extent extent, @Arg(desc = "String expression") String input) throws ExpressionException {
|
|
||||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
|
||||||
ExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
|
||||||
exp.setEnvironment(env);
|
|
||||||
return new ExpressionMask(exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "!",
|
|
||||||
aliases = {"#not", "#negate", "#!"},
|
|
||||||
desc = "Negate another mask"
|
|
||||||
)
|
|
||||||
public Mask negate(@Arg(desc = "Mask") Mask mask) throws ExpressionException {
|
|
||||||
return Masks.negate(mask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,403 +1,404 @@
|
|||||||
package com.sk89q.worldedit.command;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.sk89q.worldedit.command;
|
||||||
import com.boydti.fawe.object.DataAnglePattern;
|
//
|
||||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
//import com.boydti.fawe.object.DataAnglePattern;
|
||||||
import com.boydti.fawe.object.collection.RandomCollection;
|
//import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||||
import com.boydti.fawe.object.pattern.AngleColorPattern;
|
//import com.boydti.fawe.object.collection.RandomCollection;
|
||||||
import com.boydti.fawe.object.pattern.AverageColorPattern;
|
//import com.boydti.fawe.object.pattern.AngleColorPattern;
|
||||||
import com.boydti.fawe.object.pattern.BiomePattern;
|
//import com.boydti.fawe.object.pattern.AverageColorPattern;
|
||||||
import com.boydti.fawe.object.pattern.BufferedPattern;
|
//import com.boydti.fawe.object.pattern.BiomePattern;
|
||||||
import com.boydti.fawe.object.pattern.BufferedPattern2D;
|
//import com.boydti.fawe.object.pattern.BufferedPattern;
|
||||||
import com.boydti.fawe.object.pattern.DataPattern;
|
//import com.boydti.fawe.object.pattern.BufferedPattern2D;
|
||||||
import com.boydti.fawe.object.pattern.DesaturatePattern;
|
//import com.boydti.fawe.object.pattern.DataPattern;
|
||||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
//import com.boydti.fawe.object.pattern.DesaturatePattern;
|
||||||
import com.boydti.fawe.object.pattern.ExpressionPattern;
|
//import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||||
import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
//import com.boydti.fawe.object.pattern.ExpressionPattern;
|
||||||
import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
//import com.boydti.fawe.object.pattern.FullClipboardPattern;
|
||||||
import com.boydti.fawe.object.pattern.IdPattern;
|
//import com.boydti.fawe.object.pattern.IdDataMaskPattern;
|
||||||
import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
//import com.boydti.fawe.object.pattern.IdPattern;
|
||||||
import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
//import com.boydti.fawe.object.pattern.Linear2DBlockPattern;
|
||||||
import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
//import com.boydti.fawe.object.pattern.Linear3DBlockPattern;
|
||||||
import com.boydti.fawe.object.pattern.MaskedPattern;
|
//import com.boydti.fawe.object.pattern.LinearBlockPattern;
|
||||||
import com.boydti.fawe.object.pattern.NoXPattern;
|
//import com.boydti.fawe.object.pattern.MaskedPattern;
|
||||||
import com.boydti.fawe.object.pattern.NoYPattern;
|
//import com.boydti.fawe.object.pattern.NoXPattern;
|
||||||
import com.boydti.fawe.object.pattern.NoZPattern;
|
//import com.boydti.fawe.object.pattern.NoYPattern;
|
||||||
import com.boydti.fawe.object.pattern.OffsetPattern;
|
//import com.boydti.fawe.object.pattern.NoZPattern;
|
||||||
import com.boydti.fawe.object.pattern.PropertyPattern;
|
//import com.boydti.fawe.object.pattern.OffsetPattern;
|
||||||
import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
|
//import com.boydti.fawe.object.pattern.PropertyPattern;
|
||||||
import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
//import com.boydti.fawe.object.pattern.RandomFullClipboardPattern;
|
||||||
import com.boydti.fawe.object.pattern.RelativePattern;
|
//import com.boydti.fawe.object.pattern.RandomOffsetPattern;
|
||||||
import com.boydti.fawe.object.pattern.SaturatePattern;
|
//import com.boydti.fawe.object.pattern.RelativePattern;
|
||||||
import com.boydti.fawe.object.pattern.ShadePattern;
|
//import com.boydti.fawe.object.pattern.SaturatePattern;
|
||||||
import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
//import com.boydti.fawe.object.pattern.ShadePattern;
|
||||||
import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
//import com.boydti.fawe.object.pattern.SolidRandomOffsetPattern;
|
||||||
import com.boydti.fawe.object.random.SimplexRandom;
|
//import com.boydti.fawe.object.pattern.SurfaceRandomOffsetPattern;
|
||||||
import com.boydti.fawe.util.ColorUtil;
|
//import com.boydti.fawe.object.random.SimplexRandom;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
//import com.boydti.fawe.util.ColorUtil;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
//import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
//import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
//import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
//import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
//import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
//import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
//import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.function.pattern.ClipboardPattern;
|
//import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
//import com.sk89q.worldedit.function.pattern.ClipboardPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
//import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
//import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
//import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
//import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
//import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import java.awt.Color;
|
//import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import java.io.IOException;
|
//import java.awt.Color;
|
||||||
import java.util.Collections;
|
//import java.io.IOException;
|
||||||
import java.util.List;
|
//import java.util.Collections;
|
||||||
import java.util.Set;
|
//import java.util.List;
|
||||||
import org.enginehub.piston.annotation.Command;
|
//import java.util.Set;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
//import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
//import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.jetbrains.annotations.Range;
|
//import org.enginehub.piston.annotation.param.Arg;
|
||||||
|
//import org.jetbrains.annotations.Range;
|
||||||
//@Command(aliases = {"patterns"},
|
//
|
||||||
// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
|
////@Command(aliases = {"patterns"},
|
||||||
// descFooter = "Patterns determine what blocks are placed\n" +
|
//// desc = "Help for the various patterns. [More Info](https://git.io/vSPmA)",
|
||||||
// " - Use [brackets] for arguments\n" +
|
//// descFooter = "Patterns determine what blocks are placed\n" +
|
||||||
// " - Use , to OR multiple\n" +
|
//// " - Use [brackets] for arguments\n" +
|
||||||
// "e.g., #surfacespread[10][#existing],andesite\n" +
|
//// " - Use , to OR multiple\n" +
|
||||||
// "More Info: https://git.io/vSPmA"
|
//// "e.g., #surfacespread[10][#existing],andesite\n" +
|
||||||
|
//// "More Info: https://git.io/vSPmA"
|
||||||
|
////)
|
||||||
|
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
|
//public class PatternCommands {
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#existing",
|
||||||
|
// aliases = {"#*", "*", ".*"},
|
||||||
|
// desc = "Use the block that is already there"
|
||||||
|
// )
|
||||||
|
// public Pattern existing(Extent extent, @Arg(desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
|
||||||
|
// if (properties == null) return new ExistingPattern(extent);
|
||||||
|
// return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#clipboard",
|
||||||
|
// aliases = {"#copy"},
|
||||||
|
// desc = "Use the blocks in your clipboard as the pattern")
|
||||||
|
// public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
|
||||||
|
// ClipboardHolder holder = session.getClipboard();
|
||||||
|
// Clipboard clipboard = holder.getClipboard();
|
||||||
|
// return new ClipboardPattern(clipboard);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Command(
|
||||||
|
// name = "#simplex",
|
||||||
|
// desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
|
||||||
//)
|
//)
|
||||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
// public Pattern simplex(@Arg(desc = "scale factor") double scale, @Arg(desc = "Pattern") Pattern other) {
|
||||||
public class PatternCommands {
|
// if (other instanceof RandomPattern) {
|
||||||
|
// scale = (1d / Math.max(1, scale));
|
||||||
@Command(
|
// RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
|
||||||
name = "#existing",
|
// collection.setRandom(new SimplexRandom(scale));
|
||||||
aliases = {"#*", "*", ".*"},
|
// }
|
||||||
desc = "Use the block that is already there"
|
// return other;
|
||||||
)
|
// }
|
||||||
public Pattern existing(Extent extent, @Arg(desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
|
//
|
||||||
if (properties == null) return new ExistingPattern(extent);
|
// @Command(
|
||||||
return new PropertyPattern(extent).addRegex(".*[" + properties + "]");
|
// name = "#color",
|
||||||
}
|
// desc = "Use the block closest to a specific color"
|
||||||
|
//)
|
||||||
@Command(
|
// public Pattern color(TextureUtil textureUtil, @Arg(desc = "String color") String color) {
|
||||||
name = "#clipboard",
|
// Color colorObj = ColorUtil.parseColor(color);
|
||||||
aliases = {"#copy"},
|
// return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
|
||||||
desc = "Use the blocks in your clipboard as the pattern")
|
// }
|
||||||
public Pattern clipboard(LocalSession session) throws EmptyClipboardException {
|
//
|
||||||
ClipboardHolder holder = session.getClipboard();
|
// @Command(
|
||||||
Clipboard clipboard = holder.getClipboard();
|
// name = "#anglecolor",
|
||||||
return new ClipboardPattern(clipboard);
|
// desc = "A darker block based on the existing terrain angle"
|
||||||
}
|
//)
|
||||||
|
// public Pattern anglecolor(Extent extent, LocalSession session, @Arg(desc = "int", def = "1") int distance) {
|
||||||
@Command(
|
// return new AngleColorPattern(extent, session, distance);
|
||||||
name = "#simplex",
|
// }
|
||||||
desc = "Use simplex noise to randomize blocks. Tutorial: https://imgur.com/a/rwVAE"
|
//
|
||||||
)
|
// @Command(
|
||||||
public Pattern simplex(@Arg(desc = "scale factor") double scale, @Arg(desc = "Pattern") Pattern other) {
|
// name = "#angledata",
|
||||||
if (other instanceof RandomPattern) {
|
// desc = "Block data based on the existing terrain angle"
|
||||||
scale = (1d / Math.max(1, scale));
|
// )
|
||||||
RandomCollection<Pattern> collection = ((RandomPattern) other).getCollection();
|
// public Pattern angledata(Extent extent, @Arg(desc = "int", def = "1") int distance) {
|
||||||
collection.setRandom(new SimplexRandom(scale));
|
// return new DataAnglePattern(extent, distance);
|
||||||
}
|
// }
|
||||||
return other;
|
//
|
||||||
}
|
// @Command(
|
||||||
|
// name = "#saturate",
|
||||||
@Command(
|
// desc = "Saturate the existing block with a color"
|
||||||
name = "#color",
|
//)
|
||||||
desc = "Use the block closest to a specific color"
|
// public Pattern saturate(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||||
)
|
// Color color = ColorUtil.parseColor(colorStr);
|
||||||
public Pattern color(TextureUtil textureUtil, @Arg(desc = "String color") String color) {
|
// return new SaturatePattern(extent, color.getRGB(), session);
|
||||||
Color colorObj = ColorUtil.parseColor(color);
|
// }
|
||||||
return textureUtil.getNearestBlock(colorObj.getRGB()).getDefaultState();
|
//
|
||||||
}
|
// @Command(
|
||||||
|
// name = "#averagecolor",
|
||||||
@Command(
|
// desc = "Average between the existing block and a color"
|
||||||
name = "#anglecolor",
|
//)
|
||||||
desc = "A darker block based on the existing terrain angle"
|
// public Pattern averagecolor(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
||||||
)
|
// Color color = ColorUtil.parseColor(colorStr);
|
||||||
public Pattern anglecolor(Extent extent, LocalSession session, @Arg(desc = "int", def = "1") int distance) {
|
// return new AverageColorPattern(extent, color.getRGB(), session);
|
||||||
return new AngleColorPattern(extent, session, distance);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Command(
|
||||||
@Command(
|
// name = "#desaturate",
|
||||||
name = "#angledata",
|
// desc = "Desaturated color of the existing block"
|
||||||
desc = "Block data based on the existing terrain angle"
|
//)
|
||||||
)
|
// public Pattern desaturate(Extent extent, LocalSession session, @Arg(desc = "double", def = "100") double percent) {
|
||||||
public Pattern angledata(Extent extent, @Arg(desc = "int", def = "1") int distance) {
|
// return new DesaturatePattern(extent, percent / 100d, session);
|
||||||
return new DataAnglePattern(extent, distance);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Command(
|
||||||
@Command(
|
// name = "#lighten",
|
||||||
name = "#saturate",
|
// desc = "Lighten the existing block"
|
||||||
desc = "Saturate the existing block with a color"
|
//)
|
||||||
)
|
// public Pattern lighten(Extent extent, TextureUtil util) {
|
||||||
public Pattern saturate(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
// return new ShadePattern(extent, false, util);
|
||||||
Color color = ColorUtil.parseColor(colorStr);
|
// }
|
||||||
return new SaturatePattern(extent, color.getRGB(), session);
|
//
|
||||||
}
|
// @Command(
|
||||||
|
// name = "#darken",
|
||||||
@Command(
|
// desc = "Darken the existing block"
|
||||||
name = "#averagecolor",
|
//)
|
||||||
desc = "Average between the existing block and a color"
|
// public Pattern darken(Extent extent, TextureUtil util) {
|
||||||
)
|
// return new ShadePattern(extent, true, util);
|
||||||
public Pattern averagecolor(Extent extent, LocalSession session, @Arg(desc = "Color code") String colorStr) {
|
// }
|
||||||
Color color = ColorUtil.parseColor(colorStr);
|
//
|
||||||
return new AverageColorPattern(extent, color.getRGB(), session);
|
// @Command(
|
||||||
}
|
// name = "#fullcopy",
|
||||||
|
// desc = "Places your full clipboard at each block"
|
||||||
@Command(
|
//)
|
||||||
name = "#desaturate",
|
// public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(desc = "String", def = "#copy") String location, @Arg(desc = "boolean", def = "false") boolean rotate, @Arg(desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
|
||||||
desc = "Desaturated color of the existing block"
|
// List<ClipboardHolder> clipboards;
|
||||||
)
|
// switch (location.toLowerCase()) {
|
||||||
public Pattern desaturate(Extent extent, LocalSession session, @Arg(desc = "double", def = "100") double percent) {
|
// case "#copy":
|
||||||
return new DesaturatePattern(extent, percent / 100d, session);
|
// case "#clipboard":
|
||||||
}
|
// ClipboardHolder clipboard = session.getExistingClipboard();
|
||||||
|
// if (clipboard == null) {
|
||||||
@Command(
|
// throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
|
||||||
name = "#lighten",
|
// }
|
||||||
desc = "Lighten the existing block"
|
// if (!rotate && !flip) {
|
||||||
)
|
// return new FullClipboardPattern(extent, clipboard.getClipboard());
|
||||||
public Pattern lighten(Extent extent, TextureUtil util) {
|
// }
|
||||||
return new ShadePattern(extent, false, util);
|
// clipboards = Collections.singletonList(clipboard);
|
||||||
}
|
// break;
|
||||||
|
// default:
|
||||||
@Command(
|
// MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
|
||||||
name = "#darken",
|
// clipboards = multi != null ? multi.getHolders() : null;
|
||||||
desc = "Darken the existing block"
|
// break;
|
||||||
)
|
// }
|
||||||
public Pattern darken(Extent extent, TextureUtil util) {
|
// if (clipboards == null) {
|
||||||
return new ShadePattern(extent, true, util);
|
// throw new InputParseException("#fullcopy:<source>");
|
||||||
}
|
// }
|
||||||
|
// return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
|
||||||
@Command(
|
// }
|
||||||
name = "#fullcopy",
|
//
|
||||||
desc = "Places your full clipboard at each block"
|
// @Command(
|
||||||
)
|
// name = "#buffer",
|
||||||
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Arg(desc = "String", def = "#copy") String location, @Arg(desc = "boolean", def = "false") boolean rotate, @Arg(desc = "boolean", def = "false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
|
// desc = "Only place a block once while a pattern is in use",
|
||||||
List<ClipboardHolder> clipboards;
|
// descFooter = "Only place a block once while a pattern is in use\n" +
|
||||||
switch (location.toLowerCase()) {
|
// "Use with a brush when you don't want to apply to the same spot twice"
|
||||||
case "#copy":
|
//)
|
||||||
case "#clipboard":
|
// public Pattern buffer(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
ClipboardHolder clipboard = session.getExistingClipboard();
|
// return new BufferedPattern(actor, pattern);
|
||||||
if (clipboard == null) {
|
// }
|
||||||
throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
|
//
|
||||||
}
|
// @Command(
|
||||||
if (!rotate && !flip) {
|
// name = "#buffer2d",
|
||||||
return new FullClipboardPattern(extent, clipboard.getClipboard());
|
// desc = "Only place a block once in a column while a pattern is in use"
|
||||||
}
|
//)
|
||||||
clipboards = Collections.singletonList(clipboard);
|
// public Pattern buffer2d(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
break;
|
// return new BufferedPattern2D(actor, pattern);
|
||||||
default:
|
// }
|
||||||
MultiClipboardHolder multi = ClipboardFormats.loadAllFromInput(player, location, null, true);
|
//
|
||||||
clipboards = multi != null ? multi.getHolders() : null;
|
// @Command(
|
||||||
break;
|
// name = "#iddatamask",
|
||||||
}
|
// desc = "Use the pattern's id and the existing blocks data with the provided mask",
|
||||||
if (clipboards == null) {
|
// descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
|
||||||
throw new InputParseException("#fullcopy:<source>");
|
// " - Use to replace slabs or where the data values needs to be shifted instead of set"
|
||||||
}
|
//)
|
||||||
return new RandomFullClipboardPattern(extent, clipboards, rotate, flip);
|
// public Pattern iddatamask(Extent extent, @Range(from = 0, to = 15) @Arg(desc = "bit mask") int bitmask, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
}
|
//
|
||||||
|
// return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||||
@Command(
|
// }
|
||||||
name = "#buffer",
|
//
|
||||||
desc = "Only place a block once while a pattern is in use",
|
// @Command(
|
||||||
descFooter = "Only place a block once while a pattern is in use\n" +
|
// name = "#id",
|
||||||
"Use with a brush when you don't want to apply to the same spot twice"
|
// desc = "Only change the block id"
|
||||||
)
|
//)
|
||||||
public Pattern buffer(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
// public Pattern id(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
return new BufferedPattern(actor, pattern);
|
//
|
||||||
}
|
// return new IdPattern(extent, pattern);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#buffer2d",
|
// @Command(
|
||||||
desc = "Only place a block once in a column while a pattern is in use"
|
// name = "#data",
|
||||||
)
|
// desc = "Only change the block data"
|
||||||
public Pattern buffer2d(Actor actor, @Arg(desc = "Pattern")Pattern pattern) {
|
//)
|
||||||
return new BufferedPattern2D(actor, pattern);
|
// public Pattern data(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
}
|
//
|
||||||
|
// return new DataPattern(extent, pattern);
|
||||||
@Command(
|
// }
|
||||||
name = "#iddatamask",
|
//
|
||||||
desc = "Use the pattern's id and the existing blocks data with the provided mask",
|
// @Command(
|
||||||
descFooter = "Use the pattern's id and the existing blocks data with the provided mask\n" +
|
// name = "#biome",
|
||||||
" - Use to replace slabs or where the data values needs to be shifted instead of set"
|
// aliases = {"$"},
|
||||||
)
|
// desc = "Set the biome"
|
||||||
public Pattern iddatamask(Extent extent, @Range(from = 0, to = 15) @Arg(desc = "bit mask") int bitmask, @Arg(desc = "Pattern")Pattern pattern) {
|
//)
|
||||||
|
// public Pattern biome(Extent extent, @Arg(desc = "Biome type") BiomeType biome) {
|
||||||
return new IdDataMaskPattern(extent, pattern, bitmask);
|
//
|
||||||
}
|
// return new BiomePattern(extent, biome);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#id",
|
// @Command(
|
||||||
desc = "Only change the block id"
|
// name = "#relative",
|
||||||
)
|
// aliases = {"#~", "#r", "#rel"},
|
||||||
public Pattern id(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
// desc = "Offset the pattern to where you click"
|
||||||
|
//)
|
||||||
return new IdPattern(extent, pattern);
|
// public Pattern relative(@Arg(desc = "Pattern")Pattern pattern) {
|
||||||
}
|
//
|
||||||
|
// return new RelativePattern(pattern);
|
||||||
@Command(
|
// }
|
||||||
name = "#data",
|
//
|
||||||
desc = "Only change the block data"
|
// @Command(
|
||||||
)
|
// name = "#!x",
|
||||||
public Pattern data(Extent extent, @Arg(desc = "Pattern")Pattern pattern) {
|
// aliases = {"#nx", "#nox"},
|
||||||
|
// desc = "The pattern will not be provided the x axis info",
|
||||||
return new DataPattern(extent, pattern);
|
// descFooter = "The pattern will not be provided the z axis info.\n" +
|
||||||
}
|
// "Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
||||||
|
//)
|
||||||
@Command(
|
// public Pattern nox(@Arg(desc = "Pattern")Pattern pattern) {
|
||||||
name = "#biome",
|
//
|
||||||
aliases = {"$"},
|
// return new NoXPattern(pattern);
|
||||||
desc = "Set the biome"
|
// }
|
||||||
)
|
//
|
||||||
public Pattern biome(Extent extent, @Arg(desc = "Biome type") BiomeType biome) {
|
// @Command(
|
||||||
|
// name = "#!y",
|
||||||
return new BiomePattern(extent, biome);
|
// aliases = {"#ny", "#noy"},
|
||||||
}
|
// desc = "The pattern will not be provided the y axis info"
|
||||||
|
//)
|
||||||
@Command(
|
// public Pattern noy(@Arg(desc = "Pattern")Pattern pattern) {
|
||||||
name = "#relative",
|
//
|
||||||
aliases = {"#~", "#r", "#rel"},
|
// return new NoYPattern(pattern);
|
||||||
desc = "Offset the pattern to where you click"
|
// }
|
||||||
)
|
//
|
||||||
public Pattern relative(@Arg(desc = "Pattern")Pattern pattern) {
|
// @Command(
|
||||||
|
// name = "#!z",
|
||||||
return new RelativePattern(pattern);
|
// aliases = {"#nz", "#noz"},
|
||||||
}
|
// desc = "The pattern will not be provided the z axis info"
|
||||||
|
//)
|
||||||
@Command(
|
// public Pattern noz(@Arg(desc = "Pattern")Pattern pattern) {
|
||||||
name = "#!x",
|
//
|
||||||
aliases = {"#nx", "#nox"},
|
// return new NoZPattern(pattern);
|
||||||
desc = "The pattern will not be provided the x axis info",
|
// }
|
||||||
descFooter = "The pattern will not be provided the z axis info.\n" +
|
//
|
||||||
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
// @Command(
|
||||||
)
|
// name = "#mask",
|
||||||
public Pattern nox(@Arg(desc = "Pattern")Pattern pattern) {
|
// desc = "Apply a pattern depending on a mask"
|
||||||
|
//)
|
||||||
return new NoXPattern(pattern);
|
// public Pattern mask(@Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern")Pattern pass, @Arg(desc = "Pattern")Pattern fail) {
|
||||||
}
|
// return new MaskedPattern(mask, pass, fail);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#!y",
|
// @Command(
|
||||||
aliases = {"#ny", "#noy"},
|
// name = "#offset",
|
||||||
desc = "The pattern will not be provided the y axis info"
|
// desc = "Offset a pattern"
|
||||||
)
|
//)
|
||||||
public Pattern noy(@Arg(desc = "Pattern")Pattern pattern) {
|
// public Pattern offset(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
|
//
|
||||||
return new NoYPattern(pattern);
|
// return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Command(
|
// @Command(
|
||||||
name = "#!z",
|
// name = "#surfacespread",
|
||||||
aliases = {"#nz", "#noz"},
|
// desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given randomized offset `[0, <distance>)`. e.g., Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
||||||
desc = "The pattern will not be provided the z axis info"
|
//)
|
||||||
)
|
// public Pattern surfacespread(@Arg(desc = "spread distance (blocks)") double distance, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
public Pattern noz(@Arg(desc = "Pattern")Pattern pattern) {
|
//
|
||||||
|
// return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||||
return new NoZPattern(pattern);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Command(
|
||||||
@Command(
|
// name = "#solidspread",
|
||||||
name = "#mask",
|
// desc = "Randomly spread solid blocks"
|
||||||
desc = "Apply a pattern depending on a mask"
|
//)
|
||||||
)
|
// public Pattern solidspread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
public Pattern mask(@Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern")Pattern pass, @Arg(desc = "Pattern")Pattern fail) {
|
//
|
||||||
return new MaskedPattern(mask, pass, fail);
|
// return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Command(
|
// @Command(
|
||||||
name = "#offset",
|
// name = "#spread",
|
||||||
desc = "Offset a pattern"
|
// aliases = {"#randomoffset"},
|
||||||
)
|
// desc = "Randomly spread blocks"
|
||||||
public Pattern offset(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
//)
|
||||||
|
// public Pattern spread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
||||||
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
//
|
||||||
}
|
// return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#surfacespread",
|
// @Command(
|
||||||
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given randomized offset `[0, <distance>)`. e.g., Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
// name = "#linear",
|
||||||
)
|
// aliases = {"#l"},
|
||||||
public Pattern surfacespread(@Arg(desc = "spread distance (blocks)") double distance, @Arg(desc = "Pattern")Pattern pattern) {
|
// desc = "Sequentially set blocks from a list of patterns"
|
||||||
|
//)
|
||||||
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
// public Pattern linear(@Arg(desc = "Pattern") Pattern other) {
|
||||||
}
|
//
|
||||||
|
// if (other instanceof RandomPattern) {
|
||||||
@Command(
|
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
name = "#solidspread",
|
// return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
desc = "Randomly spread solid blocks"
|
// }
|
||||||
)
|
// return other;
|
||||||
public Pattern solidspread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
// }
|
||||||
|
//
|
||||||
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
// @Command(
|
||||||
}
|
// name = "#linear3d",
|
||||||
|
// aliases = {"#l3d"},
|
||||||
@Command(
|
// desc = "Use the x,y,z coordinate to pick a block from the list"
|
||||||
name = "#spread",
|
//)
|
||||||
aliases = {"#randomoffset"},
|
// public Pattern linear3d(@Arg(desc = "Pattern") Pattern other) {
|
||||||
desc = "Randomly spread blocks"
|
//
|
||||||
)
|
// if (other instanceof RandomPattern) {
|
||||||
public Pattern spread(@Arg(desc = "x offset") double x, @Arg(desc = "y offset") double y, @Arg(desc = "z offset") double z, @Arg(desc = "Pattern")Pattern pattern) {
|
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
|
// return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
// }
|
||||||
}
|
// return other;
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#linear",
|
// @Command(
|
||||||
aliases = {"#l"},
|
// name = "#linear2d",
|
||||||
desc = "Sequentially set blocks from a list of patterns"
|
// aliases = {"#l2d"},
|
||||||
)
|
// desc = "Use the x,z coordinate to pick a block from the list"
|
||||||
public Pattern linear(@Arg(desc = "Pattern") Pattern other) {
|
//)
|
||||||
|
// public Pattern linear2d(@Arg(desc = "Pattern") Pattern other) {
|
||||||
if (other instanceof RandomPattern) {
|
//
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
// if (other instanceof RandomPattern) {
|
||||||
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
// Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
}
|
// return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
return other;
|
// }
|
||||||
}
|
// return other;
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#linear3d",
|
// @Command(
|
||||||
aliases = {"#l3d"},
|
// name = "=",
|
||||||
desc = "Use the x,y,z coordinate to pick a block from the list"
|
// aliases = {"#=", "#expression"},
|
||||||
)
|
// desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
||||||
public Pattern linear3d(@Arg(desc = "Pattern") Pattern other) {
|
//)
|
||||||
|
// public Pattern expression(Extent extent, @Arg(desc = "Expression") String input) throws ExpressionException {
|
||||||
if (other instanceof RandomPattern) {
|
//
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
// Expression exp = Expression.compile(input, "x", "y", "z");
|
||||||
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
// WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||||
}
|
// exp.setEnvironment(env);
|
||||||
return other;
|
// return new ExpressionPattern(exp);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
@Command(
|
|
||||||
name = "#linear2d",
|
|
||||||
aliases = {"#l2d"},
|
|
||||||
desc = "Use the x,z coordinate to pick a block from the list"
|
|
||||||
)
|
|
||||||
public Pattern linear2d(@Arg(desc = "Pattern") Pattern other) {
|
|
||||||
|
|
||||||
if (other instanceof RandomPattern) {
|
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
|
||||||
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
|
||||||
}
|
|
||||||
return other;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "=",
|
|
||||||
aliases = {"#=", "#expression"},
|
|
||||||
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
|
||||||
)
|
|
||||||
public Pattern expression(Extent extent, @Arg(desc = "Expression") String input) throws ExpressionException {
|
|
||||||
|
|
||||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
|
||||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
|
||||||
exp.setEnvironment(env);
|
|
||||||
return new ExpressionPattern(exp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -84,7 +84,6 @@ public class ToolUtilCommands {
|
|||||||
if (maskOpt == null) {
|
if (maskOpt == null) {
|
||||||
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.disabled"));
|
player.printInfo(TranslatableComponent.of("worldedit.tool.mask.disabled"));
|
||||||
tool.setMask(null);
|
tool.setMask(null);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get()))
|
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get()))
|
||||||
@ -151,17 +150,6 @@ public class ToolUtilCommands {
|
|||||||
player.printInfo(TranslatableComponent.of("worldedit.tool.size.set"));
|
player.printInfo(TranslatableComponent.of("worldedit.tool.size.set"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo none should be moved to the same class where it is in upstream
|
|
||||||
@Command(
|
|
||||||
name = "none",
|
|
||||||
aliases = {"/none"},
|
|
||||||
desc = "Unbind a bound tool from your current item"
|
|
||||||
)
|
|
||||||
public void none(Player player, LocalSession session) throws WorldEditException {
|
|
||||||
session.setTool(player, null);
|
|
||||||
player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.none"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "tracemask",
|
name = "tracemask",
|
||||||
aliases = {"tarmask", "tm", "targetmask"},
|
aliases = {"tarmask", "tm", "targetmask"},
|
||||||
@ -368,31 +356,32 @@ public class ToolUtilCommands {
|
|||||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.source.mask"));
|
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.source.mask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
name = "transform",
|
// @Command(
|
||||||
desc = "Set the brush transform"
|
// name = "transform",
|
||||||
)
|
// desc = "Set the brush transform"
|
||||||
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
// )
|
||||||
public void transform(Player player, LocalSession session, EditSession editSession,
|
// @CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
||||||
@Arg(desc = "The transform", def = "") ResettableExtent transform,
|
// public void transform(Player player, LocalSession session, EditSession editSession,
|
||||||
@Switch(name = 'h', desc = "TODO")
|
// @Arg(desc = "The transform", def = "") ResettableExtent transform,
|
||||||
boolean offHand,
|
// @Switch(name = 'h', desc = "TODO")
|
||||||
Arguments arguments) throws WorldEditException {
|
// boolean offHand,
|
||||||
BrushTool tool = session.getBrushTool(player, false);
|
// Arguments arguments) throws WorldEditException {
|
||||||
if (tool == null) {
|
// BrushTool tool = session.getBrushTool(player, false);
|
||||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
// if (tool == null) {
|
||||||
return;
|
// player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
|
||||||
}
|
// return;
|
||||||
if (transform == null) {
|
// }
|
||||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform.disabled"));
|
// if (transform == null) {
|
||||||
tool.setTransform(null);
|
// player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform.disabled"));
|
||||||
return;
|
// tool.setTransform(null);
|
||||||
}
|
// return;
|
||||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
// }
|
||||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
// BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||||
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
|
// String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||||
settings.setTransform(transform);
|
// settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
|
||||||
tool.update();
|
// settings.setTransform(transform);
|
||||||
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform"));
|
// tool.update();
|
||||||
}
|
// player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.transform"));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -1,104 +1,105 @@
|
|||||||
package com.sk89q.worldedit.command;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.sk89q.worldedit.command;
|
||||||
import com.boydti.fawe.object.extent.Linear3DTransform;
|
//
|
||||||
import com.boydti.fawe.object.extent.LinearTransform;
|
//import com.boydti.fawe.object.extent.Linear3DTransform;
|
||||||
import com.boydti.fawe.object.extent.OffsetExtent;
|
//import com.boydti.fawe.object.extent.LinearTransform;
|
||||||
import com.boydti.fawe.object.extent.PatternTransform;
|
//import com.boydti.fawe.object.extent.OffsetExtent;
|
||||||
import com.boydti.fawe.object.extent.RandomOffsetTransform;
|
//import com.boydti.fawe.object.extent.PatternTransform;
|
||||||
import com.boydti.fawe.object.extent.RandomTransform;
|
//import com.boydti.fawe.object.extent.RandomOffsetTransform;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
//import com.boydti.fawe.object.extent.RandomTransform;
|
||||||
import com.boydti.fawe.object.extent.ScaleTransform;
|
//import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.object.extent.TransformExtent;
|
//import com.boydti.fawe.object.extent.ScaleTransform;
|
||||||
import com.boydti.fawe.util.ExtentTraverser;
|
//import com.boydti.fawe.object.extent.TransformExtent;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
//import com.boydti.fawe.util.ExtentTraverser;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
//import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
//import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
//import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import java.util.Set;
|
//import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import org.enginehub.piston.annotation.Command;
|
//import java.util.Set;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
//import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
//import org.enginehub.piston.annotation.CommandContainer;
|
||||||
|
//import org.enginehub.piston.annotation.param.Arg;
|
||||||
@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
//
|
||||||
public class TransformCommands {
|
//@CommandContainer//(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
|
//public class TransformCommands {
|
||||||
@Command(
|
//
|
||||||
name = "#linear",
|
// @Command(
|
||||||
aliases = {"#l"},
|
// name = "#linear",
|
||||||
desc = "Sequentially pick from a list of transform"
|
// aliases = {"#l"},
|
||||||
)
|
// desc = "Sequentially pick from a list of transform"
|
||||||
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
if (other instanceof RandomTransform) {
|
// public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
// if (other instanceof RandomTransform) {
|
||||||
return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||||
}
|
// return new LinearTransform(extents.toArray(new ResettableExtent[0]));
|
||||||
return other;
|
// }
|
||||||
}
|
// return other;
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#linear3d",
|
// @Command(
|
||||||
aliases = {"#l3d"},
|
// name = "#linear3d",
|
||||||
desc = "Use the x,y,z coordinate to pick a transform from the list"
|
// aliases = {"#l3d"},
|
||||||
)
|
// desc = "Use the x,y,z coordinate to pick a transform from the list"
|
||||||
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
if (other instanceof RandomTransform) {
|
// public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
// if (other instanceof RandomTransform) {
|
||||||
return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
// Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
|
||||||
}
|
// return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
|
||||||
return other;
|
// }
|
||||||
}
|
// return other;
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#pattern",
|
// @Command(
|
||||||
desc = "Always use a specific pattern"
|
// name = "#pattern",
|
||||||
)
|
// desc = "Always use a specific pattern"
|
||||||
public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
return new PatternTransform(other, pattern);
|
// public ResettableExtent pattern(Actor actor, LocalSession session, @Arg(desc = "Pattern") Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
}
|
// return new PatternTransform(other, pattern);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#offset",
|
// @Command(
|
||||||
desc = "Offset transform"
|
// name = "#offset",
|
||||||
)
|
// desc = "Offset transform"
|
||||||
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
// public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
}
|
// return new OffsetExtent(other, (int) x, (int) y, (int) z);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#spread",
|
// @Command(
|
||||||
aliases = {"#randomoffset"},
|
// name = "#spread",
|
||||||
desc = "Random offset transform"
|
// aliases = {"#randomoffset"},
|
||||||
)
|
// desc = "Random offset transform"
|
||||||
public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
//)
|
||||||
return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
|
// public ResettableExtent randomOffset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
}
|
// return new RandomOffsetTransform(other, (int) x, (int) y, (int) z);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#scale",
|
// @Command(
|
||||||
desc = "All changes will be scaled"
|
// name = "#scale",
|
||||||
)
|
// desc = "All changes will be scaled"
|
||||||
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
return new ScaleTransform(other, x, y, z);
|
// public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
}
|
// return new ScaleTransform(other, x, y, z);
|
||||||
|
// }
|
||||||
@Command(
|
//
|
||||||
name = "#rotate",
|
// @Command(
|
||||||
desc = "All changes will be rotate around the initial position"
|
// name = "#rotate",
|
||||||
)
|
// desc = "All changes will be rotate around the initial position"
|
||||||
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
// )
|
||||||
ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
|
// public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
|
||||||
BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
// ExtentTraverser<TransformExtent> traverser = new ExtentTraverser<>(other).find(TransformExtent.class);
|
||||||
if (affine == null) {
|
// BlockTransformExtent affine = traverser != null ? traverser.get() : null;
|
||||||
other = affine = new TransformExtent(other);
|
// if (affine == null) {
|
||||||
}
|
// other = affine = new TransformExtent(other);
|
||||||
AffineTransform transform = (AffineTransform) affine.getTransform();
|
// }
|
||||||
transform = transform.rotateX(x);
|
// AffineTransform transform = (AffineTransform) affine.getTransform();
|
||||||
transform = transform.rotateY(y);
|
// transform = transform.rotateX(x);
|
||||||
transform = transform.rotateZ(z);
|
// transform = transform.rotateY(y);
|
||||||
affine.setTransform(transform);
|
// transform = transform.rotateZ(z);
|
||||||
return other;
|
// affine.setTransform(transform);
|
||||||
}
|
// return other;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
@ -104,7 +104,6 @@ public final class RegistryConverter<V extends Keyed> implements ArgumentConvert
|
|||||||
: SuccessfulConversion.fromSingle(result);
|
: SuccessfulConversion.fromSingle(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSuggestions(String input) {
|
public List<String> getSuggestions(String input) {
|
||||||
return SuggestionHelper.getRegistrySuggestions(registry, input).collect(Collectors.toList());
|
return SuggestionHelper.getRegistrySuggestions(registry, input).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
@ -125,38 +125,39 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
public BrushTool() {
|
public BrushTool() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BrushTool fromString(Player player, LocalSession session, String json) throws CommandException, InputParseException {
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
Gson gson = new Gson();
|
// public static BrushTool fromString(Player player, LocalSession session, String json) throws CommandException, InputParseException {
|
||||||
Type type = new TypeToken<Map<String, Object>>() {
|
// Gson gson = new Gson();
|
||||||
}.getType();
|
// Type type = new TypeToken<Map<String, Object>>() {
|
||||||
Map<String, Object> root = gson.fromJson(json, type);
|
// }.getType();
|
||||||
if (root == null) {
|
// Map<String, Object> root = gson.fromJson(json, type);
|
||||||
getLogger(BrushTool.class).debug("Failed to load " + json);
|
// if (root == null) {
|
||||||
return new BrushTool();
|
// getLogger(BrushTool.class).debug("Failed to load " + json);
|
||||||
}
|
// return new BrushTool();
|
||||||
Map<String, Object> primary = (Map<String, Object>) root.get("primary");
|
// }
|
||||||
Map<String, Object> secondary = (Map<String, Object>) root.getOrDefault("secondary", primary);
|
// Map<String, Object> primary = (Map<String, Object>) root.get("primary");
|
||||||
|
// Map<String, Object> secondary = (Map<String, Object>) root.getOrDefault("secondary", primary);
|
||||||
VisualMode visual = VisualMode.valueOf((String) root.getOrDefault("visual", "NONE"));
|
//
|
||||||
TargetMode target = TargetMode.valueOf((String) root.getOrDefault("target", "TARGET_BLOCK_RANGE"));
|
// VisualMode visual = VisualMode.valueOf((String) root.getOrDefault("visual", "NONE"));
|
||||||
int range = ((Number) root.getOrDefault("range", -1)).intValue();
|
// TargetMode target = TargetMode.valueOf((String) root.getOrDefault("target", "TARGET_BLOCK_RANGE"));
|
||||||
int offset = ((Number) root.getOrDefault("offset", 0)).intValue();
|
// int range = ((Number) root.getOrDefault("range", -1)).intValue();
|
||||||
|
// int offset = ((Number) root.getOrDefault("offset", 0)).intValue();
|
||||||
BrushTool tool = new BrushTool();
|
//
|
||||||
tool.visualMode = visual;
|
// BrushTool tool = new BrushTool();
|
||||||
tool.targetMode = target;
|
// tool.visualMode = visual;
|
||||||
tool.range = range;
|
// tool.targetMode = target;
|
||||||
tool.targetOffset = offset;
|
// tool.range = range;
|
||||||
|
// tool.targetOffset = offset;
|
||||||
BrushSettings primarySettings = BrushSettings.get(tool, player, session, primary);
|
//
|
||||||
tool.setPrimary(primarySettings);
|
// BrushSettings primarySettings = BrushSettings.get(tool, player, session, primary);
|
||||||
if (primary != secondary) {
|
// tool.setPrimary(primarySettings);
|
||||||
BrushSettings secondarySettings = BrushSettings.get(tool, player, session, secondary);
|
// if (primary != secondary) {
|
||||||
tool.setSecondary(secondarySettings);
|
// BrushSettings secondarySettings = BrushSettings.get(tool, player, session, secondary);
|
||||||
}
|
// tool.setSecondary(secondarySettings);
|
||||||
|
// }
|
||||||
return tool;
|
//
|
||||||
}
|
// return tool;
|
||||||
|
// }
|
||||||
|
|
||||||
public void setHolder(BaseItem holder) {
|
public void setHolder(BaseItem holder) {
|
||||||
this.holder = holder;
|
this.holder = holder;
|
||||||
|
@ -103,7 +103,7 @@ public final class AsyncCommandBuilder<T> {
|
|||||||
|
|
||||||
public AsyncCommandBuilder<T> onSuccess(@Nullable String message, @Nullable Consumer<T> consumer) {
|
public AsyncCommandBuilder<T> onSuccess(@Nullable String message, @Nullable Consumer<T> consumer) {
|
||||||
checkArgument(message != null || consumer != null, "Can't have null message AND consumer");
|
checkArgument(message != null || consumer != null, "Can't have null message AND consumer");
|
||||||
this.successMessage = message == null ? null : TextComponent.of(message, TextColor.GRAY);
|
this.successMessage = message == null ? null : TextComponent.of(message, TextColor.LIGHT_PURPLE);
|
||||||
this.consumer = consumer;
|
this.consumer = consumer;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.gen.CommandConditionGenerator;
|
import org.enginehub.piston.gen.CommandConditionGenerator;
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
package com.sk89q.worldedit.command.util;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import org.enginehub.piston.Command;
|
|
||||||
import org.enginehub.piston.CommandManager;
|
|
||||||
import org.enginehub.piston.CommandParseResult;
|
|
||||||
import org.enginehub.piston.converter.ArgumentConverter;
|
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
|
||||||
import org.enginehub.piston.inject.Key;
|
|
||||||
import org.enginehub.piston.suggestion.Suggestion;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class DelegateCommandManager implements CommandManager {
|
|
||||||
@Override
|
|
||||||
public Command.Builder newCommand(String s) {
|
|
||||||
return parent.newCommand(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(Command command) {
|
|
||||||
parent.register(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(String name, Consumer<Command.Builder> registrationProcess) {
|
|
||||||
parent.register(name, registrationProcess);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerManager(CommandManager manager) {
|
|
||||||
parent.registerManager(manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream<Command> getAllCommands() {
|
|
||||||
return parent.getAllCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean containsCommand(String name) {
|
|
||||||
return parent.containsCommand(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Command> getCommand(String s) {
|
|
||||||
return parent.getCommand(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImmutableSet<Suggestion> getSuggestions(InjectedValueAccess injectedValueAccess, List<String> list) {
|
|
||||||
return parent.getSuggestions(injectedValueAccess, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandParseResult parse(InjectedValueAccess injectedValueAccess, List<String> list) {
|
|
||||||
return parent.parse(injectedValueAccess, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(InjectedValueAccess context, List<String> args) {
|
|
||||||
return parent.execute(context, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> void registerConverter(Key<T> key, ArgumentConverter<T> argumentConverter) {
|
|
||||||
parent.registerConverter(key, argumentConverter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> Optional<ArgumentConverter<T>> getConverter(Key<T> key) {
|
|
||||||
return parent.getConverter(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final CommandManager parent;
|
|
||||||
|
|
||||||
public DelegateCommandManager(CommandManager parent) {
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,9 +24,9 @@ import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
|||||||
import com.sk89q.worldedit.function.EntityFunction;
|
import com.sk89q.worldedit.function.EntityFunction;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of /remove.
|
* The implementation of /remove.
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
||||||
* Copyright (C) WorldEdit team and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
|
||||||
|
|
||||||
public enum HookMode {
|
|
||||||
ACTIVE, INACTIVE
|
|
||||||
}
|
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
|
@ -32,14 +32,15 @@ import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
|||||||
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
|
import com.sk89q.worldedit.util.formatting.component.InvalidComponentException;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
|
import org.enginehub.piston.Command;
|
||||||
|
import org.enginehub.piston.CommandManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.enginehub.piston.Command;
|
|
||||||
import org.enginehub.piston.CommandManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the //help command.
|
* Implementation of the //help command.
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
|
|
||||||
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
import com.sk89q.worldedit.registry.Registry;
|
import com.sk89q.worldedit.registry.Registry;
|
||||||
@ -40,6 +37,9 @@ import java.util.function.Predicate;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
|
||||||
|
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class for generating common command suggestions.
|
* Internal class for generating common command suggestions.
|
||||||
*/
|
*/
|
||||||
|
@ -1,135 +1,136 @@
|
|||||||
package com.sk89q.worldedit.extension.factory;
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
|
//package com.sk89q.worldedit.extension.factory;
|
||||||
import com.boydti.fawe.command.FaweParser;
|
//
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
//import com.boydti.fawe.command.FaweParser;
|
||||||
import com.boydti.fawe.object.extent.MultiTransform;
|
//import com.boydti.fawe.command.SuggestInputParseException;
|
||||||
import com.boydti.fawe.object.extent.RandomTransform;
|
//import com.boydti.fawe.object.extent.MultiTransform;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
//import com.boydti.fawe.object.extent.RandomTransform;
|
||||||
import com.boydti.fawe.object.random.TrueRandom;
|
//import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.util.StringMan;
|
//import com.boydti.fawe.object.random.TrueRandom;
|
||||||
import com.google.common.collect.Iterables;
|
//import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
//import com.google.common.collect.Iterables;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
//import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
//import com.sk89q.worldedit.command.TransformCommands;
|
//import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
////import com.sk89q.worldedit.command.TransformCommands;
|
||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
//import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import java.util.ArrayList;
|
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
import java.util.Map;
|
//import java.util.List;
|
||||||
|
//import java.util.Map;
|
||||||
public class DefaultTransformParser extends FaweParser<ResettableExtent> {
|
//
|
||||||
|
//public class DefaultTransformParser extends FaweParser<ResettableExtent> {
|
||||||
public DefaultTransformParser(WorldEdit worldEdit) {
|
//
|
||||||
super(worldEdit, "transforms");
|
// public DefaultTransformParser(WorldEdit worldEdit) {
|
||||||
}
|
// super(worldEdit, "transforms");
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
|
// @Override
|
||||||
if (input.isEmpty()) return null;
|
// public ResettableExtent parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||||
|
// if (input.isEmpty()) return null;
|
||||||
List<Double> unionChances = new ArrayList<>();
|
//
|
||||||
List<Double> intersectionChances = new ArrayList<>();
|
// List<Double> unionChances = new ArrayList<>();
|
||||||
|
// List<Double> intersectionChances = new ArrayList<>();
|
||||||
List<ResettableExtent> intersection = new ArrayList<>();
|
//
|
||||||
List<ResettableExtent> union = new ArrayList<>();
|
// List<ResettableExtent> intersection = new ArrayList<>();
|
||||||
final CommandLocals locals = new CommandLocals();
|
// List<ResettableExtent> union = new ArrayList<>();
|
||||||
Actor actor = context != null ? context.getActor() : null;
|
// final CommandLocals locals = new CommandLocals();
|
||||||
if (actor != null) {
|
// Actor actor = context != null ? context.getActor() : null;
|
||||||
locals.put(Actor.class, actor);
|
// if (actor != null) {
|
||||||
}
|
// locals.put(Actor.class, actor);
|
||||||
try {
|
// }
|
||||||
List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
// try {
|
||||||
for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
// List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
||||||
ParseEntry pe = entry.getKey();
|
// for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
||||||
String command = pe.input;
|
// ParseEntry pe = entry.getKey();
|
||||||
ResettableExtent transform = null;
|
// String command = pe.input;
|
||||||
double chance = 1;
|
// ResettableExtent transform;
|
||||||
if (command.isEmpty()) {
|
// double chance = 1;
|
||||||
transform = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
// if (command.isEmpty()) {
|
||||||
} else {
|
// transform = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
||||||
List<String> args = entry.getValue();
|
// } else {
|
||||||
String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
// List<String> args = entry.getValue();
|
||||||
try {
|
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||||
transform = parse(command + cmdArgs, context);
|
// try {
|
||||||
} catch (SuggestInputParseException rethrow) {
|
// transform = parse(command + cmdArgs, context);
|
||||||
throw rethrow;
|
// } catch (SuggestInputParseException rethrow) {
|
||||||
} catch (Throwable e) {
|
// throw rethrow;
|
||||||
throw new NoMatchException("See: //transforms");
|
// } catch (Throwable e) {
|
||||||
}
|
// throw new NoMatchException("See: //transforms");
|
||||||
if (transform == null) {
|
// }
|
||||||
// Legacy syntax
|
// if (transform == null) {
|
||||||
int percentIndex = command.indexOf('%');
|
// // Legacy syntax
|
||||||
if (percentIndex != -1) { // Legacy percent pattern
|
// int percentIndex = command.indexOf('%');
|
||||||
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
|
// if (percentIndex != -1) { // Legacy percent pattern
|
||||||
command = command.substring(percentIndex + 1);
|
// chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
|
||||||
if (!entry.getValue().isEmpty()) {
|
// command = command.substring(percentIndex + 1);
|
||||||
if (!command.isEmpty()) command += " ";
|
// if (!entry.getValue().isEmpty()) {
|
||||||
command += StringMan.join(entry.getValue(), " ");
|
// if (!command.isEmpty()) command += " ";
|
||||||
}
|
// command += StringMan.join(entry.getValue(), " ");
|
||||||
transform = parseFromInput(command, context);
|
// }
|
||||||
} else {
|
// transform = parseFromInput(command, context);
|
||||||
throw new NoMatchException("See: //transforms");
|
// } else {
|
||||||
}
|
// throw new NoMatchException("See: //transforms");
|
||||||
}
|
// }
|
||||||
if (pe.and) { // &
|
// }
|
||||||
intersectionChances.add(chance);
|
// if (pe.and) { // &
|
||||||
intersection.add(transform);
|
// intersectionChances.add(chance);
|
||||||
} else {
|
// intersection.add(transform);
|
||||||
if (!intersection.isEmpty()) {
|
// } else {
|
||||||
if (intersection.size() == 1) {
|
// if (!intersection.isEmpty()) {
|
||||||
throw new InputParseException("Error, floating &");
|
// if (intersection.size() == 1) {
|
||||||
}
|
// throw new InputParseException("Error, floating &");
|
||||||
MultiTransform multi = new MultiTransform();
|
// }
|
||||||
double total = 0;
|
// MultiTransform multi = new MultiTransform();
|
||||||
for (int i = 0; i < intersection.size(); i++) {
|
// double total = 0;
|
||||||
Double value = intersectionChances.get(i);
|
// for (int i = 0; i < intersection.size(); i++) {
|
||||||
total += value;
|
// Double value = intersectionChances.get(i);
|
||||||
multi.add(intersection.get(i), value);
|
// total += value;
|
||||||
}
|
// multi.add(intersection.get(i), value);
|
||||||
union.add(multi);
|
// }
|
||||||
unionChances.add(total);
|
// union.add(multi);
|
||||||
intersection.clear();
|
// unionChances.add(total);
|
||||||
intersectionChances.clear();
|
// intersection.clear();
|
||||||
}
|
// intersectionChances.clear();
|
||||||
unionChances.add(chance);
|
// }
|
||||||
union.add(transform);
|
// unionChances.add(chance);
|
||||||
}
|
// union.add(transform);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} catch (Throwable e) {
|
// }
|
||||||
throw new InputParseException(e.getMessage(), e);
|
// } catch (Throwable e) {
|
||||||
}
|
// throw new InputParseException(e.getMessage(), e);
|
||||||
if (!intersection.isEmpty()) {
|
// }
|
||||||
if (intersection.size() == 1) {
|
// if (!intersection.isEmpty()) {
|
||||||
throw new InputParseException("Error, floating &");
|
// if (intersection.size() == 1) {
|
||||||
}
|
// throw new InputParseException("Error, floating &");
|
||||||
MultiTransform multi = new MultiTransform();
|
// }
|
||||||
double total = 0;
|
// MultiTransform multi = new MultiTransform();
|
||||||
for (int i = 0; i < intersection.size(); i++) {
|
// double total = 0;
|
||||||
Double value = intersectionChances.get(i);
|
// for (int i = 0; i < intersection.size(); i++) {
|
||||||
total += value;
|
// Double value = intersectionChances.get(i);
|
||||||
multi.add(intersection.get(i), value);
|
// total += value;
|
||||||
}
|
// multi.add(intersection.get(i), value);
|
||||||
union.add(multi);
|
// }
|
||||||
unionChances.add(total);
|
// union.add(multi);
|
||||||
intersection.clear();
|
// unionChances.add(total);
|
||||||
intersectionChances.clear();
|
// intersection.clear();
|
||||||
}
|
// intersectionChances.clear();
|
||||||
if (union.isEmpty()) {
|
// }
|
||||||
throw new NoMatchException("See: //transforms");
|
// if (union.isEmpty()) {
|
||||||
} else if (union.size() == 1) {
|
// throw new NoMatchException("See: //transforms");
|
||||||
return union.get(0);
|
// } else if (union.size() == 1) {
|
||||||
} else {
|
// return union.get(0);
|
||||||
RandomTransform random = new RandomTransform(new TrueRandom());
|
// } else {
|
||||||
for (int i = 0; i < union.size(); i++) {
|
// RandomTransform random = new RandomTransform(new TrueRandom());
|
||||||
random.add(union.get(i), unionChances.get(i));
|
// for (int i = 0; i < union.size(); i++) {
|
||||||
}
|
// random.add(union.get(i), unionChances.get(i));
|
||||||
return random;
|
// }
|
||||||
}
|
// return random;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
@ -20,8 +20,18 @@
|
|||||||
package com.sk89q.worldedit.extension.factory;
|
package com.sk89q.worldedit.extension.factory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
|
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.mask.DefaultMaskParser;
|
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
@ -49,8 +59,6 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
* @param worldEdit the WorldEdit instance
|
* @param worldEdit the WorldEdit instance
|
||||||
*/
|
*/
|
||||||
public MaskFactory(WorldEdit worldEdit) {
|
public MaskFactory(WorldEdit worldEdit) {
|
||||||
super(worldEdit, new DefaultMaskParser(worldEdit));
|
|
||||||
/*
|
|
||||||
super(worldEdit, new BlocksMaskParser(worldEdit));
|
super(worldEdit, new BlocksMaskParser(worldEdit));
|
||||||
|
|
||||||
register(new ExistingMaskParser(worldEdit));
|
register(new ExistingMaskParser(worldEdit));
|
||||||
@ -62,11 +70,8 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
|||||||
register(new BlockStateMaskParser(worldEdit));
|
register(new BlockStateMaskParser(worldEdit));
|
||||||
register(new NegateMaskParser(worldEdit));
|
register(new NegateMaskParser(worldEdit));
|
||||||
register(new ExpressionMaskParser(worldEdit));
|
register(new ExpressionMaskParser(worldEdit));
|
||||||
*/
|
|
||||||
register(new BlockCategoryMaskParser(worldEdit));
|
register(new BlockCategoryMaskParser(worldEdit));
|
||||||
/*
|
|
||||||
register(new BiomeMaskParser(worldEdit));
|
register(new BiomeMaskParser(worldEdit));
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,11 @@ package com.sk89q.worldedit.extension.factory;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
|
import com.sk89q.worldedit.extension.factory.parser.pattern.BlockCategoryPatternParser;
|
||||||
import com.sk89q.worldedit.extension.factory.parser.pattern.DefaultPatternParser;
|
import com.sk89q.worldedit.extension.factory.parser.pattern.ClipboardPatternParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomPatternParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.pattern.RandomStatePatternParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.pattern.SingleBlockPatternParser;
|
||||||
|
import com.sk89q.worldedit.extension.factory.parser.pattern.TypeOrStateApplyingPatternParser;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||||
|
|
||||||
@ -40,8 +44,6 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
|||||||
* @param worldEdit the WorldEdit instance
|
* @param worldEdit the WorldEdit instance
|
||||||
*/
|
*/
|
||||||
public PatternFactory(WorldEdit worldEdit) {
|
public PatternFactory(WorldEdit worldEdit) {
|
||||||
super(worldEdit, new DefaultPatternParser(worldEdit));
|
|
||||||
/*
|
|
||||||
super(worldEdit, new SingleBlockPatternParser(worldEdit));
|
super(worldEdit, new SingleBlockPatternParser(worldEdit));
|
||||||
|
|
||||||
// split and parse each sub-pattern
|
// split and parse each sub-pattern
|
||||||
@ -51,7 +53,6 @@ public final class PatternFactory extends AbstractFactory<Pattern> {
|
|||||||
register(new ClipboardPatternParser(worldEdit));
|
register(new ClipboardPatternParser(worldEdit));
|
||||||
register(new TypeOrStateApplyingPatternParser(worldEdit));
|
register(new TypeOrStateApplyingPatternParser(worldEdit));
|
||||||
register(new RandomStatePatternParser(worldEdit));
|
register(new RandomStatePatternParser(worldEdit));
|
||||||
*/
|
|
||||||
register(new BlockCategoryPatternParser(worldEdit));
|
register(new BlockCategoryPatternParser(worldEdit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
|||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
@ -289,8 +290,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
if (typeString.isEmpty()) {
|
if (typeString.isEmpty()) {
|
||||||
throw new InputParseException("Invalid format");
|
throw new InputParseException("Invalid format");
|
||||||
}
|
}
|
||||||
// PosX
|
if ("hand".equalsIgnoreCase(typeString)) {
|
||||||
if (typeString.matches("pos[0-9]+")) {
|
// Get the block type from the item in the user's hand.
|
||||||
|
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||||
|
state = blockInHand.toBlockState();
|
||||||
|
nbt = blockInHand.getNbtData();
|
||||||
|
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||||
|
// Get the block type from the item in the user's off hand.
|
||||||
|
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||||
|
state = blockInHand.toBlockState();
|
||||||
|
nbt = blockInHand.getNbtData();
|
||||||
|
} else if (typeString.matches("pos[0-9]+")) {
|
||||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
||||||
// Get the block type from the "primary position"
|
// Get the block type from the "primary position"
|
||||||
final World world = context.requireWorld();
|
final World world = context.requireWorld();
|
||||||
@ -301,17 +311,6 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
throw new InputParseException("Your selection is not complete.");
|
throw new InputParseException("Your selection is not complete.");
|
||||||
}
|
}
|
||||||
state = world.getBlock(primaryPosition);
|
state = world.getBlock(primaryPosition);
|
||||||
} else {
|
|
||||||
if ("hand".equalsIgnoreCase(typeString)) {
|
|
||||||
// Get the block type from the item in the user's hand.
|
|
||||||
BaseBlock block = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
|
||||||
state = block.toBlockState();
|
|
||||||
nbt = block.getNbtData();
|
|
||||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
|
||||||
// Get the block type from the item in the user's off hand.
|
|
||||||
BaseBlock block = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
|
||||||
state = block.toBlockState();
|
|
||||||
nbt = block.getNbtData();
|
|
||||||
} else if (typeString.matches("slot[0-9]+")) {
|
} else if (typeString.matches("slot[0-9]+")) {
|
||||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||||
Actor actor = context.requireActor();
|
Actor actor = context.requireActor();
|
||||||
@ -338,8 +337,8 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
state = type.getDefaultState();
|
state = type.getDefaultState();
|
||||||
}
|
}
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
throw new NoMatchException(
|
||||||
}
|
"Does not match a valid block type: '" + input + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbt == null) nbt = state.getNbtData();
|
if (nbt == null) nbt = state.getNbtData();
|
||||||
@ -351,15 +350,15 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
if (stateString == null || stateString.isEmpty()) {
|
if (stateString == null || stateString.isEmpty()) {
|
||||||
state = new FuzzyBlockState(state);
|
state = new FuzzyBlockState(state);
|
||||||
} else {
|
} else {
|
||||||
BlockType type = state.getBlockType();
|
BlockType blockType = state.getBlockType();
|
||||||
FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
|
FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
|
||||||
fuzzyBuilder.type(type);
|
fuzzyBuilder.type(blockType);
|
||||||
String[] entries = stateString.split(",");
|
String[] entries = stateString.split(",");
|
||||||
for (String entry : entries) {
|
for (String entry : entries) {
|
||||||
String[] split = entry.split("=");
|
String[] split = entry.split("=");
|
||||||
String key = split[0];
|
String key = split[0];
|
||||||
String val = split[1];
|
String val = split[1];
|
||||||
Property<Object> prop = type.getProperty(key);
|
Property<Object> prop = blockType.getProperty(key);
|
||||||
fuzzyBuilder.withProperty(prop, prop.getValueFor(val));
|
fuzzyBuilder.withProperty(prop, prop.getValueFor(val));
|
||||||
}
|
}
|
||||||
state = fuzzyBuilder.build();
|
state = fuzzyBuilder.build();
|
||||||
@ -398,9 +397,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
// Allow setting mob spawn type
|
// Allow setting mob spawn type
|
||||||
if (blockAndExtraData.length > 1) {
|
if (blockAndExtraData.length > 1) {
|
||||||
String mobName = blockAndExtraData[1];
|
String mobName = blockAndExtraData[1];
|
||||||
EntityType mobType = EntityTypes.parse(mobName);
|
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
|
||||||
|
if (ent == null) {
|
||||||
|
throw new NoMatchException("Unknown entity type '" + mobName + "'");
|
||||||
|
}
|
||||||
|
mobName = ent.getId();
|
||||||
|
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||||
|
throw new NoMatchException("Unknown mob type '" + mobName + "'");
|
||||||
|
}
|
||||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||||
} else {
|
} else {
|
||||||
|
//noinspection ConstantConditions
|
||||||
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
|
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
|
||||||
}
|
}
|
||||||
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
||||||
|
@ -29,8 +29,6 @@ import com.sk89q.worldedit.internal.registry.InputParser;
|
|||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class BlockStateMaskParser extends InputParser<Mask> {
|
public class BlockStateMaskParser extends InputParser<Mask> {
|
||||||
|
|
||||||
public BlockStateMaskParser(WorldEdit worldEdit) {
|
public BlockStateMaskParser(WorldEdit worldEdit) {
|
||||||
|
@ -1,206 +1,207 @@
|
|||||||
/*
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
///*
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
// * WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) WorldEdit team and contributors
|
// * Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
*
|
// * Copyright (C) WorldEdit team and contributors
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
// *
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
// * This program is free software: you can redistribute it and/or modify it
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
// * under the terms of the GNU Lesser General Public License as published by the
|
||||||
* (at your option) any later version.
|
// * Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// * (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
// *
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* for more details.
|
// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
*
|
// * for more details.
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
// *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * You should have received a copy of the GNU Lesser General Public License
|
||||||
*/
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
// */
|
||||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
//
|
||||||
|
//package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||||
import com.boydti.fawe.command.FaweParser;
|
//
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
//import com.boydti.fawe.command.FaweParser;
|
||||||
import com.boydti.fawe.config.Caption;
|
//import com.boydti.fawe.command.SuggestInputParseException;
|
||||||
import com.boydti.fawe.util.StringMan;
|
//import com.boydti.fawe.config.Caption;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
//import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
//import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
//import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
//import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
//import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
//import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
//import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||||
import com.sk89q.worldedit.session.request.Request;
|
//import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
//import com.sk89q.worldedit.session.request.Request;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
//import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
//import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
//import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import java.util.ArrayList;
|
//
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
import java.util.Map;
|
//import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
//import java.util.stream.Collectors;
|
||||||
|
//import java.util.stream.Stream;
|
||||||
public class DefaultMaskParser extends FaweParser<Mask> {
|
//
|
||||||
public DefaultMaskParser(WorldEdit worldEdit) {
|
//public class DefaultMaskParser extends FaweParser<Mask> {
|
||||||
super(worldEdit, "masks");
|
// public DefaultMaskParser(WorldEdit worldEdit) {
|
||||||
}
|
// super(worldEdit, "masks");
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
// @Override
|
||||||
if (input.isEmpty()) {
|
// public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||||
throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()));
|
// if (input.isEmpty()) {
|
||||||
}
|
// throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()));
|
||||||
Extent extent = Request.request().getExtent();
|
// }
|
||||||
if (extent == null) extent = context.getExtent();
|
// Extent extent = Request.request().getExtent();
|
||||||
List<List<Mask>> masks = new ArrayList<>();
|
// if (extent == null) extent = context.getExtent();
|
||||||
masks.add(new ArrayList<>());
|
// List<List<Mask>> masks = new ArrayList<>();
|
||||||
|
// masks.add(new ArrayList<>());
|
||||||
final CommandLocals locals = new CommandLocals();
|
//
|
||||||
Actor actor = context != null ? context.getActor() : null;
|
// final CommandLocals locals = new CommandLocals();
|
||||||
if (actor != null) {
|
// Actor actor = context != null ? context.getActor() : null;
|
||||||
locals.put(Actor.class, actor);
|
// if (actor != null) {
|
||||||
}
|
// locals.put(Actor.class, actor);
|
||||||
try {
|
// }
|
||||||
List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
|
||||||
for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
|
||||||
ParseEntry pe = entry.getKey();
|
|
||||||
final String command = pe.input;
|
|
||||||
String full = pe.full;
|
|
||||||
Mask mask = null;
|
|
||||||
if (command.isEmpty()) {
|
|
||||||
mask = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
|
||||||
} else {
|
|
||||||
List<String> args = entry.getValue();
|
|
||||||
String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
|
||||||
try {
|
|
||||||
mask = parse(command + cmdArgs, context);
|
|
||||||
} catch (SuggestInputParseException rethrow) {
|
|
||||||
throw rethrow;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// TODO NOT IMPLEMENTED
|
|
||||||
// throw SuggestInputParseException.of(e, full, () -> {
|
|
||||||
// try {
|
// try {
|
||||||
// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
|
// List<Map.Entry<ParseEntry, List<String>>> parsed = parse(input);
|
||||||
// if (suggestions.size() <= 2) {
|
// for (Map.Entry<ParseEntry, List<String>> entry : parsed) {
|
||||||
// for (int i = 0; i < suggestions.size(); i++) {
|
// ParseEntry pe = entry.getKey();
|
||||||
// String suggestion = suggestions.get(i);
|
// final String command = pe.input;
|
||||||
// if (suggestion.indexOf(' ') != 0) {
|
// String full = pe.full;
|
||||||
// String[] split = suggestion.split(" ");
|
// Mask mask = null;
|
||||||
// suggestion = "[" + StringMan.join(split, "][") + "]";
|
// if (command.isEmpty()) {
|
||||||
// suggestions.set(i, suggestion);
|
// mask = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
||||||
|
// } else {
|
||||||
|
// List<String> args = entry.getValue();
|
||||||
|
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||||
|
// try {
|
||||||
|
// mask = parse(command + cmdArgs, context);
|
||||||
|
// } catch (SuggestInputParseException rethrow) {
|
||||||
|
// throw rethrow;
|
||||||
|
// } catch (Throwable e) {
|
||||||
|
// // TODO NOT IMPLEMENTED
|
||||||
|
//// throw SuggestInputParseException.of(e, full, () -> {
|
||||||
|
//// try {
|
||||||
|
//// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
|
||||||
|
//// if (suggestions.size() <= 2) {
|
||||||
|
//// for (int i = 0; i < suggestions.size(); i++) {
|
||||||
|
//// String suggestion = suggestions.get(i);
|
||||||
|
//// if (suggestion.indexOf(' ') != 0) {
|
||||||
|
//// String[] split = suggestion.split(" ");
|
||||||
|
//// suggestion = "[" + StringMan.join(split, "][") + "]";
|
||||||
|
//// suggestions.set(i, suggestion);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// return suggestions;
|
||||||
|
//// } catch (CommandException e1) {
|
||||||
|
//// throw new InputParseException(e1.getMessage());
|
||||||
|
//// } catch (Throwable e2) {
|
||||||
|
//// e2.printStackTrace();
|
||||||
|
//// throw new InputParseException(e2.getMessage());
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
// }
|
||||||
|
// if (mask == null) {
|
||||||
|
// // Legacy patterns
|
||||||
|
// char char0 = command.charAt(0);
|
||||||
|
// boolean charMask = input.length() > 1 && input.charAt(1) != '[';
|
||||||
|
// if (charMask && input.charAt(0) == '=') {
|
||||||
|
// return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
|
||||||
|
// }
|
||||||
|
// if (char0 == '#' || char0 == '?') {
|
||||||
|
// // TODO NOT IMPLEMENTED
|
||||||
|
//// throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
|
||||||
|
//// () -> {
|
||||||
|
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||||
|
//// return dispatcher.getAliases().stream().filter(
|
||||||
|
//// s -> s.startsWith(command.toLowerCase())
|
||||||
|
//// ).collect(Collectors.toList());
|
||||||
|
//// }
|
||||||
|
//// );
|
||||||
|
// }
|
||||||
|
// // Legacy syntax
|
||||||
|
// if (charMask) {
|
||||||
|
// switch (char0) {
|
||||||
|
// case '\\': //
|
||||||
|
// case '/': //
|
||||||
|
// case '{': //
|
||||||
|
// case '$': //
|
||||||
|
// case '%': {
|
||||||
|
// String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
|
||||||
|
// if (value.contains(":")) {
|
||||||
|
// if (value.charAt(0) == ':') value.replaceFirst(":", "");
|
||||||
|
// value = value.replaceAll(":", "][");
|
||||||
|
// }
|
||||||
|
// mask = parseFromInput("#" + char0 + "[" + value + "]", context);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// case '|':
|
||||||
|
// case '~':
|
||||||
|
// case '<':
|
||||||
|
// case '>':
|
||||||
|
// case '!':
|
||||||
|
// input = input.substring(input.indexOf(char0) + 1);
|
||||||
|
// mask = parseFromInput(char0 + "[" + input + "]", context);
|
||||||
|
// if (actor != null) {
|
||||||
|
// actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
|
||||||
|
// }
|
||||||
|
// return mask;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// return suggestions;
|
// if (mask == null) {
|
||||||
// } catch (CommandException e1) {
|
// if (command.startsWith("[")) {
|
||||||
// throw new InputParseException(e1.getMessage());
|
// int end = command.lastIndexOf(']');
|
||||||
// } catch (Throwable e2) {
|
// mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
|
||||||
// e2.printStackTrace();
|
// } else {
|
||||||
// throw new InputParseException(e2.getMessage());
|
// List<String> entries = entry.getValue();
|
||||||
|
// BlockMaskBuilder builder = new BlockMaskBuilder();
|
||||||
|
//// if (StringMan.containsAny(full, "\\^$.|?+(){}<>~$!%^&*+-/"))
|
||||||
|
// {
|
||||||
|
// try {
|
||||||
|
// builder.addRegex(full);
|
||||||
|
// } catch (InputParseException ignore) {}
|
||||||
// }
|
// }
|
||||||
// });
|
// if (mask == null) {
|
||||||
}
|
// context.setPreferringWildcard(false);
|
||||||
if (mask == null) {
|
// context.setRestricted(false);
|
||||||
// Legacy patterns
|
// BaseBlock block = worldEdit.getBlockFactory().parseFromInput(full, context);
|
||||||
char char0 = command.charAt(0);
|
// builder.add(block);
|
||||||
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
|
// mask = builder.build(extent);
|
||||||
if (charMask && input.charAt(0) == '=') {
|
|
||||||
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
|
|
||||||
}
|
|
||||||
if (char0 == '#' || char0 == '?') {
|
|
||||||
// TODO NOT IMPLEMENTED
|
|
||||||
// throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full,
|
|
||||||
// () -> {
|
|
||||||
// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
|
||||||
// return dispatcher.getAliases().stream().filter(
|
|
||||||
// s -> s.startsWith(command.toLowerCase())
|
|
||||||
// ).collect(Collectors.toList());
|
|
||||||
// }
|
// }
|
||||||
// );
|
// }
|
||||||
}
|
// }
|
||||||
// Legacy syntax
|
// }
|
||||||
if (charMask) {
|
// if (pe.and) {
|
||||||
switch (char0) {
|
// masks.add(new ArrayList<>());
|
||||||
case '\\': //
|
// }
|
||||||
case '/': //
|
// masks.get(masks.size() - 1).add(mask);
|
||||||
case '{': //
|
// }
|
||||||
case '$': //
|
// } catch (InputParseException rethrow) {
|
||||||
case '%': {
|
// throw rethrow;
|
||||||
String value = command.substring(1) + ((entry.getValue().isEmpty()) ? "" : "[" + StringMan.join(entry.getValue(), "][") + "]");
|
// } catch (Throwable e) {
|
||||||
if (value.contains(":")) {
|
// e.printStackTrace();
|
||||||
if (value.charAt(0) == ':') value.replaceFirst(":", "");
|
// throw new InputParseException(e.getMessage(), e);
|
||||||
value = value.replaceAll(":", "][");
|
// }
|
||||||
}
|
// List<Mask> maskUnions = new ArrayList<>();
|
||||||
mask = parseFromInput("#" + char0 + "[" + value + "]", context);
|
// for (List<Mask> maskList : masks) {
|
||||||
break;
|
// if (maskList.size() == 1) {
|
||||||
}
|
// maskUnions.add(maskList.get(0));
|
||||||
case '|':
|
// } else if (maskList.size() != 0) {
|
||||||
case '~':
|
// maskUnions.add(new MaskUnion(maskList));
|
||||||
case '<':
|
// }
|
||||||
case '>':
|
// }
|
||||||
case '!':
|
// if (maskUnions.size() == 1) {
|
||||||
input = input.substring(input.indexOf(char0) + 1);
|
// return maskUnions.get(0);
|
||||||
mask = parseFromInput(char0 + "[" + input + "]", context);
|
// } else if (maskUnions.size() != 0) {
|
||||||
if (actor != null) {
|
// return new MaskIntersection(maskUnions);
|
||||||
actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
|
// } else {
|
||||||
}
|
// return null;
|
||||||
return mask;
|
// }
|
||||||
}
|
//
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
if (mask == null) {
|
|
||||||
if (command.startsWith("[")) {
|
|
||||||
int end = command.lastIndexOf(']');
|
|
||||||
mask = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
|
|
||||||
} else {
|
|
||||||
List<String> entries = entry.getValue();
|
|
||||||
BlockMaskBuilder builder = new BlockMaskBuilder();
|
|
||||||
// if (StringMan.containsAny(full, "\\^$.|?+(){}<>~$!%^&*+-/"))
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
builder.addRegex(full);
|
|
||||||
} catch (InputParseException ignore) {}
|
|
||||||
}
|
|
||||||
if (mask == null) {
|
|
||||||
context.setPreferringWildcard(false);
|
|
||||||
context.setRestricted(false);
|
|
||||||
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(full, context);
|
|
||||||
builder.add(block);
|
|
||||||
mask = builder.build(extent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pe.and) {
|
|
||||||
masks.add(new ArrayList<>());
|
|
||||||
}
|
|
||||||
masks.get(masks.size() - 1).add(mask);
|
|
||||||
}
|
|
||||||
} catch (InputParseException rethrow) {
|
|
||||||
throw rethrow;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new InputParseException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
List<Mask> maskUnions = new ArrayList<>();
|
|
||||||
for (List<Mask> maskList : masks) {
|
|
||||||
if (maskList.size() == 1) {
|
|
||||||
maskUnions.add(maskList.get(0));
|
|
||||||
} else if (maskList.size() != 0) {
|
|
||||||
maskUnions.add(new MaskUnion(maskList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (maskUnions.size() == 1) {
|
|
||||||
return maskUnions.get(0);
|
|
||||||
} else if (maskUnions.size() != 0) {
|
|
||||||
return new MaskIntersection(maskUnions);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,184 +1,185 @@
|
|||||||
/*
|
// TODO: Ping @MattBDev to reimplement (or remove because this class is stupid) 2020-02-04
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
///*
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
// * WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) WorldEdit team and contributors
|
// * Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
*
|
// * Copyright (C) WorldEdit team and contributors
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
// *
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
// * This program is free software: you can redistribute it and/or modify it
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
// * under the terms of the GNU Lesser General Public License as published by the
|
||||||
* (at your option) any later version.
|
// * Free Software Foundation, either version 3 of the License, or
|
||||||
*
|
// * (at your option) any later version.
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
// *
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// * This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* for more details.
|
// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
*
|
// * for more details.
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
// *
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// * You should have received a copy of the GNU Lesser General Public License
|
||||||
*/
|
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
// */
|
||||||
package com.sk89q.worldedit.extension.factory.parser.pattern;
|
//
|
||||||
|
//package com.sk89q.worldedit.extension.factory.parser.pattern;
|
||||||
import com.boydti.fawe.command.FaweParser;
|
//
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
//import com.boydti.fawe.command.FaweParser;
|
||||||
import com.boydti.fawe.object.random.TrueRandom;
|
//import com.boydti.fawe.command.SuggestInputParseException;
|
||||||
import com.boydti.fawe.util.StringMan;
|
//import com.boydti.fawe.object.random.TrueRandom;
|
||||||
import com.google.common.collect.Iterables;
|
//import com.boydti.fawe.util.StringMan;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
//import com.google.common.collect.Iterables;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
//import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
//import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.input.NoMatchException;
|
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
//import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
//import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
//import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
//import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
//import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
|
//import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import java.util.ArrayList;
|
//
|
||||||
import java.util.List;
|
//import java.util.ArrayList;
|
||||||
import java.util.Map;
|
//import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
//import java.util.stream.Collectors;
|
||||||
|
//import java.util.stream.Stream;
|
||||||
public class DefaultPatternParser extends FaweParser<Pattern> {
|
//
|
||||||
|
//public class DefaultPatternParser extends FaweParser<Pattern> {
|
||||||
public DefaultPatternParser(WorldEdit worldEdit) {
|
//
|
||||||
super(worldEdit, "patterns");
|
// public DefaultPatternParser(WorldEdit worldEdit) {
|
||||||
}
|
// super(worldEdit, "patterns");
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
|
// @Override
|
||||||
if (input.isEmpty()) {
|
// public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||||
throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()));
|
// if (input.isEmpty()) {
|
||||||
}
|
// throw new SuggestInputParseException("No input provided", "", () -> Stream.concat(Stream.of("#", ",", "&"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList()));
|
||||||
List<Double> chances = new ArrayList<>();
|
// }
|
||||||
List<Pattern> patterns = new ArrayList<>();
|
// List<Double> chances = new ArrayList<>();
|
||||||
final CommandLocals locals = new CommandLocals();
|
// List<Pattern> patterns = new ArrayList<>();
|
||||||
Actor actor = context != null ? context.getActor() : null;
|
// final CommandLocals locals = new CommandLocals();
|
||||||
if (actor != null) {
|
// Actor actor = context != null ? context.getActor() : null;
|
||||||
locals.put(Actor.class, actor);
|
// if (actor != null) {
|
||||||
}
|
// locals.put(Actor.class, actor);
|
||||||
try {
|
// }
|
||||||
for (Map.Entry<ParseEntry, List<String>> entry : parse(input)) {
|
|
||||||
ParseEntry pe = entry.getKey();
|
|
||||||
final String command = pe.input;
|
|
||||||
String full = pe.full;
|
|
||||||
Pattern pattern = null;
|
|
||||||
double chance = 1;
|
|
||||||
if (command.isEmpty()) {
|
|
||||||
pattern = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
|
||||||
} else {
|
|
||||||
List<String> args = entry.getValue();
|
|
||||||
String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
|
||||||
try {
|
|
||||||
pattern = parse(command + cmdArgs, context);
|
|
||||||
} catch (SuggestInputParseException rethrow) {
|
|
||||||
throw rethrow;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
// TODO NOT IMPLEMENTED
|
|
||||||
// throw SuggestInputParseException.of(e, full, () -> {
|
|
||||||
// try {
|
// try {
|
||||||
// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
|
// for (Map.Entry<ParseEntry, List<String>> entry : parse(input)) {
|
||||||
// if (suggestions.size() <= 2) {
|
// ParseEntry pe = entry.getKey();
|
||||||
// for (int i = 0; i < suggestions.size(); i++) {
|
// final String command = pe.input;
|
||||||
// String suggestion = suggestions.get(i);
|
// String full = pe.full;
|
||||||
// if (suggestion.indexOf(' ') != 0) {
|
// Pattern pattern = null;
|
||||||
// String[] split = suggestion.split(" ");
|
// double chance = 1;
|
||||||
// suggestion = "[" + StringMan.join(split, "][") + "]";
|
// if (command.isEmpty()) {
|
||||||
// suggestions.set(i, suggestion);
|
// pattern = parseFromInput(StringMan.join(entry.getValue(), ','), context);
|
||||||
|
// } else {
|
||||||
|
// List<String> args = entry.getValue();
|
||||||
|
// String cmdArgs = ((args.isEmpty()) ? "" : " " + StringMan.join(args, " "));
|
||||||
|
// try {
|
||||||
|
// pattern = parse(command + cmdArgs, context);
|
||||||
|
// } catch (SuggestInputParseException rethrow) {
|
||||||
|
// throw rethrow;
|
||||||
|
// } catch (Throwable e) {
|
||||||
|
// // TODO NOT IMPLEMENTED
|
||||||
|
//// throw SuggestInputParseException.of(e, full, () -> {
|
||||||
|
//// try {
|
||||||
|
//// List<String> suggestions = dispatcher.get(command).getCallable().getSuggestions(cmdArgs, locals);
|
||||||
|
//// if (suggestions.size() <= 2) {
|
||||||
|
//// for (int i = 0; i < suggestions.size(); i++) {
|
||||||
|
//// String suggestion = suggestions.get(i);
|
||||||
|
//// if (suggestion.indexOf(' ') != 0) {
|
||||||
|
//// String[] split = suggestion.split(" ");
|
||||||
|
//// suggestion = "[" + StringMan.join(split, "][") + "]";
|
||||||
|
//// suggestions.set(i, suggestion);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// return suggestions;
|
||||||
|
//// } catch (CommandException e1) {
|
||||||
|
//// throw new InputParseException(e1.getMessage());
|
||||||
|
//// } catch (Throwable e2) {
|
||||||
|
//// e2.printStackTrace();
|
||||||
|
//// throw new InputParseException(e2.getMessage());
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
// }
|
||||||
|
// if (pattern == null) {
|
||||||
|
// // Legacy patterns
|
||||||
|
// char char0 = command.charAt(0);
|
||||||
|
// boolean charMask = input.length() > 1 && input.charAt(1) != '[';
|
||||||
|
// if (charMask && input.charAt(0) == '=') {
|
||||||
|
// return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
|
||||||
|
// }
|
||||||
|
// if (char0 == '#') {
|
||||||
|
// // TODO NOT IMPLEMENTED
|
||||||
|
//// throw new SuggestInputParseException(new NoMatchException("Unknown pattern: " + full + ", See: //patterns"), full,
|
||||||
|
//// () -> {
|
||||||
|
//// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
||||||
|
//// return dispatcher.getAliases().stream().filter(
|
||||||
|
//// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
||||||
|
//// ).collect(Collectors.toList());
|
||||||
|
//// }
|
||||||
|
//// );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (charMask) {
|
||||||
|
// if (char0 == '$') {
|
||||||
|
// String value = command.substring(1) + ((entry.getValue().isEmpty()) ? ""
|
||||||
|
// : "[" + StringMan.join(entry.getValue(), "][") + "]");
|
||||||
|
// if (value.contains(":")) {
|
||||||
|
// if (value.charAt(0) == ':') {
|
||||||
|
// value.replaceFirst(":", "");
|
||||||
|
// }
|
||||||
|
// value = value.replaceAll(":", "][");
|
||||||
|
// }
|
||||||
|
// pattern = parseFromInput(char0 + "[" + value + "]", context);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (pattern == null) {
|
||||||
|
// if (command.startsWith("[")) {
|
||||||
|
// int end = command.lastIndexOf(']');
|
||||||
|
// pattern = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
|
||||||
|
// } else {
|
||||||
|
// int percentIndex = command.indexOf('%');
|
||||||
|
// if (percentIndex != -1) { // Legacy percent pattern
|
||||||
|
// chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
|
||||||
|
// String value = command.substring(percentIndex + 1);
|
||||||
|
// if (!entry.getValue().isEmpty()) {
|
||||||
|
// if (!value.isEmpty()) value += " ";
|
||||||
|
// value += StringMan.join(entry.getValue(), " ");
|
||||||
|
// }
|
||||||
|
// pattern = parseFromInput(value, context);
|
||||||
|
// } else { // legacy block pattern
|
||||||
|
// try {
|
||||||
|
// pattern = worldEdit.getBlockFactory().parseFromInput(pe.full, context);
|
||||||
|
// } catch (NoMatchException e) {
|
||||||
|
// throw new NoMatchException(e.getMessage() + " See: //patterns");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// return suggestions;
|
|
||||||
// } catch (CommandException e1) {
|
|
||||||
// throw new InputParseException(e1.getMessage());
|
|
||||||
// } catch (Throwable e2) {
|
|
||||||
// e2.printStackTrace();
|
|
||||||
// throw new InputParseException(e2.getMessage());
|
|
||||||
// }
|
// }
|
||||||
// });
|
|
||||||
}
|
|
||||||
if (pattern == null) {
|
|
||||||
// Legacy patterns
|
|
||||||
char char0 = command.charAt(0);
|
|
||||||
boolean charMask = input.length() > 1 && input.charAt(1) != '[';
|
|
||||||
if (charMask && input.charAt(0) == '=') {
|
|
||||||
return parseFromInput(char0 + "[" + input.substring(1) + "]", context);
|
|
||||||
}
|
|
||||||
if (char0 == '#') {
|
|
||||||
// TODO NOT IMPLEMENTED
|
|
||||||
// throw new SuggestInputParseException(new NoMatchException("Unknown pattern: " + full + ", See: //patterns"), full,
|
|
||||||
// () -> {
|
|
||||||
// if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases());
|
|
||||||
// return dispatcher.getAliases().stream().filter(
|
|
||||||
// s -> s.startsWith(command.toLowerCase(Locale.ROOT))
|
|
||||||
// ).collect(Collectors.toList());
|
|
||||||
// }
|
// }
|
||||||
// );
|
// }
|
||||||
}
|
// if (pattern != null) {
|
||||||
|
// patterns.add(pattern);
|
||||||
|
// chances.add(chance);
|
||||||
if (charMask) {
|
// }
|
||||||
if (char0 == '$') {
|
// }
|
||||||
String value = command.substring(1) + ((entry.getValue().isEmpty()) ? ""
|
// } catch (InputParseException rethrow) {
|
||||||
: "[" + StringMan.join(entry.getValue(), "][") + "]");
|
// throw rethrow;
|
||||||
if (value.contains(":")) {
|
// } catch (Throwable e) {
|
||||||
if (value.charAt(0) == ':') {
|
// e.printStackTrace();
|
||||||
value.replaceFirst(":", "");
|
// throw new InputParseException(e.getMessage(), e);
|
||||||
}
|
// }
|
||||||
value = value.replaceAll(":", "][");
|
// if (patterns.isEmpty()) {
|
||||||
}
|
// return null;
|
||||||
pattern = parseFromInput(char0 + "[" + value + "]", context);
|
// }
|
||||||
}
|
// if (patterns.size() == 1) {
|
||||||
}
|
// return patterns.get(0);
|
||||||
if (pattern == null) {
|
// }
|
||||||
if (command.startsWith("[")) {
|
// RandomPattern random = new RandomPattern(new TrueRandom());
|
||||||
int end = command.lastIndexOf(']');
|
// for (int i = 0; i < patterns.size(); i++) {
|
||||||
pattern = parseFromInput(command.substring(1, end == -1 ? command.length() : end), context);
|
// random.add(patterns.get(i), chances.get(i));
|
||||||
} else {
|
// }
|
||||||
int percentIndex = command.indexOf('%');
|
// return random;
|
||||||
if (percentIndex != -1) { // Legacy percent pattern
|
// }
|
||||||
chance = Expression.compile(command.substring(0, percentIndex)).evaluate();
|
//}
|
||||||
String value = command.substring(percentIndex + 1);
|
|
||||||
if (!entry.getValue().isEmpty()) {
|
|
||||||
if (!value.isEmpty()) value += " ";
|
|
||||||
value += StringMan.join(entry.getValue(), " ");
|
|
||||||
}
|
|
||||||
pattern = parseFromInput(value, context);
|
|
||||||
} else { // legacy block pattern
|
|
||||||
try {
|
|
||||||
pattern = worldEdit.getBlockFactory().parseFromInput(pe.full, context);
|
|
||||||
} catch (NoMatchException e) {
|
|
||||||
throw new NoMatchException(e.getMessage() + " See: //patterns");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pattern != null) {
|
|
||||||
patterns.add(pattern);
|
|
||||||
chances.add(chance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InputParseException rethrow) {
|
|
||||||
throw rethrow;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new InputParseException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
if (patterns.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (patterns.size() == 1) {
|
|
||||||
return patterns.get(0);
|
|
||||||
}
|
|
||||||
RandomPattern random = new RandomPattern(new TrueRandom());
|
|
||||||
for (int i = 0; i < patterns.size(); i++) {
|
|
||||||
random.add(patterns.get(i), chances.get(i));
|
|
||||||
}
|
|
||||||
return random;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -24,12 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.command.AnvilCommands;
|
import com.boydti.fawe.command.AnvilCommands;
|
||||||
import com.boydti.fawe.command.AnvilCommandsRegistration;
|
import com.boydti.fawe.command.AnvilCommandsRegistration;
|
||||||
import com.boydti.fawe.command.CFICommands;
|
|
||||||
import com.boydti.fawe.command.CFICommandsRegistration;
|
|
||||||
import com.boydti.fawe.config.Caption;
|
import com.boydti.fawe.config.Caption;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
|
||||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.object.task.ThrowableSupplier;
|
import com.boydti.fawe.object.task.ThrowableSupplier;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
@ -62,13 +58,9 @@ import com.sk89q.worldedit.command.HistoryCommands;
|
|||||||
import com.sk89q.worldedit.command.HistoryCommandsRegistration;
|
import com.sk89q.worldedit.command.HistoryCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.HistorySubCommands;
|
import com.sk89q.worldedit.command.HistorySubCommands;
|
||||||
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
|
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.MaskCommands;
|
|
||||||
import com.sk89q.worldedit.command.MaskCommandsRegistration;
|
|
||||||
import com.sk89q.worldedit.command.NavigationCommands;
|
import com.sk89q.worldedit.command.NavigationCommands;
|
||||||
import com.sk89q.worldedit.command.NavigationCommandsRegistration;
|
import com.sk89q.worldedit.command.NavigationCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.PaintBrushCommands;
|
import com.sk89q.worldedit.command.PaintBrushCommands;
|
||||||
import com.sk89q.worldedit.command.PatternCommands;
|
|
||||||
import com.sk89q.worldedit.command.PatternCommandsRegistration;
|
|
||||||
import com.sk89q.worldedit.command.RegionCommands;
|
import com.sk89q.worldedit.command.RegionCommands;
|
||||||
import com.sk89q.worldedit.command.RegionCommandsRegistration;
|
import com.sk89q.worldedit.command.RegionCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.SchematicCommands;
|
import com.sk89q.worldedit.command.SchematicCommands;
|
||||||
@ -87,8 +79,6 @@ import com.sk89q.worldedit.command.ToolCommands;
|
|||||||
import com.sk89q.worldedit.command.ToolCommandsRegistration;
|
import com.sk89q.worldedit.command.ToolCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.ToolUtilCommands;
|
import com.sk89q.worldedit.command.ToolUtilCommands;
|
||||||
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
|
import com.sk89q.worldedit.command.ToolUtilCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.TransformCommands;
|
|
||||||
import com.sk89q.worldedit.command.TransformCommandsRegistration;
|
|
||||||
import com.sk89q.worldedit.command.UtilityCommands;
|
import com.sk89q.worldedit.command.UtilityCommands;
|
||||||
import com.sk89q.worldedit.command.UtilityCommandsRegistration;
|
import com.sk89q.worldedit.command.UtilityCommandsRegistration;
|
||||||
import com.sk89q.worldedit.command.WorldEditCommands;
|
import com.sk89q.worldedit.command.WorldEditCommands;
|
||||||
@ -304,9 +294,10 @@ public final class PlatformCommandManager {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class),
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
context -> context.injectedValue(Key.of(Actor.class))
|
// globalInjectedValues.injectValue(Key.of(CFICommands.CFISettings.class),
|
||||||
.orElseThrow(() -> new IllegalStateException("No CFI Settings")).getMeta("CFISettings"));
|
// context -> context.injectedValue(Key.of(Actor.class))
|
||||||
|
// .orElseThrow(() -> new IllegalStateException("No CFI Settings")).getMeta("CFISettings"));
|
||||||
globalInjectedValues.injectValue(Key.of(World.class),
|
globalInjectedValues.injectValue(Key.of(World.class),
|
||||||
context -> {
|
context -> {
|
||||||
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
|
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
|
||||||
@ -321,7 +312,6 @@ public final class PlatformCommandManager {
|
|||||||
} else {
|
} else {
|
||||||
throw new MissingWorldException();
|
throw new MissingWorldException();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MissingWorldException e) {
|
} catch (MissingWorldException e) {
|
||||||
exceptionConverter.convert(e);
|
exceptionConverter.convert(e);
|
||||||
throw new AssertionError("Should have thrown a new exception.", e);
|
throw new AssertionError("Should have thrown a new exception.", e);
|
||||||
@ -396,27 +386,28 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
public void registerAllCommands() {
|
public void registerAllCommands() {
|
||||||
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
|
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
|
||||||
registerSubCommands(
|
// TODO: Ping @MattBDev to reimplement (or remove) 2020-02-04
|
||||||
"patterns",
|
// registerSubCommands(
|
||||||
ImmutableList.of(),
|
// "patterns",
|
||||||
"Patterns determine what blocks are placed",
|
// ImmutableList.of(),
|
||||||
PatternCommandsRegistration.builder(),
|
// "Patterns determine what blocks are placed",
|
||||||
new PatternCommands()
|
// PatternCommandsRegistration.builder(),
|
||||||
);
|
// new PatternCommands()
|
||||||
registerSubCommands(
|
// );
|
||||||
"masks",
|
// registerSubCommands(
|
||||||
ImmutableList.of(),
|
// "masks",
|
||||||
"Masks determine which blocks are placed",
|
// ImmutableList.of(),
|
||||||
MaskCommandsRegistration.builder(),
|
// "Masks determine which blocks are placed",
|
||||||
new MaskCommands(worldEdit)
|
// MaskCommandsRegistration.builder(),
|
||||||
);
|
// new MaskCommands(worldEdit)
|
||||||
registerSubCommands(
|
// );
|
||||||
"transforms",
|
// registerSubCommands(
|
||||||
ImmutableList.of(),
|
// "transforms",
|
||||||
"Transforms modify how a block is placed",
|
// ImmutableList.of(),
|
||||||
TransformCommandsRegistration.builder(),
|
// "Transforms modify how a block is placed",
|
||||||
new TransformCommands()
|
// TransformCommandsRegistration.builder(),
|
||||||
);
|
// new TransformCommands()
|
||||||
|
// );
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"schematic",
|
"schematic",
|
||||||
ImmutableList.of("schem", "/schematic", "/schem"),
|
ImmutableList.of("schem", "/schematic", "/schem"),
|
||||||
@ -460,13 +451,14 @@ public final class PlatformCommandManager {
|
|||||||
WorldEditCommandsRegistration.builder(),
|
WorldEditCommandsRegistration.builder(),
|
||||||
new WorldEditCommands(worldEdit)
|
new WorldEditCommands(worldEdit)
|
||||||
);
|
);
|
||||||
registerSubCommands(
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
"cfi",
|
// registerSubCommands(
|
||||||
ImmutableList.of("/cfi"),
|
// "cfi",
|
||||||
"CFI commands",
|
// ImmutableList.of("/cfi"),
|
||||||
CFICommandsRegistration.builder(),
|
// "CFI commands",
|
||||||
new CFICommands(worldEdit)
|
// CFICommandsRegistration.builder(),
|
||||||
);
|
// new CFICommands(worldEdit)
|
||||||
|
// );
|
||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"/anvil",
|
"/anvil",
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
@ -608,16 +600,6 @@ public final class PlatformCommandManager {
|
|||||||
return CommandArgParser.forArgString(input).parseArgs();
|
return CommandArgParser.forArgString(input).parseArgs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T parseCommand(String args, Actor actor) {
|
|
||||||
InjectedValueAccess context;
|
|
||||||
if (actor == null) {
|
|
||||||
context = globalInjectedValues;
|
|
||||||
} else {
|
|
||||||
context = initializeInjectedValues(args::toString, actor, null);
|
|
||||||
}
|
|
||||||
return parseCommand(args, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T parseConverter(String args, InjectedValueAccess access, Class<T> clazz) {
|
public <T> T parseConverter(String args, InjectedValueAccess access, Class<T> clazz) {
|
||||||
ArgumentConverter<T> converter = commandManager.getConverter(Key.of(clazz)).orElse(null);
|
ArgumentConverter<T> converter = commandManager.getConverter(Key.of(clazz)).orElse(null);
|
||||||
if (converter != null) {
|
if (converter != null) {
|
||||||
@ -630,14 +612,6 @@ public final class PlatformCommandManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T parseCommand(String args, InjectedValueAccess access) {
|
|
||||||
if (args.isEmpty()) return null;
|
|
||||||
String[] split = parseArgs(args)
|
|
||||||
.map(Substring::getSubstring)
|
|
||||||
.toArray(String[]::new);
|
|
||||||
return (T) commandManager.execute(access, ImmutableList.copyOf(split));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void handleCommand(CommandEvent event) {
|
public void handleCommand(CommandEvent event) {
|
||||||
Request.reset();
|
Request.reset();
|
||||||
@ -771,19 +745,20 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
worldEdit.flushBlockBag(actor, editSession);
|
worldEdit.flushBlockBag(actor, editSession);
|
||||||
}
|
}
|
||||||
CFICommands.CFISettings cfi = actor.getMeta("CFISettings");
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
if (cfi != null) {
|
// CFICommands.CFISettings cfi = actor.getMeta("CFISettings");
|
||||||
HeightMapMCAGenerator gen = cfi.getGenerator();
|
// if (cfi != null) {
|
||||||
if (gen != null && gen.isModified()) {
|
// HeightMapMCAGenerator gen = cfi.getGenerator();
|
||||||
try {
|
// if (gen != null && gen.isModified()) {
|
||||||
gen.update();
|
// try {
|
||||||
CFIChangeSet set = new CFIChangeSet(gen, actor.getUniqueId());
|
// gen.update();
|
||||||
session.remember(actor, gen, set, actor.getLimit());
|
// CFIChangeSet set = new CFIChangeSet(gen, actor.getUniqueId());
|
||||||
} catch (IOException e) {
|
// session.remember(actor, gen, set, actor.getLimit());
|
||||||
e.printStackTrace();
|
// } catch (IOException e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
Request.reset();
|
Request.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
package com.sk89q.worldedit.extension.platform.binding;
|
package com.sk89q.worldedit.extension.platform.binding;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.object.extent.NullExtent;
|
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
|
||||||
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
@ -17,7 +9,6 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector2;
|
import com.sk89q.worldedit.math.Vector2;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -44,29 +35,31 @@ public class PrimitiveBindings extends Bindings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||||
* Gets an {@link Extent} from a {@link Binding}.
|
//
|
||||||
*
|
// /**
|
||||||
* @param argument the context
|
// * Gets an {@link Extent} from a {@link Binding}.
|
||||||
* @return an extent
|
// *
|
||||||
* @throws InputParseException on other error
|
// * @param argument the context
|
||||||
*/
|
// * @return an extent
|
||||||
@Binding
|
// * @throws InputParseException on other error
|
||||||
public ResettableExtent getResettableExtent(Actor actor, String argument) throws InputParseException {
|
// */
|
||||||
if (argument.equalsIgnoreCase("#null")) {
|
// @Binding
|
||||||
return new NullExtent();
|
// public ResettableExtent getResettableExtent(Actor actor, String argument) throws InputParseException {
|
||||||
}
|
// if (argument.equalsIgnoreCase("#null")) {
|
||||||
DefaultTransformParser parser = Fawe.get().getTransformParser();
|
// return new NullExtent();
|
||||||
ParserContext parserContext = new ParserContext();
|
// }
|
||||||
if (actor instanceof Entity) {
|
// DefaultTransformParser parser = Fawe.get().getTransformParser();
|
||||||
Extent extent = ((Entity) actor).getExtent();
|
// ParserContext parserContext = new ParserContext();
|
||||||
if (extent instanceof World) {
|
// if (actor instanceof Entity) {
|
||||||
parserContext.setWorld((World) extent);
|
// Extent extent = ((Entity) actor).getExtent();
|
||||||
}
|
// if (extent instanceof World) {
|
||||||
}
|
// parserContext.setWorld((World) extent);
|
||||||
parserContext.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
|
// }
|
||||||
return parser.parseFromInput(argument, parserContext);
|
// }
|
||||||
}
|
// parserContext.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
|
||||||
|
// return parser.parseFromInput(argument, parserContext);
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a type from a {@link Binding}.
|
* Gets a type from a {@link Binding}.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.sk89q.worldedit.extension.platform.binding;
|
package com.sk89q.worldedit.extension.platform.binding;
|
||||||
|
|
||||||
import com.boydti.fawe.command.CFICommands;
|
|
||||||
import com.boydti.fawe.config.Caption;
|
import com.boydti.fawe.config.Caption;
|
||||||
import com.boydti.fawe.database.DBHandler;
|
import com.boydti.fawe.database.DBHandler;
|
||||||
import com.boydti.fawe.database.RollbackDatabase;
|
import com.boydti.fawe.database.RollbackDatabase;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.command;
|
package com.sk89q.worldedit.internal.command;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -40,6 +39,8 @@ import java.util.logging.Logger;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs called commands to a logger.
|
* Logs called commands to a logger.
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,6 @@ public class CommandRegistrationHandler {
|
|||||||
|
|
||||||
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
private static final CommandPermissionsConditionGenerator PERM_GEN = new CommandPermissionsConditionGenerator();
|
||||||
|
|
||||||
|
|
||||||
private final List<CommandCallListener> callListeners;
|
private final List<CommandCallListener> callListeners;
|
||||||
|
|
||||||
public CommandRegistrationHandler(List<CommandCallListener> callListeners) {
|
public CommandRegistrationHandler(List<CommandCallListener> callListeners) {
|
||||||
|
@ -135,7 +135,7 @@ public class CommandUtil {
|
|||||||
.findAny();
|
.findAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object deprecatedCommandWarning(
|
private static int deprecatedCommandWarning(
|
||||||
CommandParameters parameters,
|
CommandParameters parameters,
|
||||||
Command command,
|
Command command,
|
||||||
String reason,
|
String reason,
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.internal.command;
|
|||||||
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
import com.sk89q.worldedit.command.util.annotation.Confirm;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
|
import java.util.Optional;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
import org.enginehub.piston.exception.StopExecutionException;
|
import org.enginehub.piston.exception.StopExecutionException;
|
||||||
import org.enginehub.piston.gen.CommandCallListener;
|
import org.enginehub.piston.gen.CommandCallListener;
|
||||||
@ -39,7 +40,12 @@ public class ConfirmHandler implements CommandCallListener {
|
|||||||
if (confirmAnnotation == null) {
|
if (confirmAnnotation == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Actor actor = parameters.injectedValue(Key.of(Actor.class)).get();
|
Optional<Actor> actorOpt = parameters.injectedValue(Key.of(Actor.class));
|
||||||
|
|
||||||
|
if (!actorOpt.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Actor actor = actorOpt.get();
|
||||||
if (!confirmAnnotation.value().passes(actor, parameters, 1)) {
|
if (!confirmAnnotation.value().passes(actor, parameters, 1)) {
|
||||||
throw new StopExecutionException(TextComponent.empty());
|
throw new StopExecutionException(TextComponent.empty());
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,12 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|||||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||||
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
||||||
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.enginehub.piston.exception.CommandException;
|
import org.enginehub.piston.exception.CommandException;
|
||||||
import org.enginehub.piston.exception.UsageException;
|
import org.enginehub.piston.exception.UsageException;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
applyLibrariesConfiguration()
|
applyLibrariesConfiguration()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
|
||||||
"shade"("FAWE-Piston:core-ap/annotations/build/libs/annotations-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
|
||||||
"shade"("FAWE-Piston:core-ap/processor/build/libs/processor-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
|
||||||
"shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}")
|
"shade"("org.enginehub.piston.core-ap:annotations:${Versions.PISTON}")
|
||||||
"shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}")
|
"shade"("org.enginehub.piston.core-ap:processor:${Versions.PISTON}")
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ dependencies {
|
|||||||
"shade"("com.sk89q:jchronic:0.2.4a") {
|
"shade"("com.sk89q:jchronic:0.2.4a") {
|
||||||
exclude(group = "junit", module = "junit")
|
exclude(group = "junit", module = "junit")
|
||||||
}
|
}
|
||||||
|
"shade"("com.thoughtworks.paranamer:paranamer:2.6")
|
||||||
"shade"("com.github.luben:zstd-jni:1.4.3-1")
|
"shade"("com.github.luben:zstd-jni:1.4.3-1")
|
||||||
"shade"("com.sk89q.lib:jlibnoise:1.0.0")
|
"shade"("com.sk89q.lib:jlibnoise:1.0.0")
|
||||||
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
"shade"("org.enginehub.piston:core:${Versions.PISTON}")
|
||||||
"shade"("FAWE-Piston:core-ap/runtime/build/libs/runtime-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
"shade"("org.enginehub.piston.core-ap:runtime:${Versions.PISTON}")
|
||||||
"shade"("FAWE-Piston:default-impl/build/libs/default-impl-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
"shade"("org.enginehub.piston:default-impl:${Versions.PISTON}")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren