Skip to content

Commit

Permalink
Fix json plugin loading
Browse files Browse the repository at this point in the history
WHY DOES THIS FIX IT?? WHY IS IT BROKEN??? WHAT THE HELL???
  • Loading branch information
MrSlimeDiamond committed Mar 21, 2024
1 parent 1c6e191 commit ac2b285
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Optional<PluginContainer> loadPlugin(@Nonnull File jar) {
PluginMetadata meta = metaOptional.get();

if (meta.getId().equals("gallium") || meta.getId().equals("minecraft") || meta.getId().equals("gtest")) {
throw new BadPluginException("Plugin IDs 'gallium', 'minecraft' and 'gtest' are reserved!");
throw new BadPluginException("Plugin IDs 'gallium', 'minecraft' and 'gtest' are reserved! Found plugin id '" + meta.getId() + "'");
}

if (meta.getId().contains(" ")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static PluginMetadata getPluginMetadataFromJson(InputStreamReader configR
String[] authors = new String[authorsJSON.length()];
for (int i = 0; i < authorsJSON.length(); i++) {
authors[i] = (String) authorsJSON.get(i);
}
}:

return new DefaultPluginMeta(name, id, description, authors, version, mainClass);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ public void loadInternalPlugin() {

@Override
public void loadTestPlugin() {
InputStream inputStream = TestPlugin.class.getResourceAsStream("/plugin.json");
InputStreamReader reader = new InputStreamReader(inputStream);
PluginMetadata pluginMetadata = PluginMetadataLoader.getPluginMetadataFromJson(reader);
// load the test plugin manually.
PluginMetadata pluginMetadata = PluginMetadataLoader.getPluginMetaFromAnnotation(TestPlugin.class);

PluginContainer pluginContainer = new PluginContainer();
pluginContainer.setMetadata(pluginMetadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.inject.Inject;
import org.apache.logging.log4j.Logger;
import org.galliumpowered.Gallium;
import org.galliumpowered.annotation.Plugin;
import org.galliumpowered.annotation.PluginLifecycleListener;
import org.galliumpowered.plugin.PluginContainer;
import org.galliumpowered.plugin.PluginLifecycleState;
Expand All @@ -11,6 +12,13 @@
import org.galliumpowered.testplugin.listeners.BlockPlaceListener;
import org.galliumpowered.testplugin.listeners.PlayerDeathListener;

@Plugin(
name = "Gallium Test Plugin",
id = "gtest",
description = "Gallium plugin for testing features",
authors = "GalliumPowered",
version = "1.0"
)
public class TestPlugin {
@Inject
private PluginContainer pluginContainer;
Expand Down
8 changes: 0 additions & 8 deletions testplugin/src/main/resources/plugin.json

This file was deleted.

0 comments on commit ac2b285

Please sign in to comment.