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

625 lines
26 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.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
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.Server;
2017-06-22 14:43:49 +00:00
import org.bukkit.World;
2020-04-03 10:10:42 +00:00
import org.bukkit.command.Command;
2017-06-22 14:43:49 +00:00
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
2020-05-04 14:25:47 +00:00
import org.bukkit.plugin.PluginDescriptionFile;
2017-06-22 14:43:49 +00:00
import org.bukkit.plugin.java.JavaPlugin;
2020-05-04 14:25:47 +00:00
import org.bukkit.plugin.java.JavaPluginLoader;
2017-06-22 14:43:49 +00:00
import io.github.thebusybiscuit.cscorelib2.config.Config;
2020-03-26 17:56:14 +00:00
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
2019-09-01 16:53:02 +00:00
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
2019-10-01 11:14:50 +00:00
import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
2020-02-16 11:17:14 +00:00
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
2020-03-19 12:14:29 +00:00
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
2020-05-07 16:00:44 +00:00
import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager;
import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService;
2020-02-08 19:50:21 +00:00
import io.github.thebusybiscuit.slimefun4.core.services.BackupService;
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.LocalizationService;
2020-03-18 13:20:49 +00:00
import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService;
import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService;
2020-03-10 20:44:24 +00:00
import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService;
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
import io.github.thebusybiscuit.slimefun4.core.services.metrics.MetricsService;
2020-03-12 02:32:04 +00:00
import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPluginService;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
2020-06-02 11:58:03 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler;
2020-06-20 17:21:44 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook;
import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe;
import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade;
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.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;
2020-05-08 16:59:51 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener;
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-01-11 22:58:05 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener;
2019-12-29 17:30:48 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemListener;
2019-12-29 13:14:51 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
2020-05-04 14:25:47 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener;
2019-12-29 13:14:51 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener;
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-03-12 02:32:04 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener;
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.VampireBladeListener;
2020-01-12 10:01:29 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener;
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-03-15 14:12:44 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
2020-02-02 17:27:32 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
2020-03-26 17:56:14 +00:00
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
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.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
2016-04-14 16:24:03 +00:00
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
2019-08-22 19:37:09 +00:00
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
2016-04-14 16:24:03 +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-05-09 16:00:10 +00:00
public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
public static SlimefunPlugin instance;
2020-05-04 14:25:47 +00:00
private MinecraftVersion minecraftVersion = MinecraftVersion.UNKNOWN;
2020-03-15 16:43:51 +00:00
private final SlimefunRegistry registry = new SlimefunRegistry();
private final TickerTask ticker = new TickerTask();
private final SlimefunCommand command = new SlimefunCommand(this);
2020-03-14 00:12:52 +00:00
2020-03-10 20:44:24 +00:00
// Services - Systems that fulfill certain tasks, treat them as a black box
private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item");
private final BlockDataService blockDataService = new BlockDataService(this, "slimefun_block");
2020-05-11 16:56:01 +00:00
private final CustomTextureService textureService = new CustomTextureService(new Config(this, "item-models.yml"));
private final GitHubService gitHubService = new GitHubService("TheBusyBiscuit/Slimefun4");
2020-05-08 13:44:12 +00:00
private final UpdaterService updaterService = new UpdaterService(this, getDescription().getVersion(), getFile());
2020-03-18 13:20:49 +00:00
private final MetricsService metricsService = new MetricsService(this);
private final AutoSavingService autoSavingService = new AutoSavingService();
private final BackupService backupService = new BackupService();
2020-03-10 20:44:24 +00:00
private final PermissionsService permissionsService = new PermissionsService(this);
private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this);
2020-03-12 02:32:04 +00:00
private final ThirdPartyPluginService thirdPartySupportService = new ThirdPartyPluginService(this);
2020-03-18 13:20:49 +00:00
private final MinecraftRecipeService recipeService = new MinecraftRecipeService(this);
private LocalizationService local;
2020-03-12 02:32:04 +00:00
2020-03-15 16:43:51 +00:00
private GPSNetwork gpsNetwork;
private NetworkManager networkManager;
2020-03-12 02:32:04 +00:00
private ProtectionManager protections;
// Important config files for Slimefun
private final Config config = new Config(this);
private final Config items = new Config(this, "Items.yml");
private final Config researches = new Config(this, "Researches.yml");
// Listeners that need to be accessed elsewhere
2020-03-27 12:19:47 +00:00
private final AncientAltarListener ancientAltarListener = new AncientAltarListener();
private final GrapplingHookListener grapplingHookListener = new GrapplingHookListener();
private final BackpackListener backpackListener = new BackpackListener();
private final SlimefunBowListener bowListener = new SlimefunBowListener();
2020-05-04 14:25:47 +00:00
public SlimefunPlugin() {
super();
}
public SlimefunPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
super(loader, description, dataFolder, file);
2020-05-20 15:20:52 +00:00
minecraftVersion = MinecraftVersion.UNIT_TEST;
2020-05-04 14:25:47 +00:00
}
@Override
public void onEnable() {
2020-05-20 15:20:52 +00:00
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
2020-05-04 14:25:47 +00:00
instance = this;
local = new LocalizationService(this, "", null);
gpsNetwork = new GPSNetwork();
command.register();
2020-05-04 14:25:47 +00:00
}
else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
2020-03-26 17:56:14 +00:00
long timestamp = System.nanoTime();
2020-03-14 00:12:52 +00:00
// We wanna ensure that the Server uses a compatible version of Minecraft
if (isVersionUnsupported()) {
getServer().getPluginManager().disablePlugin(this);
return;
}
instance = this;
// Creating all necessary Folders
getLogger().log(Level.INFO, "Loading various systems...");
createDirectories();
2020-03-15 16:43:51 +00:00
registry.load(config);
// Set up localization
local = new LocalizationService(this, config.getString("options.chat-prefix"), config.getString("options.language"));
// Setting up Networks
2020-03-15 16:43:51 +00:00
gpsNetwork = new GPSNetwork();
int networkSize = config.getInt("networks.max-size");
if (networkSize < 1) {
getLogger().log(Level.WARNING, "Your 'networks.max-size' setting is misconfigured! It must be at least 1, it was set to: {0}", networkSize);
networkSize = 1;
}
networkManager = new NetworkManager(networkSize);
// 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...");
GEOResourcesSetup.setup();
2020-03-27 11:16:42 +00:00
getLogger().log(Level.INFO, "Loading items...");
loadItems();
2020-03-27 11:16:42 +00:00
getLogger().log(Level.INFO, "Loading researches...");
loadResearches();
2020-03-10 14:20:59 +00:00
2020-03-15 16:43:51 +00:00
registry.setResearchingEnabled(getResearchCfg().getBoolean("enable-researching"));
2020-03-15 14:12:44 +00:00
PostSetup.setupWiki();
// All Slimefun Listeners
new SlimefunBootsListener(this);
new SlimefunItemListener(this);
2020-03-12 02:32:04 +00:00
new SlimefunItemConsumeListener(this);
new BlockPhysicsListener(this);
2020-05-08 16:59:51 +00:00
new CargoNodeListener(this);
new MultiBlockListener(this);
new GadgetsListener(this);
new DispenserListener(this);
2020-05-01 09:25:42 +00:00
new MobDropListener(this);
new BlockListener(this);
new EnhancedFurnaceListener(this);
new ItemPickupListener(this);
new DeathpointListener(this);
new ExplosionsListener(this);
new DebugFishListener(this);
new VanillaMachinesListener(this);
new FireworksListener(this);
new WitherListener(this);
new IronGolemListener(this);
// Item-specific Listeners
new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem());
new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem());
new SeismicAxeListener(this, (SeismicAxe) SlimefunItems.SEISMIC_AXE.getItem());
grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem());
ancientAltarListener.register(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
bowListener.register(this);
2020-03-18 13:20:49 +00:00
// Toggleable Listeners for performance reasons
2020-03-12 02:32:04 +00:00
if (config.getBoolean("items.talismans")) {
new TalismanListener(this);
}
if (config.getBoolean("items.soulbound")) {
new SoulboundListener(this);
}
if (config.getBoolean("items.backpacks")) {
backpackListener.register(this);
}
// Handle Slimefun Guide being given on Join
new SlimefunGuideListener(this, config.getBoolean("guide.receive-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)
2020-03-26 17:56:14 +00:00
Slimefun.runSync(new SlimefunStartupTask(this, () -> {
protections = new ProtectionManager(getServer());
2020-05-08 13:44:12 +00:00
textureService.register(registry.getAllSlimefunItems(), true);
2020-05-08 15:13:16 +00:00
permissionsService.register(registry.getAllSlimefunItems(), true);
recipeService.refresh();
2020-03-26 17:56:14 +00:00
}), 0);
// Setting up the command /sf and all subcommands
command.register();
// Armor Update Task
if (config.getBoolean("options.enable-armor-effects")) {
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(), 0L, config.getInt("options.armor-update-interval") * 20L);
}
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
2020-03-26 17:56:14 +00:00
ticker.start(this);
2020-03-12 02:32:04 +00:00
thirdPartySupportService.start();
2020-03-26 17:56:14 +00:00
gitHubService.start(this);
2020-03-26 17:56:14 +00:00
// Hooray!
2020-03-27 11:16:42 +00:00
getLogger().log(Level.INFO, "Slimefun has finished loading in {0}", getStartupTime(timestamp));
}
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;
});
}
}
2020-03-27 11:16:42 +00:00
private String getStartupTime(long timestamp) {
long ms = (System.nanoTime() - timestamp) / 1000000;
if (ms > 1000) {
2020-03-28 20:04:16 +00:00
return DoubleHandler.fixDouble(ms / 1000.0) + "s";
2020-03-27 11:16:42 +00:00
}
else {
return DoubleHandler.fixDouble(ms) + "ms";
}
}
/**
* This method checks for the {@link MinecraftVersion} of the {@link Server}.
* If the version is unsupported, a warning will be printed to the console.
*
* @return Whether the {@link MinecraftVersion} is unsupported
*/
private boolean isVersionUnsupported() {
String currentVersion = ReflectionUtils.getVersion();
if (currentVersion.startsWith("v")) {
2020-03-14 00:12:52 +00:00
for (MinecraftVersion version : MinecraftVersion.values()) {
if (version.matches(currentVersion)) {
minecraftVersion = version;
return false;
}
}
// Looks like you are using an unsupported Minecraft Version
getLogger().log(Level.SEVERE, "#############################################");
2020-03-14 00:12:52 +00:00
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
getLogger().log(Level.SEVERE, "### You are using the wrong version of Minecraft!");
getLogger().log(Level.SEVERE, "###");
getLogger().log(Level.SEVERE, "### You are using Minecraft {0}", ReflectionUtils.getVersion());
getLogger().log(Level.SEVERE, "### but Slimefun v{0} requires you to be using", getDescription().getVersion());
getLogger().log(Level.SEVERE, "### Minecraft {0}", String.join(" / ", getSupportedVersions()));
getLogger().log(Level.SEVERE, "#############################################");
2020-03-14 00:12:52 +00:00
return true;
}
getLogger().log(Level.WARNING, "We could not determine the version of Minecraft you were using ({0})", currentVersion);
return false;
}
private Collection<String> getSupportedVersions() {
List<String> list = new ArrayList<>();
for (MinecraftVersion version : MinecraftVersion.values()) {
if (version != MinecraftVersion.UNKNOWN) {
list.add(version.getName());
}
}
return list;
}
@Override
public void onDisable() {
2020-03-18 13:20:49 +00:00
// Slimefun never loaded successfully, so we don't even bother doing stuff here
2020-05-20 15:20:52 +00:00
if (instance == null || minecraftVersion == MinecraftVersion.UNIT_TEST) {
2020-03-18 13:20:49 +00:00
return;
}
// Cancel all tasks from this plugin immediately
Bukkit.getScheduler().cancelTasks(this);
if (ticker != null) {
// Finishes all started movements/removals of block data
ticker.halt();
ticker.run();
}
// Save all Player Profiles that are still in memory
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 \"{0}\"", world.getName());
}
}
catch (Exception x) {
getLogger().log(Level.SEVERE, x, () -> "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + getVersion());
}
}
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
menu.save();
}
// Create a new backup zip
backupService.run();
// Prevent Memory Leaks
// These static Maps should be removed at some point...
AContainer.processing = null;
AContainer.progress = null;
AGenerator.processing = null;
AGenerator.progress = null;
2020-06-20 17:21:44 +00:00
Reactor.processing = null;
Reactor.progress = null;
instance = null;
// Close all inventories on the server to prevent item dupes
// (Incase some idiot uses /reload)
for (Player p : Bukkit.getOnlinePlayers()) {
p.closeInventory();
}
}
private void createDirectories() {
2020-03-27 12:19:47 +00:00
String[] storageFolders = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
String[] pluginFolders = { "scripts", "generators", "error-reports", "cache/github", "world-settings" };
2020-03-27 12:19:47 +00:00
for (String folder : storageFolders) {
File file = new File("data-storage/Slimefun", folder);
2020-03-27 12:19:47 +00:00
if (!file.exists()) file.mkdirs();
}
2020-03-27 12:19:47 +00:00
for (String folder : pluginFolders) {
File file = new File("plugins/Slimefun", folder);
2020-03-27 12:19:47 +00:00
if (!file.exists()) file.mkdirs();
}
}
2020-03-27 11:16:42 +00:00
private void loadItems() {
try {
SlimefunItemSetup.setup(this);
}
2020-06-19 11:22:52 +00:00
catch (Exception | LinkageError x) {
2020-03-27 11:16:42 +00:00
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing SlimefunItems for Slimefun " + getVersion());
}
}
private void loadResearches() {
try {
ResearchSetup.setupResearches();
}
2020-06-19 11:22:52 +00:00
catch (Exception | LinkageError x) {
2020-03-27 11:16:42 +00:00
getLogger().log(Level.SEVERE, x, () -> "An Error occured while initializing Slimefun Researches for Slimefun " + getVersion());
}
}
public static Config getCfg() {
return instance.config;
}
public static Config getResearchCfg() {
return instance.researches;
}
public static Config getItemCfg() {
return instance.items;
}
public static GPSNetwork getGPSNetwork() {
2020-03-15 16:43:51 +00:00
return instance.gpsNetwork;
}
public static TickerTask getTicker() {
return instance.ticker;
}
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
*/
public static String getVersion() {
return instance.getDescription().getVersion();
}
public static ProtectionManager getProtectionManager() {
return instance.protections;
}
2020-04-03 10:10:42 +00:00
/**
* This returns the {@link LocalizationService} of Slimefun.
*
* @return The {@link LocalizationService} of Slimefun
*/
public static LocalizationService getLocal() {
return instance.local;
}
2020-03-18 13:20:49 +00:00
public static MinecraftRecipeService getMinecraftRecipes() {
return instance.recipeService;
}
public static CustomItemDataService getItemDataService() {
return instance.itemDataService;
}
public static CustomTextureService getItemTextureService() {
return instance.textureService;
}
2020-03-10 20:44:24 +00:00
public static PermissionsService getPermissionsService() {
return instance.permissionsService;
}
public static BlockDataService getBlockDataService() {
return instance.blockDataService;
}
2020-03-12 02:32:04 +00:00
public static ThirdPartyPluginService getThirdPartySupportService() {
return instance.thirdPartySupportService;
}
public static PerWorldSettingsService getWorldSettingsService() {
return instance.worldSettingsService;
}
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
*/
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
*/
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
*/
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-04-03 10:10:42 +00:00
/**
* The {@link Command} that was added by Slimefun.
*
* @return Slimefun's command
*/
public static SlimefunCommand getCommand() {
return instance.command;
}
2020-04-03 10:10:42 +00:00
/**
* This returns the currently installed version of Minecraft.
*
* @return The current version of Minecraft
*/
2020-03-14 00:12:52 +00:00
public static MinecraftVersion getMinecraftVersion() {
return instance.minecraftVersion;
}
public static String getCSCoreLibVersion() {
return CSCoreLib.getLib().getDescription().getVersion();
}
2020-03-14 00:12:52 +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
}