Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ tasks {
dependsOn("shadowJar")
from("build/libs") {
include("SkBee-*.jar")
exclude("*-sources.jar")
destinationDir = file("/Users/ShaneBee/Desktop/Server/${serverLocation}/plugins/")
}
}
Expand All @@ -82,7 +83,7 @@ tasks {
relocate("fr.mrmicky.fastboard", "com.shanebeestudios.skbee.api.fastboard.base")
relocate("com.shanebeestudios.vf", "com.shanebeestudios.skbee.api.virtualfurnace")
relocate("org.bstats", "com.shanebeestudios.skbee.metrics")
exclude("META-INF/**", "LICENSE")
exclude("META-INF/**", "LICENSE", "plugin.yml")
}
jar {
enabled = false
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/com/shanebeestudios/skbee/AddonLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scoreboard.Objective;
import org.skriptlang.skript.addon.SkriptAddon;

/**
* @hidden
Expand All @@ -63,28 +62,26 @@ public class AddonLoader {
private final Registration registration;
private final Config config;
private final Plugin skriptPlugin;
private final SkriptAddon addon;

public AddonLoader(SkBee plugin) {
this.plugin = plugin;
this.registration = plugin.getRegistration();
this.registration = new Registration("SkBee", true);
this.pluginManager = plugin.getServer().getPluginManager();
this.config = plugin.getPluginConfig();
MinecraftVersion.replaceLogger(LoggerBee.getLogger());
this.skriptPlugin = pluginManager.getPlugin("Skript");
this.addon = this.registration.getAddon();
}

public SkriptAddon getAddon() {
return this.addon;
public Registration getRegistration() {
return this.registration;
}

boolean canLoadPlugin() {
if (skriptPlugin == null) {
if (this.skriptPlugin == null) {
Util.logLoading("&cDependency Skript was not found, Skript elements cannot load.");
return false;
}
if (!skriptPlugin.isEnabled()) {
if (!this.skriptPlugin.isEnabled()) {
Util.logLoading("&cDependency Skript is not enabled, Skript elements cannot load.");
Util.logLoading("&cThis could mean SkBee is being forced to load before Skript.");
return false;
Expand Down Expand Up @@ -146,8 +143,7 @@ private void loadSkriptElements() {
loadTestingElements();

// Load elements into Skript
SkBeeAddonModule module = new SkBeeAddonModule(this.registration);
addon.loadModules(module);
this.registration.finalizeRegistration();

// ELEMENT COUNT
int typeCount = this.registration.getTypes().size();
Expand Down Expand Up @@ -556,8 +552,10 @@ private void loadWorldCreatorElements() {

@SuppressWarnings("ThrowableNotThrown")
private void logFailure(String element, Exception ex) {
Throwable cause = ex.getCause();
String message = cause != null ? cause.getMessage() : ex.getMessage();
Skript.exception(ex);
Util.logLoading("&e%s Elements &7failed to load due to &r'&c%s&r'", element, ex.getCause().getMessage());
Util.logLoading("&e%s Elements &7failed to load due to &r'&c%s&r'", element, message);
}

private boolean isPlugmanReloaded() {
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/com/shanebeestudios/skbee/SkBee.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.shanebeestudios.skbee.api.bound.BoundConfig;
import com.shanebeestudios.skbee.api.command.SkBeeInfo;
import com.shanebeestudios.skbee.api.region.TaskUtils;
import com.shanebeestudios.skbee.api.registration.Registration;
import com.shanebeestudios.skbee.api.structure.StructureManager;
import com.shanebeestudios.skbee.api.util.Util;
import com.shanebeestudios.skbee.api.util.update.UpdateChecker;
Expand Down Expand Up @@ -43,7 +42,6 @@ public class SkBee extends JavaPlugin {
VirtualFurnaceAPI virtualFurnaceAPI;
BeeWorldConfig beeWorldConfig;
StructureManager structureManager = null;
private Registration registration;
private AddonLoader addonLoader = null;

/**
Expand All @@ -65,10 +63,9 @@ public void onEnable() {
TaskUtils.initialize(this, Util.IS_RUNNING_FOLIA || this.config.settings_use_paper_schedulers);


this.registration = new Registration();
this.addonLoader = new AddonLoader(this);
// Check if SkriptAddon can actually load
this.properlyEnabled = addonLoader.canLoadPlugin();
this.properlyEnabled = this.addonLoader.canLoadPlugin();

loadCommands();
loadMetrics();
Expand Down Expand Up @@ -107,7 +104,7 @@ private void loadMetrics() { //6719
Version version = new Version(this.getPluginMeta().getVersion());
Table<String, String, Integer> table = HashBasedTable.create(1, 1);
table.put(
version.getMajor() + "." + version.getMinor(), // upper label
version.getMajor() + "." + version.getMinor() + ".x", // upper label
version.toString(), // lower label
1 // weight
);
Expand All @@ -117,7 +114,7 @@ private void loadMetrics() { //6719
Version version = Skript.getVersion();
Table<String, String, Integer> table = HashBasedTable.create(1, 1);
table.put(
version.getMajor() + "." + version.getMinor(), // upper label
version.getMajor() + "." + version.getMinor() + ".x", // upper label
version.toString(), // lower label
1 // weight
);
Expand All @@ -130,14 +127,14 @@ private void loadMetrics() { //6719
if (version.getMajor() == 1) {
// Minecraft 1.x.x versioning
table.put(
version.getMajor() + "." + version.getMinor(), // upper label
version.getMajor() + "." + version.getMinor() + ".x", // upper label
version.toString(), // lower label
1 // weight
);
} else {
// Minecraft (year).x.x versioning
table.put(
"" + version.getMajor(), // upper label
version.getMajor() + ".x", // upper label
version.toString(), // lower label
1 // weight
);
Expand Down Expand Up @@ -245,10 +242,6 @@ public StructureManager getStructureManager() {
return structureManager;
}

public Registration getRegistration() {
return this.registration;
}

/**
* @hidden
*/
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/com/shanebeestudios/skbee/SkBeeAddonModule.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ else if (args[0].equalsIgnoreCase("properties")) {

// JSON DOCS
else if (args[0].equalsIgnoreCase("docs")) {
JsonDocGenerator docs = new JsonDocGenerator(this.plugin, this.plugin.getRegistration());
JsonDocGenerator docs = new JsonDocGenerator(this.plugin, this.plugin.getAddonLoader().getRegistration());
docs.generateDocs();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shanebeestudios.skbee.api.wrapper;
package com.shanebeestudios.skbee.api.registration;

import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.Parser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.shanebeestudios.skbee.api.registration.Registration.StructureRegistrar;
import com.shanebeestudios.skbee.api.registration.Registration.TypeRegistrar;
import com.shanebeestudios.skbee.api.util.Util;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
Expand All @@ -42,6 +43,7 @@ public class JsonDocGenerator {
private final Registration registration;
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
private int total = 0;
private final List<String> IDS = new ArrayList<>();

public JsonDocGenerator(Plugin plugin, Registration registration) {
this.plugin = plugin;
Expand Down Expand Up @@ -168,6 +170,16 @@ private void generateEvents(JsonObject mainDoc) {
}
gemerateGeneric("type", documentation, syntaxObject, patterns.toArray(new String[0]));

// Cancelable
boolean cancellable = false;
for (Class<? extends Event> eventClass : event.eventClasses) {
if (Cancellable.class.isAssignableFrom(eventClass)) {
cancellable = true;
break;
}
}
syntaxObject.addProperty("cancellable", cancellable);

// EventValues
List<String> eventValueList = new ArrayList<>();
for (Class<? extends Event> eventClass : event.eventClasses) {
Expand Down Expand Up @@ -444,7 +456,12 @@ private void gemerateGeneric(String type, Documentation documentation, JsonObjec
private String generateId(String type, String name) {
type = type.toLowerCase(Locale.ROOT).replace(" ", "_");
name = name.toLowerCase(Locale.ROOT).replace(" ", "_");
return String.format("%s:%s:%s", this.addonName, type, name);
String id = String.format("%s:%s:%s", this.addonName, type, name);
if (this.IDS.contains(id)) {
Util.log("&cID '%s' already exists", id);
}
this.IDS.add(id);
return id;
}

@SuppressWarnings("UnstableApiUsage")
Expand Down
Loading
Loading