From 26d7df2bf486dd25bf1572959f875def1d35baa3 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Mon, 20 Feb 2023 23:06:48 +0100 Subject: [PATCH] [WIP] Add paper plugin loading for release mode --- Minepacks-Paper/pom.xml | 53 ++++++++++++++ Minepacks-Paper/resources/paper-plugin.yml | 7 ++ .../Minepacks/Paper/MinepacksBootstrap.java | 73 +++++++++++++++++++ Minepacks/pom.xml | 6 ++ pom.xml | 1 + 5 files changed, 140 insertions(+) create mode 100644 Minepacks-Paper/pom.xml create mode 100644 Minepacks-Paper/resources/paper-plugin.yml create mode 100644 Minepacks-Paper/src/at/pcgamingfreaks/Minepacks/Paper/MinepacksBootstrap.java diff --git a/Minepacks-Paper/pom.xml b/Minepacks-Paper/pom.xml new file mode 100644 index 0000000..9ca622a --- /dev/null +++ b/Minepacks-Paper/pom.xml @@ -0,0 +1,53 @@ + + 4.0.0 + Minepacks-Paper + + Minepacks-Parent + at.pcgamingfreaks + ${revision} + .. + + ${revision} + jar + + Minepacks-Paper + Paper API extension for Minepacks. + + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + + + + io.papermc.paper + paper-api + 1.19.3-R0.1-SNAPSHOT + provided + + + + + clean install + src + + + resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + + + + + diff --git a/Minepacks-Paper/resources/paper-plugin.yml b/Minepacks-Paper/resources/paper-plugin.yml new file mode 100644 index 0000000..ebcf7bf --- /dev/null +++ b/Minepacks-Paper/resources/paper-plugin.yml @@ -0,0 +1,7 @@ +name: "Minepacks" +author: "GeorgH93" +version: "${version}" +api-version: "1.19" + +main: "at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks" +bootstrapper: "at.pcgamingfreaks.Minepacks.Paper.MinepacksBootstrap" \ No newline at end of file diff --git a/Minepacks-Paper/src/at/pcgamingfreaks/Minepacks/Paper/MinepacksBootstrap.java b/Minepacks-Paper/src/at/pcgamingfreaks/Minepacks/Paper/MinepacksBootstrap.java new file mode 100644 index 0000000..19d1708 --- /dev/null +++ b/Minepacks-Paper/src/at/pcgamingfreaks/Minepacks/Paper/MinepacksBootstrap.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2023 GeorgH93 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package at.pcgamingfreaks.Minepacks.Paper; + +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +import io.papermc.paper.plugin.bootstrap.PluginBootstrap; +import io.papermc.paper.plugin.bootstrap.PluginProviderContext; + +public class MinepacksBootstrap implements PluginBootstrap +{ + @Override + public void bootstrap(@NotNull PluginProviderContext context) + { + } + + @Override + public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) + { + //TODO find a way to check if PCGF PluginLib exists + //Plugin pcgfPluginLib = Bukkit.getPluginManager().getPlugin("PCGF_PluginLib"); + boolean standalone = true; + /*if(pcgfPluginLib != null) + { + if(new Version(pcgfPluginLib.getDescription().getVersion()).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION))) + { + getLogger().info("PCGF-PluginLib to old! Switching to standalone mode!"); + } + else + { + getLogger().info("PCGF-PluginLib installed. Switching to normal mode!"); + standalone = false; + } + } + else + { + getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!"); + }*/ + try + { + if(standalone) + { + Class standaloneClass = Class.forName("at.pcgamingfreaks.MinepacksStandalone.Bukkit.Minepacks"); + return (JavaPlugin) standaloneClass.newInstance(); + } + else + { + Class normalClass = Class.forName("at.pcgamingfreaks.Minepacks.Bukkit.Minepacks"); + return (JavaPlugin) normalClass.newInstance(); + } + } + catch(Exception e) + { + throw new RuntimeException("Failed to create Minepacks plugin instance!", e); + } + } +} \ No newline at end of file diff --git a/Minepacks/pom.xml b/Minepacks/pom.xml index 8e52eed..e6451bc 100644 --- a/Minepacks/pom.xml +++ b/Minepacks/pom.xml @@ -237,6 +237,11 @@ Minepacks-BadRabbit-Bukkit ${project.version} + + at.pcgamingfreaks + Minepacks-Paper + ${project.version} + @@ -259,6 +264,7 @@ at.pcgamingfreaks:Minepacks-API at.pcgamingfreaks:Minepacks-MagicValues + at.pcgamingfreaks:Minepacks-Paper at.pcgamingfreaks:BadRabbit-Bukkit at.pcgamingfreaks:Minepacks-BadRabbit-Bukkit at.pcgamingfreaks:Minepacks diff --git a/pom.xml b/pom.xml index c95b12e..8b6f9d9 100644 --- a/pom.xml +++ b/pom.xml @@ -162,6 +162,7 @@ Components/Minepacks-BadRabbit-Bukkit + Minepacks-Paper