From 7807b72442227c53189f495a1703ff0b3ebd616f Mon Sep 17 00:00:00 2001 From: Griefed <griefed@griefed.de> Date: Wed, 26 Jan 2022 19:10:56 +0100 Subject: [PATCH] no message --- README.md | 158 ++++++++++-------- build.gradle | 4 +- .../ExamplePlugin.java | 53 ++++-- src/main/resources/addon.conf | 3 - 4 files changed, 133 insertions(+), 85 deletions(-) delete mode 100644 src/main/resources/addon.conf diff --git a/README.md b/README.md index 0846ec9..8b63bbc 100644 --- a/README.md +++ b/README.md @@ -2,42 +2,80 @@ This is an example server pack addon for [ServerPackCreator](https://github.com/Griefed/ServerPackCreator) -Server pack addons for ServerPackCreator are executed right after a server pack was generated, allowing for additional -operations and more customization of server packs. Users are free to write their own addons, distribute and share them. +The following endpoints are available in ServerPackCreator to add you extra functionality with a plugin. This example plugin provides examples for all four of them: -This example provides JavaDocs and tests. +- TabExtension: Allows you to add your own JComponent in the form of an additional tab to the GUI. You can run whatever code you want in that tab. -Using this example with a [dev-build of ServerPackCreator](https://git.griefed.de/Griefed/ServerPackCreator/-/pipelines?page=1&scope=all&ref=webservice) would result in the following output to the addons.log file: +- PreGenExtension: Will allow you to run your code before generation of a server pack starts +- PreZipExtension: Will allow you to run your code after a server pack was generated, but before the ZIP-archive is created + +- PostGenExtension: Will allow you to run your code after the server pack ZIP-archive was generated, so right at the on of the SPC process, basically. + +Using this example plugin would result in the following or similar output in ServerPackCreator itself: + +serverpackcreator.log: +``` +INFO [main] (AbstractPluginManager.java:814) - Plugin 'example-plugin@0.0.1' resolved +INFO [main] (AbstractPluginManager.java:357) - Start plugin 'example-plugin@0.0.1' +INFO [main] (ApplicationPlugins.java:74) - Available PreGenExtension plugins: +INFO [main] (ApplicationPlugins.java:76) - Name: ServerPackCreatorExampleAddon +INFO [main] (ApplicationPlugins.java:77) - Description:This is an example addon for ServerPackCreator showcasing all, currently 4, aspects ofServerPackCreators addon functionality. In this example you see code which gets executed before a server pack is generated,code that gets executed after a server pack was generated but before the ZIP-archive is created, code that gets executedafter this ZIP-archive was created, as well as code adding a new tabbed pane to the GUI. +INFO [main] (ApplicationPlugins.java:78) - Version: 0.0.1 +INFO [main] (ApplicationPlugins.java:79) - Author: Griefed +INFO [main] (ApplicationPlugins.java:83) - Available PreZipExtension plugins: +INFO [main] (ApplicationPlugins.java:85) - Name: ServerPackCreatorExampleAddon +INFO [main] (ApplicationPlugins.java:86) - Description:This is an example addon for ServerPackCreator showcasing all, currently 4, aspects ofServerPackCreators addon functionality. In this example you see code which gets executed before a server pack is generated,code that gets executed after a server pack was generated but before the ZIP-archive is created, code that gets executedafter this ZIP-archive was created, as well as code adding a new tabbed pane to the GUI. +INFO [main] (ApplicationPlugins.java:87) - Version: 0.0.1 +INFO [main] (ApplicationPlugins.java:88) - Author: Griefed +INFO [main] (ApplicationPlugins.java:92) - Available PostGenExtension plugins: +INFO [main] (ApplicationPlugins.java:94) - Name: ServerPackCreatorExampleAddon +INFO [main] (ApplicationPlugins.java:95) - Description:This is an example addon for ServerPackCreator showcasing all, currently 4, aspects ofServerPackCreators addon functionality. In this example you see code which gets executed before a server pack is generated,code that gets executed after a server pack was generated but before the ZIP-archive is created, code that gets executedafter this ZIP-archive was created, as well as code adding a new tabbed pane to the GUI. +INFO [main] (ApplicationPlugins.java:96) - Version: 0.0.1 +INFO [main] (ApplicationPlugins.java:97) - Author: Griefed +INFO [main] (ApplicationPlugins.java:101) - Available TabExtension plugins: +INFO [main] (ApplicationPlugins.java:103) - Name: ServerPackCreatorExampleAddon +INFO [main] (ApplicationPlugins.java:104) - Description:This is an example addon for ServerPackCreator showcasing all, currently 4, aspects ofServerPackCreators addon functionality. In this example you see code which gets executed before a server pack is generated,code that gets executed after a server pack was generated but before the ZIP-archive is created, code that gets executedafter this ZIP-archive was created, as well as code adding a new tabbed pane to the GUI. +INFO [main] (ApplicationPlugins.java:105) - Version: 0.0.1 +INFO [main] (ApplicationPlugins.java:106) - Author: Griefed +``` + +addons.log: ``` -2021-08-02T20:53:28,077 DEBUG [pool-2-thread-1] (AddonsHandler.java:240) - Addon work-directory is: work\temp\serverpackcreatorexampleaddon -2021-08-02T20:53:28,077 DEBUG [pool-2-thread-1] (AddonsHandler.java:254) - ProcessBuilder command is: [C:/Program Files/Java/jdk1.8.0_291/bin/java.exe, -jar, C:/Minecraft/ServerPackCreator/addons/serverpackcreatorexampleaddon.jar, C:/Minecraft/Game/Instances/Survive Create Prosper 4 1.16.5, AmbientSounds, BackTools, BetterAdvancement, BetterFoliage, BetterPing, BetterPlacement, Blur, cherished, ClientTweaks, Controlling, customdiscordrpc, CustomMainMenu, DefaultOptions, durability, DynamicSurroundings, FullscreenWindowed, iemzoom, jeiintegration, jei-professions, JustEnoughResources, keywizard, modnametooltip, MouseTweaks, multihotbar-, Neat, OldJavaWarning, PackMenu, prciseblockplacing, ResourceLoader, SimpleDiscordRichPresence, SpawnerFix, timestamps, TipTheScales, WorldNameRandomizer, config, defaultconfigs, mods, scripts, seeds, C:/Program Files/Java/jdk1.8.0_291/bin/java.exe, 1.16.5, Forge, 36.2.2, true, true, true, true, true, C:/Minecraft/ServerPackCreator] -2021-08-02T20:53:28,255 INFO [pool-2-thread-1] (AddonsHandler.java:272) - We have recieved the following configuration: [C:/Minecraft/Game/Instances/Survive Create Prosper 4 1.16.5, AmbientSounds, BackTools, BetterAdvancement, BetterFoliage, BetterPing, BetterPlacement, Blur, cherished, ClientTweaks, Controlling, customdiscordrpc, CustomMainMenu, DefaultOptions, durability, DynamicSurroundings, FullscreenWindowed, iemzoom, jeiintegration, jei-professions, JustEnoughResources, keywizard, modnametooltip, MouseTweaks, multihotbar-, Neat, OldJavaWarning, PackMenu, prciseblockplacing, ResourceLoader, SimpleDiscordRichPresence, SpawnerFix, timestamps, TipTheScales, WorldNameRandomizer, config, defaultconfigs, mods, scripts, seeds, C:/Program Files/Java/jdk1.8.0_291/bin/java.exe, 1.16.5, Forge, 36.2.2, true, true, true, true, true, C:/Minecraft/ServerPackCreator] -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Configuration passed from ServerPackCreator, processed and now usable however we wish. -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Modpack directory: C:/Minecraft/Game/Instances/Survive Create Prosper 4 1.16.5 -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Clientside-only mods: [AmbientSounds, BackTools, BetterAdvancement, BetterFoliage, BetterPing, BetterPlacement, Blur, cherished, ClientTweaks, Controlling, customdiscordrpc, CustomMainMenu, DefaultOptions, durability, DynamicSurroundings, FullscreenWindowed, iemzoom, jeiintegration, jei-professions, JustEnoughResources, keywizard, modnametooltip, MouseTweaks, multihotbar-, Neat, OldJavaWarning, PackMenu, prciseblockplacing, ResourceLoader, SimpleDiscordRichPresence, SpawnerFix, timestamps, TipTheScales, WorldNameRandomizer] -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Directories to copy to server pack: [config, defaultconfigs, mods, scripts, seeds] -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Path to Java installation: C:/Program Files/Java/jdk1.8.0_291/bin/java.exe -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Minecraft version: 1.16.5 -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Specified modloader: Forge -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Specified modloader version: 36.2.2 -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Whether to install the modloader server: true -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Whether to copy the server-icon.png: true -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Whether to copy the server.properties: true -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Whether to create a ZIP-archive of the server pack:true -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Example addon configuration for someconfig: This is an example for working with the addon.conf-file. -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - -2021-08-02T20:53:28,256 INFO [pool-2-thread-1] (AddonsHandler.java:272) - Base path for ServerPackCreator: C:/Minecraft/ServerPackCreator -2021-08-02T20:53:28,259 INFO [pool-2-thread-1] (AddonsHandler.java:284) - All addons executed. Returning to ServerPackCreator. +2022-01-26T18:20:45,896 INFO [main] (ExamplePlugin.java:45) - Starting ExamplePlugin... +2022-01-26T18:20:45,897 INFO [main] (ExamplePlugin.java:46) - This methods should prepare the environment for anything you want to do with it. +2022-01-26T18:20:45,897 INFO [main] (ExamplePlugin.java:47) - You could download some files. Create or replace some files. Basically you can do whatever you want. +2022-01-26T18:21:55,874 INFO [pool-2-thread-1] (ServerPackHandler.java:253) - Executing PreGenExtension addons +2022-01-26T18:21:55,874 INFO [pool-2-thread-1] (ServerPackHandler.java:255) - Executing plugin ServerPackCreatorExampleAddon +2022-01-26T18:21:55,874 INFO [pool-2-thread-1] (ExamplePlugin.java:58) - This would run before a server pack generation. +2022-01-26T18:21:55,875 INFO [pool-2-thread-1] (ExamplePlugin.java:59) - Received destination: G:/GitLab/ServerPackCreator/testruns/server-packs/Deathdusk +2022-01-26T18:21:55,875 INFO [pool-2-thread-1] (ExamplePlugin.java:60) - We recieved the following configurationModel: ConfigurationModel{clientMods=[AdvancementPlaques-, AmbientSounds_, backtools-, BetterAdvancements-, BetterAnimationsCollection-, BetterDarkMode-, betterf3-, BetterF3-, BetterFoliage-, BetterPingDisplay-, BetterPlacement-, Blur-, catalogue-, cherishedworlds-, classicbar-, clickadv-, ClientTweaks_, configured-, Controlling-, CraftPresence-, CTM-, customdiscordrpc-, CustomMainMenu-, defaultoptions-, DefaultOptions_, desiredservers-, Ding-, drippyloadingscreen-, drippyloadingscreen_, Durability101-, dynmus-, dynamic-music-, DynamicSurroundings-, DynamicSurroundingsHuds-, eiramoticons-, EiraMoticons_, EnchantmentDescriptions-, EquipmentCompare-, extremesoundmuffler-, extremeSoundMuffler-, Fallingleaves-, fallingleaves-, fancymenu_, findme-, flickerfix-, FpsReducer-, FullscreenWindowed-, WindowedFullscreen-, InventoryEssentials_, InventorySpam-, invtweaks-, InventoryTweaks-, ItemBorders-, itemzoom, itlt-, jeed-, jeiintegration_, JustEnoughProfessions-, JEITweaker-, justenoughbeacons-, JustEnoughCalculation-, jehc-, just-enough-harvestcraft-, JustEnoughProfessions-, JustEnoughResources-, keywizard-, konkrete_, lazydfu-, LegendaryTooltips-, LightOverlay-, light-overlay-, LLOverlayReloaded-, loadmyresources_, lootbeams-, mcbindtype-, modnametooltip_, modnametooltip-, moreoverlays-, MouseTweaks-, multihotbar-, MyServerIsCompatible-, Neat, NotifMod-, OldJavaWarning-, ornaments-, overloadedarmorbar-, PackMenu-, PickUpNotifier-, Ping-, preciseblockplacing-, presencefootsteps-, PresenceFootsteps-, ReAuth-, ResourceLoader-, shutupexperimentalsettings-, SimpleDiscordRichPresence-, smoothboot-, sounddeviceoptions-, SpawnerFix-, spoticraft-, tconplanner-, timestamps-, Tips-, TipTheScales-, Toast Control-, Toast-Control-, torohealth-, toughnessbar-, TravelersTitles-, WorldNameRandomizer-], copyDirs=[config, mods], modpackDir='C:/Minecraft/Game/Instances/Deathdusk', javaPath='C:/Program Files/Java/jdk1.8.0_291/jre/bin/java.exe', minecraftVersion='1.18.1', modLoader='Fabric', modLoaderVersion='0.12.12', javaArgs='empty', serverPackSuffix='', serverIconPath='', serverPropertiesPath='', includeServerInstallation=true, includeServerIcon=true, includeServerProperties=true, includeZipCreation=true, curseModpack=null, projectName='null', fileName='null', fileDiskName='null', projectID=0, fileID=0} +2022-01-26T18:21:55,875 INFO [pool-2-thread-1] (ExamplePlugin.java:61) - We received the following applicationProperties: {de.griefed.serverpackcreator.serverpack.autodiscoverenabled=true, de.griefed.serverpackcreator.spring.schedules.database.cleanup=0 0 24 * *, de.griefed.serverpackcreator.configuration.hastebinserver=https://haste.zneix.eu/documents, de.griefed.serverpackcreator.spring.artemis.queue.max_disk_usage=90, de.griefed.serverpackcreator.serverpack.overwrite.enabled=true, de.griefed.serverpackcreator.configuration.saveloadedconfig=false, de.griefed.serverpackcreator.gui.darkmode=true, de.griefed.serverpackcreator.configuration.directories.shouldexclude=overrides,packmenu,resourcepacks,server_pack,fancymenu, de.griefed.serverpackcreator.language=en_us, de.griefed.serverpackcreator.configuration.directories.serverpacks=server-packs, homeDir=G:/GitLab/ServerPackCreator/build/classes/java, de.griefed.serverpackcreator.curseforge.cleanup.enabled=true, de.griefed.serverpackcreator.plugins.directory=./plugins, de.griefed.serverpackcreator.versioncheck.prerelease=true, de.griefed.serverpackcreator.configuration.directories.mustinclude=mods,config,defaultconfigs,scripts,saves,seeds,libraries, de.griefed.serverpackcreator.serverpack.cleanup.enabled=true, de.griefed.serverpackcreator.spring.cursecontroller.regenerate.enabled=false, de.griefed.serverpackcreator.configuration.fallbackmodslist=AdvancementPlaques-,AmbientSounds_,backtools-,BetterAdvancements-,BetterAnimationsCollection-,BetterDarkMode-,betterf3-,BetterF3-,BetterFoliage-,BetterPingDisplay-,BetterPlacement-,Blur-,catalogue-,cherishedworlds-,classicbar-,clickadv-,ClientTweaks_,configured-,Controlling-,CraftPresence-,CTM-,customdiscordrpc-,CustomMainMenu-,defaultoptions-,DefaultOptions_,desiredservers-,Ding-,drippyloadingscreen-,drippyloadingscreen_,Durability101-,dynmus-,dynamic-music-,DynamicSurroundings-,DynamicSurroundingsHuds-,eiramoticons-,EiraMoticons_,EnchantmentDescriptions-,EquipmentCompare-,extremesoundmuffler-,extremeSoundMuffler-,Fallingleaves-,fallingleaves-,fancymenu_,findme-,flickerfix-,FpsReducer-,FullscreenWindowed-,WindowedFullscreen-,InventoryEssentials_,InventorySpam-,invtweaks-,InventoryTweaks-,ItemBorders-,itemzoom,itlt-,jeed-,jeiintegration_,JustEnoughProfessions-,JEITweaker-,justenoughbeacons-,JustEnoughCalculation-,jehc-,just-enough-harvestcraft-,JustEnoughProfessions-,JustEnoughResources-,keywizard-,konkrete_,lazydfu-,LegendaryTooltips-,LightOverlay-,light-overlay-,LLOverlayReloaded-,loadmyresources_,lootbeams-,mcbindtype-,modnametooltip_,modnametooltip-,moreoverlays-,MouseTweaks-,multihotbar-,MyServerIsCompatible-,Neat,NotifMod-,OldJavaWarning-,ornaments-,overloadedarmorbar-,PackMenu-,PickUpNotifier-,Ping-,preciseblockplacing-,presencefootsteps-,PresenceFootsteps-,ReAuth-,ResourceLoader-,shutupexperimentalsettings-,SimpleDiscordRichPresence-,smoothboot-,sounddeviceoptions-,SpawnerFix-,spoticraft-,tconplanner-,timestamps-,Tips-,TipTheScales-,Toast Control-,Toast-Control-,torohealth-,toughnessbar-,TravelersTitles-,WorldNameRandomizer-} +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ServerPackHandler.java:303) - Executing PreZipExtension addons +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ServerPackHandler.java:305) - Executing plugin ServerPackCreatorExampleAddon +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ExamplePlugin.java:98) - This would run after a server pack was generated, but BEFORE the ZIP-archive would be generated. +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ExamplePlugin.java:99) - Received destination: G:/GitLab/ServerPackCreator/testruns/server-packs/Deathdusk +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ExamplePlugin.java:100) - We recieved the following configurationModel: ConfigurationModel{clientMods=[AdvancementPlaques-, AmbientSounds_, backtools-, BetterAdvancements-, BetterAnimationsCollection-, BetterDarkMode-, betterf3-, BetterF3-, BetterFoliage-, BetterPingDisplay-, BetterPlacement-, Blur-, catalogue-, cherishedworlds-, classicbar-, clickadv-, ClientTweaks_, configured-, Controlling-, CraftPresence-, CTM-, customdiscordrpc-, CustomMainMenu-, defaultoptions-, DefaultOptions_, desiredservers-, Ding-, drippyloadingscreen-, drippyloadingscreen_, Durability101-, dynmus-, dynamic-music-, DynamicSurroundings-, DynamicSurroundingsHuds-, eiramoticons-, EiraMoticons_, EnchantmentDescriptions-, EquipmentCompare-, extremesoundmuffler-, extremeSoundMuffler-, Fallingleaves-, fallingleaves-, fancymenu_, findme-, flickerfix-, FpsReducer-, FullscreenWindowed-, WindowedFullscreen-, InventoryEssentials_, InventorySpam-, invtweaks-, InventoryTweaks-, ItemBorders-, itemzoom, itlt-, jeed-, jeiintegration_, JustEnoughProfessions-, JEITweaker-, justenoughbeacons-, JustEnoughCalculation-, jehc-, just-enough-harvestcraft-, JustEnoughProfessions-, JustEnoughResources-, keywizard-, konkrete_, lazydfu-, LegendaryTooltips-, LightOverlay-, light-overlay-, LLOverlayReloaded-, loadmyresources_, lootbeams-, mcbindtype-, modnametooltip_, modnametooltip-, moreoverlays-, MouseTweaks-, multihotbar-, MyServerIsCompatible-, Neat, NotifMod-, OldJavaWarning-, ornaments-, overloadedarmorbar-, PackMenu-, PickUpNotifier-, Ping-, preciseblockplacing-, presencefootsteps-, PresenceFootsteps-, ReAuth-, ResourceLoader-, shutupexperimentalsettings-, SimpleDiscordRichPresence-, smoothboot-, sounddeviceoptions-, SpawnerFix-, spoticraft-, tconplanner-, timestamps-, Tips-, TipTheScales-, Toast Control-, Toast-Control-, torohealth-, toughnessbar-, TravelersTitles-, WorldNameRandomizer-], copyDirs=[config, mods], modpackDir='C:/Minecraft/Game/Instances/Deathdusk', javaPath='C:/Program Files/Java/jdk1.8.0_291/jre/bin/java.exe', minecraftVersion='1.18.1', modLoader='Fabric', modLoaderVersion='0.12.12', javaArgs='empty', serverPackSuffix='', serverIconPath='', serverPropertiesPath='', includeServerInstallation=true, includeServerIcon=true, includeServerProperties=true, includeZipCreation=true, curseModpack=null, projectName='null', fileName='null', fileDiskName='null', projectID=0, fileID=0} +2022-01-26T18:22:06,414 INFO [pool-2-thread-1] (ExamplePlugin.java:101) - We received the following applicationProperties: {de.griefed.serverpackcreator.serverpack.autodiscoverenabled=true, de.griefed.serverpackcreator.spring.schedules.database.cleanup=0 0 24 * *, de.griefed.serverpackcreator.configuration.hastebinserver=https://haste.zneix.eu/documents, de.griefed.serverpackcreator.spring.artemis.queue.max_disk_usage=90, de.griefed.serverpackcreator.serverpack.overwrite.enabled=true, de.griefed.serverpackcreator.configuration.saveloadedconfig=false, de.griefed.serverpackcreator.gui.darkmode=true, de.griefed.serverpackcreator.configuration.directories.shouldexclude=overrides,packmenu,resourcepacks,server_pack,fancymenu, de.griefed.serverpackcreator.language=en_us, de.griefed.serverpackcreator.configuration.directories.serverpacks=server-packs, homeDir=G:/GitLab/ServerPackCreator/build/classes/java, de.griefed.serverpackcreator.curseforge.cleanup.enabled=true, de.griefed.serverpackcreator.plugins.directory=./plugins, de.griefed.serverpackcreator.versioncheck.prerelease=true, de.griefed.serverpackcreator.configuration.directories.mustinclude=mods,config,defaultconfigs,scripts,saves,seeds,libraries, de.griefed.serverpackcreator.serverpack.cleanup.enabled=true, de.griefed.serverpackcreator.spring.cursecontroller.regenerate.enabled=false, de.griefed.serverpackcreator.configuration.fallbackmodslist=AdvancementPlaques-,AmbientSounds_,backtools-,BetterAdvancements-,BetterAnimationsCollection-,BetterDarkMode-,betterf3-,BetterF3-,BetterFoliage-,BetterPingDisplay-,BetterPlacement-,Blur-,catalogue-,cherishedworlds-,classicbar-,clickadv-,ClientTweaks_,configured-,Controlling-,CraftPresence-,CTM-,customdiscordrpc-,CustomMainMenu-,defaultoptions-,DefaultOptions_,desiredservers-,Ding-,drippyloadingscreen-,drippyloadingscreen_,Durability101-,dynmus-,dynamic-music-,DynamicSurroundings-,DynamicSurroundingsHuds-,eiramoticons-,EiraMoticons_,EnchantmentDescriptions-,EquipmentCompare-,extremesoundmuffler-,extremeSoundMuffler-,Fallingleaves-,fallingleaves-,fancymenu_,findme-,flickerfix-,FpsReducer-,FullscreenWindowed-,WindowedFullscreen-,InventoryEssentials_,InventorySpam-,invtweaks-,InventoryTweaks-,ItemBorders-,itemzoom,itlt-,jeed-,jeiintegration_,JustEnoughProfessions-,JEITweaker-,justenoughbeacons-,JustEnoughCalculation-,jehc-,just-enough-harvestcraft-,JustEnoughProfessions-,JustEnoughResources-,keywizard-,konkrete_,lazydfu-,LegendaryTooltips-,LightOverlay-,light-overlay-,LLOverlayReloaded-,loadmyresources_,lootbeams-,mcbindtype-,modnametooltip_,modnametooltip-,moreoverlays-,MouseTweaks-,multihotbar-,MyServerIsCompatible-,Neat,NotifMod-,OldJavaWarning-,ornaments-,overloadedarmorbar-,PackMenu-,PickUpNotifier-,Ping-,preciseblockplacing-,presencefootsteps-,PresenceFootsteps-,ReAuth-,ResourceLoader-,shutupexperimentalsettings-,SimpleDiscordRichPresence-,smoothboot-,sounddeviceoptions-,SpawnerFix-,spoticraft-,tconplanner-,timestamps-,Tips-,TipTheScales-,Toast Control-,Toast-Control-,torohealth-,toughnessbar-,TravelersTitles-,WorldNameRandomizer-} +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ServerPackHandler.java:333) - Executing PostGenExtension addons +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ServerPackHandler.java:335) - Executing plugin ServerPackCreatorExampleAddon +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ExamplePlugin.java:143) - This would run after the server pack ZIP-archive was created. +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ExamplePlugin.java:144) - Received destination: G:/GitLab/ServerPackCreator/testruns/server-packs/Deathdusk +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ExamplePlugin.java:145) - We recieved the following configurationModel: ConfigurationModel{clientMods=[AdvancementPlaques-, AmbientSounds_, backtools-, BetterAdvancements-, BetterAnimationsCollection-, BetterDarkMode-, betterf3-, BetterF3-, BetterFoliage-, BetterPingDisplay-, BetterPlacement-, Blur-, catalogue-, cherishedworlds-, classicbar-, clickadv-, ClientTweaks_, configured-, Controlling-, CraftPresence-, CTM-, customdiscordrpc-, CustomMainMenu-, defaultoptions-, DefaultOptions_, desiredservers-, Ding-, drippyloadingscreen-, drippyloadingscreen_, Durability101-, dynmus-, dynamic-music-, DynamicSurroundings-, DynamicSurroundingsHuds-, eiramoticons-, EiraMoticons_, EnchantmentDescriptions-, EquipmentCompare-, extremesoundmuffler-, extremeSoundMuffler-, Fallingleaves-, fallingleaves-, fancymenu_, findme-, flickerfix-, FpsReducer-, FullscreenWindowed-, WindowedFullscreen-, InventoryEssentials_, InventorySpam-, invtweaks-, InventoryTweaks-, ItemBorders-, itemzoom, itlt-, jeed-, jeiintegration_, JustEnoughProfessions-, JEITweaker-, justenoughbeacons-, JustEnoughCalculation-, jehc-, just-enough-harvestcraft-, JustEnoughProfessions-, JustEnoughResources-, keywizard-, konkrete_, lazydfu-, LegendaryTooltips-, LightOverlay-, light-overlay-, LLOverlayReloaded-, loadmyresources_, lootbeams-, mcbindtype-, modnametooltip_, modnametooltip-, moreoverlays-, MouseTweaks-, multihotbar-, MyServerIsCompatible-, Neat, NotifMod-, OldJavaWarning-, ornaments-, overloadedarmorbar-, PackMenu-, PickUpNotifier-, Ping-, preciseblockplacing-, presencefootsteps-, PresenceFootsteps-, ReAuth-, ResourceLoader-, shutupexperimentalsettings-, SimpleDiscordRichPresence-, smoothboot-, sounddeviceoptions-, SpawnerFix-, spoticraft-, tconplanner-, timestamps-, Tips-, TipTheScales-, Toast Control-, Toast-Control-, torohealth-, toughnessbar-, TravelersTitles-, WorldNameRandomizer-], copyDirs=[config, mods], modpackDir='C:/Minecraft/Game/Instances/Deathdusk', javaPath='C:/Program Files/Java/jdk1.8.0_291/jre/bin/java.exe', minecraftVersion='1.18.1', modLoader='Fabric', modLoaderVersion='0.12.12', javaArgs='empty', serverPackSuffix='', serverIconPath='', serverPropertiesPath='', includeServerInstallation=true, includeServerIcon=true, includeServerProperties=true, includeZipCreation=true, curseModpack=null, projectName='null', fileName='null', fileDiskName='null', projectID=0, fileID=0} +2022-01-26T18:22:45,053 INFO [pool-2-thread-1] (ExamplePlugin.java:146) - We received the following applicationProperties: {de.griefed.serverpackcreator.serverpack.autodiscoverenabled=true, de.griefed.serverpackcreator.spring.schedules.database.cleanup=0 0 24 * *, de.griefed.serverpackcreator.configuration.hastebinserver=https://haste.zneix.eu/documents, de.griefed.serverpackcreator.spring.artemis.queue.max_disk_usage=90, de.griefed.serverpackcreator.serverpack.overwrite.enabled=true, de.griefed.serverpackcreator.configuration.saveloadedconfig=false, de.griefed.serverpackcreator.gui.darkmode=true, de.griefed.serverpackcreator.configuration.directories.shouldexclude=overrides,packmenu,resourcepacks,server_pack,fancymenu, de.griefed.serverpackcreator.language=en_us, de.griefed.serverpackcreator.configuration.directories.serverpacks=server-packs, homeDir=G:/GitLab/ServerPackCreator/build/classes/java, de.griefed.serverpackcreator.curseforge.cleanup.enabled=true, de.griefed.serverpackcreator.plugins.directory=./plugins, de.griefed.serverpackcreator.versioncheck.prerelease=true, de.griefed.serverpackcreator.configuration.directories.mustinclude=mods,config,defaultconfigs,scripts,saves,seeds,libraries, de.griefed.serverpackcreator.serverpack.cleanup.enabled=true, de.griefed.serverpackcreator.spring.cursecontroller.regenerate.enabled=false, de.griefed.serverpackcreator.configuration.fallbackmodslist=AdvancementPlaques-,AmbientSounds_,backtools-,BetterAdvancements-,BetterAnimationsCollection-,BetterDarkMode-,betterf3-,BetterF3-,BetterFoliage-,BetterPingDisplay-,BetterPlacement-,Blur-,catalogue-,cherishedworlds-,classicbar-,clickadv-,ClientTweaks_,configured-,Controlling-,CraftPresence-,CTM-,customdiscordrpc-,CustomMainMenu-,defaultoptions-,DefaultOptions_,desiredservers-,Ding-,drippyloadingscreen-,drippyloadingscreen_,Durability101-,dynmus-,dynamic-music-,DynamicSurroundings-,DynamicSurroundingsHuds-,eiramoticons-,EiraMoticons_,EnchantmentDescriptions-,EquipmentCompare-,extremesoundmuffler-,extremeSoundMuffler-,Fallingleaves-,fallingleaves-,fancymenu_,findme-,flickerfix-,FpsReducer-,FullscreenWindowed-,WindowedFullscreen-,InventoryEssentials_,InventorySpam-,invtweaks-,InventoryTweaks-,ItemBorders-,itemzoom,itlt-,jeed-,jeiintegration_,JustEnoughProfessions-,JEITweaker-,justenoughbeacons-,JustEnoughCalculation-,jehc-,just-enough-harvestcraft-,JustEnoughProfessions-,JustEnoughResources-,keywizard-,konkrete_,lazydfu-,LegendaryTooltips-,LightOverlay-,light-overlay-,LLOverlayReloaded-,loadmyresources_,lootbeams-,mcbindtype-,modnametooltip_,modnametooltip-,moreoverlays-,MouseTweaks-,multihotbar-,MyServerIsCompatible-,Neat,NotifMod-,OldJavaWarning-,ornaments-,overloadedarmorbar-,PackMenu-,PickUpNotifier-,Ping-,preciseblockplacing-,presencefootsteps-,PresenceFootsteps-,ReAuth-,ResourceLoader-,shutupexperimentalsettings-,SimpleDiscordRichPresence-,smoothboot-,sounddeviceoptions-,SpawnerFix-,spoticraft-,tconplanner-,timestamps-,Tips-,TipTheScales-,Toast Control-,Toast-Control-,torohealth-,toughnessbar-,TravelersTitles-,WorldNameRandomizer-} ``` +Additionally, the following files/directories would be created in the server pack-directory: + +- `./ExampleStartExtension` +- `./ExampleArchiveExtension` +- `serverpackcreator.conf` as it was used to generate the server pack +- `./some/folder/with/a/name` + # 1. The reason for allowing ServerPackCreator to run addons: -There are things which people want to do with their server packs which could most certainly be automated. Some of those -things so special, or maybe out of place, that they would not warrant a separate feature for ServerPackCreator itself. +Some people need additional functionality for their server packs, or have some additional wishes for them. Some of those +things may not fit into the core functionality of ServerPackCreator itself. It may also be that it is such a niche feature, that I either don't have the time to code it in, or simply don't want to. Maybe it doesn't fit into the overall design of ServerPackCreator, too. Who knows, it could be any of those reasons or another. @@ -47,62 +85,46 @@ Maybe it doesn't fit into the overall design of ServerPackCreator, too. Who know This allows people to write their own addons to expand the functionality of ServerPackCreator with their own features as they see fit or want. -One example would be: Automatic setup of a server pack for [BlueMap](https://www.curseforge.com/minecraft/mc-mods/bluemap). -An addon could check all mods in the specified modpacks mods-directory for textures, and if any are found, add them to -BlueMap's resourcepack folder `config/bluemap/resourcepacks`, install BlueMap for the specified Minecraft and Forge/Fabric -version and voilà ! ServerPackCreator has BlueMap Support Automation functionality, thanks to an addon, without having to wait -for me to write it and add it to ServerPackCreators core-functionality for you! +Some examples for addons can be found [in this discussion thread](https://github.com/Griefed/ServerPackCreator/discussions/201). -# 2. How +Some excerpts: +1. Changelog generator, by @TheButterbrotMan at [Feature request]: Changelog generator #198 + - A changelog generator that checks the differences to the previous version and generates a changelog. + +2. Bundle Adoptium Java with server packs, by @kreezxil at [Feature request]: Bundle Adoptium Java #199 + - Because modpacks need one of the either Java 8, 16, or 17, it would be nice to have the corresponding https://adoptium.net java prebundled with the server pack. -## 2.1 Values to work with +3. Automatic setup of a server pack for [BlueMap](https://www.curseforge.com/minecraft/mc-mods/bluemap) + - Check all mods in the specified modpacks mods-directory for textures, and if any are found, add the mod to + BlueMap's resourcepack folder `config/bluemap/resourcepacks`, install BlueMap for the specified Minecraft and Forge/Fabric + version and voilà ! -ServerPackCreator passes the configuration used to create a server pack to all addons configured as `serverpack`-addons. -That list consists of: -* modpackDir -* clientMods -* copyDirs -* javaPath -* minecraftVersion -* modLoader -* modLoaderVersion -* includeServerInstallation -* includeServerIcon -* includeServerProperties -* includeZipCreation +# 2. How -That list is parsed in `ConfigurationHandler` and written into an instance of `ConfigurationModel`, allowing you to make use -of the whole configuration with which the server pack, which was generated before the addon gets executed, got made. +During the start of ServerPackCreator, all plugins are loaded and started. If you have anything you need to run then and there, +use `public void start() {...}` and do your thing. -## 2.2 Where to get values from +## 2.1 Extensions -Working with this example, you can simply call any `get`-method in the `ConfigurationModel`-class and use it to do your -operations. +One plugin can have multiple extensions. -## 2.3 Working directory +ServerPackCreator passes the `ConfigurationModel` and `ApplicationProperties`, used to create a server pack, to all `PreGenExtension`, `PreZipExtension` and `PostGenExtension` extensions. -All addons are run in the <code>work/temp/addon_name</code>-directory. Be aware of that when creating your addons! This also means -that you should be wary of trying to cleanup the temp-directory yourself, as it could potentially interfere with any other -addon running after yours! -ServerPackCreator also passes the path to itself to any of its addons it executes, making it easier for you to work with -any and all files regarding it and the server packs. +If you have a plugin with multiple extensions of the same type, you can set the priority in which they are executed by specifiying and ordinal for your extension: `@Extension(ordinal = 1)` +The higher the ordinal, the lower the priority. See [pf4j documentation](https://pf4j.org/doc/extensions) on extensions. -## 2.4 Logs +## 2.2 Logs -Any and all message you would normally let log4j write to a log-file need to be printed using `System.out.println("Some message.")` -or similar methods. These are caught by ServerPacKCreator and added to the addons.log. +If you want to print log messages, then use the `LOG_ADDONS` logger as shown in this example. This will result in ServerPackCreator writing any and all log entries from this logger to the `addons.log`-file. # 3. Building 1. Fork and clone this repository 2. Make your changes and additions. 3. Build with `gradlew about build --info`. -4. Copy the JAR-file from `build/libs` to the addons-directory created by ServerPackCreator. +4. Copy the JAR-file from `build/libs` to the plugins-directory created by ServerPackCreator. 5. Run ServerPackCreator! -**NOTE: Please be aware that you might need to change the tests I've provided as an example for this addon. If you change the -base behaviour of this example, the chance that you will have to make changes to tests, too, is quite high.** - ## 4. Contributing If you have written an addon, let me know by creating an issue in this repository. Provide a short description of what your @@ -114,6 +136,6 @@ along with a small description, if you provided one. Example: -| Addon | Creator | Description | -| :---- | :------ | :---------- | +| Addon | Creator | Description | +|:-------------------------------------------------------------------------|:--------|:-------------------------------------------------------------------| | [ExampleAddon](https://github.com/Griefed/ServerPackCreatorExampleAddon) | Griefed | An example addon providing a starting point for addon development. | \ No newline at end of file diff --git a/build.gradle b/build.gradle index cdf2b33..0672e00 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ dependencies { embed 'org.apache.commons:commons-lang3:3.12.0' implementation 'org.apache.logging.log4j:log4j-api:2.17.1' - implementation('de.griefed.serverpackcreator:serverpackcreator:97c1999') { + implementation('de.griefed.serverpackcreator:serverpackcreator:b3b4b85') { version { branch = 'rewriteWithPlf4j' } @@ -105,7 +105,7 @@ jar { //noinspection GroovyAssignabilityCheck manifest { attributes( - "Main-Class" : "de.griefed.serverpackcreatoraddonexample.Main", + "Main-Class" : "de.griefed.serverpackcreatoraddonexample.ExamplePlugin", "Class-Path" : configurations.embed.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }, "Description" : "Example plugin for ServerPackCreator", "Built-By" : System.getProperty("user.name"), diff --git a/src/main/java/de/griefed/serverpackcreatoraddonexample/ExamplePlugin.java b/src/main/java/de/griefed/serverpackcreatoraddonexample/ExamplePlugin.java index ae7feb2..bb61292 100644 --- a/src/main/java/de/griefed/serverpackcreatoraddonexample/ExamplePlugin.java +++ b/src/main/java/de/griefed/serverpackcreatoraddonexample/ExamplePlugin.java @@ -2,10 +2,13 @@ package de.griefed.serverpackcreatoraddonexample; import de.griefed.serverpackcreator.ApplicationProperties; import de.griefed.serverpackcreator.ConfigurationModel; -import de.griefed.serverpackcreator.plugins.serverpackhandler.ServerPackArchiveCreated; -import de.griefed.serverpackcreator.plugins.serverpackhandler.ServerPackCreated; -import de.griefed.serverpackcreator.plugins.serverpackhandler.ServerPackStart; -import de.griefed.serverpackcreator.plugins.swinggui.AddTab; +import de.griefed.serverpackcreator.plugins.serverpackhandler.PostGenExtension; +import de.griefed.serverpackcreator.plugins.serverpackhandler.PreZipExtension; +import de.griefed.serverpackcreator.plugins.serverpackhandler.PreGenExtension; +import de.griefed.serverpackcreator.plugins.swinggui.TabExtension; +import de.griefed.serverpackcreator.utilities.ConfigUtilities; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.pf4j.Extension; @@ -14,6 +17,9 @@ import org.pf4j.PluginWrapper; import javax.swing.*; import java.awt.*; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; public class ExamplePlugin extends Plugin { @@ -38,19 +44,26 @@ public class ExamplePlugin extends Plugin { public void start() { LOG_ADDONS.info("Starting ExamplePlugin..."); LOG_ADDONS.info("This methods should prepare the environment for anything you want to do with it."); + LOG_ADDONS.info("You could download some files. Create or replace some files. Basically you can do whatever you want."); /* Write all your preparation code here.. */ } @Extension(ordinal = 1) - public static class ExampleStartPlugin implements ServerPackStart { + public static class ExampleStartExtension implements PreGenExtension { @Override public void run(ApplicationProperties applicationProperties, ConfigurationModel configurationModel, String destination) throws Exception { LOG_ADDONS.info("This would run before a server pack generation."); + LOG_ADDONS.info("Received destination: " + destination); LOG_ADDONS.info("We recieved the following configurationModel: " + configurationModel.toString()); LOG_ADDONS.info("We received the following applicationProperties: " + applicationProperties.toString()); + StringUtils.upperCase("some text in lower case"); + //Create example file in server pack + try { + Files.createFile(Paths.get(String.format("%s/%s",destination, this.getClass().getSimpleName()))); + } catch (Exception ignored) {} /* Write all your pre-gen stuff here... */ @@ -78,13 +91,24 @@ public class ExamplePlugin extends Plugin { } @Extension(ordinal = 1) - public static class ExampleCreatedPlugin implements ServerPackCreated { + public static class ExampleCreatedExtension implements PreZipExtension { @Override public void run(ApplicationProperties applicationProperties, ConfigurationModel configurationModel, String destination) throws Exception { LOG_ADDONS.info("This would run after a server pack was generated, but BEFORE the ZIP-archive would be generated."); + LOG_ADDONS.info("Received destination: " + destination); LOG_ADDONS.info("We recieved the following configurationModel: " + configurationModel.toString()); LOG_ADDONS.info("We received the following applicationProperties: " + applicationProperties.toString()); + StringUtils.upperCase("some text in lower case"); + //Create example file in server pack + try { + FileUtils.createParentDirectories(new File(destination + "/some/folder/with/a/name")); + } catch (Exception ex) { + LOG_ADDONS.info("Error occurred creating parent directories.", ex); + } + + new ConfigUtilities(null,null,null,applicationProperties, null) + .writeConfigToFile(configurationModel, new File(destination + "/serverpackcreator.conf")); /* Write all your post-gen-pre-zip stuff here... */ @@ -112,13 +136,19 @@ public class ExamplePlugin extends Plugin { } @Extension(ordinal = 1) - public static class ExampleArchivePlugin implements ServerPackArchiveCreated { + public static class ExampleArchiveExtension implements PostGenExtension { @Override public void run(ApplicationProperties applicationProperties, ConfigurationModel configurationModel, String destination) throws Exception { LOG_ADDONS.info("This would run after the server pack ZIP-archive was created."); + LOG_ADDONS.info("Received destination: " + destination); LOG_ADDONS.info("We recieved the following configurationModel: " + configurationModel.toString()); LOG_ADDONS.info("We received the following applicationProperties: " + applicationProperties.toString()); + //Create example file in server pack + try { + Files.createFile(Paths.get(String.format("%s/%s",destination, this.getClass().getSimpleName()))); + } catch (Exception ignored) {} + /* Write all your post-archive stuff here... */ @@ -146,7 +176,7 @@ public class ExamplePlugin extends Plugin { } @Extension(ordinal = 1) - public static class ExampleTabbedpanePlugin extends JComponent implements AddTab { + public static class ExampleAddTabExtension extends JComponent implements TabExtension { @Override public JComponent getTab() { @@ -199,11 +229,10 @@ public class ExamplePlugin extends Plugin { @Override public void run(ApplicationProperties applicationProperties, ConfigurationModel configurationModel, String destination) throws Exception { - LOG_ADDONS.info("When adding tabbed panes, you could also write some backend logic here, like threads that do some stuff."); - LOG_ADDONS.info("We recieved the following configurationModel: " + configurationModel.toString()); - LOG_ADDONS.info("We received the following applicationProperties: " + applicationProperties.toString()); /* - Write all your pre-gen stuff here... + So far, the run(...) method for AddTab extensions never gets called. + There is no point in writing code here with the intention of + ServerPackCreator executing it. */ } diff --git a/src/main/resources/addon.conf b/src/main/resources/addon.conf deleted file mode 100644 index 2d9eed5..0000000 --- a/src/main/resources/addon.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Valid values are 'serverpack' -addontype="serverpack" -someconfig="This is an example for working with the addon.conf-file." \ No newline at end of file -- GitLab