Represents a Java plugin and its main class. It contains fundamental methods and fields for a plugin to be loaded and work properly. This is an indirect implementation of org.bukkit.plugin.Plugin.
| 39 | * implementation of {@link org.bukkit.plugin.Plugin}. |
| 40 | */ |
| 41 | @NullMarked |
| 42 | public abstract class JavaPlugin extends PluginBase { |
| 43 | private boolean isEnabled = false; |
| 44 | private PluginLoader loader = null; |
| 45 | private Server server = null; |
| 46 | private File file = null; |
| 47 | private PluginDescriptionFile description = null; |
| 48 | private io.papermc.paper.plugin.configuration.PluginMeta pluginMeta = null; |
| 49 | private File dataFolder = null; |
| 50 | private ClassLoader classLoader = null; |
| 51 | private boolean naggable = true; |
| 52 | private FileConfiguration newConfig = null; |
| 53 | private File configFile = null; |
| 54 | private Logger logger = null; |
| 55 | @SuppressWarnings("deprecation") |
| 56 | private final io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> lifecycleEventManager = org.bukkit.Bukkit.getUnsafe().createPluginLifecycleEventManager(this, () -> this.allowsLifecycleRegistration); |
| 57 | private boolean allowsLifecycleRegistration = true; |
| 58 | private boolean isBeingEnabled = false; |
| 59 | |
| 60 | public JavaPlugin() { |
| 61 | if (this.getClass().getClassLoader() instanceof io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader configuredPluginClassLoader) { |
| 62 | configuredPluginClassLoader.init(this); |
| 63 | } else { |
| 64 | throw new IllegalStateException("JavaPlugin requires to be created by a valid classloader."); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | @Deprecated(forRemoval = true) |
| 69 | protected JavaPlugin(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) { |
| 70 | final ClassLoader classLoader = this.getClass().getClassLoader(); |
| 71 | if (classLoader instanceof PluginClassLoader) { |
| 72 | throw new IllegalStateException("Cannot use initialization constructor at runtime"); |
| 73 | } |
| 74 | init(loader, loader.server, description, dataFolder, file, classLoader); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Returns the folder that the plugin data files are located in. The |
| 79 | * folder may not yet exist. |
| 80 | * |
| 81 | * @return The folder. |
| 82 | */ |
| 83 | @Override |
| 84 | public final File getDataFolder() { |
| 85 | return dataFolder; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Gets the associated PluginLoader responsible for this plugin |
| 90 | * |
| 91 | * @return PluginLoader that controls this plugin |
| 92 | * @deprecated Plugin loading now occurs at a point which makes it impossible to expose this |
| 93 | * behavior. This instance will only throw unsupported operation exceptions. |
| 94 | */ |
| 95 | @Override |
| 96 | @Deprecated(forRemoval = true) |
| 97 | public final PluginLoader getPluginLoader() { |
| 98 | return loader; |
nothing calls this directly
no test coverage detected