2016-04-14 16:24:03 +00:00
|
|
|
package me.mrCookieSlime.Slimefun;
|
|
|
|
|
2017-06-22 14:43:49 +00:00
|
|
|
import java.io.File;
|
2020-02-01 00:32:38 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Set;
|
2019-08-31 10:54:54 +00:00
|
|
|
import java.util.logging.Level;
|
2020-02-01 00:32:38 +00:00
|
|
|
import java.util.stream.Collectors;
|
2017-06-22 14:43:49 +00:00
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Player;
|
2020-02-01 00:32:38 +00:00
|
|
|
import org.bukkit.plugin.Plugin;
|
2017-06-22 14:43:49 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2019-12-27 01:16:01 +00:00
|
|
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
2019-09-01 16:53:02 +00:00
|
|
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
|
2019-10-29 08:13:32 +00:00
|
|
|
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
|
2019-10-01 11:14:50 +00:00
|
|
|
import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
|
2020-02-16 11:17:14 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
2020-02-08 01:36:57 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
|
2020-01-25 13:20:58 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.api.network.NetworkManager;
|
2020-02-01 00:32:38 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
|
2019-12-22 13:00:35 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
2020-01-12 00:44:57 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.hooks.SlimefunHooks;
|
2019-12-22 22:00:05 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService;
|
2020-02-08 19:50:21 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.BackupService;
|
2019-12-08 11:58:05 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService;
|
2020-03-04 23:52:14 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
|
2019-12-22 22:00:05 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
|
2020-03-04 23:04:18 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.core.services.metrics.MetricsService;
|
2020-01-12 10:05:35 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AndroidKillingListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener;
|
2020-01-12 10:01:29 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener;
|
2020-01-11 22:58:05 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener;
|
2020-01-12 01:05:33 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener;
|
2020-02-22 23:59:55 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener;
|
2020-03-05 20:52:34 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityKillListener;
|
2020-01-11 22:58:05 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GearListener;
|
2019-12-29 17:30:48 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener;
|
2020-01-05 13:30:50 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener;
|
2020-01-25 13:20:58 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener;
|
2020-03-01 08:29:37 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener;
|
2020-01-12 10:01:29 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
|
2019-12-29 13:14:51 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener;
|
2020-03-05 20:28:50 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup;
|
2020-02-02 17:27:32 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.setup.MiscSetup;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
|
2020-02-08 01:36:57 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
|
2020-02-04 18:05:49 +00:00
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
|
|
|
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
2016-04-14 16:24:03 +00:00
|
|
|
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
2019-10-05 21:49:25 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
|
|
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AReactor;
|
2016-04-14 16:24:03 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
2019-08-25 14:07:06 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
2016-04-14 16:24:03 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
2019-08-22 19:37:09 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
2019-12-27 01:16:01 +00:00
|
|
|
import me.mrCookieSlime.Slimefun.utils.ConfigCache;
|
2016-04-14 16:24:03 +00:00
|
|
|
|
2020-03-04 23:04:18 +00:00
|
|
|
/**
|
|
|
|
* This is the main class of Slimefun.
|
|
|
|
* This is where all the magic starts, take a look around.
|
|
|
|
* Feel like home.
|
|
|
|
*
|
|
|
|
* @author TheBusyBiscuit
|
|
|
|
*
|
|
|
|
*/
|
2020-02-16 11:17:14 +00:00
|
|
|
public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
2016-11-19 23:23:37 +00:00
|
|
|
|
2020-03-04 23:04:18 +00:00
|
|
|
public static SlimefunPlugin instance;
|
|
|
|
|
|
|
|
private RecipeSnapshot recipeSnapshot;
|
|
|
|
private SlimefunRegistry registry;
|
|
|
|
|
|
|
|
// Services
|
|
|
|
private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item");
|
|
|
|
private final CustomTextureService textureService = new CustomTextureService(this);
|
|
|
|
private final BlockDataService blockDataService = new BlockDataService(this, "slimefun_block");
|
|
|
|
private final GitHubService gitHubService = new GitHubService("TheBusyBiscuit/Slimefun4");
|
|
|
|
private final UpdaterService updaterService = new UpdaterService(this, getFile());
|
|
|
|
private final AutoSavingService autoSavingService = new AutoSavingService();
|
|
|
|
private final BackupService backupService = new BackupService();
|
|
|
|
private final MetricsService metricsService = new MetricsService(this);
|
|
|
|
|
|
|
|
private TickerTask ticker;
|
|
|
|
private LocalizationService local;
|
|
|
|
private NetworkManager networkManager;
|
|
|
|
private Config researches;
|
|
|
|
private Config items;
|
|
|
|
private Config whitelist;
|
|
|
|
private Config config;
|
|
|
|
|
|
|
|
private GPSNetwork gps;
|
|
|
|
private ProtectionManager protections;
|
|
|
|
private ConfigCache settings;
|
|
|
|
private SlimefunHooks hooks;
|
2020-03-06 15:39:07 +00:00
|
|
|
private SlimefunCommand command;
|
2020-03-04 23:04:18 +00:00
|
|
|
|
|
|
|
// Supported Versions of Minecraft, to ensure people dont use it on the wrong version.
|
|
|
|
private final String[] supportedMinecraftVersions = { "v1_14_", "v1_15_" };
|
|
|
|
|
|
|
|
// Listeners that need to be accessed elsewhere
|
|
|
|
private AncientAltarListener ancientAltarListener;
|
|
|
|
private BackpackListener backpackListener;
|
|
|
|
private GrapplingHookListener grapplingHookListener;
|
|
|
|
private SlimefunBowListener bowListener;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
|
|
|
|
|
|
|
if (isVersionUnsupported()) {
|
|
|
|
getServer().getPluginManager().disablePlugin(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance = this;
|
|
|
|
|
|
|
|
// Creating all necessary Folders
|
|
|
|
getLogger().log(Level.INFO, "Loading Files...");
|
|
|
|
createDirectories();
|
|
|
|
|
|
|
|
getLogger().log(Level.INFO, "Loading Config...");
|
|
|
|
|
|
|
|
// Setup config.yml
|
|
|
|
config = new Config(this);
|
|
|
|
registry = new SlimefunRegistry();
|
|
|
|
settings = new ConfigCache(config);
|
|
|
|
|
|
|
|
// Loading all extra configs
|
|
|
|
researches = new Config(this, "Researches.yml");
|
|
|
|
items = new Config(this, "Items.yml");
|
|
|
|
whitelist = new Config(this, "whitelist.yml");
|
|
|
|
|
|
|
|
// Setup messages.yml
|
|
|
|
local = new LocalizationService(this, config.getString("options.language"));
|
|
|
|
|
|
|
|
// Setting up Network classes
|
|
|
|
networkManager = new NetworkManager(config.getInt("options.max-network-size"));
|
|
|
|
|
|
|
|
// Setting up other stuff
|
|
|
|
gps = new GPSNetwork();
|
|
|
|
|
|
|
|
// Setting up bStats
|
|
|
|
metricsService.start();
|
|
|
|
|
|
|
|
// Starting the Auto-Updater
|
|
|
|
if (config.getBoolean("options.auto-update")) {
|
|
|
|
getLogger().log(Level.INFO, "Starting Auto-Updater...");
|
|
|
|
updaterService.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
updaterService.disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Registering all GEO Resources
|
|
|
|
getLogger().log(Level.INFO, "Loading GEO-Resources...");
|
2020-03-04 23:52:14 +00:00
|
|
|
GEOResourcesSetup.setup();
|
2020-03-04 23:04:18 +00:00
|
|
|
|
|
|
|
getLogger().log(Level.INFO, "Loading Items...");
|
|
|
|
MiscSetup.setupItemSettings();
|
|
|
|
|
|
|
|
try {
|
|
|
|
SlimefunItemSetup.setup(this);
|
|
|
|
}
|
2020-03-05 22:38:39 +00:00
|
|
|
catch (Throwable x) {
|
2020-03-04 23:04:18 +00:00
|
|
|
getLogger().log(Level.SEVERE, "An Error occured while initializing SlimefunItems for Slimefun " + getVersion(), x);
|
|
|
|
}
|
|
|
|
|
|
|
|
getLogger().log(Level.INFO, "Loading Researches...");
|
2020-03-05 22:38:39 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
ResearchSetup.setupResearches();
|
|
|
|
}
|
|
|
|
catch (Throwable x) {
|
|
|
|
getLogger().log(Level.SEVERE, "An Error occured while initializing Slimefun Researches for Slimefun " + getVersion(), x);
|
|
|
|
}
|
2020-03-04 23:04:18 +00:00
|
|
|
settings.researchesEnabled = getResearchCfg().getBoolean("enable-researching");
|
|
|
|
|
|
|
|
MiscSetup.setupMisc();
|
2020-03-08 17:27:32 +00:00
|
|
|
|
2020-03-04 23:04:18 +00:00
|
|
|
textureService.setup(registry.getAllSlimefunItems());
|
|
|
|
|
|
|
|
// Setting up GitHub Connectors...
|
|
|
|
gitHubService.connect(config.getBoolean("options.print-out-github-data-retrieving"));
|
|
|
|
|
|
|
|
// All Slimefun Listeners
|
|
|
|
new SlimefunBootsListener(this);
|
|
|
|
new SlimefunItemListener(this);
|
|
|
|
new BlockPhysicsListener(this);
|
|
|
|
new MultiBlockListener(this);
|
|
|
|
new GearListener(this);
|
|
|
|
new DispenserListener(this);
|
2020-03-04 23:52:14 +00:00
|
|
|
new EntityKillListener(this);
|
2020-03-04 23:04:18 +00:00
|
|
|
new BlockListener(this);
|
|
|
|
new EnhancedFurnaceListener(this);
|
|
|
|
new TeleporterListener(this);
|
|
|
|
new AndroidKillingListener(this);
|
|
|
|
new NetworkListener(this);
|
|
|
|
new ItemPickupListener(this);
|
|
|
|
new DeathpointListener(this);
|
|
|
|
new ExplosionsListener(this);
|
|
|
|
new DebugFishListener(this);
|
|
|
|
new VanillaMachinesListener(this);
|
|
|
|
|
|
|
|
bowListener = new SlimefunBowListener(this);
|
|
|
|
ancientAltarListener = new AncientAltarListener();
|
|
|
|
grapplingHookListener = new GrapplingHookListener();
|
|
|
|
|
|
|
|
// Toggleable Listeners for performance
|
|
|
|
if (config.getBoolean("items.talismans")) new TalismanListener(this);
|
|
|
|
if (config.getBoolean("items.soulbound")) new SoulboundListener(this);
|
|
|
|
|
|
|
|
if (config.getBoolean("items.backpacks")) {
|
|
|
|
backpackListener = new BackpackListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle Slimefun Guide being given on Join
|
|
|
|
new SlimefunGuideListener(this, config.getBoolean("options.give-guide-on-first-join"));
|
|
|
|
|
|
|
|
// Load/Unload Worlds in Slimefun
|
|
|
|
new WorldListener(this);
|
|
|
|
|
|
|
|
// Clear the Slimefun Guide History upon Player Leaving
|
|
|
|
new PlayerProfileListener(this);
|
|
|
|
|
|
|
|
// Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading)
|
|
|
|
Slimefun.runSync(() -> {
|
|
|
|
recipeSnapshot = new RecipeSnapshot(this);
|
|
|
|
protections = new ProtectionManager(getServer());
|
|
|
|
MiscSetup.loadItems(settings);
|
|
|
|
|
|
|
|
for (World world : Bukkit.getWorlds()) {
|
|
|
|
new BlockStorage(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SlimefunItem.getByID("ANCIENT_ALTAR") != null) {
|
|
|
|
ancientAltarListener.load(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SlimefunItem.getByID("GRAPPLING_HOOK") != null) {
|
|
|
|
grapplingHookListener.load(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SlimefunItem.getByID("BLADE_OF_VAMPIRES") != null) {
|
|
|
|
new VampireBladeListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SlimefunItem.getByID("COOLER") != null) {
|
|
|
|
new CoolerListener(this);
|
|
|
|
}
|
|
|
|
}, 0);
|
|
|
|
|
2020-03-05 22:38:39 +00:00
|
|
|
// Setting up the command /sf and all subcommands
|
2020-03-06 15:39:07 +00:00
|
|
|
command = new SlimefunCommand(this);
|
2020-03-04 23:04:18 +00:00
|
|
|
|
|
|
|
// Armor Update Task
|
|
|
|
if (config.getBoolean("options.enable-armor-effects")) {
|
|
|
|
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(), 0L, config.getInt("options.armor-update-interval") * 20L);
|
|
|
|
}
|
|
|
|
|
|
|
|
ticker = new TickerTask();
|
|
|
|
|
|
|
|
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
|
|
|
|
|
|
|
|
// Starting all ASYNC Tasks
|
|
|
|
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
|
|
|
|
try {
|
|
|
|
ticker.run();
|
|
|
|
}
|
|
|
|
catch (Exception x) {
|
|
|
|
getLogger().log(Level.SEVERE, "An Exception was caught while ticking the Block Tickers Task for Slimefun v" + getVersion(), x);
|
|
|
|
ticker.abortTick();
|
|
|
|
}
|
|
|
|
}, 100L, config.getInt("URID.custom-ticker-delay"));
|
|
|
|
|
|
|
|
gitHubService.start(this);
|
|
|
|
|
|
|
|
// Hooray!
|
|
|
|
getLogger().log(Level.INFO, "Finished!");
|
|
|
|
hooks = new SlimefunHooks(this);
|
|
|
|
|
|
|
|
// Do not show /sf elevator command in our Log, it could get quite spammy
|
|
|
|
CSCoreLib.getLib().filterLog("([A-Za-z0-9_]{3,16}) issued server command: /sf elevator (.{0,})");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getLogger().log(Level.INFO, "#################### - INFO - ####################");
|
|
|
|
getLogger().log(Level.INFO, " ");
|
|
|
|
getLogger().log(Level.INFO, "Slimefun could not be loaded (yet).");
|
|
|
|
getLogger().log(Level.INFO, "It appears that you have not installed CS-CoreLib.");
|
|
|
|
getLogger().log(Level.INFO, "Please download and install CS-CoreLib manually:");
|
|
|
|
getLogger().log(Level.INFO, "https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
|
|
|
|
|
|
|
getCommand("slimefun").setExecutor((sender, cmd, label, args) -> {
|
|
|
|
sender.sendMessage("You have forgotten to install CS-CoreLib! Slimefun is disabled.");
|
|
|
|
sender.sendMessage("https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isVersionUnsupported() {
|
|
|
|
String currentVersion = ReflectionUtils.getVersion();
|
|
|
|
|
|
|
|
if (currentVersion.startsWith("v")) {
|
|
|
|
boolean compatibleVersion = false;
|
|
|
|
StringBuilder versions = new StringBuilder();
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (String version : supportedMinecraftVersions) {
|
|
|
|
if (currentVersion.startsWith(version)) {
|
|
|
|
compatibleVersion = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
String s = version.substring(1).replaceFirst("_", ".").replace("_", ".X");
|
|
|
|
if (i == 0) versions.append(s);
|
|
|
|
else if (i == supportedMinecraftVersions.length - 1) versions.append(" or ").append(s);
|
|
|
|
else versions.append(", ").append(s);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Looks like you are using an unsupported Minecraft Version
|
|
|
|
if (!compatibleVersion) {
|
|
|
|
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
|
|
|
getLogger().log(Level.SEVERE, "###");
|
|
|
|
getLogger().log(Level.SEVERE, "### You are using the wrong Version of Minecraft!");
|
|
|
|
getLogger().log(Level.SEVERE, "###");
|
|
|
|
getLogger().log(Level.SEVERE, "### You are using Minecraft " + ReflectionUtils.getVersion());
|
|
|
|
getLogger().log(Level.SEVERE, "### but Slimefun v" + getDescription().getVersion() + " requires you to be using");
|
|
|
|
getLogger().log(Level.SEVERE, "### Minecraft {0}", versions);
|
|
|
|
getLogger().log(Level.SEVERE, "###");
|
|
|
|
getLogger().log(Level.SEVERE, "### Please use an older Version of Slimefun and disable auto-updating");
|
|
|
|
getLogger().log(Level.SEVERE, "### or consider updating your Server Software.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
// CS-CoreLib wasn't loaded, just disabling
|
|
|
|
if (instance == null) return;
|
|
|
|
|
|
|
|
Bukkit.getScheduler().cancelTasks(this);
|
|
|
|
|
|
|
|
if (ticker != null) {
|
|
|
|
// Finishes all started movements/removals of block data
|
|
|
|
ticker.halt();
|
|
|
|
ticker.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerProfile.iterator().forEachRemaining(profile -> {
|
|
|
|
if (profile.isDirty()) {
|
|
|
|
profile.save();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
for (World world : Bukkit.getWorlds()) {
|
|
|
|
try {
|
|
|
|
BlockStorage storage = BlockStorage.getStorage(world);
|
|
|
|
|
|
|
|
if (storage != null) {
|
|
|
|
storage.save(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"" + world.getName() + "\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception x) {
|
|
|
|
getLogger().log(Level.SEVERE, "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + getVersion(), x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
|
|
|
|
menu.save();
|
|
|
|
}
|
|
|
|
|
|
|
|
backupService.run();
|
|
|
|
|
|
|
|
// Prevent Memory Leaks
|
|
|
|
AContainer.processing = null;
|
|
|
|
AContainer.progress = null;
|
|
|
|
|
|
|
|
AGenerator.processing = null;
|
|
|
|
AGenerator.progress = null;
|
|
|
|
|
|
|
|
AReactor.processing = null;
|
|
|
|
AReactor.progress = null;
|
|
|
|
|
|
|
|
instance = null;
|
|
|
|
|
|
|
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
|
|
p.closeInventory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createDirectories() {
|
|
|
|
String[] storage = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
|
|
|
|
String[] general = { "scripts", "generators", "error-reports", "cache/github" };
|
|
|
|
|
|
|
|
for (String file : storage) {
|
|
|
|
createDir("data-storage/Slimefun/" + file);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String file : general) {
|
|
|
|
createDir("plugins/Slimefun/" + file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createDir(String path) {
|
|
|
|
File file = new File(path);
|
|
|
|
if (!file.exists()) file.mkdirs();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Config getCfg() {
|
|
|
|
return instance.config;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static io.github.thebusybiscuit.cscorelib2.config.Config getResearchCfg() {
|
|
|
|
return instance.researches;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Config getItemCfg() {
|
|
|
|
return instance.items;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static io.github.thebusybiscuit.cscorelib2.config.Config getWhitelist() {
|
|
|
|
return instance.whitelist;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static GPSNetwork getGPSNetwork() {
|
|
|
|
return instance.gps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SlimefunHooks getHooks() {
|
|
|
|
return instance.hooks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ConfigCache getSettings() {
|
|
|
|
return instance.settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static TickerTask getTicker() {
|
|
|
|
return instance.ticker;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isActive() {
|
|
|
|
return instance != null;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:35:29 +00:00
|
|
|
/**
|
|
|
|
* This returns the version of Slimefun that is currently installed.
|
|
|
|
*
|
|
|
|
* @return The currently installed version of Slimefun
|
|
|
|
*/
|
2020-03-04 23:04:18 +00:00
|
|
|
public static String getVersion() {
|
|
|
|
return instance.getDescription().getVersion();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ProtectionManager getProtectionManager() {
|
|
|
|
return instance.protections;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static LocalizationService getLocal() {
|
|
|
|
return instance.local;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RecipeSnapshot getMinecraftRecipes() {
|
|
|
|
return instance.recipeSnapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CustomItemDataService getItemDataService() {
|
|
|
|
return instance.itemDataService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CustomTextureService getItemTextureService() {
|
|
|
|
return instance.textureService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BlockDataService getBlockDataService() {
|
|
|
|
return instance.blockDataService;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:35:29 +00:00
|
|
|
/**
|
|
|
|
* This method returns the {@link UpdaterService} of Slimefun.
|
|
|
|
* It is used to handle automatic updates.
|
|
|
|
*
|
|
|
|
* @return The {@link UpdaterService} for Slimefun
|
|
|
|
*/
|
2020-03-04 23:04:18 +00:00
|
|
|
public static UpdaterService getUpdater() {
|
|
|
|
return instance.updaterService;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:35:29 +00:00
|
|
|
/**
|
|
|
|
* This method returns the {@link GitHubService} of Slimefun.
|
|
|
|
* It is used to retrieve data from GitHub repositories.
|
|
|
|
*
|
|
|
|
* @return The {@link GitHubService} for Slimefun
|
|
|
|
*/
|
2020-03-04 23:04:18 +00:00
|
|
|
public static GitHubService getGitHubService() {
|
|
|
|
return instance.gitHubService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SlimefunRegistry getRegistry() {
|
|
|
|
return instance.registry;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static NetworkManager getNetworkManager() {
|
|
|
|
return instance.networkManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static AncientAltarListener getAncientAltarListener() {
|
|
|
|
return instance.ancientAltarListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static GrapplingHookListener getGrapplingHookListener() {
|
|
|
|
return instance.grapplingHookListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BackpackListener getBackpackListener() {
|
|
|
|
return instance.backpackListener;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SlimefunBowListener getBowListener() {
|
|
|
|
return instance.bowListener;
|
|
|
|
}
|
|
|
|
|
2020-03-07 10:35:29 +00:00
|
|
|
/**
|
|
|
|
* This method returns a {@link Set} of every {@link Plugin} that lists Slimefun
|
|
|
|
* as a required or optional dependency.
|
|
|
|
*
|
|
|
|
* We will just assume this to be a list of our addons.
|
|
|
|
*
|
|
|
|
* @return A {@link Set} of every {@link Plugin} that is dependent on Slimefun
|
|
|
|
*/
|
2020-03-04 23:04:18 +00:00
|
|
|
public static Set<Plugin> getInstalledAddons() {
|
|
|
|
return Arrays.stream(instance.getServer().getPluginManager().getPlugins()).filter(plugin -> plugin.getDescription().getDepend().contains(instance.getName()) || plugin.getDescription().getSoftDepend().contains(instance.getName())).collect(Collectors.toSet());
|
|
|
|
}
|
|
|
|
|
2020-03-06 15:39:07 +00:00
|
|
|
public static SlimefunCommand getCommand() {
|
|
|
|
return instance.command;
|
|
|
|
}
|
|
|
|
|
2020-03-04 23:04:18 +00:00
|
|
|
@Override
|
|
|
|
public JavaPlugin getJavaPlugin() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBugTrackerURL() {
|
|
|
|
return "https://github.com/TheBusyBiscuit/Slimefun4/issues";
|
|
|
|
}
|
2020-02-16 11:17:14 +00:00
|
|
|
|
2016-04-14 16:24:03 +00:00
|
|
|
}
|