From d68740ecd1b78fd18b9060476f46d7e0a92687ed Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 30 Aug 2017 14:44:43 +1000 Subject: [PATCH] Recover from failed injector (of minor classes) --- .../java/com/boydti/fawe/bukkit/BukkitMain.java | 6 +++++- .../java/com/boydti/fawe/bukkit/FaweBukkit.java | 14 ++++++++++---- .../com/boydti/fawe/object/brush/BlobBrush.java | 12 ++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitMain.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitMain.java index 438d7a74..1983b388 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitMain.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitMain.java @@ -52,6 +52,7 @@ public class BukkitMain extends JavaPlugin { @Override public void onEnable() { + Plugin toLoad = null; if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) { try { File output = new File(this.getDataFolder().getParentFile(), "WorldEdit.jar"); @@ -59,7 +60,7 @@ public class BukkitMain extends JavaPlugin { try (FileOutputStream fos = new FileOutputStream(output)) { fos.write(weJar); } - Bukkit.getPluginManager().loadPlugin(output); + toLoad = Bukkit.getPluginManager().loadPlugin(output); } catch (Throwable e) { e.printStackTrace(); Fawe.debug("====== INSTALL WORLDEDIT ======"); @@ -70,5 +71,8 @@ public class BukkitMain extends JavaPlugin { } } FaweBukkit imp = new FaweBukkit(this); + if (toLoad != null) { + Bukkit.getPluginManager().enablePlugin(toLoad); + } } } \ No newline at end of file diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 2e2998d9..900d809d 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -79,10 +79,16 @@ public class FaweBukkit implements IFawe, Listener { try { Fawe.set(this); setupInjector(); - com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes - BukkitWorld.inject(); // Fixes - FallbackRegistrationListener.inject(); // Fixes - BukkitPlayerBlockBag.inject(); // features + try { + com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes + BukkitWorld.inject(); // Fixes + BukkitPlayerBlockBag.inject(); // features + FallbackRegistrationListener.inject(); // Fixes + } catch (Throwable e) { + debug("========= INJECTOR FAILED ========="); + e.printStackTrace(); + debug("==================================="); + } try { new BrushListener(plugin); } catch (Throwable e) { diff --git a/core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java index c61d10d7..35c4a53e 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/BlobBrush.java @@ -35,23 +35,23 @@ public class BlobBrush implements Brush { double modY = 1d/radius.getY(); double modZ = 1d/radius.getZ(); - int radius = (int) size; + int radiusSqr = (int) (size * size); int sizeInt = (int) size * 2; for (int x = -sizeInt; x <= sizeInt; x++) { double nx = seedX + x * distort; - double d1 = Math.abs(x) * modX; + double d1 = x * x * modX; for (int y = -sizeInt; y <= sizeInt; y++) { - double d2 = d1 + Math.abs(y) * modY; + double d2 = d1 + y * y * modY; double ny = seedY + y * distort; for (int z = -sizeInt; z <= sizeInt; z++) { double nz = seedZ + z * distort; - double distance = d2 + Math.abs(z) * modZ; + double distance = d2 + z * z * modZ; double noise = this.amplitude * SimplexNoise.noise(nx, ny, nz); - if (distance + distance * noise < radius) { + if (distance + distance * noise < radiusSqr) { editSession.setBlock(px + x, py + y, pz + z, pattern); } } } } } -} +} \ No newline at end of file