Removed commands.yml

I also did a few renames as well as a command registration fix.
This commit is contained in:
MattBDev 2019-07-26 19:23:24 -04:00
parent 9a4473b73f
commit 7963b2c92f
19 changed files with 121 additions and 304 deletions

View File

@ -2,7 +2,6 @@ package com.boydti.fawe;
import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VisualQueue;
@ -311,7 +310,6 @@ public class Fawe {
// Setting up message.yml
String lang = Objects.toString(Settings.IMP.LANGUAGE);
BBC.load(new File(this.IMP.getDirectory(), (lang.isEmpty() ? "" : lang + File.separator) + "message.yml"));
Commands.load(new File(INSTANCE.IMP.getDirectory(), "commands.yml"));
} catch (Throwable e) {
debug("====== Failed to load config ======");
debug("Please validate your yaml files:");

View File

@ -1,5 +1,7 @@
package com.boydti.fawe.beta;
import static com.sk89q.worldedit.world.block.BlockTypes.states;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.Extent;
@ -9,10 +11,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable;
import static com.sk89q.worldedit.world.block.BlockTypes.states;
public class CharFilterBlock extends ChunkFilterBlock {
private CharGetBlocks get;
private IChunkSet set;
@ -29,12 +28,12 @@ public class CharFilterBlock extends ChunkFilterBlock {
}
@Override
public final ChunkFilterBlock init(final int X, final int Z, final IChunkGet chunk) {
public final ChunkFilterBlock init(final int x, final int z, final IChunkGet chunk) {
this.get = (CharGetBlocks) chunk;
this.X = X;
this.Z = Z;
this.xx = X << 4;
this.zz = Z << 4;
this.X = x;
this.Z = z;
this.xx = x << 4;
this.zz = z << 4;
return this;
}

View File

@ -1,17 +1,14 @@
package com.boydti.fawe.beta;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import javax.annotation.Nullable;
public abstract class ChunkFilterBlock extends SimpleFilterBlock {
public ChunkFilterBlock(Extent extent) {
super(extent);
}
public abstract ChunkFilterBlock init(int X, int Z, IChunkGet chunk);
public abstract ChunkFilterBlock init(int x, int z, IChunkGet chunk);
public abstract ChunkFilterBlock init(final IChunkGet iget, final IChunkSet iset, final int layer);

View File

@ -2,21 +2,19 @@ package com.boydti.fawe.command;
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.changeset.CFIChangeSet;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.exception.StopExecutionException;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class CFICommand extends CommandProcessor<Object, Object> {
public CFICommand(CommandManager manager) {
@ -51,12 +49,11 @@ public class CFICommand extends CommandProcessor<Object, Object> {
private List<String> dispatch(FawePlayer fp, CFICommands.CFISettings settings, List<String> args, InjectedValueAccess context) {
if (!settings.hasGenerator()) {
if (args.size() == 0) {
String hmCmd = CFICommands.alias() + " ";
String hmCmd = "/cfi ";
if (settings.image == null) {
hmCmd += "image";
} else {
hmCmd =
Commands.getAlias(CFICommands.class, "heightmap") + " " + settings.imageArg;
hmCmd = "heightmap" + " " + settings.imageArg;
}
TextComponent build = TextComponent.builder("What do you want to use as the base?")
.append(newline())

View File

@ -8,7 +8,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
@ -403,7 +402,7 @@ public class CFICommands {
.append(" - Block textures within a complexity range")
.append(newline())
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent
.runCommand("/cfi " + Commands.getAlias(CFICommands.class, "coloring"))))
.runCommand("/cfi coloring")))
.build();
fp.toWorldEditPlayer().print(build);
return;
@ -813,13 +812,13 @@ public class CFICommands {
//TODO fix this so it can execute commands and show tooltips.
@NonNull Builder builder = TextComponent.builder(">> Current Settings <<").append(newline())
.append("Randomization ").append("[" + Boolean.toString(rand).toUpperCase() + "]")//.cmdTip(alias() + " randomization " + (!rand))
.append("Randomization ").append("[" + Boolean.toString(rand).toUpperCase() + "]")//.cmdTip("/cfi randomization " + (!rand))
.append(newline())
.append("Mask ").append("[" + mask + "]")//.cmdTip(alias() + " mask")
.append("Mask ").append("[" + mask + "]")//.cmdTip("/cfi mask")
.append(newline())
.append("Blocks ").append("[" + blocks + "]")//.tooltip(blockList).command(alias() + " paletteBlocks")
.append("Blocks ").append("[" + blocks + "]")//.tooltip(blockList).command("/cfi paletteBlocks")
.append(newline())
.append("BiomePriority ").append("[" + biomePriority + "]")//.cmdTip(alias() + " biomepriority")
.append("BiomePriority ").append("[" + biomePriority + "]")//.cmdTip("/cfi biomepriority")
.append(newline());
if (settings.image != null) {
@ -835,16 +834,16 @@ public class CFICommands {
}
builder.append("Image: ")
.append("[" + settings.imageArg + "]")//.cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
.append("[" + settings.imageArg + "]")//.cmdTip("/cfi " + Commands.getAlias(CFICommands.class, "image"))
.append(newline()).append(newline())
.append("Let's Color: ")
//.cmdOptions(alias() + " ", colorArgs.toString(), "Biomes", "Blocks", "BlockAndBiome", "Glass")
//.cmdOptions("/cfi ", colorArgs.toString(), "Biomes", "Blocks", "BlockAndBiome", "Glass")
.append(newline());
} else {
builder.append(newline()).append("You can color a world using an image like ")
.append(TextComponent.of("[This]").clickEvent(ClickEvent.openUrl("http://i.imgur.com/vJYinIU.jpg"))).append(newline())
.append("You MUST provide an image: ")
.append("[None]");//.cmdTip(alias() + " " + Commands.getAlias(Command.class, "image")).append(newline());
.append("[None]");//.cmdTip("/cfi " + Commands.getAlias(Command.class, "image")).append(newline());
}
builder.append("< [Back]");//.cmdTip(alias()).send(fp);
fp.toWorldEditPlayer().print(builder.build());
@ -865,11 +864,9 @@ public class CFICommands {
settings.maskArg = mask != null ? split[index++] : null;
settings.whiteOnly = !disableWhiteOnly;
StringBuilder cmd = new StringBuilder("/cfi mask ");
String s = "/cfi mask http://";
String s1 = "/cfi mask <mask>";
String s2 = alias() + " " + settings.getCategory();
String s2 = "/cfi " + settings.getCategory();
TextComponent build = TextComponent.builder(">> Current Settings <<")
.append(newline())
.append("Image Mask ").append(
@ -899,13 +896,13 @@ public class CFICommands {
settings.pattern = pattern;
settings.patternArg = pattern == null ? null : split[index++];
StringBuilder cmd = new StringBuilder(alias() + " pattern ");
StringBuilder cmd = new StringBuilder("/cfi pattern ");
if (pattern != null) {
settings.getCategory().accept(fp);
} else {
String s = cmd + " stone";
String s1 = alias() + " " + settings.getCategory();
String s1 = "/cfi " + settings.getCategory();
TextComponent build = TextComponent.builder(">> Current Settings <<").append(newline())
.append("Pattern ").append(TextComponent.of("[Click Here]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s)))
@ -939,7 +936,7 @@ public class CFICommands {
desc = "Select an image"
)
@CommandPermissions("worldedit.anvil.cfi")
public void image(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, InjectedValueAccess context)throws CommandException {
public void image(FawePlayer fp, @Arg(desc = "image url or filename", def = "") ProvideBindings.ImageUri image, InjectedValueAccess context)throws CommandException {
CFISettings settings = getSettings(fp);
String[] split = getArguments(context).split(" ");
int index = 2;
@ -978,9 +975,9 @@ public class CFICommands {
TextComponent build = TextComponent.builder("What would you like to populate?")
.append(newline())
.append("(You will need to type these commands)").append(newline())
//TODO .cmdOptions(alias() + " ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
//TODO .cmdOptions("/cfi ", "", "Ores", "Ore", "Caves", "Schematics", "Smooth")
.append(newline())
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent.runCommand(alias())))
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent.runCommand("/cfi")))
.build();
fp.toWorldEditPlayer().print(build);
}
@ -1018,39 +1015,39 @@ public class CFICommands {
maskArgs.append(" -w");
}
String height = Commands.getAlias(CFICommands.class, "height");
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
String snow = Commands.getAlias(CFICommands.class, "snow");
String height = "/cfi height";
String waterHeight = "/cfi waterheight";
String snow = "/cfi snow";
//TODO
@NonNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline())
.append("Mask ").append(TextComponent.of("[" + mask + "]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " mask")))
.clickEvent(ClickEvent.runCommand(alias() + " mask")))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi mask")))
.clickEvent(ClickEvent.runCommand("/cfi mask")))
.append(newline())
.append("Pattern ").append(TextComponent.of("[" + pattern + "]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " pattern")))
.clickEvent(ClickEvent.runCommand(alias() + " pattern")))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi pattern")))
.clickEvent(ClickEvent.runCommand("/cfi pattern")))
.append(newline())
.append(newline())
.append(">> Components <<")
.append(newline())
.append(TextComponent.of("[Height]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("height") + " 120")))
.clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("height") + " 120"))).append(" - Terrain height for whole map")
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi height 120")))
.clickEvent(ClickEvent.suggestCommand("/cfi height 120"))).append(" - Terrain height for whole map")
.append(newline())
.append(TextComponent.of("[WaterHeight]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("waterheight") + " 60")))
.clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("waterheight") + " 60"))).append(" - Sea level for whole map")
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi waterheight 60")))
.clickEvent(ClickEvent.suggestCommand("/cfi waterheight 60"))).append(" - Sea level for whole map")
.append(newline())
.append(TextComponent.of("[FloorThickness]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("floorthickness") + " 60")))
.clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("floorthickness") + " 60"))).append(" - Floor thickness of entire map")
.append(TextComponent.of("[FloorThickness]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi floorthickness 60")))
.clickEvent(ClickEvent.suggestCommand("/cfi floorthickness 60"))).append(" - Floor thickness of entire map")
.append(newline())
.append(TextComponent.of("[WorldThickness]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("worldthickness") + " 60")))
.clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("worldthickness") + " 60"))).append(" - World thickness of entire map")
.append(TextComponent.of("[WorldThickness]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi worldthickness 60")))
.clickEvent(ClickEvent.suggestCommand("/cfi worldthickness 60"))).append(" - World thickness of entire map")
.append(newline())
.append(TextComponent.of("[Snow]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("snow") + maskArgs)))
.clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("snow") + maskArgs))).append(" - Set snow in the masked areas")
.append(TextComponent.of("[Snow]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi snow" + maskArgs)))
.clickEvent(ClickEvent.suggestCommand("/cfi snow" + maskArgs))).append(" - Set snow in the masked areas")
.append(newline());
if (pattern != null) {
@ -1067,38 +1064,38 @@ public class CFICommands {
msg
.append(TextComponent.of("[WaterId]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " waterId " + pattern)))
.clickEvent(ClickEvent.runCommand(alias() + " waterId " + pattern)))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi waterId " + pattern)))
.clickEvent(ClickEvent.runCommand("/cfi waterId " + pattern)))
.append(" - Water id for whole map")
.append(newline())
.append(TextComponent.of("[BedrockId]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " baseId " + pattern)))
.clickEvent(ClickEvent.runCommand(alias() + " baseId " + pattern)))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi baseId " + pattern)))
.clickEvent(ClickEvent.runCommand("/cfi baseId " + pattern)))
.append(TextComponent.of(" - Bedrock id for whole map"))
.append(newline())
.append(TextComponent.of("[Floor]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " floor " + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " floor " + compArgs)))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi floor " + compArgs)))
.clickEvent(ClickEvent.runCommand("/cfi floor " + compArgs)))
.append(TextComponent.of(" - Set the floor in the masked areas")).append(newline())
.append(TextComponent.of("[Main]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " main " + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " main " + compArgs)))
.hoverEvent(HoverEvent.showText(TextComponent.of("/cfi main " + compArgs)))
.clickEvent(ClickEvent.runCommand("/cfi main " + compArgs)))
.append(TextComponent.of(" - Set the main block in the masked areas")).append(newline())
.append(TextComponent.of("[Column]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " column" + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " column" + compArgs))).append(" - Set the columns in the masked areas").append(newline())
.append(TextComponent.of("[Overlay]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " overlay" + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " overlay" + compArgs))).append(" - Set the overlay in the masked areas").append(newline());
.append(TextComponent.of("[Column]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi column" + compArgs)))
.clickEvent(ClickEvent.runCommand("/cfi column" + compArgs))).append(" - Set the columns in the masked areas").append(newline())
.append(TextComponent.of("[Overlay]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi overlay" + compArgs)))
.clickEvent(ClickEvent.runCommand("/cfi overlay" + compArgs))).append(" - Set the overlay in the masked areas").append(newline());
}
msg.append(newline())
.append(TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(alias()))).clickEvent(ClickEvent.runCommand(alias())));
.append(TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of("/cfi"))).clickEvent(ClickEvent.runCommand("/cfi")));
fp.toWorldEditPlayer().print(msg.build());
}
private static CFISettings assertSettings(FawePlayer fp) {
CFISettings settings = getSettings(fp);
if (!settings.hasGenerator()) {
throw new StopExecutionException(TextComponent.of("Please use /" + alias()));
throw new StopExecutionException(TextComponent.of("Please use /cfi"));
}
return settings;
}
@ -1230,22 +1227,14 @@ public class CFICommands {
}
}
protected static String alias() {
return Commands.getAlias(CFICommand.class, "/cfi");
}
protected static String alias(String command) {
return Commands.getAlias(CFICommands.class, command);
}
@SuppressWarnings("unused")
protected static void mainMenu(FawePlayer fp) {
//TODO
// msg("What do you want to do now?").append(newline())
// .cmdOptions(alias() + " ", "", "Coloring", "Component", "Populate", "Brush")
// .append(newline()).text("<> [View]").command(alias() + " " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
// .append(newline()).text(">< [Cancel]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "cancel"))
// .append(newline()).text("&2>> [Done]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "done"))
// .cmdOptions("/cfi ", "", "Coloring", "Component", "Populate", "Brush")
// .append(newline()).text("<> [View]").command("/cfi " + Commands.getAlias(CFICommands.class, "download")).tooltip("View full resolution image")
// .append(newline()).text(">< [Cancel]").cmdTip("/cfi " + Commands.getAlias(CFICommands.class, "cancel"))
// .append(newline()).text("&2>> [Done]").cmdTip("/cfi " + Commands.getAlias(CFICommands.class, "done"))
// .send(fp);
}
}

View File

@ -16,6 +16,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@ -395,7 +396,7 @@ public enum BBC {
BBC(String defaultMessage, String category) {
this.defaultMessage = defaultMessage;
this.translatedMessage = defaultMessage;
this.category = category.toLowerCase();
this.category = category.toLowerCase(Locale.ROOT);
}
public String format(Object... args) {
@ -436,13 +437,13 @@ public enum BBC {
continue;
}
final String[] split = key.split("\\.");
final String node = split[split.length - 1].toUpperCase();
final String node = split[split.length - 1].toUpperCase(Locale.ROOT);
final BBC caption = allNames.contains(node) ? valueOf(node) : null;
if (caption != null) {
if (!split[0].equalsIgnoreCase(caption.category)) {
changed = true;
yml.set(key, null);
yml.set(caption.category + "." + caption.name().toLowerCase(), value);
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), value);
}
captions.add(caption);
caption.translatedMessage = (String) value;
@ -457,7 +458,7 @@ public enum BBC {
for (BBC caption : all) {
if (!captions.contains(caption)) {
changed = true;
yml.set(caption.category + "." + caption.name().toLowerCase(), caption.defaultMessage);
yml.set(caption.category + "." + caption.name().toLowerCase(Locale.ROOT), caption.defaultMessage);
}
caption.translatedMessage = StringMan.replaceFromMap(caption.translatedMessage, replacements);
}
@ -662,7 +663,7 @@ public enum BBC {
int index = builder.length();
if (!Objects.equals(color, newColor)) {
style[0] = newColor;
char code = BBC.getCode(newColor.toUpperCase());
char code = BBC.getCode(newColor.toUpperCase(Locale.ROOT));
builder.append('\u00A7').append(code);
}
for (Map.Entry<String, Object> entry2 : obj.entrySet()) {
@ -670,12 +671,12 @@ public enum BBC {
boolean newValue = Boolean.parseBoolean((String) entry2.getValue());
if (properties.put(entry2.getKey(), newValue) != newValue) {
if (newValue) {
char code = BBC.getCode(entry2.getKey().toUpperCase());
char code = BBC.getCode(entry2.getKey().toUpperCase(Locale.ROOT));
builder.append('\u00A7').append(code);
} else {
builder.insert(index, '\u00A7').append('r');
if (Objects.equals(color, newColor) && newColor != null) {
builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase()));
builder.append('\u00A7').append(BBC.getCode(newColor.toUpperCase(Locale.ROOT)));
}
}
}

View File

@ -1,123 +0,0 @@
package com.boydti.fawe.config;
import com.boydti.fawe.configuration.ConfigurationSection;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.util.StringMan;
import org.enginehub.piston.annotation.Command;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Commands {
private static YamlConfiguration cmdConfig;
private static File cmdFile;
public static void load(File file) {
cmdFile = file;
try {
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
cmdConfig = YamlConfiguration.loadConfiguration(file);
} catch (IOException e) {
e.printStackTrace();
}
}
public static Command translate(Class clazz, final Command command) {
if (cmdConfig == null || command instanceof TranslatedCommand) {
return command;
}
return new TranslatedCommand(clazz.getSimpleName(), command);
}
public static String getAlias(Class clazz, String command) {
if (cmdConfig == null) {
return command;
}
List<String> aliases = cmdConfig.getStringList(clazz + "." + command + ".aliases");
if (aliases == null) {
aliases = cmdConfig.getStringList(command + ".aliases");
}
return (aliases == null || aliases.isEmpty()) ? command : aliases.get(0);
}
public static class TranslatedCommand implements Command {
private final String name;
private final String[] aliases;
private final String desc;
private final String descFooter;
private final Command command;
public TranslatedCommand(String clazz, Command command) {
String id = command.aliases()[0];
ConfigurationSection commands;
if (cmdConfig.contains(clazz + "." + id) || !cmdConfig.contains(id)) {
commands = cmdConfig.getConfigurationSection(clazz + "." + id);
} else {
commands = cmdConfig.getConfigurationSection(id);
}
boolean set = false;
if (commands == null) {
set = (commands = cmdConfig.createSection(clazz + "." + id)) != null;
}
HashMap<String, Object> options = new HashMap<>();
options.put("name", command.name());
options.put("aliases", new ArrayList<>(Arrays.asList(command.aliases())));
options.put("help", command.desc());
options.put("desc", command.descFooter());
for (Map.Entry<String, Object> entry : options.entrySet()) {
String key = entry.getKey();
if (!commands.contains(key)) {
commands.set(key, entry.getValue());
set = true;
}
}
if (set) {
try {
cmdConfig.save(cmdFile);
} catch (IOException e) {
e.printStackTrace();
}
}
this.name = commands.getString("name");
this.aliases = commands.getStringList("aliases").toArray(new String[0]);
this.desc = commands.getString("help");
this.descFooter = commands.getString("desc");
this.command = command;
}
@Override
public Class<? extends Annotation> annotationType() {
return this.command.annotationType();
}
@Override
public String name() {
return name;
}
@Override
public String[] aliases() {
return aliases;
}
@Override
public String desc() {
return desc;
}
@Override
public String descFooter() {
return descFooter;
}
}
}

View File

@ -1,6 +1,5 @@
package com.boydti.fawe.object;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.extent.ExtentHeightCacher;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
@ -11,7 +10,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class DataAnglePattern extends AbstractPattern {
public final double FACTOR;
public final double factor;
public final Extent extent;
public final int maxY;
public final int distance;
@ -20,7 +19,7 @@ public class DataAnglePattern extends AbstractPattern {
this.extent = new ExtentHeightCacher(extent);
this.maxY = extent.getMaximumPoint().getBlockY();
this.distance = distance;
this.FACTOR = (1D / distance) * (1D / 255);
this.factor = (1D / distance) * (1D / 255);
}
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
@ -55,4 +54,4 @@ public class DataAnglePattern extends AbstractPattern {
int data = (Math.min(slope, 255)) >> 4;
return extent.setBlock(setPosition, block.withPropertyId(data));
}
}
}

View File

@ -24,7 +24,6 @@ import com.boydti.fawe.util.image.Drawable;
import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -42,7 +41,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID;
@ -50,8 +48,6 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
@ -62,6 +58,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nullable;
// TODO FIXME
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
@ -139,7 +136,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
resetPrimtives();
} catch (Throwable neverHappens) { neverHappens.printStackTrace(); }
} catch (Throwable neverHappens) {
neverHappens.printStackTrace();
}
blocks.flushChanges(out);
}
@ -171,7 +170,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
resetPrimtives();
} catch (Throwable neverHappens) { neverHappens.printStackTrace(); }
} catch (Throwable neverHappens) {
neverHappens.printStackTrace();
}
blocks.undoChanges(in);
}
@ -191,7 +192,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
}
resetPrimtives();
} catch (Throwable neverHappens) { neverHappens.printStackTrace(); }
} catch (Throwable neverHappens) {
neverHappens.printStackTrace();
}
blocks.clearChanges(); // blocks.redoChanges(in); Unsupported
}

View File

@ -69,8 +69,7 @@ public class ObjObjMap<K, V> {
// if ( k == FREE_KEY )
// return null; //end of chain already
if (k == key) //we check FREE and REMOVED prior to this call
{
if (k == key) {//we check FREE and REMOVED prior to this call
return (V) m_data[ptr + 1];
}
while (true) {

View File

@ -51,6 +51,7 @@ import java.io.Serializable;
* @version 1.0, 2009-03-17
* @since 1.6
*/
@SuppressWarnings("ALL")
public class SparseBitSet implements Cloneable, Serializable
{
/* My apologies for listing all the additional authors, but concepts, code,

View File

@ -19,7 +19,7 @@ public class AngleColorPattern extends DataAnglePattern {
public int getColor(int color, int slope) {
if (slope == 0) return color;
double newFactor = (1 - Math.min(1, slope * FACTOR));
double newFactor = (1 - Math.min(1, slope * factor));
int newRed = (int) (((color >> 16) & 0xFF) * newFactor);
int newGreen = (int) (((color >> 8) & 0xFF) * newFactor);
int newBlue = (int) (((color >> 0) & 0xFF) * newFactor);

View File

@ -412,17 +412,17 @@ public class MainUtil {
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
try (OutputStream output = con.getOutputStream(); PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
String CRLF = "\r\n";
writer.append("--" + boundary).append(CRLF);
writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF);
writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(CRLF);
String crlf = "\r\n";
writer.append("--" + boundary).append(crlf);
writer.append("Content-Disposition: form-data; name=\"param\"").append(crlf);
writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(crlf);
String param = "value";
writer.append(CRLF).append(param).append(CRLF).flush();
writer.append("--" + boundary).append(CRLF);
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"').append(CRLF);
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF);
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
writer.append(CRLF).flush();
writer.append(crlf).append(param).append(crlf).flush();
writer.append("--" + boundary).append(crlf);
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + '"').append(crlf);
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(crlf);
writer.append("Content-Transfer-Encoding: binary").append(crlf);
writer.append(crlf).flush();
OutputStream nonClosable = new AbstractDelegateOutputStream(new BufferedOutputStream(output)) {
@Override
public void close() {
@ -431,8 +431,8 @@ public class MainUtil {
writeTask.value = nonClosable;
writeTask.run();
nonClosable.flush();
writer.append(CRLF).flush();
writer.append("--" + boundary + "--").append(CRLF).flush();
writer.append(crlf).flush();
writer.append("--" + boundary + "--").append(crlf).flush();
}
int responseCode = ((HttpURLConnection) con).getResponseCode();
String content;

View File

@ -2,7 +2,6 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.TargetMode;
import com.boydti.fawe.object.brush.scroll.ScrollAction;
@ -139,7 +138,7 @@ public class BrushOptionsCommands {
public void list(Actor actor, InjectedValueAccess args,
@ArgFlag(name = 'p', desc = "Prints the requested page", def = "0")
int page) throws WorldEditException {
String baseCmd = Commands.getAlias(BrushCommands.class, "brush") + " " + Commands.getAlias(BrushOptionsCommands.class, "loadbrush");
String baseCmd = "/brush loadbrush";
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
// new RunnableVal2<Message, String[]>() {

View File

@ -1,66 +1,16 @@
package com.sk89q.worldedit.command;
import com.boydti.fawe.config.Commands;
import com.sk89q.worldedit.command.argument.Arguments;
import org.enginehub.piston.annotation.Command;
import java.util.Optional;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.WorldEdit;
import org.enginehub.piston.inject.Key;
import java.lang.reflect.Method;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
public class MethodCommands {
public static Command getCommand() {
try {
StackTraceElement[] stack = new Exception().getStackTrace();
for (StackTraceElement elem : stack) {
Class<?> clazz = Class.forName(elem.getClassName());
for (Method method : clazz.getMethods()) {
if (method.getName().equals(elem.getMethodName())) {
Command command = method.getAnnotation(Command.class);
if (command != null) return Commands.translate(clazz, command);
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
public static String getArguments(InjectedValueAccess context) {
if (context == null) return null;
Optional<Arguments> arguments = context.injectedValue(Key.of(Arguments.class));
if (arguments.isPresent()) {
return arguments.get().get();
}
return null;
return arguments.map(Arguments::get).orElse(null);
}
public static String[] getPermissions(InjectedValueAccess context) {
CommandPermissions cmdPerms = context.injectedValue(Key.of(CommandPermissions.class)).orElse(null);
if (cmdPerms != null) {
return cmdPerms.value();
}
try {
StackTraceElement[] stack = new Exception().getStackTrace();
for (StackTraceElement elem : stack) {
Class<?> clazz = Class.forName(elem.getClassName());
for (Method method : clazz.getMethods()) {
if (method.getName().equals(elem.getMethodName())) {
CommandPermissions perm = method.getAnnotation(CommandPermissions.class);
if (perm != null) return perm.value();
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
return new String[0];
}
}

View File

@ -162,7 +162,7 @@ public class NavigationCommands {
public void jumpTo(Player player,
@Arg(desc = "Location to jump to", def = "")
Location pos,
@Switch(name='f', desc = "force teleport")
@Switch(name = 'f', desc = "force teleport")
boolean force) throws WorldEditException {
if (pos == null) {

View File

@ -26,6 +26,7 @@ import com.boydti.fawe.command.AnvilCommands;
import com.boydti.fawe.command.AnvilCommandsRegistration;
import com.boydti.fawe.command.CFICommand;
import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
@ -45,6 +46,7 @@ import com.sk89q.worldedit.command.BiomeCommandsRegistration;
import com.sk89q.worldedit.command.BrushCommands;
import com.sk89q.worldedit.command.BrushCommandsRegistration;
import com.sk89q.worldedit.command.BrushOptionsCommands;
import com.sk89q.worldedit.command.BrushOptionsCommandsRegistration;
import com.sk89q.worldedit.command.ChunkCommands;
import com.sk89q.worldedit.command.ChunkCommandsRegistration;
import com.sk89q.worldedit.command.ClipboardCommands;
@ -359,6 +361,13 @@ public final class PlatformCommandManager {
WorldEditCommandsRegistration.builder(),
new WorldEditCommands(worldEdit)
);
registerSubCommands(
"cfi",
ImmutableList.of(),
"CFI commands",
CFICommandsRegistration.builder(),
new CFICommands(worldEdit)
);
registerSubCommands(
"/anvil",
ImmutableList.of(),
@ -404,7 +413,7 @@ public final class PlatformCommandManager {
);
this.registration.register(
new CFICommand(commandManager),
CFICommands.builder(),
CFICommandsRegistration.builder(),
new CFICommands(worldEdit)
);
this.registration.register(

View File

@ -351,8 +351,7 @@ public class PrimitiveBindings extends Bindings {
* @param modifiers the list of modifiers to scan
* @throws InputParseException on a validation error
*/
private static void validate(double number, Annotation[] modifiers)
{
private static void validate(double number, Annotation[] modifiers) {
for (Annotation modifier : modifiers) {
if (modifier instanceof Range) {
Range range = (Range) modifier;

View File

@ -620,18 +620,18 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
int X = chunk.getX();
int Z = chunk.getZ();
block = block.init(X, Z, get);
int x = chunk.getX();
int z = chunk.getZ();
block = block.init(x, z, get);
if ((minX + 15) >> 4 <= X && (maxX - 15) >> 4 >= X && (minZ + 15) >> 4 <= Z && (maxZ - 15) >> 4 >= Z) {
if ((minX + 15) >> 4 <= x && (maxX - 15) >> 4 >= x && (minZ + 15) >> 4 <= z && (maxZ - 15) >> 4 >= z) {
filter(chunk, filter, block, get, set, minY, maxY);
return;
}
int localMinX = Math.max(minX, X << 4) & 15;
int localMaxX = Math.min(maxX, 15 + X << 4) & 15;
int localMinZ = Math.max(minZ, Z << 4) & 15;
int localMaxZ = Math.min(maxZ, 15 + Z << 4) & 15;
int localMinX = Math.max(minX, x << 4) & 15;
int localMaxX = Math.min(maxX, 15 + x << 4) & 15;
int localMinZ = Math.max(minZ, z << 4) & 15;
int localMaxZ = Math.min(maxZ, 15 + z << 4) & 15;
int yStart = (minY & 15);
int yEnd = (maxY & 15);