1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Some code improvements.

(at least that's what was meant to be done)
This commit is contained in:
LinoxGH 2020-10-04 09:01:24 +03:00 committed by GitHub
parent 4b2f70203c
commit 38f891ca98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
*/ */
public final class ResearchSetup { public final class ResearchSetup {
private static SlimefunPlugin plugin = null;
private static boolean alreadyRan = false; private static boolean alreadyRan = false;
private ResearchSetup() {} private ResearchSetup() {}
@ -32,6 +33,11 @@ public final class ResearchSetup {
if (alreadyRan) { if (alreadyRan) {
throw new UnsupportedOperationException("Researches can only be registered once!"); throw new UnsupportedOperationException("Researches can only be registered once!");
} }
plugin = SlimefunPlugin.instance();
if (plugin == null) {
throw new Exception("Plugin cannot be null!");
}
alreadyRan = true; alreadyRan = true;
@ -281,11 +287,11 @@ public final class ResearchSetup {
register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR);
register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN); register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN);
register("energy_connectors", 268, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR); register("energy_connectors", 268, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
plugin = null;
} }
private static void register(@Nonnull String key, int id, @Nonnull String name, int defaultCost, @Nonnull ItemStack... items) { private static void register(@Nonnull String key, int id, @Nonnull String name, int defaultCost, @Nonnull ItemStack... items) {
SlimefunPlugin plugin = SlimefunPlugin.instance();
if (plugin == null) return;
Research research = new Research(new NamespacedKey(plugin, key), id, name, defaultCost); Research research = new Research(new NamespacedKey(plugin, key), id, name, defaultCost);
for (ItemStack item : items) { for (ItemStack item : items) {