Add direction for logs/stuff + tweak messages

This commit is contained in:
Jesse Boyd 2016-12-24 07:46:52 +11:00
parent 59c45f0fa7
commit 1987f7c34a
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
7 changed files with 192 additions and 107 deletions

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.configuration.MemorySection;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.object.RunnableVal3;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.StringMan;
@ -55,12 +56,21 @@ public enum BBC {
TRANSFORM_DISABLED("Global transform disabled", "WorldEdit.General"),
TRANSFORM("Global transform set", "WorldEdit.General"),
COMMAND_COPY("%s0 blocks were copied (Note: lazycopy is faster)", "WorldEdit.Copy"),
COMMAND_CUT("%s0 blocks were cut", "WorldEdit.Cut"),
COMMAND_PASTE("The clipboard has been pasted at %s0", "WorldEdit.Paste"),
COMMAND_COPY("%s0 blocks were copied.", "WorldEdit.Copy"),
COMMAND_CUT_SLOW("%s0 blocks were cut.\nTip: lazycut is safer", "WorldEdit.Cut"),
COMMAND_CUT_LAZY("%s0 blocks will be removed on paste", "WorldEdit.Cut"),
COMMAND_PASTE("The clipboard has been pasted at %s0\nTip: Paste on click with &c//br copypaste", "WorldEdit.Paste"),
COMMAND_ROTATE("The clipboard has been rotated", "WorldEdit.Rotate"),
COMMAND_FLIPPED("The clipboard has been flipped", "WorldEdit.Flip"),
COMMAND_REGEN("Region regenerated.", "WorldEdit.Regen"),
COMMAND_REGEN_0("Region regenerated.\nTip: Use a biome with /regen [biome]", "WorldEdit.Regen"),
COMMAND_REGEN_1("Region regenerated.\nTip: Use a seed with /regen [biome] [seed]", "WorldEdit.Regen"),
COMMAND_REGEN_2("Region regenerated.", "WorldEdit.Regen"),
COMMAND_TREE("%s0 trees created.", "WorldEdit.Tree"),
COMMAND_FLORA("%s0 flora created.", "WorldEdit.Flora"),
COMMAND_HISTORY_CLEAR("History cleared", "WorldEdit.History"),
@ -72,6 +82,7 @@ public enum BBC {
OPERATION("Operation queued (%s0)", "WorldEdit.Operation"),
SELECTION_WAND("Left click: select pos #1; Right click: select pos #2", "WorldEdit.Selection"),
SELECTION_WAND_DISABLE("Edit wand disabled.", "WorldEdit.Selection"),
SELECTION_WAND_ENABLE("Edit wand enabled.", "WorldEdit.Selection"),
SELECTION_CHUNK("Chunk selected (%s0)", "WorldEdit.Selection"),
@ -222,11 +233,51 @@ public enum BBC {
SEL_LIST("For a list of selection types use:&c //sel list", "Selection"),
SEL_MODES("Select one of the modes below:", "Selection"),
TIP_SEL_LIST("Tip: See the different selection modes with &c//sel list", "Tips"),
TIP_SELECT_CONNECTED("Tip: Select all connected blocks with //sel fuzzy", "Tips"),
TIP_SET_POS1("Tip: Use pos1 as a pattern with &c//set pos1", "Tips"),
TIP_FARWAND("Tip: Select distant points with &c//farwand", "Tips"),
// set
TIP_FAST("&7Tip: Set fast and without undo using &c//fast", "Tips"),
TIP_CANCEL("&7Tip: You can &c//cancel &7an edit in progress", "Tips"),
TIP_MASK("&7Tip: Set a global destination mask with &c/gmask", "Tips"),
TIP_MASK_ANGLE("Tip: Replace upward slopes of 3-20 blocks using&c //replace /-20:-3 bedrock", "Tips"),
TIP_SET_LINEAR("&7Tip: Set blocks linearly with&c //set #l3d:wood,bedrock", "Tips"),
TIP_SURFACE_SPREAD("&7Tip: Spread a flat surface with&c //set #surfacespread:5:0:5:#existing", "Tips"),
TIP_SET_HAND("&7Tip: Use your current hand with &c//set hand", "Tips"),
// replace
TIP_REPLACE_ID("&7Tip: Replace only the block id:&c //replace woodenstair #id:cobblestair", "Tips"),
TIP_REPLACE_LIGHT("Tip: Remove light sources with&c //replace #brightness:1:15 0", "Tips"),
TIP_TAB_COMPLETE("Tip: The replace command supports tab completion", "Tips"),
// clipboard
TIP_FLIP("Tip: Mirror with &c//flip", "Tips"),
TIP_DEFORM("Tip: Reshape with &c//deform", "Tips"),
TIP_TRANSFORM("Tip: Set a transform with &c//gtransform", "Tips"),
TIP_COPYPASTE("Tip: Paste on click with &c//br copypaste", "Tips"),
TIP_SOURCE_MASK("Tip: Set a source mask with &c/gsmask <mask>&7", "Tips"),
TIP_REPLACE_MARKER("Tip: Replace a block with your full clipboard using &c//replace wool #fullcopy", "Tips"),
TIP_PASTE("Tip: Place with &c//paste", "Tips"),
TIP_LAZYCOPY("Tip: lazycopy is faster", "Tips"),
TIP_DOWNLOAD("Tip: Try out &c//download", "Tips"),
TIP_ROTATE("Tip: Orientate with &c//rotate", "Tips"),
TIP_COPY_PATTERN("Tip: To use as a pattern try &c#copy", "Tips"),
// brush
TIP_BRUSH_SPLINE("&7Tip The spline &c//brush &7connects multiple shapes together", "Tips"),
TIP_BRUSH_HEIGHT("&7Tip: The height &c//brush &7smoothly raises or lowers terrain", "Tips"),
TIP_BRUSH_COPY("&7Tip: The copypaste &c//brush &7allows you to easily copy and paste objects", "Tips"),
TIP_BRUSH_MASK("&7Tip: Set a brush destination mask with &c/mask", "Tips"),
TIP_BRUSH_MASK_SOURCE("&7Tip: Set a brush source mask with &c/smask", "Tips"),
TIP_BRUSH_TRANSFORM("&7Tip: Set a brush transform with &c/transform", "Tips"),
TIP_BRUSH_RELATIVE("&7Tip: Use a relative clipboard pattern with //br sphere #~:#copy", "Tips"),
TIP_BRUSH_COMMAND("&7Tip: Try the command brush &c//br cmd <radius> <cmd1;cmd2>", "Tips"),
TIP_SEL_FUZZY("Tip: See the different selection modes with `//sel list`", "Tips"),
TIP_CANCEL("Tip: You can cancel an edit with `//cancel`", "Tips"),
TIP_DOWNLOAD("Tip: Download your clipboard with `//download`", "Tips"),
TIP_BRUSH("Tip: See all the cool brushes with `//br`", "Tips"),
@ -416,6 +467,11 @@ public enum BBC {
return this.cat;
}
public BBC or(BBC... others) {
int index = PseudoRandom.random.nextInt(others.length + 1);
return index == 0 ? this : others[index - 1];
}
public void send(Object actor, final Object... args) {
if (isEmpty()) {
return;

View File

@ -210,10 +210,13 @@ public class BrushCommands {
switch (block.getId()) {
case BlockID.SAND:
case BlockID.GRAVEL:
player.print(BBC.getPrefix() + BBC.BRUSH_SPHERE.f(radius));
BBC.BRUSH_TRY_OTHER.send(player);
return;
}
}
player.print(BBC.getPrefix() + BBC.BRUSH_SPHERE.f(radius));
BBC.TIP_BRUSH_COMMAND.or(BBC.TIP_BRUSH_RELATIVE, BBC.TIP_BRUSH_TRANSFORM, BBC.TIP_BRUSH_MASK_SOURCE, BBC.TIP_BRUSH_MASK, BBC.TIP_BRUSH_COPY, BBC.TIP_BRUSH_HEIGHT, BBC.TIP_BRUSH_SPLINE).send(player);
}
@Command(

View File

@ -118,6 +118,7 @@ public class ClipboardCommands {
clipboard.setOrigin(session.getPlacementPosition(player));
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
BBC.COMMAND_COPY.send(player, region.getArea());
BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
}
@ -154,8 +155,8 @@ public class ClipboardCommands {
}
Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
BBC.COMMAND_COPY.send(player, region.getArea());
BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player);
}
@Command(
@ -182,7 +183,7 @@ public class ClipboardCommands {
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
clipboard.setOrigin(session.getPlacementPosition(player));
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
BBC.COMMAND_CUT.send(player, region.getArea());
BBC.COMMAND_CUT_SLOW.send(player, region.getArea());
}
@Command(
@ -220,7 +221,7 @@ public class ClipboardCommands {
Operations.completeLegacy(copy);
session.setClipboard(new ClipboardHolder(clipboard, editSession.getWorldData()));
BBC.COMMAND_CUT.send(player, region.getArea());
BBC.COMMAND_CUT_LAZY.send(player, region.getArea());
}
@Command(aliases = { "download" }, desc = "Download your clipboard")
@ -318,16 +319,17 @@ public class ClipboardCommands {
selector.learnChanges();
selector.explainRegionAdjust(player, session);
}
BBC.COMMAND_PASTE.send(player, to);
BBC.COMMAND_PASTE.send(player);
BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to);
}
@Command(
aliases = { "/place" },
usage = "",
flags = "sao",
desc = "Place the clipboard's contents",
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)",
help =
"Places the clipboard's contents.\n" +
"Places the clipboard's contents without applying transformations (e.g. rotate).\n" +
"Flags:\n" +
" -a skips air blocks\n" +
" -o pastes at the original position\n" +
@ -431,6 +433,7 @@ public class ClipboardCommands {
transform = transform.rotateZ(-(zRotate != null ? zRotate : 0));
holder.setTransform(holder.getTransform().combine(transform));
BBC.COMMAND_ROTATE.send(player);
BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(player);
}
@Command(

View File

@ -288,6 +288,7 @@ public class RegionCommands {
}
int affected = editSession.replaceBlocks(region, from, Patterns.wrap(to));
BBC.VISITOR_BLOCK.send(player, affected);
BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
}
@Command(
@ -373,7 +374,10 @@ public class RegionCommands {
}
}
int affected = editSession.setBlocks(selection, Patterns.wrap(to));
BBC.OPERATION.send(player, affected);
if (affected != 0) {
BBC.OPERATION.send(player, affected);
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(player);
}
}
@Command(
@ -583,23 +587,25 @@ public class RegionCommands {
public void regenerateChunk(Player player, LocalSession session, EditSession editSession, @Selection Region region, CommandContext args) throws WorldEditException {
Mask mask = session.getMask();
Mask sourceMask = session.getSourceMask();
try {
session.setMask((Mask) null);
session.setSourceMask((Mask) null);
BaseBiome biome = null;
if (args.argsLength() >= 1) {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
}
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
editSession.regenerate(region, biome, seed);
} finally {
session.setMask(mask);
session.setSourceMask(mask);
session.setMask((Mask) null);
session.setSourceMask((Mask) null);
BaseBiome biome = null;
if (args.argsLength() >= 1) {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
List<BaseBiome> knownBiomes = biomeRegistry.getBiomes();
biome = Biomes.findBiomeByName(knownBiomes, args.getString(0), biomeRegistry);
}
Long seed = args.argsLength() != 2 || !MathMan.isInteger(args.getString(1)) ? null : Long.parseLong(args.getString(1));
editSession.regenerate(region, biome, seed);
session.setMask(mask);
session.setSourceMask(mask);
if (biome == null) {
BBC.COMMAND_REGEN_0.send(player);
} else if (seed == null) {
BBC.COMMAND_REGEN_1.send(player);
} else {
BBC.COMMAND_REGEN_2.send(player);
}
BBC.COMMAND_REGEN.send(player);
}
@Command(

View File

@ -278,6 +278,7 @@ public class SelectionCommands {
player.giveItem(we.getConfiguration().wandItem, 1);
BBC.SELECTION_WAND.send(player);
BBC.TIP_SEL_LIST.or(BBC.TIP_SELECT_CONNECTED, BBC.TIP_SET_POS1, BBC.TIP_FARWAND).send(player);
}
@Command(

View File

@ -24,11 +24,8 @@ import com.boydti.fawe.command.AnvilCommands;
import com.boydti.fawe.command.MaskBinding;
import com.boydti.fawe.command.PatternBinding;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.FakePlayer;
@ -72,7 +69,6 @@ import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.function.factory.Deform;
import com.sk89q.worldedit.function.factory.Deform.Mode;
import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
@ -360,19 +356,6 @@ public final class CommandManager {
editSession.flushQueue();
worldEdit.flushBlockBag(finalActor, editSession);
session.remember(editSession);
hasSession = editSession.size() > 0;
}
if (editSession != null) {
final long time = System.currentTimeMillis() - start;
if (time > 5 && hasSession) {
BBC.ACTION_COMPLETE.send(finalActor, (time / 1000d));
if (!Settings.HISTORY.COMBINE_STAGES) { // If stages are combined, we don't know the size yet (async flush)
ChangeSet fcs = editSession.getChangeSet();
if (fcs != null && fcs instanceof FaweStreamChangeSet) {
MainUtil.sendCompressedMessage((FaweStreamChangeSet) fcs, fp);
}
}
}
}
}
}

View File

@ -142,67 +142,91 @@ public class BundledBlockData {
if (!overwrite && (idMap.containsKey(entry.id) || legacyMap[entry.legacyId] != null)) {
return false;
}
if (entry.states != null) {
FaweState half = entry.states.get("half");
if (half != null && half.values != null) {
FaweStateValue top = half.values.get("top");
FaweStateValue bot = half.values.get("bottom");
if (top != null && top.getDirection() == null) {
top.setDirection(new Vector(0, 1, 0));
}
if (bot != null && bot.getDirection() == null) {
bot.setDirection(new Vector(0, -1, 0));
}
} else {
FaweState dir = entry.states.get("rotation");
if (dir != null && dir.values != null) {
Vector[] dirs = new Vector[]{new Vector(0, 0, -1),
new Vector(0.5, 0, -1),
new Vector(1, 0, -1),
new Vector(1, 0, -0.5),
new Vector(1, 0, 0),
new Vector(1, 0, 0.5),
new Vector(1, 0, 1),
new Vector(0.5, 0, 1),
new Vector(0, 0, 1),
new Vector(-0.5, 0, 1),
new Vector(-1, 0, 1),
new Vector(-1, 0, 0.5),
new Vector(-1, 0, 0),
new Vector(-1, 0, -0.5),
new Vector(-1, 0, -1),
new Vector(-0.5, 0, -1)};
int len = dir.values.size();
int increment = 16 / len;
int index = 0;
for (Map.Entry<String, FaweStateValue> valuesEntry : dir.values.entrySet()) {
valuesEntry.getValue().setDirection(dirs[index]);
index += increment;
}
} else if (entry.legacyId == 69) {
dir = entry.states.get("facing");
Vector[] dirs = new Vector[]{
new Vector(0, -1, 0),
new Vector(1, 0, 0),
new Vector(-1, 0, 0),
new Vector(0, 0, 1),
new Vector(0, 0, -1),
new Vector(0, 1, 0),
new Vector(0, 1, 0),
new Vector(0, -1, 0)};
int len = dir.values.size();
int index = 0;
for (Map.Entry<String, FaweStateValue> valuesEntry : dir.values.entrySet()) {
valuesEntry.getValue().setDirection(dirs[index]);
index ++;
}
}
}
}
idMap.put(entry.id, entry);
localizedMap.put(entry.localizedName.toLowerCase().replace(" ", "_"), entry);
legacyMap[entry.legacyId] = entry;
if (entry.states == null) {
return true;
}
FaweState half = entry.states.get("half");
if (half != null && half.values != null) {
FaweStateValue top = half.values.get("top");
FaweStateValue bot = half.values.get("bottom");
if (top != null && top.getDirection() == null) {
top.setDirection(new Vector(0, 1, 0));
}
if (bot != null && bot.getDirection() == null) {
bot.setDirection(new Vector(0, -1, 0));
}
return true;
}
FaweState dir = entry.states.get("rotation");
if (dir != null && dir.values != null) {
Vector[] dirs = new Vector[]{new Vector(0, 0, -1),
new Vector(0.5, 0, -1),
new Vector(1, 0, -1),
new Vector(1, 0, -0.5),
new Vector(1, 0, 0),
new Vector(1, 0, 0.5),
new Vector(1, 0, 1),
new Vector(0.5, 0, 1),
new Vector(0, 0, 1),
new Vector(-0.5, 0, 1),
new Vector(-1, 0, 1),
new Vector(-1, 0, 0.5),
new Vector(-1, 0, 0),
new Vector(-1, 0, -0.5),
new Vector(-1, 0, -1),
new Vector(-0.5, 0, -1)};
int len = dir.values.size();
int increment = 16 / len;
int index = 0;
for (Map.Entry<String, FaweStateValue> valuesEntry : dir.values.entrySet()) {
valuesEntry.getValue().setDirection(dirs[index]);
index += increment;
}
return true;
}
FaweState axis = entry.states.get("axis");
if (axis != null && axis.values != null) {
FaweStateValue x = axis.values.get("x");
FaweStateValue y = axis.values.get("y");
FaweStateValue z = axis.values.get("z");
if (x != null) {
x.setDirection(new Vector(1, 0, 0));
axis.values.put("x2", new FaweStateValue(x).setDirection(new Vector(-1, 0, 0)));
}
if (y != null) {
y.setDirection(new Vector(0, 1, 0));
axis.values.put("y2", new FaweStateValue(y).setDirection(new Vector(0, -1, 0)));
}
if (z != null) {
z.setDirection(new Vector(0, 0, 1));
axis.values.put("z2", new FaweStateValue(z).setDirection(new Vector(0, 0, -1)));
}
return true;
}
if (entry.legacyId == 69) {
dir = entry.states.get("facing");
Vector[] dirs = new Vector[]{
new Vector(0, -1, 0),
new Vector(1, 0, 0),
new Vector(-1, 0, 0),
new Vector(0, 0, 1),
new Vector(0, 0, -1),
new Vector(0, 1, 0),
new Vector(0, 1, 0),
new Vector(0, -1, 0)};
int len = dir.values.size();
int index = 0;
for (Map.Entry<String, FaweStateValue> valuesEntry : dir.values.entrySet()) {
valuesEntry.getValue().setDirection(dirs[index]);
index ++;
}
return true;
}
return true;
}
@ -328,6 +352,14 @@ public class BundledBlockData {
public Byte data;
public Vector direction;
public FaweStateValue() {}
public FaweStateValue(FaweStateValue other) {
this.state = other.state;
this.data = other.data;
this.direction = other.direction;
}
public void setState(FaweState state) {
this.state = state;
}
@ -347,8 +379,9 @@ public class BundledBlockData {
}
}
public void setDirection(Vector direction) {
public FaweStateValue setDirection(Vector direction) {
this.direction = direction;
return this;
}
@Override