Recover from failed injector (of minor classes)

This commit is contained in:
Jesse Boyd 2017-08-30 14:44:43 +10:00
parent dc686c45d0
commit d68740ecd1
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 21 additions and 11 deletions

View File

@ -52,6 +52,7 @@ public class BukkitMain extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
Plugin toLoad = null;
if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) { if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) {
try { try {
File output = new File(this.getDataFolder().getParentFile(), "WorldEdit.jar"); File output = new File(this.getDataFolder().getParentFile(), "WorldEdit.jar");
@ -59,7 +60,7 @@ public class BukkitMain extends JavaPlugin {
try (FileOutputStream fos = new FileOutputStream(output)) { try (FileOutputStream fos = new FileOutputStream(output)) {
fos.write(weJar); fos.write(weJar);
} }
Bukkit.getPluginManager().loadPlugin(output); toLoad = Bukkit.getPluginManager().loadPlugin(output);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
Fawe.debug("====== INSTALL WORLDEDIT ======"); Fawe.debug("====== INSTALL WORLDEDIT ======");
@ -70,5 +71,8 @@ public class BukkitMain extends JavaPlugin {
} }
} }
FaweBukkit imp = new FaweBukkit(this); FaweBukkit imp = new FaweBukkit(this);
if (toLoad != null) {
Bukkit.getPluginManager().enablePlugin(toLoad);
}
} }
} }

View File

@ -79,10 +79,16 @@ public class FaweBukkit implements IFawe, Listener {
try { try {
Fawe.set(this); Fawe.set(this);
setupInjector(); setupInjector();
try {
com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes com.sk89q.worldedit.bukkit.BukkitPlayer.inject(); // Fixes
BukkitWorld.inject(); // Fixes BukkitWorld.inject(); // Fixes
FallbackRegistrationListener.inject(); // Fixes
BukkitPlayerBlockBag.inject(); // features BukkitPlayerBlockBag.inject(); // features
FallbackRegistrationListener.inject(); // Fixes
} catch (Throwable e) {
debug("========= INJECTOR FAILED =========");
e.printStackTrace();
debug("===================================");
}
try { try {
new BrushListener(plugin); new BrushListener(plugin);
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -35,19 +35,19 @@ public class BlobBrush implements Brush {
double modY = 1d/radius.getY(); double modY = 1d/radius.getY();
double modZ = 1d/radius.getZ(); double modZ = 1d/radius.getZ();
int radius = (int) size; int radiusSqr = (int) (size * size);
int sizeInt = (int) size * 2; int sizeInt = (int) size * 2;
for (int x = -sizeInt; x <= sizeInt; x++) { for (int x = -sizeInt; x <= sizeInt; x++) {
double nx = seedX + x * distort; double nx = seedX + x * distort;
double d1 = Math.abs(x) * modX; double d1 = x * x * modX;
for (int y = -sizeInt; y <= sizeInt; y++) { 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; double ny = seedY + y * distort;
for (int z = -sizeInt; z <= sizeInt; z++) { for (int z = -sizeInt; z <= sizeInt; z++) {
double nz = seedZ + z * distort; 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); 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); editSession.setBlock(px + x, py + y, pz + z, pattern);
} }
} }