DL WorldEdit bukkit if they forget

This commit is contained in:
Jesse Boyd 2016-12-27 23:28:43 +11:00
parent 2d295effee
commit d43dbab7c5
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 26 additions and 10 deletions

View File

@ -27,8 +27,12 @@ import com.sk89q.worldedit.bukkit.EditSessionBlockChangeDelegate;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
@ -87,16 +91,28 @@ public class FaweBukkit implements IFawe, Listener {
}
public void setupInjector() {
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
Fawe.setupInjector();
// Inject
EditSessionBlockChangeDelegate.inject();
} else {
Fawe.debug("====== INSTALL WORLDEDIT ======");
Fawe.debug("FAWE requires WorldEdit to function correctly");
Fawe.debug("Info: https://github.com/boy0001/FastAsyncWorldedit/releases/");
Fawe.debug("===============================");
if (Bukkit.getPluginManager().getPlugin("WorldEdit") == null) {
try {
File output = new File(getDirectory().getParentFile(), "WorldEdit.jar");
URL worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9611/download/worldedit-bukkit-6.1.7-SNAPSHOT-dist.jar");
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
try (FileOutputStream fos = new FileOutputStream(output)) {
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
}
Bukkit.getPluginManager().loadPlugin(output);
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("====== INSTALL WORLDEDIT ======");
Fawe.debug("FAWE requires WorldEdit to function correctly");
Fawe.debug("Info: https://github.com/boy0001/FastAsyncWorldedit/releases/");
Fawe.debug("===============================");
return;
}
}
Fawe.setupInjector();
// Inject
EditSessionBlockChangeDelegate.inject();
}
@Override

View File

@ -239,7 +239,6 @@ public class Fawe {
this.setupMemoryListener();
timer = new FaweTimer();
Fawe.this.IMP.setupVault();
Commands.load(new File(this.IMP.getDirectory(), "commands.yml"));
// Delayed worldedit setup
TaskManager.IMP.later(new Runnable() {
@ -463,6 +462,7 @@ public class Fawe {
debug(" - http://builds.enginehub.org/job/worldedit?branch=master");
debug("=======================================");
}
Commands.load(new File(INSTANCE.IMP.getDirectory(), "commands.yml"));
} catch (Throwable e) {
debug("====== FAWE FAILED TO INITIALIZE ======");
MainUtil.handleError(e, false);