From b30190da5c678f32a51b5e24416d411f16a942a3 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 8 May 2020 23:05:29 +0200 Subject: [PATCH] Refactoring --- .../slimefun4/api/geo/ResourceManager.java | 9 +++++---- .../thebusybiscuit/slimefun4/core/SlimefunRegistry.java | 2 +- .../slimefun4/implementation/setup/PostSetup.java | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index 9fc120dcc..fb35b2b44 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -40,7 +40,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; public class ResourceManager { private final int[] backgroundSlots = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53 }; - private final ItemStack chunkTexture = SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQ0OWI5MzE4ZTMzMTU4ZTY0YTQ2YWIwZGUxMjFjM2Q0MDAwMGUzMzMyYzE1NzQ5MzJiM2M4NDlkOGZhMGRjMiJ9fX0="); + private final ItemStack chunkTexture = SkullItem.fromHash("8449b9318e33158e64a46ab0de121c3d40000e3332c1574932b3c849d8fa0dc2"); private final Config config; public ResourceManager(SlimefunPlugin plugin) { @@ -48,7 +48,8 @@ public class ResourceManager { } void register(GEOResource resource) { - boolean enabled = config.getOrSetDefault(resource.getKey().toString().replace(':', '.') + ".enabled", true); + String key = resource.getKey().getNamespace() + '.' + resource.getKey().getKey(); + boolean enabled = config.getOrSetDefault(key + ".enabled", true); if (enabled) { SlimefunPlugin.getRegistry().getGEOResources().add(resource); @@ -81,11 +82,11 @@ public class ResourceManager { if (value > 0) { int bound = resource.getMaxDeviation(); - + if (bound <= 0) { throw new IllegalStateException("GEO Resource \"" + resource.getKey() + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!"); } - + value += ThreadLocalRandom.current().nextInt(bound); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 6e24dc797..50fbf5b8c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -130,7 +130,7 @@ public class SlimefunRegistry { return enabledItems; } - public int countVanillaItems() { + public int countNonAddonItems() { return (int) getEnabledSlimefunItems().stream().filter(item -> !item.isAddonItem()).count(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java index 657d41218..79ea751ee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java @@ -87,7 +87,7 @@ public final class PostSetup { CommandSender sender = Bukkit.getConsoleSender(); int total = SlimefunPlugin.getRegistry().getEnabledSlimefunItems().size(); - int vanilla = SlimefunPlugin.getRegistry().countVanillaItems(); + int vanilla = SlimefunPlugin.getRegistry().countNonAddonItems(); sender.sendMessage(""); sender.sendMessage(ChatColor.GREEN + "######################### - Slimefun v" + SlimefunPlugin.getVersion() + " - #########################");