From ee86b7d84a2f76b7ed48e9d10fb46157544e77ab Mon Sep 17 00:00:00 2001 From: maarten Date: Thu, 17 Apr 2025 15:43:39 +0200 Subject: [PATCH] Initial commit --- .gitignore | 56 ++++++++++++ Jenkinsfile | 36 ++++++++ pom.xml | 91 +++++++++++++++++++ readme.md | 84 +++++++++++++++++ .../nl/maartenvr98/PluginTemplate/Main.java | 69 ++++++++++++++ .../PluginTemplate/commands/MyCommand.java | 15 +++ .../PluginTemplate/config/MainConfig.java | 15 +++ .../listeners/PlayerListener.java | 14 +++ src/main/resources/plugin.yml | 4 + 9 files changed, 384 insertions(+) create mode 100644 .gitignore create mode 100644 Jenkinsfile create mode 100644 pom.xml create mode 100644 readme.md create mode 100644 src/main/java/nl/maartenvr98/PluginTemplate/Main.java create mode 100644 src/main/java/nl/maartenvr98/PluginTemplate/commands/MyCommand.java create mode 100644 src/main/java/nl/maartenvr98/PluginTemplate/config/MainConfig.java create mode 100644 src/main/java/nl/maartenvr98/PluginTemplate/listeners/PlayerListener.java create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1c7e7d --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# +# Project specific excludes +# + +tomcat + +# +# Default excludes +# + +# Binaries +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip +*.war +*.ear +*.sar +*.class + +# Maven +target/ + +# IntelliJ project files +*.iml +*.iws +*.ipr +.idea/ + +# eclipse project file +.settings/ +.classpath +.project + +# NetBeans specific +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml + + +# OS +.DS_Store + +# Misc +*.swp +release.properties +pom.xml.releaseBackup +pom.xml.tag \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..37975cc --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,36 @@ +pipeline { + agent any + + tools { + maven 'Maven 3.9.9' + } + + environment { + MAVEN_OPTS = '-Dmaven.repo.local=.m2/repository' + } + + stages { + stage('Build') { + steps { + sh 'mvn clean install' + } + } + + stage('Archive Artifacts') { + steps { + script { + def artifact = sh(script: "mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout", returnStdout: true).trim() + archiveArtifacts artifacts: "**/target/${artifact}-*.jar", fingerprint: true, allowEmptyArchive: true + } + } + } + + // stage('Notify Discord') { + // steps { + // script { + // discordSend webhookURL: '', title: "${env.JOB_NAME} #${env.BUILD_NUMBER}", enableArtifactsList: true, showChangeset: true, link: env.BUILD_URL, result: currentBuild.currentResult + // } + // } + // } + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..023ae6c --- /dev/null +++ b/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + nl.maartenvr98 + PluginTemplate + 1.0-SNAPSHOT + jar + + PluginTemplate + + + 21 + UTF-8 + + + + clean package + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + ${project.build.directory}/dependency-reduced-pom.xml + + + nl.maartenvr98.PluginKit + nl.maartenvr98.PluginKit + + + + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + maartenvr98-repository-plugins + Maarten's Repository + https://maven.maartenvr98.nl/plugins + + + + + + org.spigotmc + spigot-api + 1.21.4-R0.1-SNAPSHOT + provided + + + nl.maartenvr98 + PluginKit + 1.1.3 + + + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a78ef9b --- /dev/null +++ b/readme.md @@ -0,0 +1,84 @@ +# PluginTemplate + +PluginTemplate is a simple starting point for creating Spigot plugins using the **PluginKit** framework. It provides a streamlined setup to kickstart your development with pre-configured essentials. + +## Features + +- **Integrated with PluginKit**: Build on top of your custom PluginKit framework for consistency and reduced boilerplate. +- **Pre-configured Structure**: Includes a clear folder and package layout for your Spigot plugin. +- **Ease of Use**: Designed to get you started quickly with minimal setup. + +## Requirements + +- **Java 17+** +- **Spigot API**: Compatible with Spigot version 1.16 and above. +- **PluginKit Framework**: Ensure the PluginKit framework is available in your project. + +## Getting Started + +1. **Clone the Template** + ```bash + git clone https://github.com/yourusername/PluginTemplate.git + cd PluginTemplate + + +2. **Set Up PluginKit** + + Ensure PluginKit is added as a dependency in your project. Update the pom.xml or build.gradle file if necessary. + + +3. **Customize Plugin Metadata** + + Update plugin.yml with your plugin's name, version, and other metadata: + ```yaml + name: YourPluginName + version: '1.0-SNAPSHOT' + main: nl.maartenvr98.YourPluginName.Main + api-version: '1.21' + ``` + +4. **Start coding** + + Use the provided structure to add commands, events, and any other logic for your plugin. + + +5. **Build Your Plugin** + + Use Maven or Gradle to compile your plugin: + ```bash + mvn clean package + ``` + + +6. **Test in Spigot Server** + + Copy the JAR file into your Spigot server's plugins folder and start the server. + + +## File Structure +```plaintext +PluginTemplate/ +├── src/ +│ ├── main/ +│ │ ├── java/ +│ │ │ └── nl/maartenvr98/YourPluginName +│ │ │ ├── commands/ +│ │ │ │ └── MyCommand.java +│ │ │ ├── listener/ +│ │ │ │ └── PlayerListener.java +│ │ │ ├── config/ +│ │ │ │ └── MainConfig.java +│ │ │ └── Main.java +│ │ ├── resources/ +│ │ │ ├── plugin.yml +├── pom.xml +└── README.md +``` + + +## Contributing +Contributions are welcome! Feel free to open issues or submit pull requests to improve the template + + +## License +This project is licensed under the MIT License. \ No newline at end of file diff --git a/src/main/java/nl/maartenvr98/PluginTemplate/Main.java b/src/main/java/nl/maartenvr98/PluginTemplate/Main.java new file mode 100644 index 0000000..d7d8306 --- /dev/null +++ b/src/main/java/nl/maartenvr98/PluginTemplate/Main.java @@ -0,0 +1,69 @@ +package nl.maartenvr98.PluginTemplate; + +import nl.maartenvr98.PluginKit.PluginKit; +import nl.maartenvr98.PluginKit.config.ConfigFile; +import nl.maartenvr98.PluginKit.log.Log; +import nl.maartenvr98.PluginTemplate.commands.MyCommand; +import nl.maartenvr98.PluginTemplate.config.MainConfig; +import nl.maartenvr98.PluginTemplate.listeners.PlayerListener; +import org.bukkit.plugin.java.JavaPlugin; + +public final class Main extends JavaPlugin { + + private static JavaPlugin instance; + + @Override + public void onEnable() { + instance = this; + Log.success("Enabling PluginTemplate"); + + // Setup plugin with PluginKit + PluginKit.setPlugin(this) + // Commands + .addCommand("template", new MyCommand()) + + // Listeners + .addListener(new PlayerListener()) + + // Configs + .addConfig(new MainConfig()) + + // Tasks + // .addTask(new SpawnerSpawnTask()) + + // Hooks + // .addHook("Vault", new Vault()) + + // Migrations + // .addMigration(new CreatePlayersMigration()); + + // Settings + .withSettings(settings -> { + // Define your settings here + + // settings.setMessagesConfig("messages"); + }); + + Log.success("PluginTemplate is enabled"); + } + + @Override + public void onDisable() { + Log.success("Disabling PluginTemplate"); + + // Disable plugin + PluginKit.disablePlugin(); + + Log.success("PluginTemplate is disabled"); + } + + /** + * Get plugin instance + * + * @return JavaPlugin instance + */ + public static JavaPlugin getInstance() { + return instance; + } + +} diff --git a/src/main/java/nl/maartenvr98/PluginTemplate/commands/MyCommand.java b/src/main/java/nl/maartenvr98/PluginTemplate/commands/MyCommand.java new file mode 100644 index 0000000..ca798c8 --- /dev/null +++ b/src/main/java/nl/maartenvr98/PluginTemplate/commands/MyCommand.java @@ -0,0 +1,15 @@ +package nl.maartenvr98.PluginTemplate.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class MyCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { + // Implement logic here + + return true; + } +} diff --git a/src/main/java/nl/maartenvr98/PluginTemplate/config/MainConfig.java b/src/main/java/nl/maartenvr98/PluginTemplate/config/MainConfig.java new file mode 100644 index 0000000..a3bbf37 --- /dev/null +++ b/src/main/java/nl/maartenvr98/PluginTemplate/config/MainConfig.java @@ -0,0 +1,15 @@ +package nl.maartenvr98.PluginTemplate.config; + +import nl.maartenvr98.PluginKit.config.ConfigFile; +import nl.maartenvr98.PluginKit.config.abstracts.AbstractConfig; + +public class MainConfig extends AbstractConfig { + public MainConfig() { + super("config.yml"); + } + + @Override + public void setDefaults(ConfigFile config) { + config.setDefault("foo.bar", "value"); + } +} diff --git a/src/main/java/nl/maartenvr98/PluginTemplate/listeners/PlayerListener.java b/src/main/java/nl/maartenvr98/PluginTemplate/listeners/PlayerListener.java new file mode 100644 index 0000000..42fc8ab --- /dev/null +++ b/src/main/java/nl/maartenvr98/PluginTemplate/listeners/PlayerListener.java @@ -0,0 +1,14 @@ +package nl.maartenvr98.PluginTemplate.listeners; + +import nl.maartenvr98.PluginKit.message.Message; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class PlayerListener implements Listener { + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Message.chat(event.getPlayer(), "Welcome to my server!"); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..f065c41 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: PluginTemplate +version: '1.0-SNAPSHOT' +main: nl.maartenvr98.PluginTemplate.Main +api-version: '1.21'