Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,31 @@ public Plugin getPlugin() {
};

public static VolatileCodeHandle constructVolatileCodeHandler() {
VolatileCodeHandle handle;
String mcVersion = Bukkit.getMinecraftVersion();
String convertedVersion = COMPATIBLE_VERSIONS.getOrDefault(mcVersion, mcVersion);
String version = "v" + convertedVersion.replace(".", "_");

try {
String mcVersion = Bukkit.getMinecraftVersion();
String convertedVersion = COMPATIBLE_VERSIONS.getOrDefault(mcVersion, mcVersion);
String version = "v" + convertedVersion.replace(".", "_");
Class<?> volatileCode = Class.forName("com.nisovin.magicspells.volatilecode." + version + ".VolatileCode_" + version);
Class<?> volatileCode;
try {
volatileCode = Class.forName("com.nisovin.magicspells.volatilecode." + version + ".VolatileCode_" + version);
} catch (ClassNotFoundException _) {
VolatileCodeHandle handle = new VolatileCodeLatest(helper);
MagicSpells.log("Using latest volatile code handler.");

return handle;
}

VolatileCodeHandle handle = (VolatileCodeHandle) volatileCode.getConstructor(VolatileCodeHelper.class).newInstance(helper);
MagicSpells.log("Found volatile code handler for '" + mcVersion + "'.");

handle = (VolatileCodeHandle) volatileCode.getConstructor(VolatileCodeHelper.class).newInstance(helper);
MagicSpells.log("Found volatile code handler for " + mcVersion + ".");
return handle;
} catch (Throwable ignored) {}
} catch (Throwable throwable) {
MagicSpells.error("Failed to initialize volatile code handler for '" + mcVersion + "'.");
throwable.printStackTrace();

try {
handle = new VolatileCodeLatest(helper);
MagicSpells.log("Using latest volatile code handler.");
} catch (Throwable ignored) {
handle = new VolatileCodeDisabled();
MagicSpells.error("Volatile code handler could not be initialized.");
return new VolatileCodeDisabled();
}

return handle;
}

}
Loading