1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-21 04:05:48 +00:00
Slimefun4/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java

512 lines
19 KiB
Java
Raw Normal View History

2016-04-14 16:24:03 +00:00
package me.mrCookieSlime.Slimefun;
2017-06-22 14:43:49 +00:00
import java.io.File;
import java.util.Arrays;
import java.util.Set;
2019-08-31 10:54:54 +00:00
import java.util.logging.Level;
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;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
2017-06-22 14:43:49 +00:00
import org.bukkit.plugin.java.JavaPlugin;
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;
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
import io.github.thebusybiscuit.slimefun4.api.network.NetworkManager;
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunTabCompleter;
2020-01-12 00:44:57 +00:00
import io.github.thebusybiscuit.slimefun4.core.hooks.SlimefunHooks;
import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService;
import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService;
import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService;
import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService;
import io.github.thebusybiscuit.slimefun4.core.services.GitHubService;
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
import io.github.thebusybiscuit.slimefun4.core.services.MetricsService;
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
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.AutonomousToolsListener;
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;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DamageListener;
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;
2019-12-29 13:14:51 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener;
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;
2020-01-12 10:01:29 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.IgnitionChamberListener;
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;
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;
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-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;
import io.github.thebusybiscuit.slimefun4.implementation.resources.NetherIceResource;
import io.github.thebusybiscuit.slimefun4.implementation.resources.OilResource;
import io.github.thebusybiscuit.slimefun4.implementation.resources.SaltResource;
import io.github.thebusybiscuit.slimefun4.implementation.resources.UraniumResource;
2020-02-02 17:27:32 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.setup.MiscSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
2020-02-02 17:27:32 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.setup.WikiSetup;
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.Lists.SlimefunItems;
2016-04-14 16:24:03 +00:00
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
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;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
2016-04-14 16:24:03 +00:00
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunBackup;
2019-08-22 19:37:09 +00:00
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
import me.mrCookieSlime.Slimefun.utils.ConfigCache;
import me.mrCookieSlime.Slimefun.utils.Utilities;
2016-04-14 16:24:03 +00:00
2019-08-31 09:36:45 +00:00
public final class SlimefunPlugin extends JavaPlugin {
2019-08-31 09:36:45 +00:00
public static SlimefunPlugin instance;
2019-10-29 08:13:32 +00:00
private RecipeSnapshot recipeSnapshot;
2020-02-02 17:27:32 +00:00
private SlimefunRegistry registry;
2019-11-10 16:46:18 +00:00
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");
2019-12-11 23:16:28 +00:00
private final GitHubService gitHubService = new GitHubService("TheBusyBiscuit/Slimefun4");
private final AutoSavingService autoSavingService = new AutoSavingService();
private final UpdaterService updaterService = new UpdaterService(this, getFile());
2020-01-11 19:58:14 +00:00
2019-08-31 10:54:54 +00:00
private TickerTask ticker;
private LocalizationService local;
private NetworkManager networkManager;
2019-08-31 09:36:45 +00:00
private Config researches;
private Config items;
private Config whitelist;
private Config config;
2020-01-11 19:58:14 +00:00
2019-09-21 14:21:10 +00:00
private GPSNetwork gps;
2019-09-01 16:53:02 +00:00
private ProtectionManager protections;
2019-09-21 14:21:10 +00:00
private Utilities utilities;
private ConfigCache settings;
2019-08-29 14:19:23 +00:00
private SlimefunHooks hooks;
2020-01-11 19:58:14 +00:00
2016-08-05 23:11:32 +00:00
// Supported Versions of Minecraft
2019-12-11 16:41:00 +00:00
private final String[] supported = {"v1_14_", "v1_15_"};
private AncientAltarListener ancientAltarListener;
private BackpackListener backpackListener;
2020-01-29 01:25:25 +00:00
private SlimefunBowListener bowListener;
2019-03-27 20:48:34 +00:00
2016-04-14 16:24:03 +00:00
@Override
public void onEnable() {
if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
2020-01-29 01:25:25 +00:00
if (isVersionUnsupported()) {
getServer().getPluginManager().disablePlugin(this);
return;
}
2020-01-29 01:25:25 +00:00
2016-04-14 16:24:03 +00:00
instance = this;
2020-01-11 19:58:14 +00:00
// Creating all necessary Folders
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Loading Files...");
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);
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Loading Config...");
2019-08-31 18:34:10 +00:00
// Setup config.yml
config = new Config(this);
2020-02-02 17:27:32 +00:00
registry = new SlimefunRegistry();
settings = new ConfigCache(config);
2016-08-05 23:23:40 +00:00
// Loading all extra configs
researches = new Config(this, "Researches.yml");
items = new Config(this, "Items.yml");
whitelist = new Config(this, "whitelist.yml");
2019-08-22 19:37:09 +00:00
2019-08-31 18:34:10 +00:00
// Setup messages.yml
local = new LocalizationService(this, config.getString("options.language"));
2020-01-11 19:58:14 +00:00
// Setting up Network classes
networkManager = new NetworkManager(config.getInt("options.max-network-size"));
2019-09-21 14:21:10 +00:00
// Setting up other stuff
utilities = new Utilities();
gps = new GPSNetwork();
2020-01-11 19:58:14 +00:00
// Setting up bStats
2019-11-10 17:43:37 +00:00
new MetricsService(this);
2019-08-22 19:37:09 +00:00
// Starting the Auto-Updater
if (config.getBoolean("options.auto-update")) {
updaterService.start();
}
2016-04-14 16:24:03 +00:00
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Loading Items...");
2016-04-14 16:24:03 +00:00
MiscSetup.setupItemSettings();
2020-01-11 19:58:14 +00:00
2016-04-14 16:24:03 +00:00
try {
SlimefunItemSetup.setup();
} catch (Exception x) {
2020-01-29 01:25:25 +00:00
getLogger().log(Level.SEVERE, "An Error occured while initializing SlimefunItems for Slimefun " + getVersion(), x);
2016-04-14 16:24:03 +00:00
}
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Loading Researches...");
2016-04-14 16:24:03 +00:00
ResearchSetup.setupResearches();
2020-01-11 19:58:14 +00:00
settings.researchesEnabled = getResearchCfg().getBoolean("enable-researching");
2016-04-14 16:24:03 +00:00
MiscSetup.setupMisc();
2019-11-10 16:46:18 +00:00
WikiSetup.addWikiPages(this);
textureService.setup(registry.getAllSlimefunItems());
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Loading World Generators...");
// Generating Oil as an OreGenResource (it iss a cool API)
new OilResource().register();
new NetherIceResource().register();
new UraniumResource().register();
new SaltResource().register();
2019-03-27 20:48:34 +00:00
2017-01-18 11:44:12 +00:00
// Setting up GitHub Connectors...
2019-12-11 23:16:28 +00:00
gitHubService.connect(config.getBoolean("options.print-out-github-data-retrieving"));
2019-03-27 20:48:34 +00:00
2016-08-05 23:23:40 +00:00
// All Slimefun Listeners
new SlimefunBootsListener(this);
2020-01-12 10:01:29 +00:00
new SlimefunItemListener(this);
new BlockPhysicsListener(this);
2019-12-29 13:14:51 +00:00
new MultiBlockListener(this);
2016-04-14 16:24:03 +00:00
new GearListener(this);
new AutonomousToolsListener(this);
new DamageListener(this);
2020-01-12 10:01:29 +00:00
new BlockListener(this);
2019-12-29 13:14:51 +00:00
new EnhancedFurnaceListener(this);
2016-04-14 16:24:03 +00:00
new TeleporterListener(this);
new AndroidKillingListener(this);
new NetworkListener(this);
2018-09-04 09:33:57 +00:00
new ItemPickupListener(this);
2020-01-11 22:58:05 +00:00
new DeathpointListener(this);
new ExplosionsListener(this);
2020-01-12 01:05:33 +00:00
new DebugFishListener(this);
2020-01-12 10:01:29 +00:00
new VanillaMachinesListener(this);
2020-01-29 01:25:25 +00:00
bowListener = new SlimefunBowListener(this);
ancientAltarListener = new AncientAltarListener();
2016-08-05 23:23:40 +00:00
// Toggleable Listeners for performance
2016-04-14 16:24:03 +00:00
if (config.getBoolean("items.talismans")) new TalismanListener(this);
if (config.getBoolean("items.coolers")) new CoolerListener(this);
2019-12-29 13:14:51 +00:00
if (config.getBoolean("items.soulbound")) new SoulboundListener(this);
2016-08-05 23:23:40 +00:00
if (config.getBoolean("items.backpacks")) {
backpackListener = new BackpackListener(this);
}
2016-08-05 23:23:40 +00:00
// Handle Slimefun Guide being given on Join
2020-01-27 00:05:28 +00:00
new SlimefunGuideListener(this, config.getBoolean("options.give-guide-on-first-join"));
2016-08-05 23:23:40 +00:00
// Load/Unload Worlds in Slimefun
2019-03-30 10:10:54 +00:00
new WorldListener(this);
2016-08-05 23:23:40 +00:00
// Clear the Slimefun Guide History upon Player Leaving
2019-12-29 13:14:51 +00:00
new PlayerProfileListener(this);
2016-08-05 23:23:40 +00:00
// Initiating various Stuff and all Items with a slightly delay (0ms after the Server finished loading)
Slimefun.runSync(() -> {
2019-10-29 08:13:32 +00:00
recipeSnapshot = new RecipeSnapshot(this);
2019-09-01 16:53:02 +00:00
protections = new ProtectionManager(getServer());
MiscSetup.loadItems(settings);
for (World world : Bukkit.getWorlds()) {
new BlockStorage(world);
2016-04-14 16:24:03 +00:00
}
if (SlimefunItem.getByID("ANCIENT_ALTAR") != null) {
ancientAltarListener.load(this);
}
2019-12-29 17:30:48 +00:00
if (SlimefunItem.getByID("GRAPPLING_HOOK") != null) new GrapplingHookListener(this);
2020-01-12 10:01:29 +00:00
if (SlimefunItem.getByID("IGNITION_CHAMBER") != null) new IgnitionChamberListener(this);
2016-04-14 16:24:03 +00:00
}, 0);
2020-01-11 19:58:14 +00:00
2019-09-01 09:42:03 +00:00
SlimefunCommand command = new SlimefunCommand(this);
2019-09-01 09:42:03 +00:00
getCommand("slimefun").setExecutor(command);
getCommand("slimefun").setTabCompleter(new SlimefunTabCompleter(command));
2016-08-05 23:23:40 +00:00
// Armor Update Task
2016-04-14 16:24:03 +00:00
if (config.getBoolean("options.enable-armor-effects")) {
2019-10-05 19:16:21 +00:00
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(), 0L, config.getInt("options.armor-update-interval") * 20L);
2016-04-14 16:24:03 +00:00
}
2016-04-14 16:24:03 +00:00
ticker = new TickerTask();
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
2020-01-11 19:58:14 +00:00
2016-08-05 23:23:40 +00:00
// Starting all ASYNC Tasks
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
try {
ticker.run();
}
2019-11-24 12:23:16 +00:00
catch(Exception x) {
2020-01-29 01:25:25 +00:00
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"));
2020-01-11 19:58:14 +00:00
gitHubService.start(this);
2019-04-28 15:22:30 +00:00
2016-08-05 23:23:40 +00:00
// Hooray!
2019-08-31 15:52:20 +00:00
getLogger().log(Level.INFO, "Finished!");
2019-08-29 14:19:23 +00:00
hooks = new SlimefunHooks(this);
2020-01-11 19:58:14 +00:00
utilities.oreWasherOutputs = new ItemStack[] {SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.TIN_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST, SlimefunItems.MAGNESIUM_DUST};
2016-08-05 23:23:40 +00:00
// 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,})");
2016-04-14 16:24:03 +00:00
}
2019-09-21 14:21:10 +00:00
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/");
2020-01-11 19:58:14 +00:00
2019-09-21 14:21:10 +00:00
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/");
2019-09-21 14:21:10 +00:00
return true;
});
}
2016-04-14 16:24:03 +00:00
}
2020-01-29 01:25:25 +00:00
private boolean isVersionUnsupported() {
String currentVersion = ReflectionUtils.getVersion();
if (currentVersion.startsWith("v")) {
boolean compatibleVersion = false;
StringBuilder versions = new StringBuilder();
int i = 0;
for (String version : supported) {
if (currentVersion.startsWith(version)) {
compatibleVersion = true;
}
String s = version.substring(1).replaceFirst("_", ".").replace("_", ".X");
if (i == 0) versions.append(s);
else if (i == supported.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;
}
2016-04-14 16:24:03 +00:00
@Override
public void onDisable() {
// CS-CoreLib wasn't loaded, just disabling
if (instance == null) return;
2020-01-11 19:58:14 +00:00
2016-04-14 16:24:03 +00:00
Bukkit.getScheduler().cancelTasks(this);
2019-04-28 15:22:30 +00:00
if (ticker != null) {
// Finishes all started movements/removals of block data
2019-09-02 21:14:48 +00:00
ticker.halt();
2019-04-28 15:22:30 +00:00
ticker.run();
}
2020-01-11 19:58:14 +00:00
2019-08-29 13:13:40 +00:00
PlayerProfile.iterator().forEachRemaining(profile -> {
if (profile.isDirty()) profile.save();
});
2020-01-11 19:58:14 +00:00
for (World world : Bukkit.getWorlds()) {
2019-08-22 19:37:09 +00:00
try {
2016-06-10 16:39:40 +00:00
BlockStorage storage = BlockStorage.getStorage(world);
2020-01-11 19:58:14 +00:00
if (storage != null) {
storage.save(true);
2016-06-10 16:39:40 +00:00
}
else {
2019-08-31 10:54:54 +00:00
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"" + world.getName() + "\"");
2016-04-14 16:24:03 +00:00
}
2019-08-22 19:37:09 +00:00
} catch (Exception x) {
2020-01-29 01:25:25 +00:00
getLogger().log(Level.SEVERE, "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + getVersion(), x);
2016-04-14 16:24:03 +00:00
}
2019-08-22 19:37:09 +00:00
}
2020-01-11 19:58:14 +00:00
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
2019-08-22 19:37:09 +00:00
menu.save();
}
2020-01-11 19:58:14 +00:00
2019-08-22 19:37:09 +00:00
SlimefunBackup.start();
2017-06-22 14:43:49 +00:00
// Prevent Memory Leaks
2016-04-14 16:24:03 +00:00
AContainer.processing = null;
AContainer.progress = null;
2020-01-11 19:58:14 +00:00
AGenerator.processing = null;
AGenerator.progress = null;
2020-01-11 19:58:14 +00:00
AReactor.processing = null;
AReactor.progress = null;
2019-08-31 09:36:45 +00:00
instance = null;
for (Player p : Bukkit.getOnlinePlayers()) {
2016-04-14 16:24:03 +00:00
p.closeInventory();
}
}
2019-03-27 20:46:04 +00:00
private void createDir(String path) {
2019-03-27 22:31:32 +00:00
File file = new File(path);
2019-08-27 21:08:13 +00:00
if (!file.exists()) file.mkdirs();
2019-03-27 20:46:04 +00:00
}
2016-04-14 16:24:03 +00:00
public static Config getCfg() {
2019-08-31 09:36:45 +00:00
return instance.config;
2016-04-14 16:24:03 +00:00
}
public static io.github.thebusybiscuit.cscorelib2.config.Config getResearchCfg() {
2019-08-31 09:36:45 +00:00
return instance.researches;
2016-04-14 16:24:03 +00:00
}
2016-04-14 16:24:03 +00:00
public static Config getItemCfg() {
2019-08-31 09:36:45 +00:00
return instance.items;
2016-04-14 16:24:03 +00:00
}
public static io.github.thebusybiscuit.cscorelib2.config.Config getWhitelist() {
2019-08-31 09:36:45 +00:00
return instance.whitelist;
2016-04-14 16:24:03 +00:00
}
public static GPSNetwork getGPSNetwork() {
return instance.gps;
2019-09-02 21:14:48 +00:00
}
2019-08-31 09:36:45 +00:00
public static SlimefunHooks getHooks() {
return instance.hooks;
}
2020-01-11 19:58:14 +00:00
2019-08-31 09:36:45 +00:00
public static Utilities getUtilities() {
return instance.utilities;
2019-08-27 11:28:07 +00:00
}
2020-01-11 19:58:14 +00:00
public static ConfigCache getSettings() {
2019-08-31 09:36:45 +00:00
return instance.settings;
}
2020-01-11 19:58:14 +00:00
2019-08-31 10:54:54 +00:00
public static TickerTask getTicker() {
return instance.ticker;
}
2020-01-11 19:58:14 +00:00
2019-08-31 12:17:25 +00:00
public static boolean isActive() {
return instance != null;
}
public static String getVersion() {
return instance.getDescription().getVersion();
}
2019-03-27 20:48:34 +00:00
2019-09-01 16:53:02 +00:00
public static ProtectionManager getProtectionManager() {
return instance.protections;
}
public static LocalizationService getLocal() {
2019-09-21 11:59:15 +00:00
return instance.local;
}
2020-01-11 19:58:14 +00:00
2019-10-29 08:13:32 +00:00
public static RecipeSnapshot getMinecraftRecipes() {
return instance.recipeSnapshot;
}
2020-01-11 19:58:14 +00:00
2019-11-10 16:46:18 +00:00
public static CustomItemDataService getItemDataService() {
return instance.itemDataService;
}
2020-01-11 19:58:14 +00:00
2019-11-10 16:46:18 +00:00
public static CustomTextureService getItemTextureService() {
return instance.textureService;
}
2020-01-11 19:58:14 +00:00
public static BlockDataService getBlockDataService() {
return instance.blockDataService;
}
2019-09-21 11:59:15 +00:00
2020-02-03 22:09:32 +00:00
public static UpdaterService getUpdater() {
return instance.updaterService;
}
2019-12-11 23:16:28 +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 BackpackListener getBackpackListener() {
return instance.backpackListener;
}
2020-01-29 01:25:25 +00:00
public static SlimefunBowListener getBowListener() {
return instance.bowListener;
}
2019-12-11 23:16:28 +00:00
public static Set<Plugin> getInstalledAddons() {
return Arrays.stream(instance.getServer().getPluginManager().getPlugins())
.filter(Plugin::isEnabled)
.filter(plugin -> plugin.getDescription().getDepend().contains(instance.getName()) || plugin.getDescription().getSoftDepend().contains(instance.getName()))
.collect(Collectors.toSet());
}
2016-04-14 16:24:03 +00:00
}