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

Refactoring

This commit is contained in:
TheBusyBiscuit 2020-05-08 23:05:29 +02:00
parent 5360e4d085
commit b30190da5c
3 changed files with 7 additions and 6 deletions

View File

@ -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);
}

View File

@ -130,7 +130,7 @@ public class SlimefunRegistry {
return enabledItems;
}
public int countVanillaItems() {
public int countNonAddonItems() {
return (int) getEnabledSlimefunItems().stream().filter(item -> !item.isAddonItem()).count();
}

View File

@ -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() + " - #########################");