Various minor

Fix image brush
Fix some java 9 issues
Fix metrics being disabled
Fix compile: duplicate method in SimpleBlockMaterial
Load as both FastAsyncWorldEdit and WorldEdit
This commit is contained in:
Jesse Boyd
2018-08-16 23:21:39 +10:00
parent 6ebdc00fba
commit 4ffb9bce6c
11 changed files with 90 additions and 96 deletions

View File

@ -12,6 +12,7 @@ import com.boydti.fawe.util.chat.ChatManager;
import com.boydti.fawe.util.chat.PlainChatManager;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.util.metrics.BStats;
import com.boydti.fawe.wrappers.FakePlayer;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.Vector;
@ -179,10 +180,7 @@ public class Fawe {
}
public static void debugPlain(String s) {
Actor actor = Request.request().getActor();
if (actor != null) {
actor.print(BBC.color(s));
} else if (INSTANCE != null) {
if (INSTANCE != null) {
INSTANCE.IMP.debug(s);
} else {
System.out.println(BBC.stripColor(BBC.color(s)));
@ -195,6 +193,11 @@ public class Fawe {
* @param s
*/
public static void debug(Object s) {
Actor actor = Request.request().getActor();
if (actor != null && actor.isPlayer()) {
actor.print(BBC.color(BBC.PREFIX.original() + " " + s));
return;
}
debugPlain(BBC.PREFIX.original() + " " + s);
}

View File

@ -11,9 +11,9 @@ public class Settings extends Config {
@Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable
public final String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";
public String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";
@Final
public final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
public String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
@Final
public String DATE; // These values are set from FAWE before loading
@Final
@ -33,7 +33,7 @@ public class Settings extends Config {
})
public String UPDATE = "false";
@Comment("Send anonymous usage statistics")
public boolean METRICS = false;
public boolean METRICS = true;
@Comment({
"Set true to enable WorldEdit restrictions per region (e.g. PlotSquared or WorldGuard).",
"To be allowed to WorldEdit in a region, users need the appropriate",

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.object.collection.SummedColorTable;
import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
@ -77,14 +78,14 @@ public class ImageBrush implements Brush {
final int cx = position.getBlockX();
final int cy = position.getBlockY();
final int cz = position.getBlockZ();
final SolidBlockMask solid = new SolidBlockMask(editSession);
final Mask solid = new SurfaceMask(editSession);
double scale = Math.max(width, height) / sizeDouble;
Location loc = editSession.getPlayer().getPlayer().getLocation();
float yaw = loc.getYaw();
float pitch = loc.getPitch();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse();
AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX((pitch - 90) % 360).inverse();
RecursiveVisitor visitor = new RecursiveVisitor(new Mask() {
private final Vector mutable = new Vector();

View File

@ -25,4 +25,4 @@ public class SurfaceMask extends AdjacentAnyMask {
public boolean test(Vector v) {
return !getParentMask().test(v.getBlockX(), v.getBlockY(), v.getBlockZ()) && super.test(v);
}
}
}

View File

@ -668,6 +668,10 @@ public class MainUtil {
}
public static File copyFile(File jar, String resource, File output) {
return copyFile(jar, resource, output, resource);
}
public static File copyFile(File jar, String resource, File output, String fileName) {
try {
if (output == null) {
output = Fawe.imp().getDirectory();
@ -675,11 +679,11 @@ public class MainUtil {
if (!output.exists()) {
output.mkdirs();
}
File newFile = new File(output, resource);
File newFile = new File(output, fileName);
if (newFile.exists()) {
return newFile;
}
try (InputStream stream = Fawe.imp().getClass().getResourceAsStream(resource.startsWith("/") ? resource : "/" + resource)) {
try (InputStream stream = Fawe.class.getResourceAsStream(resource.startsWith("/") ? resource : "/" + resource)) {
byte[] buffer = new byte[2048];
if (stream == null) {
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(jar))) {
@ -687,7 +691,6 @@ public class MainUtil {
while (ze != null) {
String name = ze.getName();
if (name.equals(resource)) {
new File(newFile.getParent()).mkdirs();
try (FileOutputStream fos = new FileOutputStream(newFile)) {
int len;
while ((len = zis.read(buffer)) > 0) {

View File

@ -117,12 +117,8 @@ public class ReflectionUtils9 {
}
try {
System.out.println("Target " + target + " | " + field.getName());
if (target == null) field.set(null, value);
else field.set(target, value);
// FieldAccessor fa = ReflectionFactory.getReflectionFactory().newFieldAccessor(field, false);
// fa.set(target, value);
} catch (NoSuchMethodError error) {
field.set(target, value);
}

View File

@ -2424,7 +2424,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if (dx2 + dz2 > radiusSq) {
continue;
}
<<<<<<< HEAD
outer:
for (int y = maxY; y >= 1; --y) {
BlockType type = getBlockType(x, y, z);
@ -2442,29 +2441,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
case JUNGLE_LEAVES:
case OAK_LEAVES:
case SPRUCE_LEAVES:
=======
for (int y = world.getMaxY(); y >= 1; --y) {
Vector pt = new Vector(x, y, z);
BlockType id = getBlock(pt).getBlockType();
if (id.getMaterial().isAir()) {
continue;
}
// Ice!
if (id == BlockTypes.WATER) {
if (setBlock(pt, ice)) {
++affected;
}
break;
}
// Snow should not cover these blocks
if (id.getMaterial().isTranslucent()) {
// Add snow on leaves
if (!BlockCategories.LEAVES.contains(id)) {
>>>>>>> refs/remotes/sk89q/master
break;
default:
if (type.getMaterial().isTranslucent()) {
@ -2569,7 +2545,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return number of trees created
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
<<<<<<< HEAD
public int makeForest(final Vector basePosition, final int size, final double density, TreeGenerator.TreeType treeType) {
try {
for (int x = basePosition.getBlockX() - size; x <= (basePosition.getBlockX() + size); ++x) {
@ -2601,35 +2576,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
default:
break;
}
=======
public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
int affected = 0;
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
+ size; ++x) {
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
+ size; ++z) {
// Don't want to be in the ground
if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
continue;
}
// The gods don't want a tree here
if (Math.random() >= density) {
continue;
} // def 0.05
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
// Check if we hit the ground
BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
treeType.generate(this, new Vector(x, y + 1, z));
++affected;
break;
} else if (t == BlockTypes.SNOW) {
setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState());
} else if (!t.getMaterial().isAir()) { // Trees won't grow on this!
break;
>>>>>>> refs/remotes/sk89q/master
}
}
}

View File

@ -43,7 +43,6 @@ class SimpleBlockMaterial implements BlockMaterial {
private boolean isTranslucent;
private boolean hasContainer;
private int lightOpacity;
private boolean isAir;
private int mapColor;
@Override
@ -51,10 +50,6 @@ class SimpleBlockMaterial implements BlockMaterial {
return isAir;
}
public void setAir(boolean air) {
isAir = air;
}
@Override
public int getMapColor() {
return mapColor;
@ -73,11 +68,6 @@ class SimpleBlockMaterial implements BlockMaterial {
this.lightOpacity = lightOpacity;
}
@Override
public boolean isAir() {
return this.isAir;
}
public void setIsAir(boolean isAir) {
this.isAir = isAir;
}