diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b425f09 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/addon/pom.xml b/addon/pom.xml new file mode 100644 index 0000000..8bf284e --- /dev/null +++ b/addon/pom.xml @@ -0,0 +1,28 @@ + + + + spigot-injection-example + org.example + 1.0-SNAPSHOT + + 4.0.0 + + addon + + + 18 + 18 + UTF-8 + + + + + org.example + core + 1.0-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/addon/src/main/java/org/example/addon/Main.java b/addon/src/main/java/org/example/addon/Main.java new file mode 100644 index 0000000..040915a --- /dev/null +++ b/addon/src/main/java/org/example/addon/Main.java @@ -0,0 +1,14 @@ +package org.example.addon; + +import com.hakan.spinjection.SpigotBootstrap; +import com.hakan.spinjection.annotations.Scanner; +import org.bukkit.plugin.java.JavaPlugin; + +@Scanner("org.example.addon") +public class Main extends JavaPlugin { + + @Override + public void onEnable() { + SpigotBootstrap.run(this); + } +} \ No newline at end of file diff --git a/addon/src/main/java/org/example/addon/services/FirstService.java b/addon/src/main/java/org/example/addon/services/FirstService.java new file mode 100644 index 0000000..1b6dd21 --- /dev/null +++ b/addon/src/main/java/org/example/addon/services/FirstService.java @@ -0,0 +1,13 @@ +package org.example.addon.services; + +import com.hakan.basicdi.annotations.PostConstruct; +import com.hakan.basicdi.annotations.Service; + +@Service +public class FirstService { + + @PostConstruct + public void initialize() { + System.out.println("first service: initialize called"); + } +} diff --git a/addon/src/main/java/org/example/addon/services/SecondService.java b/addon/src/main/java/org/example/addon/services/SecondService.java new file mode 100644 index 0000000..a4f4d55 --- /dev/null +++ b/addon/src/main/java/org/example/addon/services/SecondService.java @@ -0,0 +1,23 @@ +package org.example.addon.services; + +import com.hakan.basicdi.annotations.Autowired; +import com.hakan.basicdi.annotations.PostConstruct; +import com.hakan.basicdi.annotations.Service; +import org.example.core.services.TestService; + +@Service +public class SecondService { + + private final TestService testService; + + @Autowired + public SecondService(TestService testService) { + this.testService = testService; + } + + @PostConstruct + public void initialize() { + System.out.println("second service: initialize called"); + testService.initialize(); + } +} diff --git a/addon/src/main/resources/plugin.yml b/addon/src/main/resources/plugin.yml new file mode 100644 index 0000000..746aed8 --- /dev/null +++ b/addon/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: addon +main: org.example.addon.Main +version: 0.0.0 +depend: [core] \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 0000000..caff2ff --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,44 @@ + + + + spigot-injection-example + org.example + 1.0-SNAPSHOT + + 4.0.0 + + core + + + + com.github.hakan-krgn.spigot-injection + injection-core + ${spigot-injection.version} + compile + + + + + + + maven-assembly-plugin + + + package + + single + + + + + false + + jar-with-dependencies + + + + + + \ No newline at end of file diff --git a/core/src/main/java/org/example/core/Main.java b/core/src/main/java/org/example/core/Main.java new file mode 100644 index 0000000..accd3dc --- /dev/null +++ b/core/src/main/java/org/example/core/Main.java @@ -0,0 +1,14 @@ +package org.example.core; + +import com.hakan.spinjection.SpigotBootstrap; +import com.hakan.spinjection.annotations.Scanner; +import org.bukkit.plugin.java.JavaPlugin; + +@Scanner("org.example.core") +public class Main extends JavaPlugin { + + @Override + public void onEnable() { + SpigotBootstrap.run(this); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/example/core/services/TestService.java b/core/src/main/java/org/example/core/services/TestService.java new file mode 100644 index 0000000..537bfee --- /dev/null +++ b/core/src/main/java/org/example/core/services/TestService.java @@ -0,0 +1,13 @@ +package org.example.core.services; + +import com.hakan.basicdi.annotations.PostConstruct; +import com.hakan.basicdi.annotations.Service; + +@Service +public class TestService { + + @PostConstruct + public void initialize() { + System.out.println("called initialize in TestService"); + } +} diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml new file mode 100644 index 0000000..21b9a97 --- /dev/null +++ b/core/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: core +main: org.example.core.Main +version: 0.0.0 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fa3539f --- /dev/null +++ b/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + org.example + spigot-injection-example + pom + 1.0-SNAPSHOT + + core + addon + + + + 17 + 17 + UTF-8 + 0.1.4.6 + + + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + jitpack.io + https://jitpack.io + + + + + + io.papermc.paper + paper-api + 1.20.2-R0.1-SNAPSHOT + provided + + + \ No newline at end of file