Skip to content

Commit 6b3340a

Browse files
committed
Initial commit (v0.1)
0 parents  commit 6b3340a

File tree

8 files changed

+270
-0
lines changed

8 files changed

+270
-0
lines changed

pom.xml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>cz.forestTech</groupId>
8+
<artifactId>ForestPlug</artifactId>
9+
<version>0.1</version>
10+
11+
<properties>
12+
<maven.compiler.source>11</maven.compiler.source>
13+
<maven.compiler.target>11</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
18+
<build>
19+
<!-- Filter only plugin.yml -->
20+
<resources>
21+
<resource>
22+
<directory>src/main/resources</directory>
23+
<filtering>true</filtering>
24+
<includes>
25+
<include>plugin.yml</include>
26+
</includes>
27+
</resource>
28+
<resource>
29+
<directory>src/main/resources</directory>
30+
<filtering>false</filtering>
31+
<excludes>
32+
<exclude>plugin.yml</exclude>
33+
</excludes>
34+
</resource>
35+
</resources>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<configuration>
41+
<source>11</source>
42+
<target>11</target>
43+
</configuration>
44+
</plugin>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-shade-plugin</artifactId>
48+
<version>3.2.2</version>
49+
<executions>
50+
<execution>
51+
<phase>package</phase>
52+
<goals>
53+
<goal>shade</goal>
54+
</goals>
55+
<configuration>
56+
<filters>
57+
<filter>
58+
<artifact>*:*</artifact>
59+
<excludes>
60+
<exclude>META-INF/license/**</exclude>
61+
<exclude>META-INF/*</exclude>
62+
<exclude>META-INF/maven/**</exclude>
63+
<exclude>LICENSE</exclude>
64+
<exclude>NOTICE</exclude>
65+
<exclude>/*.txt</exclude>
66+
<exclude>build.properties</exclude>
67+
</excludes>
68+
</filter>
69+
</filters>
70+
</configuration>
71+
</execution>
72+
</executions>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<configuration>
78+
<source>11</source>
79+
<target>11</target>
80+
</configuration>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
85+
86+
<repositories>
87+
<repository>
88+
<id>spigot-repo</id>
89+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
90+
</repository>
91+
<repository>
92+
<id>jitpack.io</id>
93+
<url>https://jitpack.io</url>
94+
</repository>
95+
<repository>
96+
<id>maven-central</id>
97+
<url>https://oss.sonatype.org/content/groups/public</url>
98+
</repository>
99+
</repositories>
100+
101+
<dependencies>
102+
<dependency>
103+
<groupId>org.spigotmc</groupId>
104+
<artifactId>spigot-api</artifactId>
105+
<version>1.19-R0.1-SNAPSHOT</version>
106+
<scope>provided</scope>
107+
</dependency>
108+
<dependency>
109+
<groupId>org.projectlombok</groupId>
110+
<artifactId>lombok</artifactId>
111+
<version>1.18.26</version>
112+
<scope>provided</scope>
113+
</dependency>
114+
</dependencies>
115+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package cz.forestTech.addons;
2+
3+
import cz.forestTech.spigot.Spigot;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.plugin.InvalidPluginException;
6+
import org.bukkit.plugin.Plugin;
7+
import org.bukkit.plugin.PluginLoader;
8+
9+
import java.io.File;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
14+
public class AddonManager {
15+
private List<ForestAddon> addonsList;
16+
17+
private Spigot plugin;
18+
19+
public AddonManager() {
20+
plugin = Spigot.getInstance();
21+
addonsList = new ArrayList<>();
22+
loadAddons();
23+
24+
}
25+
26+
public void loadAddons() {
27+
PluginLoader pluginLoader = Bukkit.getPluginManager().getPlugin("ForestPlug").getPluginLoader();
28+
File pluginFolder = new File(plugin.getDataFolder().getParentFile(), "ForestPlug");
29+
30+
if (pluginFolder.exists() && pluginFolder.isDirectory()) {
31+
File[] pluginFiles = pluginFolder.listFiles((dir, name) -> name.toLowerCase().endsWith(".jar"));
32+
33+
if (pluginFiles != null) {
34+
for (File pluginFile : pluginFiles) {
35+
Plugin plugin = null;
36+
try {
37+
plugin = pluginLoader.loadPlugin(pluginFile);
38+
} catch (InvalidPluginException e) {
39+
throw new RuntimeException(e);
40+
}
41+
Bukkit.getPluginManager().enablePlugin(plugin);
42+
}
43+
}
44+
}
45+
}
46+
47+
public List<ForestAddon> getAddonsList() {
48+
return addonsList;
49+
}
50+
51+
public void addAddon(ForestAddon addon) {
52+
getAddonsList().add(addon);
53+
}
54+
55+
public void remove(ForestAddon addon) {
56+
getAddonsList().remove(addon);
57+
}
58+
59+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cz.forestTech.addons;
2+
3+
4+
import org.bukkit.plugin.Plugin;
5+
6+
public abstract class ForestAddon {
7+
protected Plugin plugin;
8+
9+
public ForestAddon(Plugin plugin) {
10+
this.plugin = plugin;
11+
}
12+
13+
public abstract String name();
14+
public abstract Plugin plugin();
15+
public abstract String author();
16+
public abstract String describe();
17+
18+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package cz.forestTech.addons;
2+
3+
import cz.forestTech.spigot.Spigot;
4+
5+
import java.util.List;
6+
7+
public class ForestAddonAPI {
8+
9+
private Spigot plugin;
10+
11+
public ForestAddonAPI() {
12+
plugin = Spigot.getInstance();
13+
}
14+
15+
16+
public void register(ForestAddon forestAddon) {
17+
plugin.getAddonManager().addAddon(forestAddon);
18+
}
19+
20+
public void unRegister(ForestAddon forestAddon) {
21+
plugin.getAddonManager().remove(forestAddon);
22+
}
23+
24+
public List<ForestAddon> getAddons() {
25+
return plugin.getAddonManager().getAddonsList();
26+
}
27+
28+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package cz.forestTech.bungee;
2+
3+
public class Bungee {
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package cz.forestTech.shared;
2+
3+
public enum PlatformType {
4+
5+
SPIGOT, BUNGEE
6+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package cz.forestTech.spigot;
2+
3+
import cz.forestTech.addons.AddonManager;
4+
import org.bukkit.plugin.InvalidPluginException;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
7+
8+
public class Spigot extends JavaPlugin {
9+
10+
private static Spigot instance;
11+
private AddonManager addonManager;
12+
13+
@Override
14+
public void onEnable() {
15+
instance = this;
16+
saveDefaultConfig();
17+
addonManager = new AddonManager();
18+
19+
20+
}
21+
22+
@Override
23+
public void onDisable() {
24+
25+
}
26+
27+
public static Spigot getInstance() {
28+
return instance;
29+
}
30+
31+
public AddonManager getAddonManager() {
32+
return addonManager;
33+
}
34+
}

src/main/resources/plugin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: ForestPlug
2+
main: cz.forestTech.spigot.Spigot
3+
author: ForestTech
4+
version: 0.1
5+
api-version: 1.19
6+
description: Advanced plugin with addons

0 commit comments

Comments
 (0)