Compare commits

..

3 Commits

Author SHA1 Message Date
LOOHP 94ad6d8460
Merge pull request #88 from Kas-tle/feature/prefer-limbo-yml
Prefer use of limbo.yml for plugin loading
2025-07-17 20:34:46 +01:00
LOOHP b19bba7140 Minecraft 1.21.8 2025-07-17 20:32:11 +01:00
Joshua Castle a0382bd64c
Prefer use of limbo.yml ofr plugin loading
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
2025-07-14 09:22:11 -07:00
4 changed files with 66 additions and 47 deletions

View File

@ -1,6 +1,6 @@
# Limbo # Limbo
[![Build Status](http://ci.loohpjames.com/job/Limbo/badge/icon)](http://ci.loohpjames.com/job/Limbo/) [![Build Status](http://ci.loohpjames.com/job/Limbo/badge/icon)](http://ci.loohpjames.com/job/Limbo/)
## Standalone Limbo Minecraft Server (Currently 1.21.7) ## Standalone Limbo Minecraft Server (Currently 1.21.8)
https://www.spigotmc.org/resources/82468/ https://www.spigotmc.org/resources/82468/
@ -18,7 +18,7 @@ IP: mc.loohpjames.com
``` ```
![Server Banner](https://api.loohpjames.com/serverbanner.png?ip=mc.loohpjames.com&width=918&name=IP:%20mc.loohpjames.com) ![Server Banner](https://api.loohpjames.com/serverbanner.png?ip=mc.loohpjames.com&width=918&name=IP:%20mc.loohpjames.com)
*** ***
### Downloads (1.17.1-1.21.7) ### Downloads (1.17.1-1.21.8)
- [Jenkins](http://ci.loohpjames.com/job/Limbo/) - [Jenkins](http://ci.loohpjames.com/job/Limbo/)
*** ***
### Offical Plugins ### Offical Plugins

View File

@ -136,7 +136,7 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<finalName>${project.artifactId}-${project.version}-1.21.7</finalName> <finalName>${project.artifactId}-${project.version}-1.21.8</finalName>
</build> </build>
<profiles> <profiles>
@ -229,7 +229,7 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.18.0</version> <version>3.14.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.Querz</groupId> <groupId>com.github.Querz</groupId>

View File

@ -132,7 +132,7 @@ public final class Limbo {
//=========================== //===========================
public final String SERVER_IMPLEMENTATION_VERSION = "1.21.7"; public final String SERVER_IMPLEMENTATION_VERSION = "1.21.8";
public final int SERVER_IMPLEMENTATION_PROTOCOL = 772; public final int SERVER_IMPLEMENTATION_PROTOCOL = 772;
public final String LIMBO_IMPLEMENTATION_VERSION; public final String LIMBO_IMPLEMENTATION_VERSION;

View File

@ -52,48 +52,67 @@ public class PluginManager {
this.plugins = new LinkedHashMap<>(); this.plugins = new LinkedHashMap<>();
} }
protected void loadPlugins() { protected void loadPlugins() {
for (File file : pluginFolder.listFiles()) { for (File file : pluginFolder.listFiles()) {
if (file.isFile() && file.getName().endsWith(".jar")) { if (file.isFile() && file.getName().endsWith(".jar")) {
boolean found = false; try (ZipInputStream zip = new ZipInputStream(new FileInputStream(file))) {
try (ZipInputStream zip = new ZipInputStream(new FileInputStream(file))) { ZipEntry limboYmlEntry = null;
while (true) { ZipEntry pluginYmlEntry = null;
ZipEntry entry = zip.getNextEntry();
if (entry == null) { while (true) {
break; ZipEntry entry = zip.getNextEntry();
} if (entry == null) {
String name = entry.getName(); break;
if (name.endsWith("plugin.yml") || name.endsWith("limbo.yml")) { }
found = true; String name = entry.getName();
if (name.endsWith("limbo.yml")) {
FileConfiguration pluginYaml = new FileConfiguration(zip); limboYmlEntry = entry;
String main = pluginYaml.get("main", String.class); } else if (name.endsWith("plugin.yml")) {
String pluginName = pluginYaml.get("name", String.class); pluginYmlEntry = entry;
}
if (plugins.containsKey(pluginName)) { }
System.err.println("Ambiguous plugin name in " + file.getName() + " with the plugin \"" + plugins.get(pluginName).getClass().getName() + "\"");
break; ZipEntry chosenEntry = limboYmlEntry != null ? limboYmlEntry : pluginYmlEntry;
}
URLClassLoader child = new URLClassLoader(new URL[] {file.toURI().toURL()}, Limbo.getInstance().getClass().getClassLoader()); if (chosenEntry != null) {
Class<?> clazz = Class.forName(main, true, child); try (ZipInputStream processZip = new ZipInputStream(new FileInputStream(file))) {
LimboPlugin plugin = (LimboPlugin) clazz.getDeclaredConstructor().newInstance(); while (true) {
plugin.setInfo(pluginYaml, file); ZipEntry currentEntry = processZip.getNextEntry();
plugins.put(plugin.getName(), plugin); if (currentEntry == null) {
plugin.onLoad(); break;
Limbo.getInstance().getConsole().sendMessage("Loading plugin " + file.getName() + " " + plugin.getInfo().getVersion() + " by " + plugin.getInfo().getAuthor()); }
break;
} if (currentEntry.getName().equals(chosenEntry.getName())) {
} FileConfiguration pluginYaml = new FileConfiguration(processZip);
} catch (Exception e) { String main = pluginYaml.get("main", String.class);
System.err.println("Unable to load plugin \"" + file.getName() + "\""); String pluginName = pluginYaml.get("name", String.class);
e.printStackTrace();
} if (plugins.containsKey(pluginName)) {
if (!found) { System.err.println("Ambiguous plugin name in " + file.getName() + " with the plugin \"" + plugins.get(pluginName).getClass().getName() + "\"");
System.err.println("Jar file " + file.getName() + " has no plugin.yml!"); break;
} }
}
} URLClassLoader child = new URLClassLoader(new URL[]{file.toURI().toURL()}, Limbo.getInstance().getClass().getClassLoader());
} Class<?> clazz = Class.forName(main, true, child);
LimboPlugin plugin = (LimboPlugin) clazz.getDeclaredConstructor().newInstance();
plugin.setInfo(pluginYaml, file);
plugins.put(plugin.getName(), plugin);
plugin.onLoad();
Limbo.getInstance().getConsole().sendMessage("Loading plugin " + file.getName() + " " + plugin.getInfo().getVersion() + " by " + plugin.getInfo().getAuthor());
break;
}
}
}
} else {
System.err.println("Jar file " + file.getName() + " has no plugin.yml or limbo.yml!");
}
} catch (Exception e) {
System.err.println("Unable to load plugin \"" + file.getName() + "\"");
e.printStackTrace();
}
}
}
}
public List<LimboPlugin> getPlugins() { public List<LimboPlugin> getPlugins() {
return new ArrayList<>(plugins.values()); return new ArrayList<>(plugins.values());