mirror of
https://github.com/BentoBoxWorld/BSkyBlock.git
synced 2024-11-22 11:45:36 +01:00
Adds safety code to copy BSkyBlock to addons if it is run as a plugin.
This commit is contained in:
parent
fe719121f4
commit
dceb74dfb1
44
src/main/java/world/bentobox/bskyblock/CopyToBentoBox.java
Normal file
44
src/main/java/world/bentobox/bskyblock/CopyToBentoBox.java
Normal 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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
name: BSkyBlock
|
||||
main: world.bentobox.bskyblock.CopyToBentoBox
|
||||
version: ${version}
|
||||
description: A SkyBlock Plugin
|
||||
author: tastybento
|
||||
depend: [BentoBox]
|
Loading…
Reference in New Issue
Block a user