Adds safety code to copy BSkyBlock to addons if it is run as a plugin.

This commit is contained in:
tastybento 2019-05-04 11:36:42 -07:00
parent fe719121f4
commit dceb74dfb1
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package world.bentobox.bskyblock;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.io.Files;
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
public class CopyToBentoBox extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onBentoBoxReady(BentoBoxReadyEvent e) {
getLogger().severe("BSkyBlock.jar must be in the BentoBox/addons folder! Trying to move it there...");
File addons = new File(getFile().getParent(), "BentoBox/addons");
if (addons.exists()) {
File to = new File(addons, getFile().getName());
if (!to.exists()) {
try {
Files.move(getFile(), to);
getLogger().severe(getFile().getName() + " moved successfully. Restart server now to activate!");
} catch (IOException ex) {
getLogger().severe("Failed to move it. " + ex.getMessage());
getLogger().severe("Move " + getFile().getName() + " manually into the BentoBox/addons folder. Then restart server.");
}
}
} else {
getLogger().severe("BentoBox folders do not exist! " + addons.getAbsolutePath());
}
}
}

View File

@ -0,0 +1,6 @@
name: BSkyBlock
main: world.bentobox.bskyblock.CopyToBentoBox
version: ${version}
description: A SkyBlock Plugin
author: tastybento
depend: [BentoBox]