From 239df5cc30d6455092b0b515138c86b89007a866 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 7 Sep 2020 12:45:27 +0200 Subject: [PATCH 001/163] [CI skip] Updated change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4169204dc..0e96beab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 * Fixed #2266 * Fixed #2275 * Fixed Multi Tools consuming hunger points when holding a Wind Staff in your off hand +* Fixed Teleports getting stuck sometimes ## Release Candidate 15 (01 Aug 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#15 From 53dea5e195e3f1d5356dc54c6053052ac26a6c4e Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Mon, 7 Sep 2020 22:38:23 +0100 Subject: [PATCH 002/163] Some good old micro-optimisations --- .../slimefun4/api/MinecraftVersion.java | 2 ++ .../slimefun4/api/geo/ResourceManager.java | 4 +-- .../core/guide/SlimefunGuideLayout.java | 2 ++ .../core/guide/options/GuideLayoutOption.java | 2 +- .../localization/SlimefunLocalization.java | 2 +- .../localization/SupportedLanguage.java | 2 ++ .../services/profiler/PerformanceRating.java | 2 ++ .../services/profiler/SlimefunProfiler.java | 2 +- .../implementation/SlimefunPlugin.java | 4 +-- .../items/androids/Instruction.java | 29 +++++++++++++++++++ .../items/androids/ProgrammableAndroid.java | 27 +++++++++++++---- .../slimefun4/utils/HeadTexture.java | 2 ++ .../testing/tests/utils/TestHeadTextures.java | 2 +- 13 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index 43ad2d8b3..c4c8c0dd5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -50,6 +50,8 @@ public enum MinecraftVersion { */ UNIT_TEST("Unit Test Environment"); + public static final MinecraftVersion[] values = values(); + private final String name; private final String prefix; 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 8a47e6745..ecaa01476 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 @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.geo; import java.util.ArrayList; -import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.OptionalInt; @@ -175,7 +175,7 @@ public class ResourceManager { menu.addItem(4, new CustomItem(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler()); List resources = new ArrayList<>(SlimefunPlugin.getRegistry().getGEOResources().values()); - Collections.sort(resources, (a, b) -> a.getName(p).toLowerCase(Locale.ROOT).compareTo(b.getName(p).toLowerCase(Locale.ROOT))); + resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT))); int index = 10; int pages = (resources.size() - 1) / 36 + 1; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java index bf095f48d..278352c9d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java @@ -31,4 +31,6 @@ public enum SlimefunGuideLayout { */ CHEAT_SHEET; + public static final SlimefunGuideLayout[] values = values(); + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java index 92379ac9b..f30704905 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java @@ -101,7 +101,7 @@ class GuideLayoutOption implements SlimefunGuideOption { @Override public Optional getSelectedOption(Player p, ItemStack guide) { - for (SlimefunGuideLayout layout : SlimefunGuideLayout.values()) { + for (SlimefunGuideLayout layout : SlimefunGuideLayout.values) { if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(layout), true, false)) { return Optional.of(layout); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java index 1f765a0fd..a4e21ba01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java @@ -85,7 +85,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed protected abstract void addLanguage(@Nonnull String id, @Nonnull String texture); protected void loadEmbeddedLanguages() { - for (SupportedLanguage lang : SupportedLanguage.values()) { + for (SupportedLanguage lang : SupportedLanguage.values) { if (lang.isReadyForRelease() || SlimefunPlugin.getUpdater().getBranch() != SlimefunBranch.STABLE) { addLanguage(lang.getLanguageId(), lang.getTexture()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SupportedLanguage.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SupportedLanguage.java index 704ef7125..76287f772 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SupportedLanguage.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SupportedLanguage.java @@ -58,6 +58,8 @@ enum SupportedLanguage { MACEDONIAN("mk", false, "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"), TAGALOG("tl", true, "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937"); + public static final SupportedLanguage[] values = values(); + private final String id; private final boolean releaseReady; private final String textureHash; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java index 67629cbef..b03191c6c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceRating.java @@ -31,6 +31,8 @@ public enum PerformanceRating implements Predicate { HURTFUL(ChatColor.DARK_RED, 500), BAD(ChatColor.DARK_RED, Float.MAX_VALUE); + public static final PerformanceRating[] values = values(); + private final ChatColor color; private final float threshold; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index a61513547..9c250fb99 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -297,7 +297,7 @@ public class SlimefunProfiler { public PerformanceRating getPerformance() { float percentage = getPercentageOfTick(); - for (PerformanceRating rating : PerformanceRating.values()) { + for (PerformanceRating rating : PerformanceRating.values) { if (rating.test(percentage)) { return rating; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 1826627f4..4e64e85c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -313,7 +313,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { String currentVersion = ReflectionUtils.getVersion(); if (currentVersion.startsWith("v")) { - for (MinecraftVersion version : MinecraftVersion.values()) { + for (MinecraftVersion version : MinecraftVersion.values) { if (version.matches(currentVersion)) { minecraftVersion = version; return false; @@ -340,7 +340,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { private Collection getSupportedVersions() { List list = new ArrayList<>(); - for (MinecraftVersion version : MinecraftVersion.values()) { + for (MinecraftVersion version : MinecraftVersion.values) { if (version != MinecraftVersion.UNKNOWN) { list.add(version.getName()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java index 02a24c1af..9adfc8afd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java @@ -1,5 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.HashMap; +import java.util.Map; import java.util.function.Predicate; import org.apache.commons.lang.Validate; @@ -140,10 +145,20 @@ enum Instruction { android.refuel(inv, target); }); + private static final Map cacheMap = new HashMap<>(); + + public static final Instruction[] values = values(); + private final ItemStack item; private final AndroidType type; private final AndroidAction method; + static { + for (Instruction instruction : values) { + cacheMap.put(instruction.name(), instruction); + } + } + Instruction(AndroidType type, HeadTexture head, AndroidAction method) { this.type = type; this.item = SlimefunUtils.getCustomHead(head.getTexture()); @@ -162,9 +177,23 @@ enum Instruction { return type; } + @ParametersAreNonnullByDefault public void execute(ProgrammableAndroid android, Block b, BlockMenu inventory, BlockFace face) { Validate.notNull(method, "Instruction '" + name() + "' must be executed manually!"); method.perform(android, b, inventory, face); } + /** + * Get a value from the cache map rather than calling {@link Enum#valueOf(Class, String)}. + * This is 25-40% quicker than the standard {@link Enum#valueOf(Class, String)} depending on + * your Java version. It also means that you can avoid an IllegalArgumentException which let's + * face it is always good. + * + * @param value The value which you would like to look up. + * @return The {@link Instruction} or null if it does not exist. + */ + @Nullable + public static Instruction getFromCache(@Nonnull String value) { + return cacheMap.get(value); + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 61d3f0368..17e8d16e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.function.Predicate; +import java.util.logging.Level; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; @@ -254,8 +255,17 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, }); } else { - ItemStack stack = Instruction.valueOf(script[i]).getItem(); - menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(script[i]).name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate")); + Instruction instruction = Instruction.getFromCache(script[i]); + if (instruction == null) { + SlimefunPlugin.instance().getLogger().log(Level.WARNING, + "Failed to get instruction '{0}', maybe your server is out of date?", + script[i] + ); + return; + } + + ItemStack stack = instruction.getItem(); + menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate")); menu.addMenuClickHandler(i, (pl, slot, item, action) -> { if (action.isRightClicked() && action.isShiftClicked()) { if (script.length == 54) { @@ -285,7 +295,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, private String addInstruction(String[] script, int index, Instruction instruction) { int i = 0; - StringBuilder builder = new StringBuilder(Instruction.START + "-"); + StringBuilder builder = new StringBuilder(Instruction.START.name() + '-'); for (String current : script) { if (i > 0) { @@ -494,7 +504,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, protected List getValidScriptInstructions() { List list = new ArrayList<>(); - for (Instruction part : Instruction.values()) { + for (Instruction part : Instruction.values) { if (part == Instruction.START || part == Instruction.REPEAT) { continue; } @@ -647,7 +657,14 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, } BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1)); - Instruction instruction = Instruction.valueOf(script[index]); + Instruction instruction = Instruction.getFromCache(script[index]); + if (instruction == null) { + SlimefunPlugin.instance().getLogger().log(Level.WARNING, + "Failed to get instruction '{0}', maybe your server is out of date?", + script[index] + ); + return; + } executeInstruction(instruction, b, menu, data, index); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java index 050e5a564..019979dfb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java @@ -109,6 +109,8 @@ public enum HeadTexture { IRON_GOLEM("89091d79ea0f59ef7ef94d7bba6e5f17f2f7d4572c44f90f76c4819a714"), PIGLIN_HEAD("2882af1294a74023e6919a31d1a027310f2e142afb4667d230d155e7f21dbb41"); + public static final HeadTexture[] values = values(); + private final String texture; HeadTexture(@Nonnull String texture) { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java index c320da673..ecaaa4368 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestHeadTextures.java @@ -16,7 +16,7 @@ class TestHeadTextures { void testForDuplicates() { Set textures = new HashSet<>(); - for (HeadTexture head : HeadTexture.values()) { + for (HeadTexture head : HeadTexture.values) { String texture = head.getTexture(); Assertions.assertNotNull(texture); From fe22c5e9eda22ff0b77198bba1cf91c9e2452594 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 8 Sep 2020 12:06:12 +0200 Subject: [PATCH 003/163] Fixes #2300 (and deprecated bStats) --- CHANGELOG.md | 7 + pom.xml | 16 +- .../items/androids/Instruction.java | 18 +- .../items/androids/ProgrammableAndroid.java | 13 +- .../Slimefun/bstats/bukkit/Metrics.java | 750 ++++++++++++++++++ 5 files changed, 779 insertions(+), 25 deletions(-) create mode 100644 src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e96beab4..7af1c823e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ **Table of contents** +- [Release Candidate 17 (TBD)](#release-candidate-17-tbd) - [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020) - [Release Candidate 15 (01 Aug 2020)](#release-candidate-15-01-aug-2020) - [Release Candidate 14 (12 Jul 2020)](#release-candidate-14-12-jul-2020) @@ -21,6 +22,12 @@ +## Release Candidate 17 (TBD) + +#### Fixes +* Fixed #2300 +* Fixed #2296 + ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/pom.xml b/pom.xml index 06ff1e416..a7508adc7 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ - 4.3-UNOFFICIAL + 4.8-UNOFFICIAL 2013 jar @@ -161,10 +161,6 @@ - - org.bstats - me.mrCookieSlime.Slimefun.bstats - io.github.thebusybiscuit.cscorelib2 me.mrCookieSlime.Slimefun.cscorelib2 @@ -173,6 +169,10 @@ io.papermc.lib io.github.thebusybiscuit.slimefun4.libraries.paperlib + + kong.unirest + io.github.thebusybiscuit.slimefun4.libraries.unirest + @@ -337,12 +337,6 @@ 0.25.1 compile - - org.bstats - bstats-bukkit - 1.7 - compile - io.papermc paperlib diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java index 9adfc8afd..e80029472 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java @@ -145,8 +145,7 @@ enum Instruction { android.refuel(inv, target); }); - private static final Map cacheMap = new HashMap<>(); - + private static final Map nameLookup = new HashMap<>(); public static final Instruction[] values = values(); private final ItemStack item; @@ -155,24 +154,28 @@ enum Instruction { static { for (Instruction instruction : values) { - cacheMap.put(instruction.name(), instruction); + nameLookup.put(instruction.name(), instruction); } } - Instruction(AndroidType type, HeadTexture head, AndroidAction method) { + @ParametersAreNonnullByDefault + Instruction(AndroidType type, HeadTexture head, @Nullable AndroidAction method) { this.type = type; this.item = SlimefunUtils.getCustomHead(head.getTexture()); this.method = method; } + @ParametersAreNonnullByDefault Instruction(AndroidType type, HeadTexture head) { this(type, head, null); } + @Nonnull public ItemStack getItem() { return item; } + @Nonnull public AndroidType getRequiredType() { return type; } @@ -189,11 +192,14 @@ enum Instruction { * your Java version. It also means that you can avoid an IllegalArgumentException which let's * face it is always good. * - * @param value The value which you would like to look up. + * @param value + * The value which you would like to look up. + * * @return The {@link Instruction} or null if it does not exist. */ @Nullable public static Instruction getFromCache(@Nonnull String value) { - return cacheMap.get(value); + Validate.notNull(value, "An Instruction cannot be null!"); + return nameLookup.get(value); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 17e8d16e6..096abbf8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -256,11 +256,9 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, } else { Instruction instruction = Instruction.getFromCache(script[i]); + if (instruction == null) { - SlimefunPlugin.instance().getLogger().log(Level.WARNING, - "Failed to get instruction '{0}', maybe your server is out of date?", - script[i] - ); + SlimefunPlugin.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[i]); return; } @@ -658,13 +656,12 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1)); Instruction instruction = Instruction.getFromCache(script[index]); + if (instruction == null) { - SlimefunPlugin.instance().getLogger().log(Level.WARNING, - "Failed to get instruction '{0}', maybe your server is out of date?", - script[index] - ); + SlimefunPlugin.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[index]); return; } + executeInstruction(instruction, b, menu, data, index); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java b/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java new file mode 100644 index 000000000..217ecd8a1 --- /dev/null +++ b/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java @@ -0,0 +1,750 @@ +package me.mrCookieSlime.Slimefun.bstats.bukkit; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.ServicePriority; + +import javax.net.ssl.HttpsURLConnection; +import java.io.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.logging.Level; +import java.util.zip.GZIPOutputStream; + +/** + * bStats collects some data for plugin authors. + *

+ * Check out https://bStats.org/ to learn more about bStats! + * + * @deprecated This class is not guaranteed to be included in future versions of Slimefun! Please shade bStats yourself + * by following the instructions at: https://bstats.org/getting-started/include-metrics + */ +@Deprecated +public class Metrics { + + static { + // You can use the property to disable the check in your test environment + if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) { + // Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D + final String defaultPackage = new String(new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't' }); + final String examplePackage = new String(new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' }); + // We want to make sure nobody just copy & pastes the example and use the wrong package names + if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) { + throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); + } + } + } + + // The version of this bStats class + public static final int B_STATS_VERSION = 1; + + // The url to which the data is sent + private static final String URL = "https://bStats.org/submitData/bukkit"; + + // Is bStats enabled on this server? + private boolean enabled; + + // Should failed requests be logged? + private static boolean logFailedRequests; + + // Should the sent data be logged? + private static boolean logSentData; + + // Should the response text be logged? + private static boolean logResponseStatusText; + + // The uuid of the server + private static String serverUUID; + + // The plugin + private final Plugin plugin; + + // The plugin id + private final int pluginId; + + // A list with all custom charts + private final List charts = new ArrayList<>(); + + /** + * Class constructor. + * + * @param plugin + * The plugin which stats should be submitted. + * @param pluginId + * The id of the plugin. + * It can be found at What is my plugin id? + */ + public Metrics(Plugin plugin, int pluginId) { + if (plugin == null) { + throw new IllegalArgumentException("Plugin cannot be null!"); + } + this.plugin = plugin; + this.pluginId = pluginId; + + // Get the config file + File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); + File configFile = new File(bStatsFolder, "config.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + + // Check if the config file exists + if (!config.isSet("serverUuid")) { + + // Add default values + config.addDefault("enabled", true); + // Every server gets it's unique random id. + config.addDefault("serverUuid", UUID.randomUUID().toString()); + // Should failed request be logged? + config.addDefault("logFailedRequests", false); + // Should the sent data be logged? + config.addDefault("logSentData", false); + // Should the response text be logged? + config.addDefault("logResponseStatusText", false); + + // Inform the server owners about bStats + config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true); + try { + config.save(configFile); + } + catch (IOException ignored) {} + } + + // Load the data + enabled = config.getBoolean("enabled", true); + serverUUID = config.getString("serverUuid"); + logFailedRequests = config.getBoolean("logFailedRequests", false); + logSentData = config.getBoolean("logSentData", false); + logResponseStatusText = config.getBoolean("logResponseStatusText", false); + + if (enabled) { + boolean found = false; + // Search for all other bStats Metrics classes to see if we are the first one + for (Class service : Bukkit.getServicesManager().getKnownServices()) { + try { + service.getField("B_STATS_VERSION"); // Our identifier :) + found = true; // We aren't the first + break; + } + catch (NoSuchFieldException ignored) {} + } + // Register our service + Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal); + if (!found) { + // We are the first! + startSubmitting(); + } + } + } + + /** + * Checks if bStats is enabled. + * + * @return Whether bStats is enabled or not. + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Adds a custom chart. + * + * @param chart + * The chart to add. + */ + public void addCustomChart(CustomChart chart) { + if (chart == null) { + throw new IllegalArgumentException("Chart cannot be null!"); + } + charts.add(chart); + } + + /** + * Starts the Scheduler which submits our data every 30 minutes. + */ + private void startSubmitting() { + final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags + timer.scheduleAtFixedRate(new TimerTask() { + + @Override + public void run() { + if (!plugin.isEnabled()) { // Plugin was disabled + timer.cancel(); + return; + } + // Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit + // scheduler + // Don't be afraid! The connection to the bStats server is still async, only the stats collection is + // sync ;) + Bukkit.getScheduler().runTask(plugin, () -> submitData()); + } + }, 1000 * 60 * 5, 1000 * 60 * 30); + // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start + // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! + // WARNING: Just don't do it! + } + + /** + * Gets the plugin specific data. + * This method is called using Reflection. + * + * @return The plugin specific data. + */ + public JsonObject getPluginData() { + JsonObject data = new JsonObject(); + + String pluginName = plugin.getDescription().getName(); + String pluginVersion = plugin.getDescription().getVersion(); + + data.addProperty("pluginName", pluginName); // Append the name of the plugin + data.addProperty("id", pluginId); // Append the id of the plugin + data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin + JsonArray customCharts = new JsonArray(); + for (CustomChart customChart : charts) { + // Add the data of the custom charts + JsonObject chart = customChart.getRequestJsonObject(); + if (chart == null) { // If the chart is null, we skip it + continue; + } + customCharts.add(chart); + } + data.add("customCharts", customCharts); + + return data; + } + + /** + * Gets the server specific data. + * + * @return The server specific data. + */ + private JsonObject getServerData() { + // Minecraft specific data + int playerAmount; + try { + // Around MC 1.8 the return type was changed to a collection from an array, + // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; + Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); + playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; + } + catch (Exception e) { + playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed + } + int onlineMode = Bukkit.getOnlineMode() ? 1 : 0; + String bukkitVersion = Bukkit.getVersion(); + String bukkitName = Bukkit.getName(); + + // OS/Java specific data + String javaVersion = System.getProperty("java.version"); + String osName = System.getProperty("os.name"); + String osArch = System.getProperty("os.arch"); + String osVersion = System.getProperty("os.version"); + int coreCount = Runtime.getRuntime().availableProcessors(); + + JsonObject data = new JsonObject(); + + data.addProperty("serverUUID", serverUUID); + + data.addProperty("playerAmount", playerAmount); + data.addProperty("onlineMode", onlineMode); + data.addProperty("bukkitVersion", bukkitVersion); + data.addProperty("bukkitName", bukkitName); + + data.addProperty("javaVersion", javaVersion); + data.addProperty("osName", osName); + data.addProperty("osArch", osArch); + data.addProperty("osVersion", osVersion); + data.addProperty("coreCount", coreCount); + + return data; + } + + /** + * Collects the data and sends it afterwards. + */ + private void submitData() { + final JsonObject data = getServerData(); + + JsonArray pluginData = new JsonArray(); + // Search for all other bStats Metrics classes to get their plugin data + for (Class service : Bukkit.getServicesManager().getKnownServices()) { + try { + service.getField("B_STATS_VERSION"); // Our identifier :) + + for (RegisteredServiceProvider provider : Bukkit.getServicesManager().getRegistrations(service)) { + try { + Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider()); + if (plugin instanceof JsonObject) { + pluginData.add((JsonObject) plugin); + } + else { // old bstats version compatibility + try { + Class jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject"); + if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { + Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString"); + jsonStringGetter.setAccessible(true); + String jsonString = (String) jsonStringGetter.invoke(plugin); + JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject(); + pluginData.add(object); + } + } + catch (ClassNotFoundException e) { + // minecraft version 1.14+ + if (logFailedRequests) { + this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e); + } + } + } + } + catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} + } + } + catch (NoSuchFieldException ignored) {} + } + + data.add("plugins", pluginData); + + // Create a new thread for the connection to the bStats server + new Thread(() -> { + try { + // Send the data + sendData(plugin, data); + } + catch (Exception e) { + // Something went wrong! :( + if (logFailedRequests) { + plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); + } + } + }).start(); + } + + /** + * Sends the data to the bStats server. + * + * @param plugin + * Any plugin. It's just used to get a logger instance. + * @param data + * The data to send. + * @throws Exception + * If the request failed. + */ + private static void sendData(Plugin plugin, JsonObject data) throws Exception { + if (data == null) { + throw new IllegalArgumentException("Data cannot be null!"); + } + if (Bukkit.isPrimaryThread()) { + throw new IllegalAccessException("This method must not be called from the main thread!"); + } + if (logSentData) { + plugin.getLogger().info("Sending data to bStats: " + data); + } + HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection(); + + // Compress the data to save bandwidth + byte[] compressedData = compress(data.toString()); + + // Add headers + connection.setRequestMethod("POST"); + connection.addRequestProperty("Accept", "application/json"); + connection.addRequestProperty("Connection", "close"); + connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request + connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); + connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format + connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION); + + // Send data + connection.setDoOutput(true); + try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { + outputStream.write(compressedData); + } + + StringBuilder builder = new StringBuilder(); + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + builder.append(line); + } + } + + if (logResponseStatusText) { + plugin.getLogger().info("Sent data to bStats and received response: " + builder); + } + } + + /** + * Gzips the given String. + * + * @param str + * The string to gzip. + * @return The gzipped String. + * @throws IOException + * If the compression failed. + */ + private static byte[] compress(final String str) throws IOException { + if (str == null) { + return null; + } + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { + gzip.write(str.getBytes(StandardCharsets.UTF_8)); + } + return outputStream.toByteArray(); + } + + /** + * Represents a custom chart. + */ + public static abstract class CustomChart { + + // The id of the chart + final String chartId; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + */ + CustomChart(String chartId) { + if (chartId == null || chartId.isEmpty()) { + throw new IllegalArgumentException("ChartId cannot be null or empty!"); + } + this.chartId = chartId; + } + + private JsonObject getRequestJsonObject() { + JsonObject chart = new JsonObject(); + chart.addProperty("chartId", chartId); + try { + JsonObject data = getChartData(); + if (data == null) { + // If the data is null we don't send the chart. + return null; + } + chart.add("data", data); + } + catch (Throwable t) { + if (logFailedRequests) { + Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t); + } + return null; + } + return chart; + } + + protected abstract JsonObject getChartData() throws Exception; + + } + + /** + * Represents a custom simple pie. + */ + public static class SimplePie extends CustomChart { + + private final Callable callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public SimplePie(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + String value = callable.call(); + if (value == null || value.isEmpty()) { + // Null = skip the chart + return null; + } + data.addProperty("value", value); + return data; + } + } + + /** + * Represents a custom advanced pie. + */ + public static class AdvancedPie extends CustomChart { + + private final Callable> callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public AdvancedPie(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + JsonObject values = new JsonObject(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + continue; // Skip this invalid + } + allSkipped = false; + values.addProperty(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + data.add("values", values); + return data; + } + } + + /** + * Represents a custom drilldown pie. + */ + public static class DrilldownPie extends CustomChart { + + private final Callable>> callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public DrilldownPie(String chartId, Callable>> callable) { + super(chartId); + this.callable = callable; + } + + @Override + public JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + JsonObject values = new JsonObject(); + Map> map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean reallyAllSkipped = true; + for (Map.Entry> entryValues : map.entrySet()) { + JsonObject value = new JsonObject(); + boolean allSkipped = true; + for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { + value.addProperty(valueEntry.getKey(), valueEntry.getValue()); + allSkipped = false; + } + if (!allSkipped) { + reallyAllSkipped = false; + values.add(entryValues.getKey(), value); + } + } + if (reallyAllSkipped) { + // Null = skip the chart + return null; + } + data.add("values", values); + return data; + } + } + + /** + * Represents a custom single line chart. + */ + public static class SingleLineChart extends CustomChart { + + private final Callable callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public SingleLineChart(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + int value = callable.call(); + if (value == 0) { + // Null = skip the chart + return null; + } + data.addProperty("value", value); + return data; + } + + } + + /** + * Represents a custom multi line chart. + */ + public static class MultiLineChart extends CustomChart { + + private final Callable> callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public MultiLineChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + JsonObject values = new JsonObject(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + continue; // Skip this invalid + } + allSkipped = false; + values.addProperty(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + data.add("values", values); + return data; + } + + } + + /** + * Represents a custom simple bar chart. + */ + public static class SimpleBarChart extends CustomChart { + + private final Callable> callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public SimpleBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + JsonObject values = new JsonObject(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + for (Map.Entry entry : map.entrySet()) { + JsonArray categoryValues = new JsonArray(); + categoryValues.add(new JsonPrimitive(entry.getValue())); + values.add(entry.getKey(), categoryValues); + } + data.add("values", values); + return data; + } + + } + + /** + * Represents a custom advanced bar chart. + */ + public static class AdvancedBarChart extends CustomChart { + + private final Callable> callable; + + /** + * Class constructor. + * + * @param chartId + * The id of the chart. + * @param callable + * The callable which is used to request the chart data. + */ + public AdvancedBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } + + @Override + protected JsonObject getChartData() throws Exception { + JsonObject data = new JsonObject(); + JsonObject values = new JsonObject(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue().length == 0) { + continue; // Skip this invalid + } + allSkipped = false; + JsonArray categoryValues = new JsonArray(); + for (int categoryValue : entry.getValue()) { + categoryValues.add(new JsonPrimitive(categoryValue)); + } + values.add(entry.getKey(), categoryValues); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + data.add("values", values); + return data; + } + } + +} \ No newline at end of file From 3a5c1ee22bfadabee75adb006f4856df7f14e5ff Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 8 Sep 2020 12:22:57 +0200 Subject: [PATCH 004/163] [CI skip] Removed deprecated class --- pom.xml | 4 - .../Slimefun/api/energy/ChargableBlock.java | 138 ------------------ 2 files changed, 142 deletions(-) delete mode 100644 src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java diff --git a/pom.xml b/pom.xml index a7508adc7..3d59d3227 100644 --- a/pom.xml +++ b/pom.xml @@ -63,10 +63,6 @@ worldedit-repo https://maven.sk89q.com/repo/ - - bStats-repo - https://repo.codemc.org/repository/maven-public - placeholderapi-repo https://repo.extendedclip.com/content/repositories/placeholderapi/ diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java b/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java deleted file mode 100644 index 7e3a84c25..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.mrCookieSlime.Slimefun.api.energy; - -import org.bukkit.Location; -import org.bukkit.block.Block; - -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.BlockStorage; - -/** - * - * @deprecated Use the methods provided by {@link EnergyNetComponent} instead. - * - */ -@Deprecated -public final class ChargableBlock { - - private static final String KEY = "energy-charge"; - - private ChargableBlock() {} - - public static boolean isChargable(Block b) { - return isChargable(b.getLocation()); - } - - public static boolean isChargable(Location l) { - SlimefunItem item = BlockStorage.check(l); - return item instanceof EnergyNetComponent && ((EnergyNetComponent) item).isChargeable(); - } - - public static int getCharge(Block b) { - return getCharge(b.getLocation()); - } - - public static int getCharge(Location l) { - String charge = BlockStorage.getLocationInfo(l, KEY); - - if (charge != null) { - return Integer.parseInt(charge); - } - else { - BlockStorage.addBlockInfo(l, KEY, "0", false); - return 0; - } - } - - public static void setCharge(Location l, int charge) { - if (charge < 0) { - charge = 0; - } - else { - int capacity = getMaxCharge(l); - - if (charge > capacity) { - charge = capacity; - } - } - - if (charge != getCharge(l)) { - BlockStorage.addBlockInfo(l, KEY, String.valueOf(charge), false); - } - } - - public static void setUnsafeCharge(Location l, int charge, boolean updateTexture) { - if (charge != getCharge(l)) { - BlockStorage.addBlockInfo(l, KEY, String.valueOf(charge), false); - - if (updateTexture) { - SlimefunUtils.updateCapacitorTexture(l, charge, getMaxCharge(l)); - } - } - } - - public static int addCharge(Block b, int charge) { - return addCharge(b.getLocation(), charge); - } - - public static int addCharge(Location l, int addedCharge) { - SlimefunItem item = BlockStorage.check(l); - - if (item == null) { - BlockStorage.clearBlockInfo(l); - return 0; - } - - int capacity = ((EnergyNetComponent) item).getCapacity(); - - int charge = getCharge(l); - int availableSpace = capacity - charge; - int rest = addedCharge; - - if (availableSpace > 0 && addedCharge > 0) { - if (availableSpace > addedCharge) { - charge += addedCharge; - rest = 0; - } - else { - rest = addedCharge - availableSpace; - charge = capacity; - } - - setCharge(l, charge); - - if (item instanceof Capacitor) { - SlimefunUtils.updateCapacitorTexture(l, charge, capacity); - } - } - else if (addedCharge < 0 && charge >= -addedCharge) { - charge += addedCharge; - setCharge(l, charge); - - if (item instanceof Capacitor) { - SlimefunUtils.updateCapacitorTexture(l, charge, capacity); - } - } - - return rest; - } - - public static int getMaxCharge(Block b) { - return getMaxCharge(b.getLocation()); - } - - public static int getMaxCharge(Location l) { - SlimefunItem item = BlockStorage.check(l); - - if (item == null) { - BlockStorage.clearBlockInfo(l); - return 0; - } - - return item instanceof EnergyNetComponent ? ((EnergyNetComponent) item).getCapacity() : 0; - - } - -} From c7a1336e189faa9d1c55c57c02eb981e67385d0d Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 8 Sep 2020 10:30:17 +0000 Subject: [PATCH 005/163] Update dependency com.github.TheBusyBiscuit:CS-CoreLib2 to v0.26 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3d59d3227..93ef224f4 100644 --- a/pom.xml +++ b/pom.xml @@ -330,7 +330,7 @@ com.github.TheBusyBiscuit CS-CoreLib2 - 0.25.1 + 0.26 compile From a30d41ea9e164d642c1808d37937e2d67a00035c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 11:31:52 +0200 Subject: [PATCH 006/163] [CI skip] Updated change log --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7af1c823e..7f5059795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ ## Release Candidate 17 (TBD) +#### Changes +* Improved Auto-Updater (Multi-Threading and more) + #### Fixes * Fixed #2300 * Fixed #2296 From f2eeadb24bb5e507cfba7f7ff1f99b2e28c321ab Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 9 Sep 2020 13:18:43 +0200 Subject: [PATCH 007/163] [CI skip] Some minor changes --- pom.xml | 1 + .../slimefun4/implementation/items/blocks/Composter.java | 6 +++--- .../slimefun4/implementation/items/blocks/Crucible.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 93ef224f4..a058ba564 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ thebusybiscuit-github https://sonarcloud.io DEBUG + src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java target/site/jacoco/jacoco.xml diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java index 43ac95fc8..dfe498fca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java @@ -8,6 +8,7 @@ import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -17,7 +18,6 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; -import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; @@ -50,12 +50,12 @@ public class Composter extends SimpleSlimefunItem implements Re private List getMachineRecipes() { List items = new LinkedList<>(); - for (Material leave : MaterialCollections.getAllLeaves()) { + for (Material leave : Tag.LEAVES.getValues()) { items.add(new ItemStack(leave, 8)); items.add(new ItemStack(Material.DIRT)); } - for (Material sapling : MaterialCollections.getAllSaplings()) { + for (Material sapling : Tag.SAPLINGS.getValues()) { items.add(new ItemStack(sapling, 8)); items.add(new ItemStack(Material.DIRT)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java index b87d1cfe6..b7e490b6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java @@ -60,7 +60,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec items.add(new ItemStack(Material.TERRACOTTA, 12)); items.add(new ItemStack(Material.LAVA_BUCKET)); - for (Material leave : MaterialCollections.getAllLeaves()) { + for (Material leave : Tag.LEAVES.getValues()) { items.add(new ItemStack(leave, 16)); items.add(new ItemStack(Material.WATER_BUCKET)); } From e628ad26854813e90dd84897a6509e6f6aae9185 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:25:20 +0200 Subject: [PATCH 008/163] Added MachineProcessCompleteEvent --- .../events/MachineProcessCompleteEvent.java | 54 +++++++++++++++++++ .../abstractItems/AContainer.java | 4 ++ 2 files changed, 58 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java new file mode 100644 index 000000000..97632e2fe --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java @@ -0,0 +1,54 @@ +package io.github.thebusybiscuit.slimefun4.api.events; + +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; +import org.bukkit.block.Block; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * This {@link Event} is fired whenever an {@link AContainer} has completed its process. + * + * @author poma123 + * + */ +public class MachineProcessCompleteEvent extends Event { + + private static final HandlerList handlerList = new HandlerList(); + + private final Block block; + private final MachineRecipe machineRecipe; + + @ParametersAreNonnullByDefault + public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { + this.block = block; + this.machineRecipe = machineRecipe; + } + + /** This method returns the {@link Block} of the machine. + * + * @return the {@link Block} of the machine + */ + public Block getMachine() { + return block; + } + + /** This returns the used {@link MachineRecipe} in the process. + * + * @return the {@link MachineRecipe} of the process. + */ + public MachineRecipe getMachineRecipe() { + return machineRecipe; + } + + @Override + public HandlerList getHandlers() { + return handlerList; + } + + public static HandlerList getHandlerList() { + return handlerList; + } +} \ No newline at end of file diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 2a61919ec..3851ac0d4 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -5,6 +5,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import io.github.thebusybiscuit.slimefun4.api.events.MachineProcessCompleteEvent; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -254,6 +256,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, inv.pushItem(output.clone(), getOutputSlots()); } + Bukkit.getPluginManager().callEvent(new MachineProcessCompleteEvent(b, getProcessing(b))); + progress.remove(b); processing.remove(b); } From 274c5ada2f6289e2a58838a06b4d78d12116aa3f Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:25:47 +0200 Subject: [PATCH 009/163] Minor improvement --- .../Objects/SlimefunItem/abstractItems/AContainer.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 3851ac0d4..83f78ee83 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -243,11 +243,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, } removeCharge(b.getLocation(), getEnergyConsumption()); - progress.put(b, timeleft - 1); - } - else { - progress.put(b, timeleft - 1); } + progress.put(b, timeleft - 1); } else { inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); From 25bd60fd0e902aecf7f39fccb954cc59a05abc9a Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:26:01 +0200 Subject: [PATCH 010/163] Fixed a typo --- .../slimefun4/api/events/GEOResourceGenerationEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java index 9bcae84dc..cc659b773 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java @@ -17,7 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; /** * This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated. - * This only ocurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource} + * This only occurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource} * but cannot find it. * * You can modify this {@link Event} by listening to it. From a4eb852b195b04c4eb59cae04ee4a682a26298f3 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:34:01 +0200 Subject: [PATCH 011/163] Added annotations --- .../api/events/MachineProcessCompleteEvent.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java index 97632e2fe..542844574 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.Block; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; /** @@ -22,7 +23,7 @@ public class MachineProcessCompleteEvent extends Event { private final MachineRecipe machineRecipe; @ParametersAreNonnullByDefault - public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { + public MachineProcessCompleteEvent(@Nonnull Block block, @Nonnull MachineRecipe machineRecipe) { this.block = block; this.machineRecipe = machineRecipe; } @@ -31,6 +32,7 @@ public class MachineProcessCompleteEvent extends Event { * * @return the {@link Block} of the machine */ + @Nonnull public Block getMachine() { return block; } @@ -39,16 +41,19 @@ public class MachineProcessCompleteEvent extends Event { * * @return the {@link MachineRecipe} of the process. */ + @Nonnull public MachineRecipe getMachineRecipe() { return machineRecipe; } + @Nonnull + public static HandlerList getHandlerList() { + return handlerList; + } + + @Nonnull @Override public HandlerList getHandlers() { return handlerList; } - - public static HandlerList getHandlerList() { - return handlerList; - } } \ No newline at end of file From 87543ccb83ec85eacbf57e4b0c320b469273c59e Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:35:17 +0200 Subject: [PATCH 012/163] Fixed javadocs --- .../slimefun4/api/events/MachineProcessCompleteEvent.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java index 542844574..cfb6cadfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java @@ -28,7 +28,8 @@ public class MachineProcessCompleteEvent extends Event { this.machineRecipe = machineRecipe; } - /** This method returns the {@link Block} of the machine. + /** + * This method returns the {@link Block} of the machine. * * @return the {@link Block} of the machine */ @@ -37,7 +38,8 @@ public class MachineProcessCompleteEvent extends Event { return block; } - /** This returns the used {@link MachineRecipe} in the process. + /** + * This returns the used {@link MachineRecipe} in the process. * * @return the {@link MachineRecipe} of the process. */ From 8f34365aaac2fb94508a39ae69bc2426a25b36e8 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 9 Sep 2020 14:51:21 +0200 Subject: [PATCH 013/163] Removed redundant annotations --- .../slimefun4/api/events/MachineProcessCompleteEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java index cfb6cadfc..9e18ff7cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java @@ -23,7 +23,7 @@ public class MachineProcessCompleteEvent extends Event { private final MachineRecipe machineRecipe; @ParametersAreNonnullByDefault - public MachineProcessCompleteEvent(@Nonnull Block block, @Nonnull MachineRecipe machineRecipe) { + public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { this.block = block; this.machineRecipe = machineRecipe; } From 6d6359ce2638317a7130b42147caa6d8aa808e12 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Wed, 9 Sep 2020 16:50:04 +0300 Subject: [PATCH 014/163] Improved the code. --- .../slimefun4/core/networks/cargo/ChestTerminalNetwork.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index 7def32c14..eadc5ecf0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -325,6 +325,12 @@ abstract class ChestTerminalNetwork extends Network { return System.nanoTime() - timestamp; } } + + @Override + public void markDirty(@Nonnull Location l) { + connectedCache.remove(l); + super.markDirty(l); + } private void updateTerminal(Location l, BlockMenu terminal, int slot, int index, List items) { if (items.size() > index) { From 1b80c698c5e695b06cfb42481245cd902164af52 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Wed, 9 Sep 2020 21:36:29 +0300 Subject: [PATCH 015/163] Fixed a typo. --- .../slimefun4/core/networks/cargo/ChestTerminalNetwork.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index eadc5ecf0..fdf732de2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -328,7 +328,7 @@ abstract class ChestTerminalNetwork extends Network { @Override public void markDirty(@Nonnull Location l) { - connectedCache.remove(l); + connectorCache.remove(l); super.markDirty(l); } From 6e4ad1345fdb8bcebe3cff4d6d8e16be35becafd Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 10 Sep 2020 13:58:58 +0200 Subject: [PATCH 016/163] This has to be async --- .../slimefun4/api/events/MachineProcessCompleteEvent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java index 9e18ff7cf..9b4c8b376 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java @@ -24,6 +24,8 @@ public class MachineProcessCompleteEvent extends Event { @ParametersAreNonnullByDefault public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { + super(true); + this.block = block; this.machineRecipe = machineRecipe; } @@ -58,4 +60,4 @@ public class MachineProcessCompleteEvent extends Event { public HandlerList getHandlers() { return handlerList; } -} \ No newline at end of file +} From d22f7f31d8f7d3dff2bdb076bf943b9ceaaeb8c3 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 10 Sep 2020 14:36:41 +0200 Subject: [PATCH 017/163] Renamed to AsyncMachineProcessCompleteEvent --- ...mpleteEvent.java => AsyncMachineProcessCompleteEvent.java} | 4 ++-- .../Objects/SlimefunItem/abstractItems/AContainer.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/api/events/{MachineProcessCompleteEvent.java => AsyncMachineProcessCompleteEvent.java} (90%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java index 9b4c8b376..61babfd83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java @@ -15,7 +15,7 @@ import javax.annotation.ParametersAreNonnullByDefault; * @author poma123 * */ -public class MachineProcessCompleteEvent extends Event { +public class AsyncMachineProcessCompleteEvent extends Event { private static final HandlerList handlerList = new HandlerList(); @@ -23,7 +23,7 @@ public class MachineProcessCompleteEvent extends Event { private final MachineRecipe machineRecipe; @ParametersAreNonnullByDefault - public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { + public AsyncMachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { super(true); this.block = block; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 83f78ee83..4dce26884 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import io.github.thebusybiscuit.slimefun4.api.events.MachineProcessCompleteEvent; +import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineProcessCompleteEvent; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -253,7 +253,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, inv.pushItem(output.clone(), getOutputSlots()); } - Bukkit.getPluginManager().callEvent(new MachineProcessCompleteEvent(b, getProcessing(b))); + Bukkit.getPluginManager().callEvent(new AsyncMachineProcessCompleteEvent(b, getProcessing(b))); progress.remove(b); processing.remove(b); From 6b95ed02936f0d6dbbb9ee53b34f8c5378573bed Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Thu, 10 Sep 2020 16:02:03 -0500 Subject: [PATCH 018/163] Added Charge Command --- .../commands/subcommands/ChargeCommand.java | 54 +++++++++++++++ .../subcommands/SlimefunSubCommands.java | 1 + .../github/ContributionsConnector.java | 1 + src/main/resources/languages/messages_en.yml | 7 +- src/main/resources/plugin.yml | 3 + .../tests/commands/TestChargeCommand.java | 69 +++++++++++++++++++ 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java new file mode 100644 index 000000000..5390ad24c --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java @@ -0,0 +1,54 @@ +package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; + +import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +/** + * {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable} + * item to max. + * + * @author FluffyBear + * + */ +class ChargeCommand extends SubCommand { + + ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { + super(plugin, cmd, "charge", false); + } + + @Override + protected String getDescription() { + return "commands.charge.description"; + } + + @Override + public void onExecute(CommandSender sender, String[] args) { + if (sender instanceof Player) { + if (sender.hasPermission("slimefun.charge.command")) { + Player p = (Player) sender; + ItemStack item = p.getInventory().getItemInMainHand(); + SlimefunItem slimefunItem = SlimefunItem.getByItem(item); + if (slimefunItem instanceof Rechargeable) { + Rechargeable rechargeableItem = (Rechargeable) slimefunItem; + rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item)); + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.charge-success", true); + } + else { + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true); + } + } + else { + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); + } + } + else { + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index 0d337f1f4..10378c3ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -37,6 +37,7 @@ public final class SlimefunSubCommands { commands.add(new SearchCommand(plugin, cmd)); commands.add(new DebugFishCommand(plugin, cmd)); commands.add(new BackpackCommand(plugin, cmd)); + commands.add(new ChargeCommand(plugin, cmd)); return commands; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java index c28756c7c..0ee739265 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java @@ -33,6 +33,7 @@ class ContributionsConnector extends GitHubConnector { aliases.put("BurningBrimstone", "Bluedevil74"); aliases.put("bverhoeven", "soczol"); aliases.put("ramdon-person", "ramdon_person"); + aliases.put("NCBPFluffyBear", "FluffyBear_"); } private final String prefix; diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index 817c031a1..c292b1c82 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -21,7 +21,12 @@ commands: player-never-joined: '&4No player with that name could be found!' backpack-does-not-exist: '&4The specified backpack does not exist!' restored-backpack-given: '&aYour backpack has been restored and was added to your inventory!' - + + charge: + description: Charges the item you are holding + charge-success: Item has been charged! + not-rechargeable: This item can not be charged! + guide: locked: 'LOCKED' work-in-progress: 'This feature is not fully finished yet!' diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4e99df2dc..5c84cd1a9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -49,6 +49,9 @@ permissions: slimefun.command.backpack: description: Allows you to do /sf backpack default: op + slimefun.command.charge: + description: Allows you to do /sf charge + default: op slimefun.android.bypass: description: Allows you to edit other Players Androids default: op diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java new file mode 100644 index 000000000..1df630357 --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java @@ -0,0 +1,69 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.commands; + +import be.seeseemelk.mockbukkit.MockBukkit; +import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class TestChargeCommand { + + private static ServerMock server; + private static SlimefunPlugin plugin; + + @BeforeAll + public static void load() { + server = MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Test + @DisplayName("Test if /charge charges the item the player is holding") + void testCommand() { + Category category = TestUtilities.getCategory(plugin, "rechargeable"); + final SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("RECHARGEABLE_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); + new RechargeableMock(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); + + Player player = server.addPlayer(); + player.setOp(true); + player.getInventory().setItemInMainHand(RECHARGEABLE_ITEM.clone()); + server.execute("slimefun", player, "charge"); + + ItemStack chargedItemStack = player.getInventory().getItemInMainHand(); + Rechargeable chargedItem = (Rechargeable) SlimefunItem.getByItem(chargedItemStack); + + Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), chargedItem.getMaxItemCharge(chargedItemStack)); + } + + + private class RechargeableMock extends SlimefunItem implements Rechargeable { + + public RechargeableMock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } + + @Override + public float getMaxItemCharge(ItemStack item) { + return 100; + } + } + +} \ No newline at end of file From 57f52f62c6ab9de0328f3255b3b70020fc020138 Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Thu, 10 Sep 2020 16:27:50 -0500 Subject: [PATCH 019/163] Did requested changes --- .../commands/subcommands/ChargeCommand.java | 2 +- .../tests/commands/TestChargeCommand.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java index 5390ad24c..f110b278c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java @@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack; /** * {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable} - * item to max. + * item to maximum charge, defined by {@link Rechargeable#getMaxItemCharge(ItemStack)}. * * @author FluffyBear * diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java index 1df630357..d4a696cbb 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java @@ -36,27 +36,32 @@ class TestChargeCommand { } @Test - @DisplayName("Test if /charge charges the item the player is holding") + @DisplayName("Test if /sf charge charges the item the player is holding") void testCommand() { Category category = TestUtilities.getCategory(plugin, "rechargeable"); - final SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("RECHARGEABLE_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); - new RechargeableMock(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); + final SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); + new SlimefunChargeTest(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); Player player = server.addPlayer(); player.setOp(true); player.getInventory().setItemInMainHand(RECHARGEABLE_ITEM.clone()); - server.execute("slimefun", player, "charge"); ItemStack chargedItemStack = player.getInventory().getItemInMainHand(); Rechargeable chargedItem = (Rechargeable) SlimefunItem.getByItem(chargedItemStack); + Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), 0); + server.execute("slimefun", player, "charge"); + + chargedItemStack = player.getInventory().getItemInMainHand(); + chargedItem = (Rechargeable) SlimefunItem.getByItem(chargedItemStack); + Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), chargedItem.getMaxItemCharge(chargedItemStack)); } - private class RechargeableMock extends SlimefunItem implements Rechargeable { + private class SlimefunChargeTest extends SlimefunItem implements Rechargeable { - public RechargeableMock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public SlimefunChargeTest(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } From 128bc65417a8ce77fd26c6476d04c299d9c88ab9 Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Thu, 10 Sep 2020 16:36:52 -0500 Subject: [PATCH 020/163] Did requested changes --- .../testing/tests/commands/TestChargeCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java index d4a696cbb..3f55ef0bc 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java @@ -39,8 +39,8 @@ class TestChargeCommand { @DisplayName("Test if /sf charge charges the item the player is holding") void testCommand() { Category category = TestUtilities.getCategory(plugin, "rechargeable"); - final SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); - new SlimefunChargeTest(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); + SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); + new RechargeableMock(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); Player player = server.addPlayer(); player.setOp(true); @@ -59,9 +59,9 @@ class TestChargeCommand { } - private class SlimefunChargeTest extends SlimefunItem implements Rechargeable { + private class RechargeableMock extends SlimefunItem implements Rechargeable { - public SlimefunChargeTest(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public RechargeableMock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } From 37c0ce4ce01fad82d98c4c1a0275f49ceb5b34d1 Mon Sep 17 00:00:00 2001 From: NCBPFluffyBear <31554056+ncbpfluffybear@users.noreply.github.com> Date: Thu, 10 Sep 2020 23:52:19 -0500 Subject: [PATCH 021/163] Organized imports --- .../commands/subcommands/ChargeCommand.java | 7 ++++--- .../tests/commands/TestChargeCommand.java | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java index f110b278c..3ea6b70e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java @@ -1,13 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; /** * {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java index 3f55ef0bc..6a964506e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java @@ -1,5 +1,15 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.commands; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import be.seeseemelk.mockbukkit.MockBukkit; import be.seeseemelk.mockbukkit.ServerMock; import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; @@ -10,14 +20,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; class TestChargeCommand { From 5989fde47651217ee36628dc7d41364752208ef5 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Sep 2020 10:21:07 +0200 Subject: [PATCH 022/163] [CI skip] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5059795..cd6937313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ ## Release Candidate 17 (TBD) +#### Additions +* Added /sf charge + #### Changes * Improved Auto-Updater (Multi-Threading and more) From 252933688995d3c96f462cc9a36bd7327d6c5e67 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Sep 2020 17:50:38 +0200 Subject: [PATCH 023/163] [CI skip] Auto-Approve should now trigger twice --- .github/workflows/auto-approve.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index 0fc4f724d..0ae2f9d90 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -10,7 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: hmarr/auto-approve-action@v2.0.0 + - name: Approve via actions + uses: hmarr/auto-approve-action@v2.0.0 + if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]' + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Approve via TheBusyBot + uses: hmarr/auto-approve-action@v2.0.0 if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]' with: github-token: "${{ secrets.ACCESS_TOKEN }}" From 1f636271d6bb4d0915808ab399ae1a674f0b154a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 11 Sep 2020 17:54:12 +0200 Subject: [PATCH 024/163] [CI skip] Rename workflow --- .github/workflows/{conflicts.yml => merge-conflicts.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{conflicts.yml => merge-conflicts.yml} (100%) diff --git a/.github/workflows/conflicts.yml b/.github/workflows/merge-conflicts.yml similarity index 100% rename from .github/workflows/conflicts.yml rename to .github/workflows/merge-conflicts.yml From ca20594032d1f9fb68d5e79e1b576b32f0ea02b1 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:27:38 +0300 Subject: [PATCH 025/163] Added changed the used SoundCategory. --- .../slimefun4/implementation/items/blocks/InfusedHopper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java index 8e98ce420..b94e1305d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; @@ -54,7 +55,7 @@ public class InfusedHopper extends SimpleSlimefunItem { } if (sound && !silent.getValue().booleanValue()) { - b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F); + b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 2F); } } From 0177ee13dd4050f24fa45b2390f10be48f05e590 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:29:28 +0300 Subject: [PATCH 026/163] Changed the used SoundCategory. --- .../slimefun4/implementation/tasks/MagnetTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java index 4d0b793f8..480041401 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/MagnetTask.java @@ -4,6 +4,7 @@ import javax.annotation.Nonnull; import org.bukkit.GameMode; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -55,7 +56,7 @@ public class MagnetTask extends PlayerTask { } if (playSound) { - p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.25F, 0.9F); + p.playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.25F, 0.9F); } } From be5f793695aaef2b22e7d95fd450d8a0dab6db48 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:02:17 +0200 Subject: [PATCH 027/163] Fixed a bunch of typos --- .github/workflows/closed-issues-reason.yml | 2 +- CHANGELOG.md | 14 +++++++------- README.md | 2 +- .../slimefun4/api/geo/ResourceManager.java | 4 ++-- .../slimefun4/api/gps/TeleportationManager.java | 2 +- .../slimefun4/core/commands/package-info.java | 2 +- .../slimefun4/core/guide/options/package-info.java | 2 +- .../core/networks/cargo/ChestTerminalNetwork.java | 2 +- .../slimefun4/core/package-info.java | 4 ++-- .../slimefun4/core/researching/Research.java | 2 +- .../slimefun4/core/services/AutoSavingService.java | 2 +- .../slimefun4/core/services/BlockDataService.java | 2 +- .../core/services/profiler/SlimefunProfiler.java | 2 +- .../slimefun4/implementation/SlimefunPlugin.java | 2 +- .../implementation/items/VanillaItem.java | 2 +- .../items/magical/EnchantmentRune.java | 2 +- .../items/multiblocks/OreWasher.java | 2 +- .../listeners/ButcherAndroidListener.java | 2 +- .../listeners/DebugFishListener.java | 2 +- .../listeners/VillagerTradingListener.java | 2 +- .../implementation/resources/UraniumResource.java | 4 ++-- .../slimefun4/implementation/tasks/ArmorTask.java | 2 +- .../implementation/tasks/SlimefunStartupTask.java | 2 +- .../slimefun4/implementation/tasks/TickerTask.java | 2 +- .../slimefun4/utils/FireworkUtils.java | 2 +- .../utils/itemstack/ItemStackWrapper.java | 2 +- .../Objects/SlimefunItem/SlimefunItem.java | 10 +++++----- .../tests/listeners/TestSlimefunGuideListener.java | 2 +- .../listeners/TestVanillaMachinesListener.java | 2 +- .../listeners/TestVillagerTradingListener.java | 2 +- 30 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.github/workflows/closed-issues-reason.yml b/.github/workflows/closed-issues-reason.yml index e95e90e84..243012fcd 100644 --- a/.github/workflows/closed-issues-reason.yml +++ b/.github/workflows/closed-issues-reason.yml @@ -43,7 +43,7 @@ jobs: * [ ] Your issue is not a bug, please only use this issue tracker to report bugs. Any other kind of communication should happen on discord. * [ ] Your issue has already been reported before, it is a duplicate. Check the other issues first before posting! * [ ] You posted an error without using pastebin. Please always post errors via pastebin otherwise they become nearly unreadable. - * [ ] You seem to be reporting multiple bugs at once. Please make a seperate issue for each bug you encountered, so we can properly handle them individually. + * [ ] You seem to be reporting multiple bugs at once. Please make a separate issue for each bug you encountered, so we can properly handle them individually. * [ ] Your issue has already been fixed in a later version of Slimefun or CS-CoreLib, you should update. * [ ] You are using an outdated and unsupported version of Slimefun / CS-CoreLib, again, you should update. * [ ] You are using an unofficially modified build of Slimefun. We only support official versions of Slimefun - for obvious reasons. diff --git a/CHANGELOG.md b/CHANGELOG.md index cd6937313..fc9637aa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -238,7 +238,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#14 * Fixed a rare concurrency issue with world saving * Fixed some contributors showing up twice * Fixed #2062 -* Fixed Grappling hooks disappearing when fired at Item frames or paintaings +* Fixed Grappling hooks disappearing when fired at Item frames or paintings * Fixed Grappling hooks not getting removed when the Player leaves * Fixed Grappling hooks making Bat sounds * Fixed #1959 @@ -284,7 +284,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 * Auto Disenchanting is now a tiny bit faster * Small performance improvements * Dried Kelp Blocks can now be used as fuel for Tier 1 Androids -* Androids now have a seperate category in the Slimefun Guide +* Androids now have a separate category in the Slimefun Guide * Android Interface recipes now require steel ingots * Changed and unified a couple of tooltips * Changed tooltip on jetpacks and jet boots to say "Crouch" instead of "Hold Shift" @@ -331,7 +331,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#12 * Fixed #1834 * Fixed #1843 * Fixed #1873 -* Fixed Electric Smeltery not prioritisting recipes +* Fixed Electric Smeltery not prioritising recipes * Fixed #1851 * Fixed #1891 * Fixed #1893 @@ -431,7 +431,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#10 * Internal clean up and further documentation * Changed Automatic Ignition Chamber to be a Dropper * Teleporters are now significantly faster -* Item permissions have been moved to a seperate permissions.yml file +* Item permissions have been moved to a separate permissions.yml file * Salt now only requires 2 blocks of Sand * Fireworks from researching no longer damages entities * Very slight performance improvements for Cargo networks @@ -516,7 +516,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#6 https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#5 #### Additions -* Aded preset messages.yml files +* Added preset messages.yml files * Added user-configurable localization * Added many more options to the messages.yml * Added custom model data support for Languages @@ -529,8 +529,8 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#5 * Added ability to translate messages for Players * Added the ability to translate Researches * Added StatusEffect API -* Added translatibility to categories -* Added translatibility to geo-resources +* Added translatability to categories +* Added translatability to geo-resources #### Changes * Removed Solar Array diff --git a/README.md b/README.md index 3cc4a8c32..84dd916b8 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Over 100 people have already contributed to this amazing project. You guys are a Please consider helping us maintain this project too, your engagement keeps the project alive <3. ### Translations -Slimefun4 has recently added suport for translations, note that translations are still _work in progress_.
+Slimefun4 has recently added support for translations, note that translations are still _work in progress_.
So not everything may be available for translation yet.
[Read more...](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun) 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 ecaa01476..792bb6de0 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 @@ -89,9 +89,9 @@ public class ResourceManager { * @param world * The {@link World} of this {@link Location} * @param x - * The {@link Chunk} x cordinate + * The {@link Chunk} x coordinate * @param z - * The {@link Chunk} z cordinate + * The {@link Chunk} z coordinate * * @return An {@link OptionalInt}, either empty or containing the amount of the given {@link GEOResource} */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index f70839edf..47e6f804e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -148,7 +148,7 @@ public final class TeleportationManager { @ParametersAreNonnullByDefault private void onTeleport(Player p, Location destination, boolean success, boolean resistance) { // This needs to run on the main Thread so we force it, as the - // async teleportation might happen on a seperate Thread. + // async teleportation might happen on a separate Thread. Slimefun.runSync(() -> { if (success) { // Apply Resistance Effect, if enabled diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java index f3736695a..13a08a12a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java @@ -1,4 +1,4 @@ /** - * This package contains everything related to slimefun's ingame command. + * This package contains everything related to Slimefun's ingame command. */ package io.github.thebusybiscuit.slimefun4.core.commands; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java index 87fda6b4e..14f426c5c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java @@ -1,5 +1,5 @@ /** - * This package contains the Settings menu forthe {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide} as + * This package contains the Settings menu for the {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide} as * well as the interface {@link io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideOption} for adding * your own options */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index fdf732de2..cdb6ea3ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -453,7 +453,7 @@ abstract class ChestTerminalNetwork extends Network { } } catch (Exception x) { - Slimefun.getLogger().log(Level.SEVERE, "An Exception occured while trying to read data from a Barrel", x); + Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while trying to read data from a Barrel", x); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java index 155bed61c..4a303ab0e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java @@ -1,5 +1,5 @@ /** - * This package holds the core systems of Slimefun, these are not neccessarily used as an API - * but ratherprovide the core functionality of this {@link org.bukkit.plugin.Plugin}. + * This package holds the core systems of Slimefun, these are not necessarily used as an API + * but rather provide the core functionality of this {@link org.bukkit.plugin.Plugin}. */ package io.github.thebusybiscuit.slimefun4.core; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java index 5ddb56b59..63e69b884 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java @@ -86,7 +86,7 @@ public class Research implements Keyed { /** * This method returns whether this {@link Research} is enabled. * {@code false} can mean that this particular {@link Research} was disabled or that - * researches alltogether have been disabled. + * researches altogether have been disabled. * * @return Whether this {@link Research} is enabled or not */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java index 6ee30899f..d965cefde 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java @@ -46,7 +46,7 @@ public class AutoSavingService { /** * This method saves every {@link PlayerProfile} in memory and removes profiles - * that were markes for deletion. + * that were marked for deletion. */ private void saveAllPlayers() { Iterator iterator = PlayerProfile.iterator(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java index 5fcb9face..809d3f336 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java @@ -74,7 +74,7 @@ public class BlockDataService implements PersistentDataService, Keyed { /** * This method checks whether the given {@link Material} is a Tile Entity. * This is used to determine whether the {@link Block} produced by this {@link Material} - * produces a {@link TileState}, making it useable as a {@link PersistentDataHolder}. + * produces a {@link TileState}, making it usable as a {@link PersistentDataHolder}. * * Due to {@link Block#getState()} being a very expensive call performance-wise though, * this simple lookup method is used instead. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index 9c250fb99..b69118d89 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -81,7 +81,7 @@ public class SlimefunProfiler { /** * This method schedules a given amount of entries for the future. * Be careful to {@link #closeEntry(Location, SlimefunItem, long)} all of them again! - * No {@link PerformanceSummary} will be sent until all entires were closed. + * No {@link PerformanceSummary} will be sent until all entries were closed. * * If the specified amount is negative, scheduled entries will be removed * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 4e64e85c9..d1fd6ca5f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -251,7 +251,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { recipeService.refresh(); } catch (Exception | LinkageError x) { - getLogger().log(Level.SEVERE, x, () -> "An Exception occured while iterating through the Recipe list on Minecraft Version " + minecraftVersion.getName() + " (Slimefun v" + getVersion() + ")"); + getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while iterating through the Recipe list on Minecraft Version " + minecraftVersion.getName() + " (Slimefun v" + getVersion() + ")"); } }), 0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java index 166a9b371..abaf92d2a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java @@ -17,7 +17,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * automatically * replace it in the recipes by its vanilla equivalent. * - * A {@link VanillaItem} is also automatically useable in workbenches. + * A {@link VanillaItem} is also automatically usable in workbenches. * * @author TheBusyBiscuit * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java index f4522a725..d3ee4d37f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java @@ -72,7 +72,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { addRandomEnchantment(p, item); } catch (Exception x) { - error("An Exception occured while trying to apply an Enchantment Rune", x); + error("An Exception occurred while trying to apply an Enchantment Rune", x); } }, 20L); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java index 099ab6f04..1fdfc48aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java @@ -38,7 +38,7 @@ public class OreWasher extends MultiBlockMachine { @Override protected void registerDefaultRecipes(List recipes) { // Iron and Gold are displayed as Ore Crusher recipes, as that is their primary - // way of obtainining them. But we also wanna display them here, so we just + // way of obtaining them. But we also wanna display them here, so we just // add these two recipes manually recipes.add(SlimefunItems.SIFTED_ORE); recipes.add(SlimefunItems.IRON_DUST); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java index 6e00d584e..f2de2473b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java @@ -26,7 +26,7 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.api.Slimefun; /** - * This {@link Listener} handles the collecton of drops from an {@link Entity} that was + * This {@link Listener} handles the collection of drops from an {@link Entity} that was * killed by a {@link ButcherAndroid}. * * @author TheBusyBiscuit diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java index b88085838..e084cb084 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java @@ -98,7 +98,7 @@ public class DebugFishListener implements Listener { sendInfo(p, b); } catch (Exception x) { - Slimefun.getLogger().log(Level.SEVERE, "An Exception occured while using a Debug-Fish", x); + Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while using a Debug-Fish", x); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java index 7f8dba7a0..8a95420e5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java @@ -31,7 +31,7 @@ public class VillagerTradingListener implements Listener { } @EventHandler(ignoreCancelled = true) - public void onPreBrew(InventoryClickEvent e) { + public void onPreTrade(InventoryClickEvent e) { Inventory clickedInventory = e.getClickedInventory(); Inventory topInventory = e.getView().getTopInventory(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java index 57324b8ae..3b7f3584f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java @@ -12,8 +12,8 @@ class UraniumResource extends SlimefunResource { } @Override - public int getDefaultSupply(Environment envionment, Biome biome) { - if (envionment == Environment.NORMAL) { + public int getDefaultSupply(Environment environment, Biome biome) { + if (environment == Environment.NORMAL) { return 5; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java index d4188abf4..1ece100a1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java @@ -32,7 +32,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link ArmorTask} is responsible for handling {@link PotionEffect PotionEffects} for * {@link Radioactive} items or any {@link SlimefunArmorPiece}. - * It also handles the prevention of radioation through a Hazmat Suit + * It also handles the prevention of radiation through a Hazmat Suit * * @author TheBusyBiscuit * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java index d9c439772..5731622f1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java @@ -57,7 +57,7 @@ public class SlimefunStartupTask implements Runnable { new BlockStorage(world); } catch (Exception x) { - Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occured while trying to load World \"" + world.getName() + "\" for Slimefun v" + SlimefunPlugin.getVersion()); + Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while trying to load World \"" + world.getName() + "\" for Slimefun v" + SlimefunPlugin.getVersion()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index 64a2ffb13..2fc7f82db 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -132,7 +132,7 @@ public class TickerTask implements Runnable { } } catch (ArrayIndexOutOfBoundsException | NumberFormatException x) { - Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception has occured while trying to parse Chunk: " + chunk); + Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception has occurred while trying to parse Chunk: " + chunk); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java index 9e315fe81..6c0f4adcb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java @@ -16,7 +16,7 @@ import org.bukkit.entity.Firework; import org.bukkit.inventory.meta.FireworkMeta; /** - * This is a simple utility classs for spawning random and colorful {@link Firework} rockets. + * This is a simple utility class for spawning random and colorful {@link Firework} rockets. * * @author TheBusyBiscuit * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java index ef0dbbd3e..696d548ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java @@ -24,7 +24,7 @@ import org.bukkit.inventory.meta.ItemMeta; */ public final class ItemStackWrapper extends ItemStack { - private static final String ERROR_MESSAGE = "ItemStackWrappers are immutable and not indended for actual usage."; + private static final String ERROR_MESSAGE = "ItemStackWrappers are immutable and not intended for actual usage."; private final ItemMeta meta; private final int amount; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index 7520c71c3..b70654d26 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -564,14 +564,14 @@ public class SlimefunItem implements Placeable { * This sets whether or not this {@link SlimefunItem} is allowed to be * used in a normal Crafting Table. * - * @param useable + * @param usable * Whether this {@link SlimefunItem} should be useable in a workbench * * @return This instance of {@link SlimefunItem} */ @Nonnull - public SlimefunItem setUseableInWorkbench(boolean useable) { - this.useableInWorkbench = useable; + public SlimefunItem setUseableInWorkbench(boolean usable) { + this.useableInWorkbench = usable; return this; } @@ -717,7 +717,7 @@ public class SlimefunItem implements Placeable { } /** - * This method returns the wiki page that has been asigned to this item. + * This method returns the wiki page that has been assigned to this item. * It will return null, if no wiki page was found. * * @see SlimefunItem#addOficialWikipage(String) @@ -888,7 +888,7 @@ public class SlimefunItem implements Placeable { for (SlimefunItem sfi : SlimefunPlugin.getRegistry().getAllSlimefunItems()) { if (sfi.isItem(wrapper)) { // If we have to loop all items for the given item, then at least - // set the id via PersistenDataAPI for future performance boosts + // set the id via PersistentDataAPI for future performance boosts SlimefunPlugin.getItemDataService().setItemData(item, sfi.getID()); return sfi; diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java index aadef5254..94cacd965 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java @@ -59,7 +59,7 @@ class TestSlimefunGuideListener { /** * This returns an {@link Arguments} {@link Stream} of boolean combinations. - * It performs a certesian product on two boolean sets. + * It performs a cartesian product on two boolean sets. * * @return a {@link Stream} of {@link Arguments} */ diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java index 71ca41ca3..a36b616f1 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java @@ -258,7 +258,7 @@ public class TestVanillaMachinesListener { } @Test - public void testBrewingithVanillaItem() { + public void testBrewingWithVanillaItem() { VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.BLAZE_POWDER, true); item.register(plugin); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVillagerTradingListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVillagerTradingListener.java index ebcc2c629..64961661d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVillagerTradingListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVillagerTradingListener.java @@ -56,7 +56,7 @@ class TestVillagerTradingListener { InventoryView view = player.openInventory(inv); view.setCursor(item); InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE); - listener.onPreBrew(event); + listener.onPreTrade(event); return event; } From acd26b68dd341a22d506b4b906603dd67a526791 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:29:23 +0200 Subject: [PATCH 028/163] We can use useable anyway --- .../slimefun4/core/services/BlockDataService.java | 2 +- .../slimefun4/implementation/items/VanillaItem.java | 2 +- .../Slimefun/Objects/SlimefunItem/SlimefunItem.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java index 809d3f336..5fcb9face 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java @@ -74,7 +74,7 @@ public class BlockDataService implements PersistentDataService, Keyed { /** * This method checks whether the given {@link Material} is a Tile Entity. * This is used to determine whether the {@link Block} produced by this {@link Material} - * produces a {@link TileState}, making it usable as a {@link PersistentDataHolder}. + * produces a {@link TileState}, making it useable as a {@link PersistentDataHolder}. * * Due to {@link Block#getState()} being a very expensive call performance-wise though, * this simple lookup method is used instead. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java index abaf92d2a..166a9b371 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java @@ -17,7 +17,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * automatically * replace it in the recipes by its vanilla equivalent. * - * A {@link VanillaItem} is also automatically usable in workbenches. + * A {@link VanillaItem} is also automatically useable in workbenches. * * @author TheBusyBiscuit * diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index b70654d26..1800613fa 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -564,14 +564,14 @@ public class SlimefunItem implements Placeable { * This sets whether or not this {@link SlimefunItem} is allowed to be * used in a normal Crafting Table. * - * @param usable + * @param useable * Whether this {@link SlimefunItem} should be useable in a workbench * * @return This instance of {@link SlimefunItem} */ @Nonnull - public SlimefunItem setUseableInWorkbench(boolean usable) { - this.useableInWorkbench = usable; + public SlimefunItem setUseableInWorkbench(boolean useable) { + this.useableInWorkbench = useable; return this; } From 3fcc7fafacebabc75d89080744dfba07e4c5c13c Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 12 Sep 2020 14:50:22 +0200 Subject: [PATCH 029/163] Fixed colors & functionality of cheat sheet --- .../listeners/SlimefunGuideListener.java | 11 ++++++++--- .../slimefun4/utils/itemstack/SlimefunGuideItem.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 879a10025..363f6ca0c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -62,9 +62,14 @@ public class SlimefunGuideListener implements Listener { } } else if (openGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { - // We rather just run the command here, - // all necessary permission checks will be handled there. - p.chat("/sf cheat"); + if (!p.isSneaking()) { + // We rather just run the command here, + // all necessary permission checks will be handled there. + p.chat("/sf cheat"); + } + else { + SlimefunGuideSettings.openSettings(p, e.getItem()); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java index 78bff2c33..2cb93cf15 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java @@ -33,7 +33,7 @@ public class SlimefunGuideItem extends ItemStack { meta.setDisplayName(ChatColors.color(name)); List lore = new LinkedList<>(); - lore.add(implementation instanceof CheatSheetSlimefunGuide ? "&4&lOnly openable by Admins" : ""); + lore.add(implementation instanceof CheatSheetSlimefunGuide ? ChatColors.color("&4&lOnly openable by Admins") : ""); lore.add(ChatColors.color("&eRight Click &8\u21E8 &7Browse Items")); lore.add(ChatColors.color("&eShift + Right Click &8\u21E8 &7Open Settings / Credits")); From 03f7e64107424328c95c9d2b33a0105a3bf7f305 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 12 Sep 2020 14:50:22 +0200 Subject: [PATCH 030/163] Fixed colors & functionality of cheat sheet --- .../listeners/SlimefunGuideListener.java | 11 ++++++++--- .../slimefun4/utils/itemstack/SlimefunGuideItem.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 879a10025..9e15f33f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -62,9 +62,14 @@ public class SlimefunGuideListener implements Listener { } } else if (openGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { - // We rather just run the command here, - // all necessary permission checks will be handled there. - p.chat("/sf cheat"); + if (p.isSneaking()) { + SlimefunGuideSettings.openSettings(p, e.getItem()); + } + else { + // We rather just run the command here, + // all necessary permission checks will be handled there. + p.chat("/sf cheat"); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java index 78bff2c33..2cb93cf15 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java @@ -33,7 +33,7 @@ public class SlimefunGuideItem extends ItemStack { meta.setDisplayName(ChatColors.color(name)); List lore = new LinkedList<>(); - lore.add(implementation instanceof CheatSheetSlimefunGuide ? "&4&lOnly openable by Admins" : ""); + lore.add(implementation instanceof CheatSheetSlimefunGuide ? ChatColors.color("&4&lOnly openable by Admins") : ""); lore.add(ChatColors.color("&eRight Click &8\u21E8 &7Browse Items")); lore.add(ChatColors.color("&eShift + Right Click &8\u21E8 &7Open Settings / Credits")); From f5635809806f9e005e34ca1527e3855207cfcb9e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 15:44:53 +0200 Subject: [PATCH 031/163] Added Hacktoberfest Issue template --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/hacktoberfest-issue.md diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md new file mode 100644 index 000000000..041908264 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -0,0 +1,58 @@ +--- +name: Hacktoberfest Issue +about: "- DO NOT USE - Please post your suggestions on discord and we will create + an issue for you if applicable." +title: '' +labels: Hacktoberfest +assignees: '' + +--- + + + + + + +This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/).
+A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt! + +## :mag_right: Scope +The following bullet points explain what the scope of this feature should be. +It should give a general idea of what we want, you can of course deviate from this as needed. + + + +### :anchor: Difficulty +Here is our honest estimate on how difficult (on a scale of 1-5) the implementation may be: + + +:white_circle::white_circle::white_circle::white_circle::white_circle: + +## :construction: Technical Challenges +These are some challenges which may need to be overcome, we wanna be as transparent as possible, so here is some guidance on what may present itself as an obstacle. + + + +## :memo: Relevant Classes or Snippets +Here are some classes or code snippets which we think might help you get a better understanding where to look for in this gigantic codebase + + + +## :book: Useful Resources +If you need help on how to get started, maybe try looking into the following resources! + +* Hacktoberfest + * [Getting started with Hacktoberfest](https://hacktoberfest.digitalocean.com/details#get-started) + * [Hacktoberfest FAQ](https://hacktoberfest.digitalocean.com/faq) +* GitHub/Open-Source + * [How to contribute to Open-Source](https://opensource.guide/how-to-contribute/) + * [Working with forks](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) + * [Creating a Pull Request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) +* Slimefun + * [Contributing to Slimefun](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md) + * [Code of Conduct](https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md) + +


+ +If you want to work on this, simply comment down below and state your interests! Please also comment again if you have changed your mind. Anyone is allowed to discuss in the comments below, feel free to collaborate and work together :heart:
+You can always ask for help here if you get stuck. From 6c442125eb6d1da38e2c95109c0c21d6ccfcaa8d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 15:49:23 +0200 Subject: [PATCH 032/163] Update hacktoberfest-issue.md --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 041908264..9606d008e 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -25,7 +25,7 @@ It should give a general idea of what we want, you can of course deviate from th ### :anchor: Difficulty Here is our honest estimate on how difficult (on a scale of 1-5) the implementation may be: - + :white_circle::white_circle::white_circle::white_circle::white_circle: ## :construction: Technical Challenges From 238be74da3d25199df753a1eb3612f04b561b11f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 15:51:15 +0200 Subject: [PATCH 033/163] Update hacktoberfest-issue.md --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 9606d008e..40d86dd1e 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -22,7 +22,7 @@ It should give a general idea of what we want, you can of course deviate from th -### :anchor: Difficulty +## :anchor: Difficulty Here is our honest estimate on how difficult (on a scale of 1-5) the implementation may be: From e22db45fbb2139e389b4a51b5347ed7e69c2a094 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 15:54:46 +0200 Subject: [PATCH 034/163] Update hacktoberfest-issue.md --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 40d86dd1e..414961156 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -13,8 +13,7 @@ assignees: '' -This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/).
-A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt! +This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt! ## :mag_right: Scope The following bullet points explain what the scope of this feature should be. From 1d7403f523ff61e3e4a718fb6b79a2236f253c03 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 15:59:52 +0200 Subject: [PATCH 035/163] Update hacktoberfest-issue.md --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 414961156..7cf871c88 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -10,7 +10,7 @@ assignees: '' - + This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt! From efea4b25537f0577cf9002e3db78f7bbc89d8337 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 16:09:36 +0200 Subject: [PATCH 036/163] #TeamTrees --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 7cf871c88..7ec58b887 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -13,7 +13,7 @@ assignees: '' -This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt! +This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt or plant a tree! ## :mag_right: Scope The following bullet points explain what the scope of this feature should be. From a9dd96c07bfcc246391c5e0e6488e823742b8ebb Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 16:22:42 +0200 Subject: [PATCH 037/163] [CI skip] Updated hacktoberfest template --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 7ec58b887..5e898bd67 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -13,7 +13,7 @@ assignees: '' -This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests** to any public open-source project on GitHub and earn a limited-edition T-shirt or plant a tree! +This Issue is part of [Hacktoberfest](https://hacktoberfest.digitalocean.com/) - A yearly event which encourages participation in the open-source community. [Sign up on their website](https://hacktoberfest.digitalocean.com/) and submit **four pull requests during october (Oct 1st - Oct 31st)** to any public open-source project on GitHub and earn a limited-edition T-shirt or plant a tree! ## :mag_right: Scope The following bullet points explain what the scope of this feature should be. From 611465ab3573a54e9a2164364e71dfb8dabb1265 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 12 Sep 2020 16:24:15 +0200 Subject: [PATCH 038/163] [CI skip] Updated action --- .github/workflows/close-invalid-issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-invalid-issues.yml b/.github/workflows/close-invalid-issues.yml index 1760338b9..7122b36cf 100644 --- a/.github/workflows/close-invalid-issues.yml +++ b/.github/workflows/close-invalid-issues.yml @@ -10,7 +10,7 @@ jobs: name: Invalid Issues runs-on: ubuntu-latest - if: contains(github.event.issue.labels.*.name, 'Bug Report') == false + if: contains(github.event.issue.labels.*.name, 'Bug Report') == false && contains(github.event.issue.labels.*.name, 'Hacktoberfest') == false steps: - name: Close Issue uses: maxkomarychev/octions/octions/issues/update@master From ebdb29536490165fcde5991e90478473e993c6cb Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 12 Sep 2020 22:23:28 +0000 Subject: [PATCH 039/163] Update dependency com.github.seeseemelk:MockBukkit-v1.16 to v0.5.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a058ba564..1c3570737 100644 --- a/pom.xml +++ b/pom.xml @@ -309,7 +309,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.5.0 + 0.5.2 test From d0434de4d529aaea8b590bd2974103580f2dc2a5 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 09:38:41 +0200 Subject: [PATCH 040/163] [CI skip] Added emojis to CONTRIBUTING.md --- .github/CONTRIBUTING.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 41c2c0e94..37ad73101 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,7 +3,7 @@ This document outlines various ways how you can help contribute to Slimefun and All contributions must be inline with our [Code of Conduct](https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md) and [License](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE). Please also follow the templates for Issues and Pull Requests we provide. -## 1. Issues: Bug Reports +## :beetle: 1. Issues: Bug Reports One of the foundations for good software is reliability. To facilitate this reliability, our community must work together to crush bugs that arise. This of course requires good information and knowledge about ongoing bugs and issues though. @@ -15,7 +15,7 @@ If you encounter an issue which has already been reported, please don't open a n It would be awesome though if you could post a comment on the existing issue which explains how you were able to reproduce this yourself. The more context and information we get, the easier we can fix it. -## 2. Pull Requests: Bug Fixes +## :hammer_and_wrench: 2. Pull Requests: Bug Fixes Bugs that have been reported need to be fixed of course.
Any open Issue on our [Issues Tracker](https://github.com/Slimefun/Slimefun4/issues) is waiting to be fixed. @@ -23,7 +23,7 @@ This is an Open-Source project and we love Pull Requests. So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun/Slimefun4/pulls) which fixes this bug. You can also comment on the existing Issue, proposing your idea or communicating that you wanna work on this. -## 3. Pull Requests: Additions/Changes +## :toolbox: 3. Pull Requests: Additions/Changes Slimefun is an Open-Source project and anyone is allowed to make changes or add content to this plugin! Please visit our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and share your ideas first, we hate to reject changes because the community disagrees.
@@ -36,7 +36,7 @@ Therefore our `#approved` is a great place to start looking for ideas on what to Also consider making an addon for your additions when they get too large, too abstract or too "niche". You can check out our [Developer Guide](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide) for a guide on how to create a Slimefun addon.. -## 4. Pull Requests: Translations +## :earth_africa: 4. Pull Requests: Translations Another great way to contribute to Slimefun is by working on translations for the project. Slimefun's translation is available on [gitlocalize.com](https://gitlocalize.com/repo/3841). Just find a language you are fluent in and translate away. But make sure to submit a "Review Request" when you are done. @@ -48,7 +48,7 @@ Language Moderators are responsible for proof-reading any new translations for t For more info on how or what to translate, check out our article on [How to translate Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun). -## 5. Pull Requests: Wiki contributions +## :scroll: 5. Pull Requests: Wiki contributions Slimefun is a very large project and might be quite intimidating for new players. That's why good documentation is always nice and helpful. If you have played with Slimefun for a while and gotten yourself familiar with how things work, please consider contributing your experiences and knowledge to others via the wiki! @@ -57,7 +57,7 @@ It would help out a lot :heart: You can find a tutorial on how to contribute to our wiki right here:
https://github.com/Slimefun/Slimefun4/wiki/Expanding-the-Wiki -## 6. Pull Requests: Code Quality +## :star: 6. Pull Requests: Code Quality Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) to monitor Code Quality. We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) is a great place to start. From 0c7597f3c933e8076e0548f95435e39ad2219a65 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 09:40:54 +0200 Subject: [PATCH 041/163] [CI skip] Added emojis to Code of Conduct --- .github/CODE_OF_CONDUCT.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index ea3ea2c67..1bfbe1872 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -6,14 +6,14 @@ This document should serve the purpose of outlining the behaviour we expect from any participant of the project. -## Scope +## :mag_right: Scope This Code of Conduct applies to all sections of the [Slimefun4 GitHub repository](https://github.com/Slimefun/Slimefun4), our [Slimefun GitHub organization](https://github.com/Slimefun) and all repositories owned by said organization.
For our official Discord server, please refer to our article on [Discord Rules](https://github.com/Slimefun/Slimefun4/wiki/Discord-Rules). Everyone who engages with this project on any of these repositories is expected to follow the Code of Conduct.
This includes maintainers, contributors, sponsors and anyone who engages in the "Issues" section on GitHub. -## Engagement +## :loudspeaker: Engagement This is an Open-Source project, anyone is welcome to engage and contribute!
We generally expect users to engage in the Issues section by reporting bugs or commenting on bug reports to give additional context, help, guidance or to propose possible solutions and fixes. Pull Requests are very much welcome and encouraged! They keep the project alive, so if you see an Issue and know how to fix it, feel free to create a Pull Request! @@ -24,7 +24,7 @@ And even if you shouldn't know where to start or how to proceed, our [Discord Se When commenting, please keep in mind that this software is offered for **free**. Don't expect to receive lightning-fast replies 24 hours a day. Everyone here works on this project in their free time and usually has work, school, university or family to take care of, so we appreciate patience and understanding. -## Our Standards +## :scroll: Our Standards Examples of behavior that contributes to a positive environment for our community include but are not limited to: * Demonstrating empathy and kindness towards other people * Being respectful of differing opinions, viewpoints, and experiences @@ -43,7 +43,7 @@ Examples of unacceptable behavior include but are not limited to: * Impatient, aggresive and toxic behaviour * Other conduct which could reasonably be considered inappropriate in a professional setting -## Enforcement Responsibilities +## :round_pushpin: Enforcement Responsibilities Our project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, @@ -57,7 +57,7 @@ decisions when appropriate. You can see a list of people who are recognized as "project maintainers" for Slimefun on the Slimefun GitHub organization:
https://github.com/orgs/Slimefun/people -## Enforcement +## :wrench: Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders (labelled on Discord as "Admins" or "Moderators") responsible for enforcement on our [Discord Server](https://github.com/Slimefun/Slimefun4#discord). If you want your issue to be handled discreetly, message `TheBusyBiscuit#2610` or `Walshy#9709` privately on Discord and state your concerns. @@ -66,7 +66,7 @@ All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. -## Attribution +## :balance_scale: Attribution This Code of Conduct is a **modified version** of the original [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. From 5d81808cbab1a8ddb9f7b4eef59bc14d9edaa348 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 09:44:35 +0200 Subject: [PATCH 042/163] [Ci skip] Added emojis to bug reporting template --- .github/ISSUE_TEMPLATE/bug-report.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 8c869ff27..9a8cff0f4 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -9,37 +9,37 @@ assignees: '' -## Description (REQUIRED) +## :round_pushpin: Description (REQUIRED) -## Steps to reproduce the Issue (REQUIRED) +## :bookmark_tabs: Steps to reproduce the Issue (REQUIRED) -## Expected behavior (REQUIRED) +## :bulb: Expected behavior (REQUIRED) -## Server Log +## :scroll: Server Log -## Error Reports +## :open_file_folder: Error Reports -## Environment (REQUIRED) +## :compass: Environment (REQUIRED) From 59ef5249124e2a85226fe7ce61efa508d88e75e4 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 11:23:38 +0200 Subject: [PATCH 043/163] Updated pom.xml --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index a058ba564..5932f92fc 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.8 - 1.16.2 + 1.16.3 https://hub.spigotmc.org/javadocs/spigot/ @@ -48,10 +48,6 @@ - - jitpack.io - https://jitpack.io - spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ @@ -60,6 +56,10 @@ paper-repo https://papermc.io/repo/repository/maven-public/ + + jitpack.io + https://jitpack.io + worldedit-repo https://maven.sk89q.com/repo/ From 8838ab0963d7c93a02a7410c4b4cc88194e30f16 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 11:37:07 +0200 Subject: [PATCH 044/163] [CI skip] Lock CS-CoreLib version --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84dd916b8..bb9b92267 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It currently adds over **500 new items and recipes** to Minecraft ([Read more ab But it also comes with a lot of Addons too!
Check out our [Addons](https://github.com/Slimefun/Slimefun4/wiki/Addons), you may find exactly what you were looking for. -### Quick navigation +### :compass: Quick navigation * **[Download Slimefun4](#download-slimefun-4)** * **[Screenshots](#screenshots)** * **[Discord Support Server](#discord)** diff --git a/pom.xml b/pom.xml index 80cfe8630..f9d6cbed5 100644 --- a/pom.xml +++ b/pom.xml @@ -287,7 +287,7 @@ com.github.TheBusyBiscuit CS-CoreLib - 31390302cf + 1.7 provided From 7b10410a70a6787d13e63128bc30b32b989ada30 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 11:38:04 +0200 Subject: [PATCH 045/163] [Ci skip] A small change --- .../AsyncMachineProcessCompleteEvent.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java index 61babfd83..3091980e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java @@ -1,13 +1,14 @@ package io.github.thebusybiscuit.slimefun4.api.events; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.block.Block; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; /** * This {@link Event} is fired whenever an {@link AContainer} has completed its process. @@ -17,7 +18,7 @@ import javax.annotation.ParametersAreNonnullByDefault; */ public class AsyncMachineProcessCompleteEvent extends Event { - private static final HandlerList handlerList = new HandlerList(); + private static final HandlerList handlers = new HandlerList(); private final Block block; private final MachineRecipe machineRecipe; @@ -25,7 +26,7 @@ public class AsyncMachineProcessCompleteEvent extends Event { @ParametersAreNonnullByDefault public AsyncMachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { super(true); - + this.block = block; this.machineRecipe = machineRecipe; } @@ -52,12 +53,12 @@ public class AsyncMachineProcessCompleteEvent extends Event { @Nonnull public static HandlerList getHandlerList() { - return handlerList; + return handlers; } @Nonnull @Override public HandlerList getHandlers() { - return handlerList; + return getHandlerList(); } } From 20c3835fc1b08d224fbc7998589d8313683e5f75 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:26:12 +0200 Subject: [PATCH 046/163] [CI skip] Updated README and CONTRIBUTING files --- .github/CONTRIBUTING.md | 18 +++++++++++++++- README.md | 46 ++++------------------------------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 37ad73101..5d729a0ed 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -15,6 +15,22 @@ If you encounter an issue which has already been reported, please don't open a n It would be awesome though if you could post a comment on the existing issue which explains how you were able to reproduce this yourself. The more context and information we get, the easier we can fix it. +## :toolbox: How to compile Slimefun4 +Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.
+To compile Slimefun yourself, follow these steps: + +1. Clone the project via git
+`$ git clone https://github.com/Slimefun/Slimefun4/` +2. Compile the project using Maven
+`$ mvn clean package` +3. Extract the compiled `Slimefun-v4.X-UNOFFICIAL.jar` from your `/target/` directory. + +If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. +Then you should be able build it via Maven using the goals `clean package`. + +If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel. +**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. + ## :hammer_and_wrench: 2. Pull Requests: Bug Fixes Bugs that have been reported need to be fixed of course.
Any open Issue on our [Issues Tracker](https://github.com/Slimefun/Slimefun4/issues) is waiting to be fixed. @@ -23,7 +39,7 @@ This is an Open-Source project and we love Pull Requests. So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun/Slimefun4/pulls) which fixes this bug. You can also comment on the existing Issue, proposing your idea or communicating that you wanna work on this. -## :toolbox: 3. Pull Requests: Additions/Changes +## :wrench: 3. Pull Requests: Additions/Changes Slimefun is an Open-Source project and anyone is allowed to make changes or add content to this plugin! Please visit our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and share your ideas first, we hate to reject changes because the community disagrees.
diff --git a/README.md b/README.md index bb9b92267..4e1a17550 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Check out our [Addons](https://github.com/Slimefun/Slimefun4/wiki/Addons), you m * **[Bug Tracker](https://github.com/Slimefun/Slimefun4/issues)** * **[Wiki](https://github.com/Slimefun/Slimefun4/wiki)** * **[FAQ](https://github.com/Slimefun/Slimefun4/wiki/FAQ)** +* **[How to contribute](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md)** ## Download Slimefun 4 (See also: [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun)) @@ -66,7 +67,7 @@ Well, we asked some users on our [Discord server](#discord) to send us some scre | *Screenshot provided by GalaxyKat11#3816* | *Screenshot provided by TamThan#7987* | *Screenshot provided by Kilaruna#4981* | ## Discord -You can find Slimefun's community on Discord and connect with **over 2000** users of this plugin from all over the world.
+You can find Slimefun's community on Discord and connect with **over 2500** users of this plugin from all over the world.
Click the badge down below to join the server for suggestions/questions or other discussions about this plugin.
We are also hosting a community event every so often, join us to find out more.
**Important**: We do **not** accept bug reports on discord, please use our [Issue Tracker](https://github.com/Slimefun/Slimefun4/issues) to submit bug reports! @@ -102,49 +103,10 @@ The wiki is entirely community-run, so if you find an article missing, feel free ## Contributing to this project Slimefun 4 is an Open-Source project and licensed under [GNU GPLv3](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE).
-Over 100 people have already contributed to this amazing project. You guys are awesome.
+Over 150+ people have already contributed to this amazing project. You guys are awesome.
Please consider helping us maintain this project too, your engagement keeps the project alive <3. -### Translations -Slimefun4 has recently added support for translations, note that translations are still _work in progress_.
-So not everything may be available for translation yet.
-[Read more...](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun) - -### Pull requests -This is an open-source community project, so **your contributions keep this plugin alive!**
-Pull Requests can be fixes, changes or even additions, but please keep in mind that if you add too much content to Slimefun 4, you should maybe consider making an Addon for it instead ([Developer Guide](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide)). - -#### Compiling -Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.
-To compile Slimefun yourself, follow these steps: - -1. Clone the project via git
-`$ git clone https://github.com/Slimefun/Slimefun4/` -2. Compile the project using Maven
-`$ mvn clean package` - -If you are already using an IDE, make sure to import the project via git and set it as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`. - -If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel. Note that we will not accept any bug reports from custom-compiled versions of Slimefun. - -### Code Quality -Slimefun uses [Sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) to monitor Code Quality. - -| [Overall Maintainability](https://sonarcloud.io/documentation/user-guide/metric-definitions/#maintainability) | "Code Smells" | "Technical Debt" | Test Coverage | -| ---- | ---- | ---- | ---- | -| [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=code_smells)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=sqale_index)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=coverage)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | - -##### "Code Smells" -Code Smells are portions of the source code that are confusing, lack documentation or are just done very badly in general. These code smells should be held to a bare minimum. - -_Please contact us on [Discord](#discord) before working on any code smells. Some design patterns may not be changed abruptly because an addon might depend on them._ - -##### "Technical Debt" -Technical Debt is basically an estimate for how long it would take to fix all issues and code smells. - -##### Test Coverage -Slimefun now also uses Automated Tests to determine whether an update could break something. The coverage shows how much these tests cover. Higher coverage means less breaking changes and as a result also better and more reliable builds. -Due to this being a very huge project though, getting to `100% coverage` is probably close to impossible. But increasing that number even slightly still helps. So feel free to write Unit Tests for Slimefun and place them in the [/src/test/java/](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java) folder. +You can find more info on how to contribute to this project in our [CONTRIBUTING.md](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md). ## Disclaimers Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project. From 1e408665a759fc8504177aa00953eb2524b11580 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:32:30 +0200 Subject: [PATCH 047/163] [Ci skip] Removed deprecated method --- .../listeners/BlockListener.java | 7 ------- .../Objects/SlimefunBlockHandler.java | 19 ------------------- 2 files changed, 26 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index f01d2a22b..2089e28b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -83,13 +83,6 @@ public class BlockListener implements Listener { } BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true); - - SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID()); - - if (blockHandler != null) { - blockHandler.onPlace(e.getPlayer(), e.getBlock(), sfItem); - } - sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e)); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java index d69c6eb65..2fcce02eb 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunBlockHandler.java @@ -4,7 +4,6 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; @@ -22,24 +21,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; @FunctionalInterface public interface SlimefunBlockHandler { - /** - * This method gets called when the {@link Block} is placed. - * Use this method to initialize block data. - * - * @deprecated Use a {@link BlockPlaceHandler} instead - * - * @param p - * The {@link Player} who placed it - * @param b - * The {@link Block} that was placed - * @param item - * The {@link SlimefunItem} that will be stored inside the {@link Block} - */ - @Deprecated - default void onPlace(Player p, Block b, SlimefunItem item) { - // This has been deprecated - } - /** * This method gets called when the {@link Block} is broken. * The {@link Player} will be null if the {@link Block} exploded From 04105b1b47f06b27ed387aad4be9eade0c2e5b39 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:37:01 +0200 Subject: [PATCH 048/163] [CI skip] Added a line-break --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5d729a0ed..b95b5d7cc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -28,7 +28,7 @@ To compile Slimefun yourself, follow these steps: If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`. -If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel. +If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel.
**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. ## :hammer_and_wrench: 2. Pull Requests: Bug Fixes From 817ec43153283eba0fc89ec19b86723fda085406 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:38:13 +0200 Subject: [PATCH 049/163] [CI skip] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9637aa0..dcbaef565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ #### Fixes * Fixed #2300 * Fixed #2296 +* Fixed colors of Cheat Sheet Slimefun Guide +* Fixed Cheat Sheet Slimefun Guide being unable to open the settings menu via shift + right click ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From fe0395991e12b8e8236cac5915f2ddeeffd6a536 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 12:41:32 +0200 Subject: [PATCH 050/163] [CI skip] Updated contributing guidelines --- .github/CONTRIBUTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b95b5d7cc..748538680 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -82,8 +82,9 @@ To prevent any accidents from happening, please contact us on our [Discord Serve #### Documentation Code documentation is also a great way to improve the maintainability of the project. -Every class and every public method should have a Javadocs tag assigned to it. -Classes should also include an "author" tag to indicate who worked on that class. +1. Every class and every public method should have a Javadocs section assigned to it. +2. Classes should also include an `@author` tag to indicate who worked on that class. +3. Methods and parameters should be annotated with `@Nullable` or `@Nonnull` to indicate whether or not null values are accepted. Feel free to visit our [Javadocs](https://slimefun.github.io/javadocs/Slimefun4/docs/overview-summary.html) @@ -92,4 +93,4 @@ Unit Tests help us test the project to work as intended in an automated manner.< More or better Unit Tests are always good to have, so feel free to submit a Test and place it in our [src/test/java](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java/io/github/thebusybiscuit/slimefun4/testing) directory We are using [Junit 5 - Jupiter](https://github.com/junit-team/junit5/) and [MockBukkit](https://github.com/seeseemelk/MockBukkit) as our testing environment.
-Every new Unit Test should have a "DisplayName" annotation with a plain text description on what the Unit Test tests. +Every new Unit Test should have a `@DisplayName` annotation with a plain text description on what the Unit Test tests. From df327efdcc232c3c07f3e4261e71e4f268030741 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 13 Sep 2020 14:41:54 +0000 Subject: [PATCH 051/163] Update dependency org.junit.jupiter:junit-jupiter to v5.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9d6cbed5..c70d0f6fd 100644 --- a/pom.xml +++ b/pom.xml @@ -303,7 +303,7 @@ org.junit.jupiter junit-jupiter - 5.6.2 + 5.7.0 test From 5b217246b6df1a0ed30082a8ec028e030a9ce238 Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Sun, 13 Sep 2020 17:48:48 +0200 Subject: [PATCH 052/163] fixed issue --- .../slimefun4/implementation/items/medical/MedicalSupply.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java index 243bb3d81..e619b5b8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java @@ -38,7 +38,7 @@ public abstract class MedicalSupply extends SimpleSlimefu if (n.hasPotionEffect(PotionEffectType.WEAKNESS)) n.removePotionEffect(PotionEffectType.WEAKNESS); if (n.hasPotionEffect(PotionEffectType.CONFUSION)) n.removePotionEffect(PotionEffectType.CONFUSION); if (n.hasPotionEffect(PotionEffectType.BLINDNESS)) n.removePotionEffect(PotionEffectType.BLINDNESS); - if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) n.removePotionEffect(PotionEffectType.BLINDNESS); + if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) n.removePotionEffect(PotionEffectType.BAD_OMEN); } /** From 19b95331d6929a6bffa0fdb095ad0120ebbe40bd Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 13 Sep 2020 23:55:16 +0300 Subject: [PATCH 053/163] Added fire tag. --- .../thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java index 0cdf91270..83bb966b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java @@ -45,6 +45,9 @@ public class MultiBlock { if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { SUPPORTED_TAGS.add(Tag.WOODEN_FENCES); } + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { + SUPPORTED_TAGS.add(Tag.FIRE); + } } @Nonnull From efe65bcd209f5d32ce0c6d5ea17ef82a9c905d50 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Mon, 14 Sep 2020 00:11:34 +0300 Subject: [PATCH 054/163] Fixed unit tests. --- .../github/thebusybiscuit/slimefun4/testing/TestUtilities.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java index 7abf1db96..bd963339c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -84,6 +84,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK, Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK); server.createMaterialTag(NamespacedKey.minecraft("corals"), Material.BRAIN_CORAL, Material.BUBBLE_CORAL, Material.FIRE_CORAL, Material.HORN_CORAL, Material.TUBE_CORAL); server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); + server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE); } } From 5fb1ca2b8e986e970b14ef9094614686d015e788 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 13 Sep 2020 23:38:29 +0200 Subject: [PATCH 055/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcbaef565..441a5d015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ * Fixed #2296 * Fixed colors of Cheat Sheet Slimefun Guide * Fixed Cheat Sheet Slimefun Guide being unable to open the settings menu via shift + right click +* Fixed #2320 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 3a0de6f800f2abcb262c37a89ec515a718a55537 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 14 Sep 2020 13:58:44 +0200 Subject: [PATCH 056/163] [CI skip] Updated issues template --- .github/ISSUE_TEMPLATE/bug-report.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 9a8cff0f4..8976c23d5 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -17,7 +17,7 @@ assignees: '' ## :bookmark_tabs: Steps to reproduce the Issue (REQUIRED) - + @@ -30,13 +30,13 @@ assignees: '' ## :scroll: Server Log - + -## :open_file_folder: Error Reports +## :open_file_folder: /error-reports/ Folder - + ## :compass: Environment (REQUIRED) From 824d524d9adc94c14f2e418280064223eed3fad7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 15 Sep 2020 21:47:54 +0000 Subject: [PATCH 057/163] Update dependency org.jacoco:jacoco-maven-plugin to v0.8.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c70d0f6fd..b096d7d7b 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 From 0e070a01c78f0075927e7cdeae8333d3e50957b6 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 17 Sep 2020 18:29:52 +0200 Subject: [PATCH 058/163] [CI skip] Updated contributing guidelines --- .github/CONTRIBUTING.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 748538680..816159b8a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -15,22 +15,6 @@ If you encounter an issue which has already been reported, please don't open a n It would be awesome though if you could post a comment on the existing issue which explains how you were able to reproduce this yourself. The more context and information we get, the easier we can fix it. -## :toolbox: How to compile Slimefun4 -Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.
-To compile Slimefun yourself, follow these steps: - -1. Clone the project via git
-`$ git clone https://github.com/Slimefun/Slimefun4/` -2. Compile the project using Maven
-`$ mvn clean package` -3. Extract the compiled `Slimefun-v4.X-UNOFFICIAL.jar` from your `/target/` directory. - -If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. -Then you should be able build it via Maven using the goals `clean package`. - -If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel.
-**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. - ## :hammer_and_wrench: 2. Pull Requests: Bug Fixes Bugs that have been reported need to be fixed of course.
Any open Issue on our [Issues Tracker](https://github.com/Slimefun/Slimefun4/issues) is waiting to be fixed. @@ -94,3 +78,19 @@ More or better Unit Tests are always good to have, so feel free to submit a Test We are using [Junit 5 - Jupiter](https://github.com/junit-team/junit5/) and [MockBukkit](https://github.com/seeseemelk/MockBukkit) as our testing environment.
Every new Unit Test should have a `@DisplayName` annotation with a plain text description on what the Unit Test tests. + +## :toolbox: How to compile Slimefun4 +Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.
+To compile Slimefun yourself, follow these steps: + +1. Clone the project via git
+`$ git clone https://github.com/Slimefun/Slimefun4/` +2. Compile the project using Maven
+`$ mvn clean package` +3. Extract the compiled `Slimefun-v4.X-UNOFFICIAL.jar` from your `/target/` directory. + +If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. +Then you should be able build it via Maven using the goals `clean package`. + +If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel.
+**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. From d79db00bf7d902d1058d9d7369c49dab78408e4c Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 18 Sep 2020 00:28:24 +0000 Subject: [PATCH 059/163] Update dependency org.mockito:mockito-core to v3.5.11 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b096d7d7b..3b8ebbf3c 100644 --- a/pom.xml +++ b/pom.xml @@ -323,7 +323,7 @@ org.mockito mockito-core - 3.5.10 + 3.5.11 test From 917bcce636afc6cd186e0ffb09d21332d3a7438b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 18 Sep 2020 10:48:36 +0200 Subject: [PATCH 060/163] Fixed an issue with ChestTerminal --- CHANGELOG.md | 1 + .../core/networks/cargo/ChestTerminalNetwork.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 441a5d015..0e4c7aa28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * Fixed colors of Cheat Sheet Slimefun Guide * Fixed Cheat Sheet Slimefun Guide being unable to open the settings menu via shift + right click * Fixed #2320 +* Fixed some issues with ChestTerminal ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index cdb6ea3ff..7ca0ccf21 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -15,6 +15,8 @@ import java.util.Set; import java.util.logging.Level; import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; @@ -296,7 +298,8 @@ abstract class ChestTerminalNetwork extends Network { try { for (Location l : terminals) { BlockMenu terminal = BlockStorage.getInventory(l); - int page = Integer.parseInt(BlockStorage.getLocationInfo(l, "page")); + String data = BlockStorage.getLocationInfo(l, "page"); + int page = data == null ? 1 : Integer.parseInt(data); if (!items.isEmpty() && items.size() < (page - 1) * TERMINAL_SLOTS.length + 1) { page = 1; @@ -325,13 +328,14 @@ abstract class ChestTerminalNetwork extends Network { return System.nanoTime() - timestamp; } } - + @Override public void markDirty(@Nonnull Location l) { connectorCache.remove(l); super.markDirty(l); } + @ParametersAreNonnullByDefault private void updateTerminal(Location l, BlockMenu terminal, int slot, int index, List items) { if (items.size() > index) { ItemStackAndInteger item = items.get(index); @@ -390,6 +394,7 @@ abstract class ChestTerminalNetwork extends Network { return items; } + @ParametersAreNonnullByDefault private void findAllItems(List items, Location l, Block target) { UniversalBlockMenu menu = BlockStorage.getUniversalInventory(target); @@ -422,6 +427,7 @@ abstract class ChestTerminalNetwork extends Network { } } + @ParametersAreNonnullByDefault private void gatherItemsFromBarrel(Location l, BlockMenu blockMenu, List items) { try { Config cfg = BlockStorage.getLocationInfo(blockMenu.getLocation()); @@ -457,13 +463,15 @@ abstract class ChestTerminalNetwork extends Network { } } + @ParametersAreNonnullByDefault private void handleWithdraw(DirtyChestMenu menu, List items, Location l) { for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) { filter(menu.getItemInSlot(slot), items, l); } } - private void filter(ItemStack stack, List items, Location node) { + @ParametersAreNonnullByDefault + private void filter(@Nullable ItemStack stack, List items, Location node) { if (stack != null && CargoUtils.matchesFilter(node.getBlock(), stack)) { boolean add = true; From fa1aad7bf8b118aa410bcd19317fc9964ecfbe47 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 19 Sep 2020 10:36:27 +0200 Subject: [PATCH 061/163] Added AsyncGeneratorProcessCompleteEvent --- .../AsyncGeneratorProcessCompleteEvent.java | 77 +++++++++++++++++++ .../abstractItems/AGenerator.java | 4 + 2 files changed, 81 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java new file mode 100644 index 000000000..b1787f351 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java @@ -0,0 +1,77 @@ +package io.github.thebusybiscuit.slimefun4.api.events; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +/** + * This {@link Event} is fired whenever an {@link AGenerator} has completed its process. + * + * @author poma123 + * + */ +public class AsyncGeneratorProcessCompleteEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + + private final Location location; + private final AGenerator generator; + private final MachineFuel machineFuel; + + @ParametersAreNonnullByDefault + public AsyncGeneratorProcessCompleteEvent(Location l, AGenerator generator, MachineFuel machineFuel) { + super(true); + + this.location = l; + this.generator = generator; + this.machineFuel = machineFuel; + } + + /** + * This returns the {@link Location} of the generator. + * + * @return The {@link Location} of the generator + */ + @Nonnull + public Location getLocation() { + return location; + } + + /** + * The {@link SlimefunItem} instance of the generator. + * + * @return The {@link SlimefunItem} instance of the generator + */ + @Nonnull + public AGenerator getGenerator() { + return generator; + } + + /** + * This returns the used {@link MachineFuel} in the process. + * + * @return The {@link MachineFuel} of the process + */ + @Nonnull + public MachineFuel getMachineFuel() { + return machineFuel; + } + + @Nonnull + public static HandlerList getHandlerList() { + return handlers; + } + + @Nonnull + @Override + public HandlerList getHandlers() { + return getHandlerList(); + } +} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index 41a20f16a..5164679ea 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems; import java.util.HashMap; import java.util.Map; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.api.events.AsyncGeneratorProcessCompleteEvent; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider; @@ -163,6 +165,8 @@ public abstract class AGenerator extends AbstractEnergyProvider { inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); + Bukkit.getPluginManager().callEvent(new AsyncGeneratorProcessCompleteEvent(l, AGenerator.this, getProcessing(l))); + progress.remove(l); processing.remove(l); return 0; From b98cdcf7d8a65508ab189044274ca0534b2310cf Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 19 Sep 2020 10:37:06 +0200 Subject: [PATCH 062/163] Added AsyncReactorProcessCompleteEvent --- .../AsyncReactorProcessCompleteEvent.java | 77 +++++++++++++++++++ .../items/electric/reactors/Reactor.java | 3 + 2 files changed, 80 insertions(+) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java new file mode 100644 index 000000000..3667f4392 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java @@ -0,0 +1,77 @@ +package io.github.thebusybiscuit.slimefun4.api.events; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +/** + * This {@link Event} is fired whenever a {@link Reactor} has completed its process. + * + * @author poma123 + * + */ +public class AsyncReactorProcessCompleteEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + + private final Location location; + private final Reactor reactor; + private final MachineFuel machineFuel; + + @ParametersAreNonnullByDefault + public AsyncReactorProcessCompleteEvent(Location l, Reactor reactor, MachineFuel machineFuel) { + super(true); + + this.location = l; + this.reactor = reactor; + this.machineFuel = machineFuel; + } + + /** + * This returns the {@link Location} of the reactor. + * + * @return The {@link Location} of the reactor + */ + @Nonnull + public Location getLocation() { + return location; + } + + /** + * The {@link SlimefunItem} instance of the reactor. + * + * @return The {@link SlimefunItem} instance of the reactor + */ + @Nonnull + public Reactor getReactor() { + return reactor; + } + + /** + * This returns the used {@link MachineFuel} in the process. + * + * @return The {@link MachineFuel} of the process + */ + @Nonnull + public MachineFuel getMachineFuel() { + return machineFuel; + } + + @Nonnull + public static HandlerList getHandlerList() { + return handlers; + } + + @Nonnull + @Override + public HandlerList getHandlers() { + return getHandlerList(); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java index 8a5ba74bb..98bc100e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java @@ -21,6 +21,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; +import io.github.thebusybiscuit.slimefun4.api.events.AsyncReactorProcessCompleteEvent; import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -376,6 +377,8 @@ public abstract class Reactor extends AbstractEnergyProvider { } } + Bukkit.getPluginManager().callEvent(new AsyncReactorProcessCompleteEvent(l, Reactor.this, getProcessing(l))); + progress.remove(l); processing.remove(l); } From 24a97c59d896dd83ff54a84c6cd6d86d2480ea85 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 19 Sep 2020 10:37:33 +0200 Subject: [PATCH 063/163] Refactoring --- .../AsyncMachineProcessCompleteEvent.java | 31 +++++++++++++------ .../abstractItems/AContainer.java | 4 +-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java index 3091980e4..ff59dd0fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java @@ -3,12 +3,13 @@ package io.github.thebusybiscuit.slimefun4.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.block.Block; +import org.bukkit.Location; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** * This {@link Event} is fired whenever an {@link AContainer} has completed its process. @@ -20,31 +21,43 @@ public class AsyncMachineProcessCompleteEvent extends Event { private static final HandlerList handlers = new HandlerList(); - private final Block block; + private final Location location; + private final AContainer container; private final MachineRecipe machineRecipe; @ParametersAreNonnullByDefault - public AsyncMachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) { + public AsyncMachineProcessCompleteEvent(Location l, AContainer container, MachineRecipe machineRecipe) { super(true); - this.block = block; + this.location = l; + this.container = container; this.machineRecipe = machineRecipe; } /** - * This method returns the {@link Block} of the machine. + * This returns the {@link Location} of the machine. * - * @return the {@link Block} of the machine + * @return The {@link Location} of the machine */ @Nonnull - public Block getMachine() { - return block; + public Location getLocation() { + return location; + } + + /** + * The {@link SlimefunItem} instance of the machine. + * + * @return The {@link SlimefunItem} instance of the machine + */ + @Nonnull + public AContainer getMachine() { + return container; } /** * This returns the used {@link MachineRecipe} in the process. * - * @return the {@link MachineRecipe} of the process. + * @return The {@link MachineRecipe} of the process */ @Nonnull public MachineRecipe getMachineRecipe() { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index 4dce26884..ee2617d7f 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -5,7 +5,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineProcessCompleteEvent; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -16,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineProcessCompleteEvent; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; @@ -253,7 +253,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, inv.pushItem(output.clone(), getOutputSlots()); } - Bukkit.getPluginManager().callEvent(new AsyncMachineProcessCompleteEvent(b, getProcessing(b))); + Bukkit.getPluginManager().callEvent(new AsyncMachineProcessCompleteEvent(b.getLocation(), AContainer.this, getProcessing(b))); progress.remove(b); processing.remove(b); From 749bb972a398aab739e7eaa3884df0f8801ed823 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 19 Sep 2020 11:51:02 +0200 Subject: [PATCH 064/163] [CI skip] Added a few more annotations --- .../slimefun4/core/attributes/EnergyNetProvider.java | 1 + .../thebusybiscuit/slimefun4/core/attributes/Placeable.java | 6 +++++- .../slimefun4/core/attributes/ProtectiveArmor.java | 5 +++++ .../thebusybiscuit/slimefun4/utils/FireworkUtils.java | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java index 6e2c7f0eb..db5a43982 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java @@ -28,6 +28,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; public interface EnergyNetProvider extends EnergyNetComponent { @Override + @Nonnull default EnergyNetComponentType getEnergyComponentType() { return EnergyNetComponentType.GENERATOR; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java index abd41a071..413490c7a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java @@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; import java.util.Collection; +import javax.annotation.Nonnull; + import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -18,9 +20,11 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; */ public interface Placeable { + @Nonnull Collection getDrops(); - Collection getDrops(Player p); + @Nonnull + Collection getDrops(@Nonnull Player p); /** * This method determines how to treat this {@link Block} when it is broken. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java index 8726ad7d0..f51c94378 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; @@ -29,6 +32,7 @@ public interface ProtectiveArmor extends ItemAttribute { * * @return The {@link ProtectionType}s. */ + @Nonnull ProtectionType[] getProtectionTypes(); /** @@ -44,5 +48,6 @@ public interface ProtectiveArmor extends ItemAttribute { * * @return The set {@link NamespacedKey}, null if none is found. */ + @Nullable NamespacedKey getArmorSetId(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java index 6c0f4adcb..c4f114ba4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java @@ -31,6 +31,7 @@ public final class FireworkUtils { createFirework(l, color); } + @Nonnull public static Firework createFirework(@Nonnull Location l, @Nonnull Color color) { Firework fw = (Firework) l.getWorld().spawnEntity(l, EntityType.FIREWORK); FireworkMeta meta = fw.getFireworkMeta(); @@ -56,10 +57,12 @@ public final class FireworkUtils { } } + @Nonnull public static FireworkEffect getRandomEffect(@Nonnull Random random, @Nonnull Color color) { return FireworkEffect.builder().flicker(random.nextBoolean()).withColor(color).with(random.nextBoolean() ? Type.BALL : Type.BALL_LARGE).trail(random.nextBoolean()).build(); } + @Nonnull private static Color getRandomColor() { return COLORS[ThreadLocalRandom.current().nextInt(COLORS.length)]; } From 8592051f8744e269d317dca0e69e0d1ab84c3fa7 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 19 Sep 2020 18:58:38 +0200 Subject: [PATCH 065/163] Requested changes --- .../AsyncGeneratorProcessCompleteEvent.java | 16 ++-------------- .../events/AsyncMachineProcessCompleteEvent.java | 9 ++++----- .../events/AsyncReactorProcessCompleteEvent.java | 16 ++-------------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java index b1787f351..f3a1c792d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncGeneratorProcessCompleteEvent.java @@ -17,33 +17,21 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * @author poma123 * */ -public class AsyncGeneratorProcessCompleteEvent extends Event { +public class AsyncGeneratorProcessCompleteEvent extends AsyncMachineProcessCompleteEvent { private static final HandlerList handlers = new HandlerList(); - private final Location location; private final AGenerator generator; private final MachineFuel machineFuel; @ParametersAreNonnullByDefault public AsyncGeneratorProcessCompleteEvent(Location l, AGenerator generator, MachineFuel machineFuel) { - super(true); + super(l, null, null); - this.location = l; this.generator = generator; this.machineFuel = machineFuel; } - /** - * This returns the {@link Location} of the generator. - * - * @return The {@link Location} of the generator - */ - @Nonnull - public Location getLocation() { - return location; - } - /** * The {@link SlimefunItem} instance of the generator. * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java index ff59dd0fb..02d9412df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineProcessCompleteEvent.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; +import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.event.Event; @@ -25,8 +25,7 @@ public class AsyncMachineProcessCompleteEvent extends Event { private final AContainer container; private final MachineRecipe machineRecipe; - @ParametersAreNonnullByDefault - public AsyncMachineProcessCompleteEvent(Location l, AContainer container, MachineRecipe machineRecipe) { + public AsyncMachineProcessCompleteEvent(@Nonnull Location l, @Nullable AContainer container, @Nullable MachineRecipe machineRecipe) { super(true); this.location = l; @@ -49,7 +48,7 @@ public class AsyncMachineProcessCompleteEvent extends Event { * * @return The {@link SlimefunItem} instance of the machine */ - @Nonnull + @Nullable public AContainer getMachine() { return container; } @@ -59,7 +58,7 @@ public class AsyncMachineProcessCompleteEvent extends Event { * * @return The {@link MachineRecipe} of the process */ - @Nonnull + @Nullable public MachineRecipe getMachineRecipe() { return machineRecipe; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java index 3667f4392..6a4dd9dfb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncReactorProcessCompleteEvent.java @@ -17,33 +17,21 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; * @author poma123 * */ -public class AsyncReactorProcessCompleteEvent extends Event { +public class AsyncReactorProcessCompleteEvent extends AsyncMachineProcessCompleteEvent { private static final HandlerList handlers = new HandlerList(); - private final Location location; private final Reactor reactor; private final MachineFuel machineFuel; @ParametersAreNonnullByDefault public AsyncReactorProcessCompleteEvent(Location l, Reactor reactor, MachineFuel machineFuel) { - super(true); + super(l, null, null); - this.location = l; this.reactor = reactor; this.machineFuel = machineFuel; } - /** - * This returns the {@link Location} of the reactor. - * - * @return The {@link Location} of the reactor - */ - @Nonnull - public Location getLocation() { - return location; - } - /** * The {@link SlimefunItem} instance of the reactor. * From 641def84813921c7f07de1721e83fcea75574425 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sat, 19 Sep 2020 21:43:52 -0400 Subject: [PATCH 066/163] Added Energized Capacitor (From Discord suggestion) --- .../slimefun4/implementation/SlimefunItems.java | 2 ++ .../slimefun4/implementation/setup/ResearchSetup.java | 2 +- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 9ddcea567..78fbd9b46 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -675,6 +675,8 @@ public final class SlimefunItems { public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&aBig Energy Capacitor", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &71024 J Capacity"); public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&aLarge Energy Capacitor", "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &78192 J Capacity"); public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity"); + public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity"); + /* Robots */ public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack("PROGRAMMABLE_ANDROID", HeadTexture.PROGRAMMABLE_ANDROID, "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index 7c6b97378..a0e19ca3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -175,7 +175,7 @@ public final class ResearchSetup { register("fuel", 165, "Fuel", 30, SlimefunItems.FUEL_BUCKET, SlimefunItems.REFINERY); register("hologram_projector", 166, "Holograms", 36, SlimefunItems.HOLOGRAM_PROJECTOR); register("capacitors", 167, "Tier 1 Capacitors", 25, SlimefunItems.SMALL_CAPACITOR, SlimefunItems.MEDIUM_CAPACITOR, SlimefunItems.BIG_CAPACITOR); - register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR); + register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR, SlimefunItems.ENERGIZED_CAPACITOR); register("solar_generators", 169, "Solar Power Plant", 14, SlimefunItems.SOLAR_GENERATOR); register("electric_furnaces", 170, "Powered Furnace", 15, SlimefunItems.ELECTRIC_FURNACE); register("electric_ore_grinding", 171, "Crushing and Grinding", 20, SlimefunItems.ELECTRIC_ORE_GRINDER, SlimefunItems.ELECTRIC_INGOT_PULVERIZER); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 64df84bfc..7aad7979a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -1524,6 +1524,10 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO, new ItemStack(Material.REDSTONE), SlimefunItems.LARGE_CAPACITOR, new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO}) .register(plugin); + new Capacitor(categories.electricity, 524288, SlimefunItems.ENERGIZED_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {new ItemStack(Material.NETHER_STAR), SlimefunItems.REDSTONE_ALLOY, new ItemStack(Material.NETHER_STAR), new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO_EDGED_CAPACITOR, new ItemStack(Material.REDSTONE), new ItemStack(Material.NETHER_STAR), SlimefunItems.REDSTONE_ALLOY, new ItemStack(Material.NETHER_STAR)}) + .register(plugin); + new SolarGenerator(categories.electricity, 2, 0, SlimefunItems.SOLAR_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, null, SlimefunItems.ALUMINUM_INGOT, null}) .register(plugin); From 55a384ab8709dde7465bdd085eed9595d10cbdef Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 20 Sep 2020 12:16:56 -0400 Subject: [PATCH 067/163] Made energized capacitor tier 3 (Did I miss any code?) --- .../slimefun4/implementation/setup/ResearchSetup.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index a0e19ca3d..7828c7f05 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -175,7 +175,9 @@ public final class ResearchSetup { register("fuel", 165, "Fuel", 30, SlimefunItems.FUEL_BUCKET, SlimefunItems.REFINERY); register("hologram_projector", 166, "Holograms", 36, SlimefunItems.HOLOGRAM_PROJECTOR); register("capacitors", 167, "Tier 1 Capacitors", 25, SlimefunItems.SMALL_CAPACITOR, SlimefunItems.MEDIUM_CAPACITOR, SlimefunItems.BIG_CAPACITOR); - register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR, SlimefunItems.ENERGIZED_CAPACITOR); + register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR); + register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); + register("solar_generators", 169, "Solar Power Plant", 14, SlimefunItems.SOLAR_GENERATOR); register("electric_furnaces", 170, "Powered Furnace", 15, SlimefunItems.ELECTRIC_FURNACE); register("electric_ore_grinding", 171, "Crushing and Grinding", 20, SlimefunItems.ELECTRIC_ORE_GRINDER, SlimefunItems.ELECTRIC_INGOT_PULVERIZER); From 5857b851990c9baadc05431c1831177b255d56e7 Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 20 Sep 2020 12:52:16 -0400 Subject: [PATCH 068/163] Added research text --- .../slimefun4/implementation/setup/ResearchSetup.java | 1 - src/main/resources/languages/researches_en.yml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index 7828c7f05..c31629be6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -177,7 +177,6 @@ public final class ResearchSetup { register("capacitors", 167, "Tier 1 Capacitors", 25, SlimefunItems.SMALL_CAPACITOR, SlimefunItems.MEDIUM_CAPACITOR, SlimefunItems.BIG_CAPACITOR); register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR); register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); - register("solar_generators", 169, "Solar Power Plant", 14, SlimefunItems.SOLAR_GENERATOR); register("electric_furnaces", 170, "Powered Furnace", 15, SlimefunItems.ELECTRIC_FURNACE); register("electric_ore_grinding", 171, "Crushing and Grinding", 20, SlimefunItems.ELECTRIC_ORE_GRINDER, SlimefunItems.ELECTRIC_INGOT_PULVERIZER); diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index e93209b01..034d9c312 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -144,6 +144,7 @@ slimefun: hologram_projector: Holograms capacitors: Tier 1 Capacitors high_tier_capacitors: Tier 2 Capacitors + even_higher_tier_capacitors: Tier 3 Capacitors solar_generators: Solar Power Plant electric_furnaces: Powered Furnace electric_ore_grinding: Crushing and Grinding From cbafa4c59c2af86767337703f569346bf04aa72b Mon Sep 17 00:00:00 2001 From: Seggan Date: Sun, 20 Sep 2020 20:15:32 -0400 Subject: [PATCH 069/163] Moved some code and changed energized capacitor recipe --- .../slimefun4/implementation/setup/ResearchSetup.java | 2 +- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index c31629be6..59590e914 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -176,7 +176,6 @@ public final class ResearchSetup { register("hologram_projector", 166, "Holograms", 36, SlimefunItems.HOLOGRAM_PROJECTOR); register("capacitors", 167, "Tier 1 Capacitors", 25, SlimefunItems.SMALL_CAPACITOR, SlimefunItems.MEDIUM_CAPACITOR, SlimefunItems.BIG_CAPACITOR); register("high_tier_capacitors", 168, "Tier 2 Capacitors", 32, SlimefunItems.LARGE_CAPACITOR, SlimefunItems.CARBONADO_EDGED_CAPACITOR); - register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); register("solar_generators", 169, "Solar Power Plant", 14, SlimefunItems.SOLAR_GENERATOR); register("electric_furnaces", 170, "Powered Furnace", 15, SlimefunItems.ELECTRIC_FURNACE); register("electric_ore_grinding", 171, "Crushing and Grinding", 20, SlimefunItems.ELECTRIC_ORE_GRINDER, SlimefunItems.ELECTRIC_INGOT_PULVERIZER); @@ -275,6 +274,7 @@ public final class ResearchSetup { register("shulker_shell", 263, "Synthetic Shulkers", 30, SlimefunItems.SYNTHETIC_SHULKER_SHELL); register("villager_rune", 264, "Reset Villager Trades", 26, SlimefunItems.VILLAGER_RUNE, SlimefunItems.STRANGE_NETHER_GOO); register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); + register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 7aad7979a..0bb375f9c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -1525,8 +1525,8 @@ public final class SlimefunItemSetup { .register(plugin); new Capacitor(categories.electricity, 524288, SlimefunItems.ENERGIZED_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.NETHER_STAR), SlimefunItems.REDSTONE_ALLOY, new ItemStack(Material.NETHER_STAR), new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO_EDGED_CAPACITOR, new ItemStack(Material.REDSTONE), new ItemStack(Material.NETHER_STAR), SlimefunItems.REDSTONE_ALLOY, new ItemStack(Material.NETHER_STAR)}) - .register(plugin); + new ItemStack[] {SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO, new ItemStack(Material.NETHER_STAR), SlimefunItems.CARBONADO_EDGED_CAPACITOR, new ItemStack(Material.NETHER_STAR), SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO}) + .register(plugin); new SolarGenerator(categories.electricity, 2, 0, SlimefunItems.SOLAR_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, null, SlimefunItems.ALUMINUM_INGOT, null}) From 0227e0cc30d39d0180b93ed0ac33a1ee61fa7bf1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 12:51:13 +0200 Subject: [PATCH 070/163] [CI skip] Reduced technical debt --- .../slimefun4/api/ErrorReport.java | 7 ++-- .../slimefun4/api/player/PlayerProfile.java | 2 + .../services/plugins/PlaceholderAPIHook.java | 38 ++++++++++++------- .../Slimefun/api/SlimefunItemStack.java | 34 +++++++++++------ 4 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 930c7fe48..edaf225ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Function; import java.util.logging.Level; @@ -41,7 +42,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; public class ErrorReport { private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm", Locale.ROOT); - private static int count; + private static final AtomicInteger count = new AtomicInteger(0); private SlimefunAddon addon; private T throwable; @@ -124,12 +125,12 @@ public class ErrorReport { * @return The amount of {@link ErrorReport ErrorReports} created. */ public static int count() { - return count; + return count.get(); } private void print(@Nonnull Consumer printer) { this.file = getNewFile(); - count++; + count.incrementAndGet(); try (PrintStream stream = new PrintStream(file, StandardCharsets.UTF_8.name())) { stream.println(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index ac30d55ff..db3043ab1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -404,6 +404,8 @@ public final class PlayerProfile { * @return Whether the {@link PlayerProfile} was already loaded */ public static boolean request(@Nonnull OfflinePlayer p) { + Validate.notNull(p, "Cannot request a Profile for null"); + if (!SlimefunPlugin.getRegistry().getPlayerProfiles().containsKey(p.getUniqueId())) { // Should probably prevent multiple requests for the same profile in the future Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance(), () -> { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java index 5201b10e9..c0a40bf01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java @@ -5,6 +5,7 @@ import java.util.Set; import java.util.stream.Stream; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -24,16 +25,19 @@ class PlaceholderAPIHook extends PlaceholderExpansion { this.author = plugin.getDescription().getAuthors().toString(); } + @Nonnull @Override public String getIdentifier() { return "slimefun"; } + @Nonnull @Override public String getVersion() { return version; } + @Nonnull @Override public String getAuthor() { return author; @@ -49,9 +53,18 @@ class PlaceholderAPIHook extends PlaceholderExpansion { return true; } + private boolean isPlaceholder(@Nullable OfflinePlayer p, boolean requiresProfile, @Nonnull String params, @Nonnull String placeholder) { + if (requiresProfile) { + return p != null && placeholder.equals(params) && PlayerProfile.request(p); + } + else { + return placeholder.equals(params); + } + } + @Override - public String onRequest(OfflinePlayer p, String params) { - if (params.equals("researches_total_xp_levels_spent") && PlayerProfile.request(p)) { + public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { + if (isPlaceholder(p, true, params, "researches_total_xp_levels_spent")) { Optional profile = PlayerProfile.find(p); if (profile.isPresent()) { @@ -60,7 +73,7 @@ class PlaceholderAPIHook extends PlaceholderExpansion { } } - if (params.equals("researches_total_researches_unlocked") && PlayerProfile.request(p)) { + if (isPlaceholder(p, true, params, "researches_total_researches_unlocked")) { Optional profile = PlayerProfile.find(p); if (profile.isPresent()) { @@ -69,11 +82,11 @@ class PlaceholderAPIHook extends PlaceholderExpansion { } } - if (params.equals("researches_total_researches")) { + if (isPlaceholder(p, false, params, "researches_total_researches")) { return String.valueOf(SlimefunPlugin.getRegistry().getResearches().size()); } - if (params.equals("researches_percentage_researches_unlocked") && PlayerProfile.request(p)) { + if (isPlaceholder(p, true, params, "researches_percentage_researches_unlocked")) { Optional profile = PlayerProfile.find(p); if (profile.isPresent()) { @@ -82,7 +95,7 @@ class PlaceholderAPIHook extends PlaceholderExpansion { } } - if (params.equals("researches_title") && PlayerProfile.request(p)) { + if (isPlaceholder(p, true, params, "researches_title")) { Optional profile = PlayerProfile.find(p); if (profile.isPresent()) { @@ -90,20 +103,17 @@ class PlaceholderAPIHook extends PlaceholderExpansion { } } - if (params.equals("gps_complexity")) { + if (isPlaceholder(p, false, params, "gps_complexity") && p != null) { return String.valueOf(SlimefunPlugin.getGPSNetwork().getNetworkComplexity(p.getUniqueId())); } - if (params.equals("timings_lag")) { + if (isPlaceholder(p, false, params, "timings_lag")) { return SlimefunPlugin.getProfiler().getTime(); } - if (params.equals("language")) { - if (!(p instanceof Player)) { - return "Unknown"; - } - - return SlimefunPlugin.getLocalization().getLanguage((Player) p).getName((Player) p); + if (isPlaceholder(p, false, params, "language") && p instanceof Player) { + Player player = (Player) p; + return SlimefunPlugin.getLocalization().getLanguage(player).getName(player); } return null; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index 916e4780c..feb7253df 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -33,7 +33,7 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -public class SlimefunItemStack extends CustomItem { +public class SlimefunItemStack extends CustomItem implements Cloneable { private String id; private ImmutableItemMeta immutableMeta; @@ -243,16 +243,6 @@ public class SlimefunItemStack extends CustomItem { locked = true; } - @Override - public ItemStack clone() { - return new SlimefunItemStack(id, this); - } - - @Override - public String toString() { - return "SlimefunItemStack (" + id + (getAmount() > 1 ? (" x " + getAmount()) : "") + ')'; - } - @Nonnull public Optional getSkullTexture() { return Optional.ofNullable(texture); @@ -292,4 +282,26 @@ public class SlimefunItemStack extends CustomItem { throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); } } + + @Override + public ItemStack clone() { + return new SlimefunItemStack(id, this); + } + + @Override + public String toString() { + return "SlimefunItemStack (" + id + (getAmount() > 1 ? (" x " + getAmount()) : "") + ')'; + } + + @Override + public final boolean equals(Object obj) { + // We don't want people to override this, it should use the super method + return super.equals(obj); + } + + @Override + public final int hashCode() { + // We don't want people to override this, it should use the super method + return super.hashCode(); + } } From cdc495e62b25bc4366e0d8777cc3d9d6ebd6056b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 13:09:45 +0200 Subject: [PATCH 071/163] Fixes #2325 --- CHANGELOG.md | 1 + .../listeners/TalismanListener.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4c7aa28..f30ddf444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ * Fixed Cheat Sheet Slimefun Guide being unable to open the settings menu via shift + right click * Fixed #2320 * Fixed some issues with ChestTerminal +* Fixed #2325 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index e757d2872..df17d39e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -133,11 +133,19 @@ public class TalismanListener implements Listener { LivingEntity entity = e.getEntity(); - if (!(entity instanceof Player) && !(entity instanceof ArmorStand) && Talisman.checkFor(e, SlimefunItems.TALISMAN_HUNTER)) { + if (entity instanceof Player || entity instanceof ArmorStand) { + // We absolutely don't want to double the + // drops from players or ArmorStands + return; + } + + // We are also excluding entities which can pickup items, this is not perfect + // but it at least prevents dupes by tossing items to zombies + if (!entity.getCanPickupItems() && Talisman.checkFor(e, SlimefunItems.TALISMAN_HUNTER)) { Collection extraDrops = getExtraDrops(e.getEntity(), e.getDrops()); for (ItemStack drop : extraDrops) { - if (drop != null) { + if (drop != null && drop.getType() != Material.AIR) { e.getDrops().add(drop.clone()); } } @@ -163,7 +171,10 @@ public class TalismanListener implements Listener { } } - // Prevent duplication of handheld items or armor + // WARNING: This check is broken as entities now set their + // equipment to NULL before calling the event! + + // Prevents duplication of handheld items or armor EntityEquipment equipment = entity.getEquipment(); if (equipment != null) { for (ItemStack item : equipment.getArmorContents()) { From 9dfd43fda6b848732c346f286990e2adb6b43efe Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 13:14:56 +0200 Subject: [PATCH 072/163] Fixed Climbing Pick having no animation in creative mode --- CHANGELOG.md | 1 + .../items/tools/ClimbingPick.java | 50 ++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f30ddf444..a0855ad0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ * Fixed #2320 * Fixed some issues with ChestTerminal * Fixed #2325 +* Fixed Climbing Pick having no animation in creative mode ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java index aa32a59ce..39df55419 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java @@ -9,6 +9,9 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; @@ -55,6 +58,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements private final Map materialSpeeds; private final Set users = new HashSet<>(); + @ParametersAreNonnullByDefault public ClimbingPick(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); addItemSetting(dualWielding, damageOnUse); @@ -123,6 +127,8 @@ public class ClimbingPick extends SimpleSlimefunItem implements }; } + @Nonnull + @ParametersAreNonnullByDefault private ItemStack getOtherHandItem(Player p, EquipmentSlot hand) { if (hand == EquipmentSlot.HAND) { return p.getInventory().getItemInOffHand(); @@ -132,6 +138,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements } } + @ParametersAreNonnullByDefault private void climb(Player p, EquipmentSlot hand, ItemStack item, Block block) { double power = materialSpeeds.getOrDefault(block.getType(), 0.0); @@ -144,7 +151,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements power += efficiencyLevel * 0.1; } - Slimefun.runSync(() -> users.remove(p.getUniqueId()), 3L); + Slimefun.runSync(() -> users.remove(p.getUniqueId()), 4L); Vector velocity = new Vector(0, power * BASE_POWER, 0); ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, this, item, block); Bukkit.getPluginManager().callEvent(event); @@ -162,25 +169,37 @@ public class ClimbingPick extends SimpleSlimefunItem implements } } + @ParametersAreNonnullByDefault private void swing(Player p, Block b, EquipmentSlot hand, ItemStack item) { - if (p.getGameMode() != GameMode.CREATIVE) { - if (isDualWieldingEnabled()) { - if (ThreadLocalRandom.current().nextBoolean()) { - damageItem(p, p.getInventory().getItemInMainHand()); - playAnimation(p, b, EquipmentSlot.HAND); - } - else { - damageItem(p, p.getInventory().getItemInOffHand()); - playAnimation(p, b, EquipmentSlot.OFF_HAND); - } + if (isDualWieldingEnabled()) { + if (ThreadLocalRandom.current().nextBoolean()) { + damageItem(p, p.getInventory().getItemInMainHand()); + playAnimation(p, b, EquipmentSlot.HAND); } else { - damageItem(p, item); - playAnimation(p, b, hand); + damageItem(p, p.getInventory().getItemInOffHand()); + playAnimation(p, b, EquipmentSlot.OFF_HAND); } } + else { + damageItem(p, item); + playAnimation(p, b, hand); + } } + @Override + public void damageItem(Player p, ItemStack item) { + if (p.getGameMode() != GameMode.CREATIVE) { + DamageableItem.super.damageItem(p, item); + } + } + + @Override + public boolean isDamageable() { + return damageOnUse.getValue(); + } + + @ParametersAreNonnullByDefault private void playAnimation(Player p, Block b, EquipmentSlot hand) { MinecraftVersion version = SlimefunPlugin.getMinecraftVersion(); @@ -198,11 +217,6 @@ public class ClimbingPick extends SimpleSlimefunItem implements } } - @Override - public boolean isDamageable() { - return damageOnUse.getValue(); - } - @Override public List getDisplayRecipes() { List display = new ArrayList<>(); From 5cd1d99b705bfbe152d92185be062927ae812ac8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 13:23:14 +0200 Subject: [PATCH 073/163] Fixes #2322 --- CHANGELOG.md | 1 + .../items/magical/StormStaff.java | 51 ++++++++++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0855ad0a..53851bfbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ * Fixed some issues with ChestTerminal * Fixed #2325 * Fixed Climbing Pick having no animation in creative mode +* Fixed #2322 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java index 8e14f1ed1..5c72e5ceb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java @@ -2,6 +2,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -40,10 +43,12 @@ public class StormStaff extends SimpleSlimefunItem { private static final NamespacedKey usageKey = new NamespacedKey(SlimefunPlugin.instance(), "stormstaff_usage"); public static final int MAX_USES = 8; + @ParametersAreNonnullByDefault public StormStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe, getCraftedOutput()); } + @Nonnull private static ItemStack getCraftedOutput() { ItemStack item = SlimefunItems.STAFF_STORM.clone(); ItemMeta im = item.getItemMeta(); @@ -82,10 +87,11 @@ public class StormStaff extends SimpleSlimefunItem { }; } + @ParametersAreNonnullByDefault private void useItem(Player p, ItemStack item, Location loc) { loc.getWorld().strikeLightning(loc); - if (p.getInventory().getItemInMainHand().getType() == Material.SHEARS) { + if (item.getType() == Material.SHEARS) { return; } @@ -98,22 +104,43 @@ public class StormStaff extends SimpleSlimefunItem { } } - ItemMeta meta = item.getItemMeta(); - int usesLeft = meta.getPersistentDataContainer().getOrDefault(usageKey, PersistentDataType.INTEGER, MAX_USES); + damageItem(p, item); + } - if (usesLeft == 1) { - p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); - item.setAmount(0); + @ParametersAreNonnullByDefault + private void damageItem(Player p, ItemStack item) { + if (item.getAmount() > 1) { + item.setAmount(item.getAmount() - 1); + + // Seperate one item from the stack and damage it + ItemStack seperateItem = item.clone(); + seperateItem.setAmount(1); + damageItem(p, seperateItem); + + // Try to give the Player the new item + if (!p.getInventory().addItem(seperateItem).isEmpty()) { + // or throw it on the ground + p.getWorld().dropItemNaturally(p.getLocation(), seperateItem); + } } else { - usesLeft--; - meta.getPersistentDataContainer().set(usageKey, PersistentDataType.INTEGER, usesLeft); + ItemMeta meta = item.getItemMeta(); + int usesLeft = meta.getPersistentDataContainer().getOrDefault(usageKey, PersistentDataType.INTEGER, MAX_USES); - List lore = meta.getLore(); - lore.set(4, ChatColors.color("&e" + usesLeft + ' ' + (usesLeft > 1 ? "Uses" : "Use") + " &7left")); - meta.setLore(lore); + if (usesLeft == 1) { + p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); + item.setAmount(0); + } + else { + usesLeft--; + meta.getPersistentDataContainer().set(usageKey, PersistentDataType.INTEGER, usesLeft); - item.setItemMeta(meta); + List lore = meta.getLore(); + lore.set(4, ChatColors.color("&e" + usesLeft + ' ' + (usesLeft > 1 ? "Uses" : "Use") + " &7left")); + meta.setLore(lore); + + item.setItemMeta(meta); + } } } From a36dfc1151048795d48fee120fd41502e84f2477 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 15:47:06 +0200 Subject: [PATCH 074/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53851bfbb..d1119161b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ #### Additions * Added /sf charge +* Added Energized Energy Capacitor #### Changes * Improved Auto-Updater (Multi-Threading and more) From b7def0f58dfe01876ff8be5eda14c4f08999d3e6 Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Mon, 21 Sep 2020 22:14:22 +0200 Subject: [PATCH 075/163] Added materials to CoalGenerator --- .../electric/generators/CoalGenerator.java | 43 +++++++ .../slimefun4/testing/TestUtilities.java | 108 ++++++++++++------ 2 files changed, 118 insertions(+), 33 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java index 84e7c29fe..dc242181c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java @@ -10,6 +10,8 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import javax.annotation.Nonnull; + public abstract class CoalGenerator extends AGenerator { public CoalGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -22,6 +24,11 @@ public abstract class CoalGenerator extends AGenerator { registerFuel(new MachineFuel(12, new ItemStack(Material.BLAZE_ROD))); registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK))); + // Boats + for (Material mat : Tag.ITEMS_BOATS.getValues()) { + registerFuel(new MachineFuel(6, new ItemStack(mat))); + } + // Coal & Charcoal registerFuel(new MachineFuel(8, new ItemStack(Material.COAL))); registerFuel(new MachineFuel(8, new ItemStack(Material.CHARCOAL))); @@ -35,8 +42,44 @@ public abstract class CoalGenerator extends AGenerator { for (Material mat : Tag.PLANKS.getValues()) { registerFuel(new MachineFuel(1, new ItemStack(mat))); } + + // Wooden Slabs + for (Material mat : Tag.WOODEN_SLABS.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // Wooden Buttons + for (Material mat : Tag.WOODEN_BUTTONS.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // Wooden Fences + for (Material mat : Tag.WOODEN_FENCES.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // wooden Trapdoors + for (Material mat : Tag.WOODEN_TRAPDOORS.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // Wooden Pressure Plates + for (Material mat : Tag.WOODEN_PRESSURE_PLATES.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // Wooden Doors + for (Material mat : Tag.WOODEN_DOORS.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } + + // Signs + for (Material mat : Tag.SIGNS.getValues()) { + registerFuel(new MachineFuel(1, new ItemStack(mat))); + } } + @Nonnull @Override public ItemStack getProgressBar() { return new ItemStack(Material.FLINT_AND_STEEL); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java index bd963339c..37b446fc2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -1,21 +1,5 @@ package io.github.thebusybiscuit.slimefun4.testing; -import static org.mockito.Mockito.when; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.OfflinePlayer; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import org.junit.jupiter.api.Assertions; -import org.mockito.Mockito; - import be.seeseemelk.mockbukkit.ServerMock; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; @@ -25,6 +9,21 @@ import io.github.thebusybiscuit.slimefun4.testing.mocks.MockSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.OfflinePlayer; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; +import org.junit.jupiter.api.Assertions; +import org.mockito.Mockito; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import static org.mockito.Mockito.when; public final class TestUtilities { @@ -44,14 +43,17 @@ public final class TestUtilities { } public static SlimefunItem mockSlimefunItem(Plugin plugin, String id, ItemStack item) { - Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category")); + Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test " + + "Category")); return new MockSlimefunItem(category, item, id); } public static VanillaItem mockVanillaItem(Plugin plugin, Material type, boolean enabled) { - Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category")); - VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, new ItemStack[9]); + Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test " + + "Category")); + VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, + new ItemStack[9]); SlimefunPlugin.getItemCfg().setValue(type.name() + ".enabled", enabled); return item; } @@ -73,18 +75,58 @@ public final class TestUtilities { public static void registerDefaultTags(ServerMock server) { // We really don't need these to be accurate, just fill them with some examples // that approximate the actual content - server.createMaterialTag(NamespacedKey.minecraft("logs"), Material.OAK_LOG, Material.STRIPPED_OAK_LOG, Material.OAK_WOOD, Material.STRIPPED_OAK_WOOD, Material.ACACIA_LOG, Material.STRIPPED_ACACIA_LOG, Material.ACACIA_WOOD, Material.STRIPPED_ACACIA_WOOD); - server.createMaterialTag(NamespacedKey.minecraft("wooden_trapdoors"), Material.OAK_TRAPDOOR, Material.BIRCH_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.JUNGLE_TRAPDOOR, Material.ACACIA_TRAPDOOR, Material.DARK_OAK_TRAPDOOR); - server.createMaterialTag(NamespacedKey.minecraft("wooden_slabs"), Material.OAK_SLAB, Material.BIRCH_SLAB, Material.JUNGLE_SLAB, Material.SPRUCE_SLAB, Material.ACACIA_SLAB, Material.DARK_OAK_SLAB); - server.createMaterialTag(NamespacedKey.minecraft("wooden_fences"), Material.OAK_FENCE, Material.BIRCH_FENCE, Material.JUNGLE_FENCE, Material.SPRUCE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE); - server.createMaterialTag(NamespacedKey.minecraft("planks"), Material.OAK_PLANKS, Material.BIRCH_PLANKS, Material.SPRUCE_PLANKS, Material.JUNGLE_PLANKS, Material.ACACIA_PLANKS, Material.DARK_OAK_PLANKS); - server.createMaterialTag(NamespacedKey.minecraft("small_flowers"), Material.POPPY, Material.DANDELION, Material.AZURE_BLUET, Material.LILY_OF_THE_VALLEY); - server.createMaterialTag(NamespacedKey.minecraft("leaves"), Material.OAK_LEAVES, Material.BIRCH_LEAVES, Material.SPRUCE_LEAVES, Material.JUNGLE_LEAVES, Material.ACACIA_LEAVES, Material.DARK_OAK_LEAVES); - server.createMaterialTag(NamespacedKey.minecraft("saplings"), Material.OAK_SAPLING, Material.BIRCH_SAPLING, Material.SPRUCE_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING); - server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK, Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK); - server.createMaterialTag(NamespacedKey.minecraft("corals"), Material.BRAIN_CORAL, Material.BUBBLE_CORAL, Material.FIRE_CORAL, Material.HORN_CORAL, Material.TUBE_CORAL); - server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE); - server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE); - } + server.createMaterialTag(NamespacedKey.minecraft("logs"), Material.OAK_LOG, + Material.STRIPPED_OAK_LOG, Material.OAK_WOOD, Material.STRIPPED_OAK_WOOD, + Material.ACACIA_LOG, Material.STRIPPED_ACACIA_LOG, Material.ACACIA_WOOD, Material.STRIPPED_ACACIA_WOOD + ); + server.createMaterialTag(NamespacedKey.minecraft("wooden_trapdoors"), Material.OAK_TRAPDOOR, + Material.BIRCH_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.JUNGLE_TRAPDOOR, + Material.ACACIA_TRAPDOOR, Material.DARK_OAK_TRAPDOOR + ); + server.createMaterialTag(NamespacedKey.minecraft("wooden_slabs"), Material.OAK_SLAB, Material.BIRCH_SLAB, + Material.JUNGLE_SLAB, Material.SPRUCE_SLAB, Material.ACACIA_SLAB, Material.DARK_OAK_SLAB + ); + server.createMaterialTag(NamespacedKey.minecraft("wooden_fences"), Material.OAK_FENCE, Material.BIRCH_FENCE, + Material.JUNGLE_FENCE, Material.SPRUCE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE + ); + server.createMaterialTag(NamespacedKey.minecraft("planks"), Material.OAK_PLANKS, Material.BIRCH_PLANKS, + Material.SPRUCE_PLANKS, Material.JUNGLE_PLANKS, Material.ACACIA_PLANKS, Material.DARK_OAK_PLANKS + ); + server.createMaterialTag(NamespacedKey.minecraft("small_flowers"), Material.POPPY, Material.DANDELION, + Material.AZURE_BLUET, Material.LILY_OF_THE_VALLEY + ); + server.createMaterialTag(NamespacedKey.minecraft("leaves"), Material.OAK_LEAVES, Material.BIRCH_LEAVES, + Material.SPRUCE_LEAVES, Material.JUNGLE_LEAVES, Material.ACACIA_LEAVES, Material.DARK_OAK_LEAVES + ); + server.createMaterialTag(NamespacedKey.minecraft("saplings"), Material.OAK_SAPLING, Material.BIRCH_SAPLING, + Material.SPRUCE_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING + ); + server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK, + Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK + ); + server.createMaterialTag(NamespacedKey.minecraft("corals"), Material.BRAIN_CORAL, Material.BUBBLE_CORAL, + Material.FIRE_CORAL, Material.HORN_CORAL, Material.TUBE_CORAL + ); + server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, + Material.FROSTED_ICE, Material.BLUE_ICE + ); + server.createMaterialTag(NamespacedKey.minecraft("boats"), Material.BIRCH_BOAT, Material.ACACIA_BOAT, + Material.DARK_OAK_BOAT, Material.JUNGLE_BOAT, Material.OAK_BOAT, Material.SPRUCE_BOAT + ); + server.createMaterialTag(NamespacedKey.minecraft("wooden_buttons"), Material.BIRCH_BUTTON, + Material.ACACIA_BUTTON, Material.SPRUCE_BUTTON, Material.DARK_OAK_BUTTON, + Material.JUNGLE_BOAT, Material.OAK_BUTTON + ); + server.createMaterialTag(NamespacedKey.minecraft("signs"), Material.SPRUCE_SIGN, Material.ACACIA_SIGN, + Material.OAK_SIGN, Material.JUNGLE_SIGN, Material.DARK_OAK_SIGN, Material.BIRCH_SIGN + ); + server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.SPRUCE_DOOR, Material.ACACIA_DOOR, + Material.OAK_DOOR, Material.JUNGLE_DOOR, Material.DARK_OAK_DOOR, Material.BIRCH_DOOR + ); + server.createMaterialTag(NamespacedKey.minecraft("wooden_pressure_plates"), Material.SPRUCE_PRESSURE_PLATE, + Material.ACACIA_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE, + Material.DARK_OAK_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE + ); -} + } +} \ No newline at end of file From 59f422c757db7d5649adcde8d4addd92db827afd Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Mon, 21 Sep 2020 22:16:32 +0200 Subject: [PATCH 076/163] note to self listen to your notes --- .../thebusybiscuit/slimefun4/testing/TestUtilities.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java index 37b446fc2..c07a65eda 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -43,17 +43,14 @@ public final class TestUtilities { } public static SlimefunItem mockSlimefunItem(Plugin plugin, String id, ItemStack item) { - Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test " + - "Category")); + Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category")); return new MockSlimefunItem(category, item, id); } public static VanillaItem mockVanillaItem(Plugin plugin, Material type, boolean enabled) { - Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test " + - "Category")); - VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, - new ItemStack[9]); + Category category = new Category(new NamespacedKey(plugin, "test"), new CustomItem(Material.EMERALD, "&4Test Category")); + VanillaItem item = new VanillaItem(category, new ItemStack(type), type.name(), RecipeType.NULL, new ItemStack[9]); SlimefunPlugin.getItemCfg().setValue(type.name() + ".enabled", enabled); return item; } From f63d246b82dec911414c8355256571fb4a927c0b Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Mon, 21 Sep 2020 22:26:54 +0200 Subject: [PATCH 077/163] changed doors to wooden_doors --- .../github/thebusybiscuit/slimefun4/testing/TestUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java index c07a65eda..425770f5a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -117,7 +117,7 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("signs"), Material.SPRUCE_SIGN, Material.ACACIA_SIGN, Material.OAK_SIGN, Material.JUNGLE_SIGN, Material.DARK_OAK_SIGN, Material.BIRCH_SIGN ); - server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.SPRUCE_DOOR, Material.ACACIA_DOOR, + server.createMaterialTag(NamespacedKey.minecraft("wooden_doors"), Material.SPRUCE_DOOR, Material.ACACIA_DOOR, Material.OAK_DOOR, Material.JUNGLE_DOOR, Material.DARK_OAK_DOOR, Material.BIRCH_DOOR ); server.createMaterialTag(NamespacedKey.minecraft("wooden_pressure_plates"), Material.SPRUCE_PRESSURE_PLATE, From c8d22fa381f94fa83c97c12b947d4bffd3028405 Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Mon, 21 Sep 2020 22:32:04 +0200 Subject: [PATCH 078/163] did requested changes --- .../items/electric/generators/CoalGenerator.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java index dc242181c..1f0499a61 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java @@ -26,7 +26,7 @@ public abstract class CoalGenerator extends AGenerator { // Boats for (Material mat : Tag.ITEMS_BOATS.getValues()) { - registerFuel(new MachineFuel(6, new ItemStack(mat))); + registerFuel(new MachineFuel(5, new ItemStack(mat))); } // Coal & Charcoal @@ -35,7 +35,7 @@ public abstract class CoalGenerator extends AGenerator { // Logs for (Material mat : Tag.LOGS.getValues()) { - registerFuel(new MachineFuel(2, new ItemStack(mat))); + registerFuel(new MachineFuel(4, new ItemStack(mat))); } // Wooden Planks @@ -60,22 +60,22 @@ public abstract class CoalGenerator extends AGenerator { // wooden Trapdoors for (Material mat : Tag.WOODEN_TRAPDOORS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(3, new ItemStack(mat))); } // Wooden Pressure Plates for (Material mat : Tag.WOODEN_PRESSURE_PLATES.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(2, new ItemStack(mat))); } // Wooden Doors for (Material mat : Tag.WOODEN_DOORS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(2, new ItemStack(mat))); } // Signs for (Material mat : Tag.SIGNS.getValues()) { - registerFuel(new MachineFuel(1, new ItemStack(mat))); + registerFuel(new MachineFuel(2, new ItemStack(mat))); } } From 1c0abdd3feff5bd3cce2d5a021395bec0844b6a4 Mon Sep 17 00:00:00 2001 From: "Panda.com" Date: Mon, 21 Sep 2020 23:22:13 +0200 Subject: [PATCH 079/163] Did i really get out of bed for this --- .../github/thebusybiscuit/slimefun4/testing/TestUtilities.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java index 425770f5a..b6625ce90 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java @@ -107,6 +107,8 @@ public final class TestUtilities { server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE, Material.FROSTED_ICE, Material.BLUE_ICE ); + server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE); + server.createMaterialTag(NamespacedKey.minecraft("boats"), Material.BIRCH_BOAT, Material.ACACIA_BOAT, Material.DARK_OAK_BOAT, Material.JUNGLE_BOAT, Material.OAK_BOAT, Material.SPRUCE_BOAT ); From d35ee992aeaed1d7bd7bcf9ce5694215aeed7bf5 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 21 Sep 2020 23:54:21 +0200 Subject: [PATCH 080/163] [CI skip] Added another Unit Test --- .../items/tools/PortableCrafter.java | 11 ++++ .../items/tools/TapeMeasure.java | 8 +++ .../testing/tests/gps/TestWaypoints.java | 24 +++++--- .../implementations/food/TestDietCookie.java | 6 +- .../implementations/food/TestMeatJerky.java | 6 +- .../food/TestMonsterJerky.java | 6 +- .../tools/TestPortableDustbin.java | 59 +++++++++++++++++++ .../listeners/TestIronGolemListener.java | 12 ++-- .../listeners/TestMultiblockListener.java | 9 ++- .../listeners/TestSlimefunGuideListener.java | 2 + .../tests/multiblocks/TestMultiBlocks.java | 40 ++++++++----- .../tests/services/TestItemDataService.java | 12 ++-- 12 files changed, 154 insertions(+), 41 deletions(-) create mode 100644 src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestPortableDustbin.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java index 4a9d02af4..e7ce34b01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java @@ -1,7 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; @@ -11,8 +14,16 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * The {@link PortableCrafter} is one of the oldest items in Slimefun. + * It allows a {@link Player} to open up the {@link CraftingInventory} via right click. + * + * @author TheBusyBiscuit + * + */ public class PortableCrafter extends SimpleSlimefunItem implements NotPlaceable { + @ParametersAreNonnullByDefault public PortableCrafter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java index 919ddd8c1..c9fb3cd54 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java @@ -4,6 +4,9 @@ import java.text.DecimalFormat; import java.util.Optional; import java.util.UUID; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.block.Block; @@ -34,6 +37,7 @@ public class TapeMeasure extends SimpleSlimefunItem implements N private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "anchor"); private final DecimalFormat format = new DecimalFormat("##.###"); + @ParametersAreNonnullByDefault public TapeMeasure(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); } @@ -56,6 +60,7 @@ public class TapeMeasure extends SimpleSlimefunItem implements N }; } + @ParametersAreNonnullByDefault private void setAnchor(Player p, ItemStack item, Block block) { ItemMeta meta = item.getItemMeta(); @@ -74,6 +79,8 @@ public class TapeMeasure extends SimpleSlimefunItem implements N } + @Nonnull + @ParametersAreNonnullByDefault private Optional getAnchor(Player p, ItemStack item) { ItemMeta meta = item.getItemMeta(); @@ -102,6 +109,7 @@ public class TapeMeasure extends SimpleSlimefunItem implements N } } + @ParametersAreNonnullByDefault private void measure(Player p, ItemStack item, Block block) { Optional anchor = getAnchor(p, item); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/gps/TestWaypoints.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/gps/TestWaypoints.java index 6ae75c56c..f8d644f50 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/gps/TestWaypoints.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/gps/TestWaypoints.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -15,7 +16,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; -public class TestWaypoints { +class TestWaypoints { private static ServerMock server; @@ -31,7 +32,8 @@ public class TestWaypoints { } @Test - public void testAddWaypointToProfile() throws InterruptedException { + @DisplayName("Test Waypoints being added to the profile") + void testAddWaypointToProfile() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); @@ -48,7 +50,8 @@ public class TestWaypoints { } @Test - public void testRemoveWaypointFromProfile() throws InterruptedException { + @DisplayName("Test Waypoints being removed from the profile") + void testRemoveWaypointFromProfile() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); @@ -68,7 +71,8 @@ public class TestWaypoints { } @Test - public void testWaypointAlreadyExisting() throws InterruptedException { + @DisplayName("Verify that two waypoints cannot have the same name") + void testWaypointAlreadyExisting() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); @@ -81,7 +85,8 @@ public class TestWaypoints { } @Test - public void testTooManyWaypoints() throws InterruptedException { + @DisplayName("Verify that a maximum amount of waypoints is enforced") + void testTooManyWaypoints() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); @@ -95,7 +100,8 @@ public class TestWaypoints { } @Test - public void testWaypointEvent() throws InterruptedException { + @DisplayName("Verify that a WaypointCreateEvent is thrown") + void testWaypointEvent() throws InterruptedException { GPSNetwork network = new GPSNetwork(); Player player = server.addPlayer(); TestUtilities.awaitProfile(player); @@ -105,7 +111,8 @@ public class TestWaypoints { } @Test - public void testWaypointComparison() throws InterruptedException { + @DisplayName("Test equal Waypoints being equal") + void testWaypointComparison() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); @@ -121,7 +128,8 @@ public class TestWaypoints { } @Test - public void testIsDeathpoint() throws InterruptedException { + @DisplayName("Test Deathpoints being recognized as Deathpoints") + void testIsDeathpoint() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestDietCookie.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestDietCookie.java index f7e9336e3..606c2acff 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestDietCookie.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestDietCookie.java @@ -7,6 +7,7 @@ import org.bukkit.potion.PotionEffectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -19,7 +20,7 @@ import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class TestDietCookie implements SlimefunItemTest { +class TestDietCookie implements SlimefunItemTest { private static ServerMock server; private static SlimefunPlugin plugin; @@ -44,7 +45,8 @@ public class TestDietCookie implements SlimefunItemTest { } @Test - public void testConsumptionBehaviour() { + @DisplayName("Test Diet Cookies giving Levitation Effect") + void testConsumptionBehaviour() { PlayerMock player = server.addPlayer(); DietCookie cookie = registerSlimefunItem(plugin, "TEST_DIET_COOKIE"); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMeatJerky.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMeatJerky.java index 9a84f1c2e..40aba208c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMeatJerky.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMeatJerky.java @@ -5,6 +5,7 @@ import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -17,7 +18,7 @@ import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class TestMeatJerky implements SlimefunItemTest { +class TestMeatJerky implements SlimefunItemTest { private static ServerMock server; private static SlimefunPlugin plugin; @@ -42,7 +43,8 @@ public class TestMeatJerky implements SlimefunItemTest { } @Test - public void testConsumptionBehaviour() { + @DisplayName("Test Meat Jerky giving extra saturation") + void testConsumptionBehaviour() { PlayerMock player = server.addPlayer(); MeatJerky jerky = registerSlimefunItem(plugin, "TEST_MEAT_JERKY"); float saturation = player.getSaturation(); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMonsterJerky.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMonsterJerky.java index 0002be40d..4b23f7d20 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMonsterJerky.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/food/TestMonsterJerky.java @@ -6,6 +6,7 @@ import org.bukkit.potion.PotionEffectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -18,7 +19,7 @@ import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public class TestMonsterJerky implements SlimefunItemTest { +class TestMonsterJerky implements SlimefunItemTest { private static ServerMock server; private static SlimefunPlugin plugin; @@ -43,7 +44,8 @@ public class TestMonsterJerky implements SlimefunItemTest { } @Test - public void testConsumptionBehaviour() { + @DisplayName("Test Monster Jerky giving Saturation and removing Hunger") + void testConsumptionBehaviour() { PlayerMock player = server.addPlayer(); player.addPotionEffect(PotionEffectType.HUNGER.createEffect(20, 2)); MonsterJerky jerky = registerSlimefunItem(plugin, "TEST_MONSTER_JERKY"); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestPortableDustbin.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestPortableDustbin.java new file mode 100644 index 000000000..41ac7fe2c --- /dev/null +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestPortableDustbin.java @@ -0,0 +1,59 @@ +package io.github.thebusybiscuit.slimefun4.testing.tests.items.implementations.tools; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import be.seeseemelk.mockbukkit.MockBukkit; +import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PortableDustbin; +import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; +import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +class TestPortableDustbin implements SlimefunItemTest { + + private static ServerMock server; + private static SlimefunPlugin plugin; + + @BeforeAll + public static void load() { + server = MockBukkit.mock(); + plugin = MockBukkit.load(SlimefunPlugin.class); + } + + @AfterAll + public static void unload() { + MockBukkit.unmock(); + } + + @Override + public PortableDustbin registerSlimefunItem(SlimefunPlugin plugin, String id) { + SlimefunItemStack item = new SlimefunItemStack(id, Material.BUCKET, "&4Test Dustbin"); + PortableDustbin dustbin = new PortableDustbin(TestUtilities.getCategory(plugin, "dustbin"), item, RecipeType.NULL, new ItemStack[9]); + dustbin.register(plugin); + return dustbin; + } + + @Test + @DisplayName("Test Dustbin opening an empty Inventory") + void testRightClickBehaviour() { + Player player = server.addPlayer(); + PortableDustbin dustbin = registerSlimefunItem(plugin, "TEST_PORTABLE_DUSTBIN"); + + simulateRightClick(player, dustbin); + + // We expect an empty Inventory to be open now + Inventory openInventory = player.getOpenInventory().getTopInventory(); + Assertions.assertTrue(openInventory.isEmpty()); + } + +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java index 2f6be5615..020522d7e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -22,7 +23,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.IronGolemList import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -public class TestIronGolemListener { +class TestIronGolemListener { private static SlimefunPlugin plugin; private static IronGolemListener listener; @@ -62,7 +63,8 @@ public class TestIronGolemListener { } @Test - public void testWithIron() { + @DisplayName("Test Iron Golem Healing not being disturbed") + void testWithIron() { // This should heal the Iron Golem ItemStack item = new ItemStack(Material.IRON_INGOT); @@ -74,7 +76,8 @@ public class TestIronGolemListener { } @Test - public void testWithSlimefunIron() { + @DisplayName("Test Iron Golem Healing with Slimefun Items being cancelled") + void testWithSlimefunIron() { SlimefunItem slimefunItem = TestUtilities.mockSlimefunItem(plugin, "SLIMEFUN_IRON", new CustomItem(Material.IRON_INGOT, "&cSlimefun Iron")); slimefunItem.register(plugin); @@ -87,7 +90,8 @@ public class TestIronGolemListener { } @Test - public void testWithVanillaIron() { + @DisplayName("Test Iron Golem Healing with vanilla items not being disturbed") + void testWithVanillaIron() { VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.IRON_INGOT, true); item.register(plugin); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java index 4d7d96ef4..a56f3efe7 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestMultiblockListener.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -24,7 +25,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockLis import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -public class TestMultiblockListener { +class TestMultiblockListener { private static SlimefunPlugin plugin; private static MultiBlockListener listener; @@ -48,7 +49,8 @@ public class TestMultiblockListener { } @Test - public void testNoMultiblock() { + @DisplayName("Test MultiBlocks not messing up normal interactions") + void testNoMultiblock() { Player player = server.addPlayer(); World world = server.addSimpleWorld("Multiblock Test World"); Block b = world.getBlockAt(3456, 90, -100); @@ -62,7 +64,8 @@ public class TestMultiblockListener { } @Test - public void testMultiblock() { + @DisplayName("Test MultiBlocks being recognized on right click") + void testMultiblock() { Player player = server.addPlayer(); World world = server.addSimpleWorld("Multiblock Test World"); Block top = world.getBlockAt(1234, 92, -60); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java index 94cacd965..91cee4018 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestSlimefunGuideListener.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -37,6 +38,7 @@ class TestSlimefunGuideListener { } @ParameterizedTest + @DisplayName("Test Slimefun Guides being given on first join") @MethodSource("cartesianBooleans") void testFirstJoin(boolean hasPlayedBefore, boolean giveSlimefunGuide) { SlimefunGuideListener listener = new SlimefunGuideListener(plugin, giveSlimefunGuide); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java index 2579c9261..b226d5c0a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/multiblocks/TestMultiBlocks.java @@ -5,6 +5,7 @@ import org.bukkit.block.BlockFace; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; @@ -15,7 +16,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -public class TestMultiBlocks { +class TestMultiBlocks { private static SlimefunPlugin plugin; @@ -32,7 +33,8 @@ public class TestMultiBlocks { } @Test - public void testInvalidConstructors() { + @DisplayName("Test Exceptions for invalid MultiBlock constructors") + void testInvalidConstructors() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); Assertions.assertThrows(IllegalArgumentException.class, () -> new MultiBlock(null, null, null)); @@ -44,7 +46,8 @@ public class TestMultiBlocks { } @Test - public void testValidConstructor() { + @DisplayName("Test MultiBlock constructor") + void testValidConstructor() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[9], BlockFace.DOWN); @@ -54,7 +57,8 @@ public class TestMultiBlocks { } @Test - public void testSymmetry() { + @DisplayName("Test symmetric MultiBlocks") + void testSymmetry() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { null, null, null, Material.DIAMOND_BLOCK, null, Material.DIAMOND_BLOCK, null, Material.DISPENSER, null }, BlockFace.DOWN); @@ -65,28 +69,31 @@ public class TestMultiBlocks { } @Test - public void testEqual() { + @DisplayName("Test equal MultiBlocks being equal") + void testEqual() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); - Assertions.assertTrue(multiblock.equals(multiblock2)); + Assertions.assertEquals(multiblock, multiblock2); } @Test - public void testEqualWithTags() { + @DisplayName("Test equal MultiBlocks with Tags but different Materials being equal") + void testEqualWithTags() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); // The wooden fences are different but the structure should still match. MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.OAK_FENCE, Material.OAK_FENCE, Material.OAK_FENCE, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.BIRCH_FENCE, Material.BIRCH_FENCE, Material.BIRCH_FENCE, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); - Assertions.assertTrue(multiblock.equals(multiblock2)); + Assertions.assertEquals(multiblock, multiblock2); } @Test - public void testEqualWithMovingPistons() { + @DisplayName("Test MultiBlocks with moving pistons still being equal") + void testEqualWithMovingPistons() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PISTON_MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); // Some Pistons are moving but that should not interefere with the Multiblock @@ -94,12 +101,13 @@ public class TestMultiBlocks { MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.MOVING_PISTON, Material.PISTON, Material.MOVING_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN); MultiBlock multiblock3 = new MultiBlock(item, new Material[] { Material.PISTON, Material.PISTON, Material.STICKY_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN); - Assertions.assertTrue(multiblock.equals(multiblock2)); - Assertions.assertFalse(multiblock.equals(multiblock3)); + Assertions.assertEquals(multiblock, multiblock2); + Assertions.assertNotEquals(multiblock, multiblock3); } @Test - public void testNotEqual() { + @DisplayName("Test different MultiBlocks not being equal") + void testNotEqual() { SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test")); MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN); @@ -107,10 +115,10 @@ public class TestMultiBlocks { MultiBlock multiblock3 = new MultiBlock(item, new Material[] { Material.DROPPER, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.DIAMOND_BLOCK, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.TNT }, BlockFace.DOWN); MultiBlock multiblock4 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.SELF); - Assertions.assertFalse(multiblock.equals(null)); - Assertions.assertFalse(multiblock.equals(multiblock2)); - Assertions.assertFalse(multiblock.equals(multiblock3)); - Assertions.assertFalse(multiblock.equals(multiblock4)); + Assertions.assertNotEquals(multiblock, null); + Assertions.assertNotEquals(multiblock, multiblock2); + Assertions.assertNotEquals(multiblock, multiblock3); + Assertions.assertNotEquals(multiblock, multiblock4); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TestItemDataService.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TestItemDataService.java index 544deba6f..7a6d261c8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TestItemDataService.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TestItemDataService.java @@ -9,13 +9,14 @@ import org.bukkit.inventory.meta.ItemMeta; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import be.seeseemelk.mockbukkit.MockBukkit; import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -public class TestItemDataService { +class TestItemDataService { private static SlimefunPlugin plugin; @@ -31,13 +32,15 @@ public class TestItemDataService { } @Test - public void testInitialization() { + @DisplayName("Test CustomItemDataService constructor") + void testInitialization() { CustomItemDataService service = new CustomItemDataService(plugin, "test"); Assertions.assertEquals(new NamespacedKey(plugin, "test"), service.getKey()); } @Test - public void testSetDataItem() { + @DisplayName("Test setting item data for an ItemStack") + void testSetDataItem() { CustomItemDataService service = new CustomItemDataService(plugin, "test"); ItemStack item = new ItemStack(Material.EMERALD); @@ -49,7 +52,8 @@ public class TestItemDataService { } @Test - public void testSetDataItemMeta() { + @DisplayName("Test setting item data for an ItemMeta") + void testSetDataItemMeta() { CustomItemDataService service = new CustomItemDataService(plugin, "test"); ItemStack item = new ItemStack(Material.EMERALD); ItemMeta meta = item.getItemMeta(); From f60fbc7fcd43d18c789560588358fb8a3b9c61e9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 10:15:02 +0200 Subject: [PATCH 081/163] [CI skip] Updated Discord Banner in README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e1a17550..9213aa050 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,8 @@ Not following these rules can lead to a kick or even a ban from the server.

- Discord Invite -
- (Click the badge to join) + Discord Invite +

## Wiki From e0a76fa0e8cf9b3f76757f3a215250fba1375437 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 15:32:06 +0200 Subject: [PATCH 082/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1119161b..703909db5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ #### Additions * Added /sf charge * Added Energized Energy Capacitor +* Added various new fuel types to the Coal Generator #### Changes * Improved Auto-Updater (Multi-Threading and more) From dd11cd0f300b5cd6b61366b975fcaab3219d61b0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 18:38:40 +0200 Subject: [PATCH 083/163] [CI skip] Removed redundant interface --- .../java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index feb7253df..8f78c8a11 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -33,7 +33,7 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -public class SlimefunItemStack extends CustomItem implements Cloneable { +public class SlimefunItemStack extends CustomItem { private String id; private ImmutableItemMeta immutableMeta; From 99e46fcb2afe7cf050e4aa132dce74f9ddc46a5f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 22 Sep 2020 19:39:06 +0200 Subject: [PATCH 084/163] [CI skip] Relocated and documented two methods --- .../slimefun4/api/ErrorReport.java | 3 +- .../slimefun4/api/gps/GPSNetwork.java | 3 +- .../api/gps/TeleportationManager.java | 7 +- .../slimefun4/api/network/Network.java | 4 +- .../slimefun4/api/player/PlayerBackpack.java | 4 +- .../commands/subcommands/BackpackCommand.java | 3 +- .../slimefun4/core/guide/SlimefunGuide.java | 3 +- .../core/networks/cargo/CargoNet.java | 2 +- .../core/networks/energy/EnergyNet.java | 3 +- .../slimefun4/core/researching/Research.java | 9 ++- .../core/services/MetricsService.java | 3 +- .../implementation/SlimefunPlugin.java | 64 ++++++++++++++++++- .../guide/BookSlimefunGuide.java | 6 +- .../items/androids/ProgrammableAndroid.java | 3 +- .../items/blocks/BlockPlacer.java | 7 +- .../implementation/items/blocks/Crucible.java | 18 ++++-- .../machines/AbstractEntityAssembler.java | 3 +- .../electric/reactors/NetherStarReactor.java | 4 +- .../items/electric/reactors/Reactor.java | 5 +- .../implementation/items/food/Juice.java | 10 +-- .../items/food/MonsterJerky.java | 4 +- .../items/gps/ElevatorPlate.java | 3 +- .../items/magical/EnchantmentRune.java | 4 +- .../items/magical/SoulboundRune.java | 4 +- .../items/multiblocks/ArmorForge.java | 2 +- .../items/multiblocks/Compressor.java | 3 +- .../items/multiblocks/MagicWorkbench.java | 2 +- .../items/multiblocks/PressureChamber.java | 3 +- .../items/multiblocks/miner/ActiveMiner.java | 6 +- .../items/tools/ClimbingPick.java | 3 +- .../listeners/AncientAltarListener.java | 4 +- .../listeners/ButcherAndroidListener.java | 3 +- .../listeners/CoolerListener.java | 14 ++-- .../listeners/GrapplingHookListener.java | 9 ++- .../listeners/SlimefunBowListener.java | 3 +- .../listeners/TalismanListener.java | 3 +- .../tasks/AncientAltarTask.java | 3 +- .../implementation/tasks/ArmorTask.java | 4 +- .../implementation/tasks/TickerTask.java | 2 +- .../slimefun4/utils/SlimefunUtils.java | 3 +- .../utils/holograms/ReactorHologram.java | 4 +- .../utils/holograms/SimpleHologram.java | 6 +- .../Slimefun/api/BlockStorage.java | 2 +- .../mrCookieSlime/Slimefun/api/Slimefun.java | 29 --------- .../api/inventory/BlockMenuPreset.java | 3 +- 45 files changed, 152 insertions(+), 138 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index edaf225ce..873f5e221 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -27,7 +27,6 @@ import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This class represents an {@link ErrorReport}. @@ -53,7 +52,7 @@ public class ErrorReport { this.throwable = throwable; this.addon = addon; - Slimefun.runSync(() -> print(printer)); + SlimefunPlugin.runSync(() -> print(printer)); } @ParametersAreNonnullByDefault diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index d57d1bb20..e7507604e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -37,7 +37,6 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link GPSNetwork} is a manager class for all {@link GPSTransmitter Transmitters} and waypoints. @@ -288,7 +287,7 @@ public class GPSNetwork { return; } - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { WaypointCreateEvent event = new WaypointCreateEvent(p, name, l); Bukkit.getPluginManager().callEvent(event); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 47e6f804e..32c4d485a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -27,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.api.Slimefun; public final class TeleportationManager { @@ -79,7 +78,7 @@ public final class TeleportationManager { index++; } - Slimefun.runSync(() -> menu.open(p)); + SlimefunPlugin.runSync(() -> menu.open(p)); }); } @@ -137,7 +136,7 @@ public final class TeleportationManager { source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); source.getWorld().playSound(source, Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F); - Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); + SlimefunPlugin.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); } } else { @@ -149,7 +148,7 @@ public final class TeleportationManager { private void onTeleport(Player p, Location destination, boolean success, boolean resistance) { // This needs to run on the main Thread so we force it, as the // async teleportation might happen on a separate Thread. - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (success) { // Apply Resistance Effect, if enabled if (resistance) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java index 21872a875..bc974b25b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java @@ -16,8 +16,8 @@ import org.bukkit.Particle; import org.bukkit.Particle.DustOptions; import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * An abstract Network class to manage networks in a stateful way @@ -217,7 +217,7 @@ public abstract class Network { * every {@link Location} that this {@link Network} is connected to. */ public void display() { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { DustOptions options = new DustOptions(Color.BLUE, 3F); for (Location l : connectedLocations) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java index 581198d6e..3ef400fd8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java @@ -10,9 +10,9 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.config.Config; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This class represents the instance of a {@link SlimefunBackpack} that is ready to @@ -123,7 +123,7 @@ public class PlayerBackpack { * The players who this Backpack will be shown to */ public void open(Player... players) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { for (Player p : players) { p.openInventory(inventory); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java index 1b1478e30..6454bcbd8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java @@ -12,7 +12,6 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; -import me.mrCookieSlime.Slimefun.api.Slimefun; class BackpackCommand extends SubCommand { @@ -58,7 +57,7 @@ class BackpackCommand extends SubCommand { return; } - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone(); SlimefunPlugin.getBackpackListener().setBackpackId(backpackOwner, item, 2, id); ((Player) sender).getInventory().addItem(item); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index cc15b1d1b..290be0f44 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -14,7 +14,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuid import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This is a static utility class that provides convenient access to the methods @@ -73,7 +72,7 @@ public final class SlimefunGuide { } private static void openMainMenuAsync(Player player, SlimefunGuideLayout layout, int selectedPage) { - if (!PlayerProfile.get(player, profile -> Slimefun.runSync(() -> openMainMenu(profile, layout, selectedPage)))) { + if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, layout, selectedPage)))) { SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index c7fa6fcef..0b277ad30 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -180,7 +180,7 @@ public class CargoNet extends ChestTerminalNetwork { SlimefunPlugin.getProfiler().scheduleEntries((terminals.isEmpty() ? 1 : 2) + inputs.size()); CargoNetworkTask runnable = new CargoNetworkTask(this, inputs, outputs, chestTerminalInputs, chestTerminalOutputs); - Slimefun.runSync(runnable); + SlimefunPlugin.runSync(runnable); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java index f10217f74..12127579b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java @@ -27,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link EnergyNet} is an implementation of {@link Network} that deals with @@ -229,7 +228,7 @@ public class EnergyNet extends Network { explodedBlocks.add(loc); BlockStorage.clearBlockInfo(loc); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { loc.getBlock().setType(Material.LAVA); loc.getWorld().createExplosion(loc, 0F, false); }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java index 63e69b884..907a390ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java @@ -26,7 +26,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * Represents a research, which is bound to one @@ -230,7 +229,7 @@ public class Research implements Keyed { */ public void unlock(@Nonnull Player p, boolean instant, @Nonnull Consumer callback) { if (!instant) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F); SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)).replace("%progress%", "0%")); }, 10L); @@ -238,7 +237,7 @@ public class Research implements Keyed { PlayerProfile.get(p, profile -> { if (!profile.hasUnlocked(this)) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ResearchUnlockEvent event = new ResearchUnlockEvent(p, this); Bukkit.getPluginManager().callEvent(event); @@ -250,7 +249,7 @@ public class Research implements Keyed { SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p))); playResearchAnimation(p); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { finishResearch(p, profile, callback); SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId()); }, (RESEARCH_PROGRESS.length + 1) * 20L); @@ -275,7 +274,7 @@ public class Research implements Keyed { for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) { int j = i; - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F); SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)).replace("%progress%", RESEARCH_PROGRESS[j - 1] + "%")); }, i * 20L); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java index feaee4dc8..14277f7c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java @@ -22,7 +22,6 @@ import kong.unirest.HttpResponse; import kong.unirest.JsonNode; import kong.unirest.Unirest; import kong.unirest.UnirestException; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This Class represents a Metrics Service that sends data to https://bstats.org/ @@ -102,7 +101,7 @@ public class MetricsService { String version = metricsClass.getPackage().getImplementationVersion(); // This is required to be sync due to bStats. - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { try { start.invoke(null); plugin.getLogger().info("Metrics build #" + version + " started."); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index d1fd6ca5f..ab0b9e2d0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.command.Command; @@ -21,6 +22,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPluginLoader; +import org.bukkit.scheduler.BukkitTask; import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler; @@ -101,7 +103,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; /** @@ -241,7 +242,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { registerListeners(); // Initiating various Stuff and all items with a slight delay (0ms after the Server finished loading) - Slimefun.runSync(new SlimefunStartupTask(this, () -> { + runSync(new SlimefunStartupTask(this, () -> { protections = new ProtectionManager(getServer()); textureService.register(registry.getAllSlimefunItems(), true); permissionsService.register(registry.getAllSlimefunItems(), true); @@ -706,4 +707,63 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { return "https://github.com/Slimefun/Slimefun4/issues"; } + /** + * This method schedules a delayed synchronous task for Slimefun. + * For Slimefun only, not for addons. + * + * This method should only be invoked by Slimefun itself. + * Addons must schedule their own tasks using their own {@link Plugin} instance. + * + * @param runnable + * The {@link Runnable} to run + * @param delay + * The delay for this task + * + * @return The resulting {@link BukkitTask} or null if Slimefun was disabled + */ + @Nullable + public static BukkitTask runSync(@Nonnull Runnable runnable, long delay) { + Validate.notNull(runnable, "Cannot run null"); + Validate.isTrue(delay >= 0, "The delay cannot be negative"); + + if (getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { + runnable.run(); + return null; + } + + if (instance == null || !instance.isEnabled()) { + return null; + } + + return instance.getServer().getScheduler().runTaskLater(instance, runnable, delay); + } + + /** + * This method schedules a synchronous task for Slimefun. + * For Slimefun only, not for addons. + * + * This method should only be invoked by Slimefun itself. + * Addons must schedule their own tasks using their own {@link Plugin} instance. + * + * @param runnable + * The {@link Runnable} to run + * + * @return The resulting {@link BukkitTask} or null if Slimefun was disabled + */ + @Nullable + public static BukkitTask runSync(@Nonnull Runnable runnable) { + Validate.notNull(runnable, "Cannot run null"); + + if (getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { + runnable.run(); + return null; + } + + if (instance == null || !instance.isEnabled()) { + return null; + } + + return instance.getServer().getScheduler().runTask(instance, runnable); + } + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java index 79369acce..d15c1936e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java @@ -80,7 +80,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main") + " -\n\n")); header.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p))); - header.setClickEvent(new ClickEvent(guideSearch, player -> Slimefun.runSync(() -> { + header.setClickEvent(new ClickEvent(guideSearch, player -> SlimefunPlugin.runSync(() -> { SlimefunPlugin.getLocalization().sendMessage(player, "guide.search.message"); ChatInput.waitForPlayer(SlimefunPlugin.instance(), player, msg -> SlimefunGuide.openSearch(profile, msg, true, true)); }, 1))); @@ -234,13 +234,13 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { } component.setHoverEvent(new HoverEvent(lore)); - component.setClickEvent(new ClickEvent(key, player -> Slimefun.runSync(() -> displayItem(profile, item, true)))); + component.setClickEvent(new ClickEvent(key, player -> SlimefunPlugin.runSync(() -> displayItem(profile, item, true)))); items.add(component); } } private void research(Player p, PlayerProfile profile, SlimefunItem item, Research research, Category category, int page) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId())) { if (research.canUnlock(p)) { if (profile.hasUnlocked(research)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 096abbf8e..b94d6f590 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -55,7 +55,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -848,7 +847,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, }); block.setBlockData(blockData); - Slimefun.runSync(() -> SkullBlock.setFromBase64(block, texture)); + SlimefunPlugin.runSync(() -> SkullBlock.setFromBase64(block, texture)); b.setType(Material.AIR); BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java index 225af96dd..d71d43ed8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java @@ -32,7 +32,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -156,7 +155,7 @@ public class BlockPlacer extends SlimefunItem { dispenser.getInventory().removeItem(new CustomItem(item, 1)); } else { - Slimefun.runSync(() -> dispenser.getInventory().removeItem(item), 2L); + SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } }); @@ -171,7 +170,7 @@ public class BlockPlacer extends SlimefunItem { dispenser.getInventory().removeItem(new CustomItem(item, 1)); } else { - Slimefun.runSync(() -> dispenser.getInventory().removeItem(item), 2L); + SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } } @@ -209,7 +208,7 @@ public class BlockPlacer extends SlimefunItem { dispenser.getInventory().removeItem(new CustomItem(item, 1)); } else { - Slimefun.runSync(() -> dispenser.getInventory().removeItem(item), 2L); + SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java index b7e490b6a..4ed2e7e3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java @@ -4,6 +4,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.Tag; @@ -24,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Crucible extends SimpleSlimefunItem implements RecipeDisplayItem { @@ -100,6 +102,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec }; } + @ParametersAreNonnullByDefault private boolean craft(Player p, ItemStack input) { for (int i = 0; i < recipes.size(); i += 2) { ItemStack convert = recipes.get(i); @@ -116,7 +119,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec return false; } - private void generateLiquid(Block block, boolean water) { + private void generateLiquid(@Nonnull Block block, boolean water) { if (block.getType() == (water ? Material.WATER : Material.LAVA)) { addLiquidLevel(block, water); } @@ -126,11 +129,11 @@ public class Crucible extends SimpleSlimefunItem implements Rec block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F); } else { - Slimefun.runSync(() -> placeLiquid(block, water), 50L); + SlimefunPlugin.runSync(() -> placeLiquid(block, water), 50L); } } - private void addLiquidLevel(Block block, boolean water) { + private void addLiquidLevel(@Nonnull Block block, boolean water) { int level = ((Levelled) block.getBlockData()).getLevel(); if (level > 7) { @@ -142,11 +145,11 @@ public class Crucible extends SimpleSlimefunItem implements Rec } else { int finalLevel = 7 - level; - Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L); + SlimefunPlugin.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L); } } - private void placeLiquid(Block block, boolean water) { + private void placeLiquid(@Nonnull Block block, boolean water) { if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || block.getType() == Material.VOID_AIR) { block.setType(water ? Material.WATER : Material.LAVA); } @@ -167,6 +170,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1); } + @ParametersAreNonnullByDefault private void runPostTask(Block block, Sound sound, int times) { if (!(block.getBlockData() instanceof Levelled)) { block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F); @@ -180,7 +184,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec block.setBlockData(le, false); if (times < 8) { - Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L); + SlimefunPlugin.runSync(() -> runPostTask(block, sound, times + 1), 50L); } else { block.getWorld().playSound(block.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java index d1de20267..0f4ff3ff0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java @@ -28,7 +28,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -206,7 +205,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl removeCharge(b.getLocation(), getEnergyConsumption()); double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { Location loc = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D); spawnEntity(loc); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java index c8324f23f..227ecbde7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java @@ -13,11 +13,11 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.holograms.ReactorHologram; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -43,7 +43,7 @@ public abstract class NetherStarReactor extends Reactor { @Override public void extraTick(@Nonnull Location l) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ArmorStand hologram = ReactorHologram.getArmorStand(l, true); for (Entity entity : hologram.getNearbyEntities(5, 5, 5)) { if (entity instanceof LivingEntity && entity.isValid()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java index 8a5ba74bb..1f8f6ab24 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java @@ -37,7 +37,6 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -332,7 +331,7 @@ public abstract class Reactor extends AbstractEnergyProvider { boolean explosion = explosionsQueue.contains(l); if (explosion) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ReactorExplodeEvent event = new ReactorExplodeEvent(l, Reactor.this); Bukkit.getPluginManager().callEvent(event); @@ -349,7 +348,7 @@ public abstract class Reactor extends AbstractEnergyProvider { } private void checkForWaterBlocks(Location l) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { // We will pick a surrounding block at random and see if this is water. // If it isn't, then we will make it explode. int index = ThreadLocalRandom.current().nextInt(WATER_BLOCKS.length); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java index 15d2d1c78..7f2592ed4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java @@ -12,6 +12,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; @@ -19,7 +20,6 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -81,18 +81,18 @@ public class Juice extends SimpleSlimefunItem { private void removeGlassBottle(Player p, ItemStack item) { if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInMainHand(), true)) { if (p.getInventory().getItemInMainHand().getAmount() == 1) { - Slimefun.runSync(() -> p.getEquipment().getItemInMainHand().setAmount(0)); + SlimefunPlugin.runSync(() -> p.getEquipment().getItemInMainHand().setAmount(0)); } else { - Slimefun.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); + SlimefunPlugin.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); } } else if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInOffHand(), true)) { if (p.getInventory().getItemInOffHand().getAmount() == 1) { - Slimefun.runSync(() -> p.getEquipment().getItemInOffHand().setAmount(0)); + SlimefunPlugin.runSync(() -> p.getEquipment().getItemInOffHand().setAmount(0)); } else { - Slimefun.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); + SlimefunPlugin.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java index 1766b481f..5f3b1c59d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java @@ -5,10 +5,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -27,7 +27,7 @@ public class MonsterJerky extends SimpleSlimefunItem { @Override public ItemConsumptionHandler getItemHandler() { - return (e, p, item) -> Slimefun.runSync(() -> { + return (e, p, item) -> SlimefunPlugin.runSync(() -> { if (p.hasPotionEffect(PotionEffectType.HUNGER)) { p.removePotionEffect(PotionEffectType.HUNGER); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java index e3eb557ca..275c94b4a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java @@ -34,7 +34,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class ElevatorPlate extends SimpleSlimefunItem { @@ -152,7 +151,7 @@ public class ElevatorPlate extends SimpleSlimefunItem { @ParametersAreNonnullByDefault private void teleport(Player player, String floorName, Block target) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { users.add(player.getUniqueId()); float yaw = player.getEyeLocation().getYaw() + 180; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java index d3ee4d37f..081636866 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java @@ -67,7 +67,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { return (e, p, item) -> { if (isItem(item.getItemStack())) { if (Slimefun.hasUnlocked(p, this, true)) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { try { addRandomEnchantment(p, item); } @@ -124,7 +124,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { // This lightning is just an effect, it deals no damage. l.getWorld().strikeLightningEffect(l); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { // Being sure entities are still valid and not picked up or whatsoever. if (rune.isValid() && item.isValid() && itemStack.getAmount() == 1) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java index 9a9c4d54e..a02fb63ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java @@ -50,7 +50,7 @@ public class SoulboundRune extends SimpleSlimefunItem { return true; } - Slimefun.runSync(() -> activate(p, item), 20L); + SlimefunPlugin.runSync(() -> activate(p, item), 20L); return true; } @@ -76,7 +76,7 @@ public class SoulboundRune extends SimpleSlimefunItem { // This lightning is just an effect, it deals no damage. l.getWorld().strikeLightningEffect(l); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { // Being sure entities are still valid and not picked up or whatsoever. if (rune.isValid() && item.isValid() && itemStack.getAmount() == 1) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java index cd97b214f..189592597 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java @@ -84,7 +84,7 @@ public class ArmorForge extends MultiBlockMachine { for (int j = 0; j < 4; j++) { int current = j; - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (current < 3) { p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java index 854e047e0..4d467b340 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java @@ -21,7 +21,6 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Compressor extends MultiBlockMachine { @@ -83,7 +82,7 @@ public class Compressor extends MultiBlockMachine { for (int i = 0; i < 4; i++) { int j = i; - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (j < 3) { p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java index 1b0de4047..5b6ed3bd8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java @@ -94,7 +94,7 @@ public class MagicWorkbench extends BackpackCrafter { private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) { for (int j = 0; j < 4; j++) { int current = j; - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java index b10c5fcbc..de4cedb38 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java @@ -22,7 +22,6 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class PressureChamber extends MultiBlockMachine { @@ -75,7 +74,7 @@ public class PressureChamber extends MultiBlockMachine { for (int i = 0; i < 4; i++) { int j = i; - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4); p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java index 4ed3f3d72..06fc54f83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java @@ -191,7 +191,7 @@ class ActiveMiner implements Runnable { ores++; // Repeat the same column when we hit an ore. - Slimefun.runSync(this, 4); + SlimefunPlugin.runSync(this, 4); return; } } @@ -232,7 +232,7 @@ class ActiveMiner implements Runnable { return; } - Slimefun.runSync(this, 5); + SlimefunPlugin.runSync(this, 5); } /** @@ -317,7 +317,7 @@ class ActiveMiner implements Runnable { } } } - + return 0; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java index 39df55419..9a6e23676 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java @@ -36,7 +36,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -151,7 +150,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements power += efficiencyLevel * 0.1; } - Slimefun.runSync(() -> users.remove(p.getUniqueId()), 4L); + SlimefunPlugin.runSync(() -> users.remove(p.getUniqueId()), 4L); Vector velocity = new Vector(0, power * BASE_POWER, 0); ClimbingPickLaunchEvent event = new ClimbingPickLaunchEvent(p, velocity, this, item, block); Bukkit.getPluginManager().callEvent(event); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 414559673..2c550defe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -155,7 +155,7 @@ public class AncientAltarListener implements Listener { UUID uuid = entity.getUniqueId(); removedItems.add(uuid); - Slimefun.runSync(() -> removedItems.remove(uuid), 30L); + SlimefunPlugin.runSync(() -> removedItems.remove(uuid), 30L); entity.remove(); p.getInventory().addItem(pedestalItem.getOriginalItemStack(entity)); @@ -228,7 +228,7 @@ public class AncientAltarListener implements Listener { b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ILLUSIONER_PREPARE_MIRROR, 1, 1); AncientAltarTask task = new AncientAltarTask(this, b, altarItem.getSpeed(), result.get(), pedestals, consumed, p); - Slimefun.runSync(task, 10L); + SlimefunPlugin.runSync(task, 10L); } else { altars.remove(b); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java index f2de2473b..d2db858fc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java @@ -23,7 +23,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This {@link Listener} handles the collection of drops from an {@link Entity} that was @@ -45,7 +44,7 @@ public class ButcherAndroidListener implements Listener { if (e.getEntity().hasMetadata(METADATA_KEY)) { AndroidInstance obj = (AndroidInstance) e.getEntity().getMetadata(METADATA_KEY).get(0).value(); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { List items = new ArrayList<>(); // Collect any nearby dropped items diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java index fa4becf8a..7794dd071 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java @@ -23,8 +23,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; import me.mrCookieSlime.Slimefun.api.Slimefun; /** - * This {@link Listener} listens for a {@link FoodLevelChangeEvent} or an {@link EntityDamageEvent} for starvation damage - * and consumes a {@link Juice} from any {@link Cooler} that can be found in the {@link Inventory} of the given {@link Player}. + * This {@link Listener} listens for a {@link FoodLevelChangeEvent} or an {@link EntityDamageEvent} for starvation + * damage + * and consumes a {@link Juice} from any {@link Cooler} that can be found in the {@link Inventory} of the given + * {@link Player}. * * @author TheBusyBiscuit * @author Linox @@ -55,18 +57,18 @@ public class CoolerListener implements Listener { checkAndConsume(p); } } - + @EventHandler public void onHungerDamage(EntityDamageEvent e) { if (cooler == null || cooler.isDisabled() || !(e.getEntity() instanceof Player)) { return; } - + if (e.getCause() == DamageCause.STARVATION) { checkAndConsume((Player) e.getEntity()); } } - + private void checkAndConsume(@Nonnull Player p) { for (ItemStack item : p.getInventory().getContents()) { if (cooler.isItem(item)) { @@ -92,7 +94,7 @@ public class CoolerListener implements Listener { private void takeJuiceFromCooler(@Nonnull Player p, @Nonnull ItemStack cooler) { PlayerProfile.getBackpack(cooler, backpack -> { if (backpack != null) { - Slimefun.runSync(() -> consumeJuice(p, backpack)); + SlimefunPlugin.runSync(() -> consumeJuice(p, backpack)); } }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index f44f8c98f..b28bfaa84 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -28,7 +28,6 @@ import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This {@link Listener} is responsible for the mechanics behind the {@link GrapplingHook}. @@ -74,7 +73,7 @@ public class GrapplingHookListener implements Listener { return; } - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (e.getEntity() instanceof Arrow) { handleGrapplingHook((Arrow) e.getEntity()); } @@ -174,7 +173,7 @@ public class GrapplingHookListener implements Listener { p.setVelocity(velocity); hook.remove(); - Slimefun.runSync(() -> activeHooks.remove(p.getUniqueId()), 20L); + SlimefunPlugin.runSync(() -> activeHooks.remove(p.getUniqueId()), 20L); } } } @@ -191,14 +190,14 @@ public class GrapplingHookListener implements Listener { activeHooks.put(uuid, hook); // To fix issue #253 - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { GrapplingHookEntity entity = activeHooks.get(uuid); if (entity != null) { SlimefunPlugin.getBowListener().getProjectileData().remove(uuid); entity.remove(); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { activeHooks.remove(uuid); invulnerability.remove(uuid); }, 20L); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java index 7d6c8e9ef..351263132 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java @@ -21,7 +21,6 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * This {@link Listener} is responsible for tracking {@link Arrow Arrows} fired from a @@ -64,7 +63,7 @@ public class SlimefunBowListener implements Listener { @EventHandler public void onArrowHit(ProjectileHitEvent e) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { if (e.getEntity().isValid() && e.getEntity() instanceof Arrow) { projectiles.remove(e.getEntity().getUniqueId()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index df17d39e0..f1c119cd9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -45,7 +45,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.TalismanEnchantment; -import me.mrCookieSlime.Slimefun.api.Slimefun; public class TalismanListener implements Listener { @@ -216,7 +215,7 @@ public class TalismanListener implements Listener { int itemSlot = slot; // Update the item forcefully - Slimefun.runSync(() -> inv.setItem(itemSlot, item), 1L); + SlimefunPlugin.runSync(() -> inv.setItem(itemSlot, item), 1L); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java index b3615365c..a6fd8bdeb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java @@ -27,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link AncientAltarTask} is responsible for the animation that happens when a ritual @@ -103,7 +102,7 @@ public class AncientAltarTask implements Runnable { } this.stage += 1; - Slimefun.runSync(this, speed); + SlimefunPlugin.runSync(this, speed); } private boolean checkLockedItems() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java index 1ece100a1..8b92ac872 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java @@ -112,7 +112,7 @@ public class ArmorTask implements Runnable { } if (item != null && armorpiece.getItem().isPresent()) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { SlimefunArmorPiece slimefunArmor = armorpiece.getItem().get(); if (Slimefun.hasUnlocked(p, slimefunArmor, true)) { @@ -172,7 +172,7 @@ public class ArmorTask implements Runnable { // If the item is enabled in the world, then make radioactivity do its job SlimefunPlugin.getLocalization().sendMessage(p, "messages.radiation"); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { p.addPotionEffects(radiationEffects); // if radiative fire is enabled diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index 2fc7f82db..61dd2a5aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -147,7 +147,7 @@ public class TickerTask implements Runnable { item.getBlockTicker().update(); // We are inserting a new timestamp because synchronized // actions are always ran with a 50ms delay (1 game tick) - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { Block b = l.getBlock(); tickBlock(l, b, item, data, System.nanoTime()); }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 98e5d28fa..d8ed4e0db 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -36,7 +36,6 @@ import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.EmeraldEnchants.EmeraldEnchants; import me.mrCookieSlime.EmeraldEnchants.ItemEnchantment; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** @@ -351,7 +350,7 @@ public final class SlimefunUtils { Validate.notNull(l, "Cannot update a texture for null"); Validate.isTrue(capacity > 0, "Capacity must be greater than zero!"); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { Block b = l.getBlock(); if (b.getType() == Material.PLAYER_HEAD || b.getType() == Material.PLAYER_WALL_HEAD) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/ReactorHologram.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/ReactorHologram.java index 0060a0454..a0d56e4bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/ReactorHologram.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/ReactorHologram.java @@ -8,7 +8,7 @@ import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; -import me.mrCookieSlime.Slimefun.api.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; public final class ReactorHologram { @@ -35,7 +35,7 @@ public final class ReactorHologram { } public static void update(@Nonnull Location l, @Nonnull String name) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ArmorStand hologram = getArmorStand(l, true); if (!hologram.isCustomNameVisible()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java index fc24ea0a8..05419dbf4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java @@ -10,7 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; -import me.mrCookieSlime.Slimefun.api.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; /** * This utility class provides a few static methods for modifying a simple Text-based Hologram. @@ -23,14 +23,14 @@ public final class SimpleHologram { private SimpleHologram() {} public static void update(@Nonnull Block b, @Nonnull String name) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ArmorStand hologram = getArmorStand(b, true); hologram.setCustomName(ChatColors.color(name)); }); } public static void remove(@Nonnull Block b) { - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { ArmorStand hologram = getArmorStand(b, false); if (hologram != null) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java index b261a0b37..4d7221f5d 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -799,7 +799,7 @@ public class BlockStorage { for (HumanEntity human : new ArrayList<>(menu.toInventory().getViewers())) { // Prevents "java.lang.IllegalStateException: Asynchronous entity add!" // when closing the inventory while holding an item - Slimefun.runSync(human::closeInventory); + SlimefunPlugin.runSync(human::closeInventory); } inventories.get(l).delete(l); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java index b7d7af302..701e7ce1e 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java @@ -3,12 +3,9 @@ package me.mrCookieSlime.Slimefun.api; import java.util.Optional; import java.util.logging.Logger; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitTask; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -180,30 +177,4 @@ public final class Slimefun { } return true; } - - public static BukkitTask runSync(Runnable r) { - if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { - r.run(); - return null; - } - - if (SlimefunPlugin.instance() == null || !SlimefunPlugin.instance().isEnabled()) { - return null; - } - - return Bukkit.getScheduler().runTask(SlimefunPlugin.instance(), r); - } - - public static BukkitTask runSync(Runnable r, long delay) { - if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { - r.run(); - return null; - } - - if (SlimefunPlugin.instance() == null || !SlimefunPlugin.instance().isEnabled()) { - return null; - } - - return Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), r, delay); - } } \ No newline at end of file diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java index 4cf2a02cf..7a5182569 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java @@ -13,7 +13,6 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; public abstract class BlockMenuPreset extends ChestMenu { @@ -189,7 +188,7 @@ public abstract class BlockMenuPreset extends ChestMenu { public void newInstance(BlockMenu menu, Location l) { Validate.notNull(l, "Cannot create a new BlockMenu without a Location"); - Slimefun.runSync(() -> { + SlimefunPlugin.runSync(() -> { locked = true; try { From 8a1780de2cdde032d424c7950fa9ba4c34fb3f96 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 23 Sep 2020 16:11:06 +0200 Subject: [PATCH 085/163] [CI skip] Failing URL checks be gone --- .github/workflows/url-checker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/url-checker.yml b/.github/workflows/url-checker.yml index 3fb71f773..e0e150008 100644 --- a/.github/workflows/url-checker.yml +++ b/.github/workflows/url-checker.yml @@ -23,4 +23,4 @@ jobs: print_all: False retry_count: 2 ## These URLs will always be correct, even if their services may be offline right now - white_listed_patterns: http://textures.minecraft.net/texture/,https://pastebin.com/,https://www.spigotmc.org/threads/spigot-bungeecord-1-16-1.447405/#post-3852349 + white_listed_patterns: http://textures.minecraft.net/texture/,https://pastebin.com/,https://www.spigotmc.org/threads/spigot-bungeecord-1-16-1.447405/#post-3852349,https://gitlocalize.com/repo/3841 From f2e0606362776e669fc57e318f60483e3e1f9983 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 24 Sep 2020 15:53:41 +0000 Subject: [PATCH 086/163] Update dependency org.mockito:mockito-core to v3.5.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b8ebbf3c..4f34685ad 100644 --- a/pom.xml +++ b/pom.xml @@ -323,7 +323,7 @@ org.mockito mockito-core - 3.5.11 + 3.5.13 test From beb3a0132373964c9dcbe3ac142e90ed9a3937c2 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 24 Sep 2020 19:40:22 +0200 Subject: [PATCH 087/163] [CI skip] Updated sonarcloud settings --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4f34685ad..f737084b2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.github.thebusybiscuit + com.github.slimefun Slimefun @@ -26,8 +26,8 @@ https://hub.spigotmc.org/javadocs/spigot/ - TheBusyBiscuit_Slimefun4 - thebusybiscuit-github + Slimefun_Slimefun4 + slimefun https://sonarcloud.io DEBUG src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java From 8568ba300ae4d3f68e99fe85a92005a1e943f78e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 25 Sep 2020 09:46:02 +0200 Subject: [PATCH 088/163] Small performance optimization and deprecated an old class --- .../api/inventory/BlockMenuPreset.java | 70 +++++++++++++++++-- .../api/inventory/DirtyChestMenu.java | 40 ++++++++--- .../api/inventory/ItemManipulationEvent.java | 7 ++ 3 files changed, 102 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java index 7a5182569..be7877c56 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java @@ -3,10 +3,14 @@ package me.mrCookieSlime.Slimefun.api.inventory; import java.util.HashSet; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; @@ -29,13 +33,15 @@ public abstract class BlockMenuPreset extends ChestMenu { private ItemManipulationEvent event; - public BlockMenuPreset(String id, String title) { + public BlockMenuPreset(@Nonnull String id, @Nonnull String title) { this(id, title, false); } - public BlockMenuPreset(String id, String title, boolean universal) { + public BlockMenuPreset(@Nonnull String id, @Nonnull String title, boolean universal) { super(title); + Validate.notNull(id, "You need to specify an id!"); + this.id = id; this.inventoryTitle = title; this.universal = universal; @@ -52,15 +58,57 @@ public abstract class BlockMenuPreset extends ChestMenu { public abstract void init(); - public abstract boolean canOpen(Block b, Player p); + /** + * This method returns whether a given {@link Player} is allowed to open the + * {@link BlockMenu} of that {@link Block}. + * Override this as necessary. + * + * @param b + * The {@link Block} trying to be opened + * @param p + * The {@link Player} who wants to open the {@link BlockMenu} + * + * @return Whether that {@link Player} is allowed + */ + public abstract boolean canOpen(@Nonnull Block b, @Nonnull Player p); public abstract int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow); + /** + * This method is deprecated. + * + * @deprecated Override {@link #onItemStackChange(DirtyChestMenu, int, ItemStack, ItemStack)} instead + * + * @param event + * The event + */ + @Deprecated public void registerEvent(ItemManipulationEvent event) { this.event = event; } - public void newInstance(BlockMenu menu, Block b) { + /** + * This method is called whenever an {@link ItemStack} changes. + * You can override this as necessary if you need to listen to these events + * + * @param menu + * The {@link Inventory} affected by this + * @param slot + * The affected slot + * @param previous + * The {@link ItemStack} in that slot before the operation + * @param next + * The {@link ItemStack} that it changes to + * + * @return The new outcome of this operation + */ + @Nullable + protected ItemStack onItemStackChange(@Nonnull DirtyChestMenu menu, int slot, @Nullable ItemStack previous, @Nullable ItemStack next) { + // Override this as necessary + return next; + } + + public void newInstance(@Nonnull BlockMenu menu, @Nonnull Block b) { // This method can optionally be overridden by implementations } @@ -75,7 +123,7 @@ public abstract class BlockMenuPreset extends ChestMenu { } @Override - public ChestMenu addItem(int slot, ItemStack item) { + public ChestMenu addItem(int slot, @Nullable ItemStack item) { checkIfLocked(); occupiedSlots.add(slot); @@ -88,6 +136,7 @@ public abstract class BlockMenuPreset extends ChestMenu { return super.addMenuClickHandler(slot, handler); } + @Nonnull public ChestMenu setSize(int size) { checkIfLocked(); @@ -133,10 +182,12 @@ public abstract class BlockMenuPreset extends ChestMenu { return universal; } + @Nonnull public Set getPresetSlots() { return occupiedSlots; } + @Nonnull public Set getInventorySlots() { Set emptySlots = new HashSet<>(); @@ -158,7 +209,7 @@ public abstract class BlockMenuPreset extends ChestMenu { return emptySlots; } - protected void clone(DirtyChestMenu menu) { + protected void clone(@Nonnull DirtyChestMenu menu) { menu.setPlayerInventoryClickable(true); for (int slot : occupiedSlots) { @@ -185,7 +236,7 @@ public abstract class BlockMenuPreset extends ChestMenu { menu.registerEvent(event); } - public void newInstance(BlockMenu menu, Location l) { + public void newInstance(@Nonnull BlockMenu menu, @Nonnull Location l) { Validate.notNull(l, "Cannot create a new BlockMenu without a Location"); SlimefunPlugin.runSync(() -> { @@ -206,6 +257,8 @@ public abstract class BlockMenuPreset extends ChestMenu { * * @return Our identifier */ + + @Nonnull public String getID() { return id; } @@ -215,10 +268,13 @@ public abstract class BlockMenuPreset extends ChestMenu { * * @return The associated {@link SlimefunItem} */ + + @Nonnull public SlimefunItem getSlimefunItem() { return SlimefunItem.getByID(id); } + @Nullable public static BlockMenuPreset getPreset(String id) { return id == null ? null : SlimefunPlugin.getRegistry().getMenuPresets().get(id); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index f00223c45..e53fa9406 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -1,6 +1,10 @@ package me.mrCookieSlime.Slimefun.api.inventory; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.bukkit.Material; import org.bukkit.block.Block; @@ -21,7 +25,7 @@ public class DirtyChestMenu extends ChestMenu { protected ItemManipulationEvent event; protected int changes = 1; - public DirtyChestMenu(BlockMenuPreset preset) { + public DirtyChestMenu(@Nonnull BlockMenuPreset preset) { super(preset.getTitle()); this.preset = preset; @@ -49,6 +53,7 @@ public class DirtyChestMenu extends ChestMenu { return changes; } + @Nonnull public BlockMenuPreset getPreset() { return preset; } @@ -77,15 +82,23 @@ public class DirtyChestMenu extends ChestMenu { } } - public boolean fits(ItemStack item, int... slots) { - return InvUtils.fits(toInventory(), new ItemStackWrapper(item), slots); + public boolean fits(@Nonnull ItemStack item, int... slots) { + if (getItemInSlot(slots[0]) == null) { + // Very small optimization + return true; + } + else { + return InvUtils.fits(toInventory(), new ItemStackWrapper(item), slots); + } } + @Nullable public ItemStack pushItem(ItemStack item, int... slots) { if (item == null || item.getType() == Material.AIR) { throw new IllegalArgumentException("Cannot push null or AIR"); } + ItemStackWrapper wrapper = null; int amount = item.getAmount(); for (int slot : slots) { @@ -99,9 +112,15 @@ public class DirtyChestMenu extends ChestMenu { replaceExistingItem(slot, item); return null; } - else if (stack.getAmount() < stack.getMaxStackSize() && ItemUtils.canStack(item, stack)) { - amount -= (stack.getMaxStackSize() - stack.getAmount()); - stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize())); + else if (stack.getAmount() < stack.getMaxStackSize()) { + if (wrapper == null) { + wrapper = new ItemStackWrapper(item); + } + + if (ItemUtils.canStack(wrapper, stack)) { + amount -= (stack.getMaxStackSize() - stack.getAmount()); + stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize())); + } } } @@ -132,9 +151,14 @@ public class DirtyChestMenu extends ChestMenu { } public void replaceExistingItem(int slot, ItemStack item, boolean event) { - if (event && this.event != null) { + if (event) { ItemStack previous = getItemInSlot(slot); - item = this.event.onEvent(slot, previous, item); + + if (this.event != null) { + item = this.event.onEvent(slot, previous, item); + } + + item = preset.onItemStackChange(this, slot, previous, item); } super.replaceExistingItem(slot, item); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/ItemManipulationEvent.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/ItemManipulationEvent.java index 3a7899dbd..ce6591b0a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/ItemManipulationEvent.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/ItemManipulationEvent.java @@ -2,6 +2,13 @@ package me.mrCookieSlime.Slimefun.api.inventory; import org.bukkit.inventory.ItemStack; +/** + * @deprecated Please use {@link BlockMenuPreset#onItemStackChange(DirtyChestMenu, int, ItemStack, ItemStack)} instead. + * + * @author TheBusyBiscuit + * + */ +@Deprecated @FunctionalInterface public interface ItemManipulationEvent { From eac311754747b737b5e86882006bf270fa74e056 Mon Sep 17 00:00:00 2001 From: flaxeneel2 <60919292+flaxeneel2@users.noreply.github.com> Date: Sat, 26 Sep 2020 17:27:35 +0400 Subject: [PATCH 089/163] Grappling hook edit [+] Added a setting to allow the grappling hook to stay in inventory instead of being dropped on the floor on use --- .../implementation/items/tools/GrapplingHook.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java index 8d0c68682..fb2772a7b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java @@ -22,6 +22,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class GrapplingHook extends SimpleSlimefunItem { + private final ItemSetting stayininvonuse = new ItemSetting<>("stay-in-inv-on-use", false); //this set to false will override despawnTicks option private final ItemSetting despawnTicks = new ItemSetting<>("despawn-seconds", 60); public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -47,7 +48,9 @@ public class GrapplingHook extends SimpleSlimefunItem { ItemStack item = e.getItem(); if (item.getType() == Material.LEAD) { - item.setAmount(item.getAmount() - 1); + if (!stayininvonuse.getValue()) { + item.setAmount(item.getAmount() - 1); + } } Vector direction = p.getEyeLocation().getDirection().multiply(2.0); @@ -62,8 +65,10 @@ public class GrapplingHook extends SimpleSlimefunItem { bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000)); bat.setLeashHolder(arrow); - boolean state = item.getType() != Material.SHEARS; - SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue()); + if (!stayininvonuse.getValue()) { + boolean state = item.getType() != Material.SHEARS; + SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue()); + } } }; } From 4d49e1ec8fc41e47b1d173ff51b985bd84268d94 Mon Sep 17 00:00:00 2001 From: Ome_R Date: Sat, 26 Sep 2020 17:39:20 +0300 Subject: [PATCH 090/163] Fixed CargoNetworkTask not checking for other slots before dropping items on ground --- .../slimefun4/core/networks/cargo/CargoNetworkTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java index a65bdb25a..85b1ce474 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -111,7 +111,8 @@ class CargoNetworkTask implements Runnable { if (inv.getItem(previousSlot) == null) { inv.setItem(previousSlot, stack); } - else { + // Making sure the item cannot be added to another slot before dropping it on ground + else if((stack = inv.addItem(stack).get(0)) != null){ inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); } } From 87eb9cb75ed172e8af0273ad3305fbc69bb722da Mon Sep 17 00:00:00 2001 From: flaxeneel2 <60919292+flaxeneel2@users.noreply.github.com> Date: Sat, 26 Sep 2020 20:53:36 +0400 Subject: [PATCH 091/163] final commit [+] desired feature fully implemented [+] set the default value to false [+] now added option does not mess with despawn-seconds [+] added keepinv boolean to the functions --- .../implementation/items/tools/GrapplingHook.java | 12 ++++++------ .../listeners/GrapplingHookEntity.java | 11 +++++++---- .../listeners/GrapplingHookListener.java | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java index fb2772a7b..eff36b69e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java @@ -22,13 +22,14 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class GrapplingHook extends SimpleSlimefunItem { - private final ItemSetting stayininvonuse = new ItemSetting<>("stay-in-inv-on-use", false); //this set to false will override despawnTicks option + private final ItemSetting stayininvonuse = new ItemSetting<>("stay-in-inv-on-use", false); private final ItemSetting despawnTicks = new ItemSetting<>("despawn-seconds", 60); public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); addItemSetting(despawnTicks); + addItemSetting(stayininvonuse); } @Override @@ -36,6 +37,7 @@ public class GrapplingHook extends SimpleSlimefunItem { return e -> { Player p = e.getPlayer(); UUID uuid = p.getUniqueId(); + Boolean keepininv = stayininvonuse.getValue(); if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) { e.cancel(); @@ -48,7 +50,7 @@ public class GrapplingHook extends SimpleSlimefunItem { ItemStack item = e.getItem(); if (item.getType() == Material.LEAD) { - if (!stayininvonuse.getValue()) { + if (!keepininv) { item.setAmount(item.getAmount() - 1); } } @@ -65,10 +67,8 @@ public class GrapplingHook extends SimpleSlimefunItem { bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000)); bat.setLeashHolder(arrow); - if (!stayininvonuse.getValue()) { - boolean state = item.getType() != Material.SHEARS; - SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue()); - } + boolean state = item.getType() != Material.SHEARS; + SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), keepininv); } }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java index ee99817e5..8524fea3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java @@ -15,13 +15,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; final class GrapplingHookEntity { private final boolean dropItem; - + private final boolean keepininv; private final Arrow arrow; private final Entity leashTarget; @ParametersAreNonnullByDefault - GrapplingHookEntity(Player p, Arrow arrow, Entity leashTarget, boolean dropItem) { + GrapplingHookEntity(Player p, Arrow arrow, Entity leashTarget, boolean dropItem, boolean keepininv) { this.arrow = arrow; + this.keepininv = keepininv; this.leashTarget = leashTarget; this.dropItem = p.getGameMode() != GameMode.CREATIVE && dropItem; } @@ -33,8 +34,10 @@ final class GrapplingHookEntity { public void drop(@Nonnull Location l) { if (dropItem) { - Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); - item.setPickupDelay(16); + if (!keepininv) { + Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); + item.setPickupDelay(16); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index b28bfaa84..b9eb73dba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -183,8 +183,8 @@ public class GrapplingHookListener implements Listener { } @ParametersAreNonnullByDefault - public void addGrapplingHook(Player p, Arrow arrow, Bat bat, boolean dropItem, long despawnTicks) { - GrapplingHookEntity hook = new GrapplingHookEntity(p, arrow, bat, dropItem); + public void addGrapplingHook(Player p, Arrow arrow, Bat bat, boolean dropItem, long despawnTicks, boolean keepininv) { + GrapplingHookEntity hook = new GrapplingHookEntity(p, arrow, bat, dropItem, keepininv); UUID uuid = p.getUniqueId(); activeHooks.put(uuid, hook); From 678061d08ffbb187c6b0743bc100c9aa941c1709 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 26 Sep 2020 17:28:09 +0000 Subject: [PATCH 092/163] Update dependency com.konghq:unirest-java to v3.11.00 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f737084b2..7ae608427 100644 --- a/pom.xml +++ b/pom.xml @@ -343,7 +343,7 @@ com.konghq unirest-java - 3.10.00 + 3.11.00 compile From 4966d3ad4cb65f88aec56fbc2a2c5a45203cb52e Mon Sep 17 00:00:00 2001 From: TheSilentPro Date: Sat, 26 Sep 2020 21:46:01 +0200 Subject: [PATCH 093/163] Separate player-only and no-permission messages --- .../commands/subcommands/BackpackCommand.java | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java index 6454bcbd8..7f7734323 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java @@ -26,43 +26,47 @@ class BackpackCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (!(sender instanceof Player) || !sender.hasPermission("slimefun.command.backpack")) { - SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); - return; - } + if (sender instanceof Player) { + if (sender.hasPermission("slimefun.command.backpack")) { + if (args.length != 3) { + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack ")); + return; + } - if (args.length != 3) { - SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack ")); - return; - } + if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) { + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.invalid-id"); + return; + } - if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) { - SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.invalid-id"); - return; - } + @SuppressWarnings("deprecation") + OfflinePlayer backpackOwner = Bukkit.getOfflinePlayer(args[1]); - @SuppressWarnings("deprecation") - OfflinePlayer backpackOwner = Bukkit.getOfflinePlayer(args[1]); + if (!(backpackOwner instanceof Player) && !backpackOwner.hasPlayedBefore()) { + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.player-never-joined"); + return; + } - if (!(backpackOwner instanceof Player) && !backpackOwner.hasPlayedBefore()) { - SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.player-never-joined"); - return; - } + int id = Integer.parseInt(args[2]); - int id = Integer.parseInt(args[2]); + PlayerProfile.get(backpackOwner, profile -> { + if (!profile.getBackpack(id).isPresent()) { + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.backpack-does-not-exist"); + return; + } - PlayerProfile.get(backpackOwner, profile -> { - if (!profile.getBackpack(id).isPresent()) { - SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.backpack-does-not-exist"); - return; + SlimefunPlugin.runSync(() -> { + ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone(); + SlimefunPlugin.getBackpackListener().setBackpackId(backpackOwner, item, 2, id); + ((Player) sender).getInventory().addItem(item); + SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given"); + }); + }); + } else { + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - - SlimefunPlugin.runSync(() -> { - ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone(); - SlimefunPlugin.getBackpackListener().setBackpackId(backpackOwner, item, 2, id); - ((Player) sender).getInventory().addItem(item); - SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given"); - }); - }); + } + else { + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); + } } } From 75da0b883a576ab41c9c2829950a91187c6c549f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 26 Sep 2020 22:05:47 +0200 Subject: [PATCH 094/163] Refactored code --- .../core/networks/cargo/CargoNetworkTask.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java index 85b1ce474..7ac5912ed 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -108,12 +108,18 @@ class CargoNetworkTask implements Runnable { Inventory inv = inventories.get(inputTarget.getLocation()); if (inv != null) { + // Check if the original slot hasn't been occupied in the meantime if (inv.getItem(previousSlot) == null) { inv.setItem(previousSlot, stack); } - // Making sure the item cannot be added to another slot before dropping it on ground - else if((stack = inv.addItem(stack).get(0)) != null){ - inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); + else { + // Try to add the item into another available slot then + ItemStack rest = inv.addItem(stack).get(0); + + if (rest != null) { + // If the item still couldn't be inserted, simply drop it on the ground + inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), rest); + } } } else { From b41c60934e182ae01b0aab57d4c85ec0438b722a Mon Sep 17 00:00:00 2001 From: TheSilentPro Date: Sat, 26 Sep 2020 22:06:23 +0200 Subject: [PATCH 095/163] Fix code consistency --- .../slimefun4/core/commands/subcommands/BackpackCommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java index 7f7734323..20274c7e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java @@ -61,7 +61,8 @@ class BackpackCommand extends SubCommand { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given"); }); }); - } else { + } + else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } } From 518f3c2ebcbe6cc4c7c3cd446249b1d160167f0c Mon Sep 17 00:00:00 2001 From: flaxeneel2 <60919292+flaxeneel2@users.noreply.github.com> Date: Sun, 27 Sep 2020 16:54:35 +0400 Subject: [PATCH 096/163] Made requested changes [+] Used a better name for the boolean [+] replaced Boolean with primitive boolean [+] Used pascal naming system --- .../implementation/items/tools/GrapplingHook.java | 12 ++++++------ .../listeners/GrapplingHookEntity.java | 10 +++++----- .../listeners/GrapplingHookListener.java | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java index eff36b69e..4932c1bd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java @@ -22,14 +22,14 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class GrapplingHook extends SimpleSlimefunItem { - private final ItemSetting stayininvonuse = new ItemSetting<>("stay-in-inv-on-use", false); + private final ItemSetting consumeOnUse = new ItemSetting<>("consume-on-use", true); private final ItemSetting despawnTicks = new ItemSetting<>("despawn-seconds", 60); public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); addItemSetting(despawnTicks); - addItemSetting(stayininvonuse); + addItemSetting(consumeOnUse); } @Override @@ -37,7 +37,7 @@ public class GrapplingHook extends SimpleSlimefunItem { return e -> { Player p = e.getPlayer(); UUID uuid = p.getUniqueId(); - Boolean keepininv = stayininvonuse.getValue(); + boolean consumeOnUseValue = consumeOnUse.getValue(); if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) { e.cancel(); @@ -50,8 +50,8 @@ public class GrapplingHook extends SimpleSlimefunItem { ItemStack item = e.getItem(); if (item.getType() == Material.LEAD) { - if (!keepininv) { - item.setAmount(item.getAmount() - 1); + if (consumeOnUseValue) { + item.setAmount(item.getAmount() - 1); //If consume on use is enabled, this line will take 1 grappling hook out of player's hand } } @@ -68,7 +68,7 @@ public class GrapplingHook extends SimpleSlimefunItem { bat.setLeashHolder(arrow); boolean state = item.getType() != Material.SHEARS; - SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), keepininv); + SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), consumeOnUseValue); } }; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java index 8524fea3d..aaecb3b5e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java @@ -15,14 +15,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; final class GrapplingHookEntity { private final boolean dropItem; - private final boolean keepininv; + private final boolean wasConsumed; private final Arrow arrow; private final Entity leashTarget; @ParametersAreNonnullByDefault - GrapplingHookEntity(Player p, Arrow arrow, Entity leashTarget, boolean dropItem, boolean keepininv) { + GrapplingHookEntity(Player p, Arrow arrow, Entity leashTarget, boolean dropItem, boolean wasConsumed) { this.arrow = arrow; - this.keepininv = keepininv; + this.wasConsumed = wasConsumed; this.leashTarget = leashTarget; this.dropItem = p.getGameMode() != GameMode.CREATIVE && dropItem; } @@ -34,10 +34,10 @@ final class GrapplingHookEntity { public void drop(@Nonnull Location l) { if (dropItem) { - if (!keepininv) { + if (wasConsumed) { Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); item.setPickupDelay(16); - } + } //If a grappling hook was consumed, then this will drop one on the floor } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index b9eb73dba..f7463a370 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -183,8 +183,8 @@ public class GrapplingHookListener implements Listener { } @ParametersAreNonnullByDefault - public void addGrapplingHook(Player p, Arrow arrow, Bat bat, boolean dropItem, long despawnTicks, boolean keepininv) { - GrapplingHookEntity hook = new GrapplingHookEntity(p, arrow, bat, dropItem, keepininv); + public void addGrapplingHook(Player p, Arrow arrow, Bat bat, boolean dropItem, long despawnTicks, boolean wasConsumed) { + GrapplingHookEntity hook = new GrapplingHookEntity(p, arrow, bat, dropItem, wasConsumed); UUID uuid = p.getUniqueId(); activeHooks.put(uuid, hook); From a82680b9fa1a0d8d57eaad74438f4dc6e3c7777e Mon Sep 17 00:00:00 2001 From: flaxeneel2 <60919292+flaxeneel2@users.noreply.github.com> Date: Sun, 27 Sep 2020 21:16:28 +0400 Subject: [PATCH 097/163] commenting fixes --- .../slimefun4/implementation/items/tools/GrapplingHook.java | 3 ++- .../implementation/listeners/GrapplingHookEntity.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java index 4932c1bd1..0a9b9cb8f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java @@ -50,8 +50,9 @@ public class GrapplingHook extends SimpleSlimefunItem { ItemStack item = e.getItem(); if (item.getType() == Material.LEAD) { + //If consume on use is enabled, the if statement below will take 1 grappling hook out of player's hand if (consumeOnUseValue) { - item.setAmount(item.getAmount() - 1); //If consume on use is enabled, this line will take 1 grappling hook out of player's hand + item.setAmount(item.getAmount() - 1); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java index aaecb3b5e..57cfa4c9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java @@ -34,10 +34,11 @@ final class GrapplingHookEntity { public void drop(@Nonnull Location l) { if (dropItem) { + //If a grappling hook was consumed, then the below if statement will be executed and will drop one grappling hook on the floor if (wasConsumed) { Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); item.setPickupDelay(16); - } //If a grappling hook was consumed, then this will drop one on the floor + } } } From 1bca830cb06a8692a58e4f6ffb928715cfd7dc0c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 27 Sep 2020 20:13:38 +0200 Subject: [PATCH 098/163] [CI skip] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 703909db5..b5deb13e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ * Added /sf charge * Added Energized Energy Capacitor * Added various new fuel types to the Coal Generator +* Added a config option for Grappling Hooks to not be consumed on use #### Changes * Improved Auto-Updater (Multi-Threading and more) @@ -42,6 +43,7 @@ * Fixed #2325 * Fixed Climbing Pick having no animation in creative mode * Fixed #2322 +* Fixed some cargo incompatibilities with overflowing inventories ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From fdd3dbbb4e957b3daf84051549f7650f2c6c6194 Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sun, 27 Sep 2020 21:41:25 +0300 Subject: [PATCH 099/163] Update AbstractCargoNode.java --- .../slimefun4/implementation/items/cargo/AbstractCargoNode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java index 667e2362f..ebd887788 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java @@ -83,7 +83,7 @@ abstract class AbstractCargoNode extends SlimefunItem { menu.addMenuClickHandler(slotPrev, (p, slot, item, action) -> { int newChannel = channel - 1; - if (channel < 0) { + if (newChannel < 0) { if (isChestTerminalInstalled) { newChannel = 16; } From abd23406dee4db8389ec97bd3e02fd5f7d0d2e98 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 27 Sep 2020 21:54:44 +0200 Subject: [PATCH 100/163] [CI skip] Moved CONTRIBUTING.md to root directory --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 2 +- .github/CONTRIBUTING.md => CONTRIBUTING.md | 2 +- README.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename .github/CONTRIBUTING.md => CONTRIBUTING.md (98%) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 5e898bd67..75f1e0827 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -48,7 +48,7 @@ If you need help on how to get started, maybe try looking into the following res * [Working with forks](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) * [Creating a Pull Request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) * Slimefun - * [Contributing to Slimefun](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md) + * [Contributing to Slimefun](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md) * [Code of Conduct](https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md)
diff --git a/.github/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 98% rename from .github/CONTRIBUTING.md rename to CONTRIBUTING.md index 816159b8a..b95b1ae2e 100644 --- a/.github/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,5 +92,5 @@ To compile Slimefun yourself, follow these steps: If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`. -If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel.
+If you have any further questions, then please join our [Discord Support Server](https://github.com/Slimefun/Slimefun4#discord) and ask your questions in the `#programming-help` channel.
**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. diff --git a/README.md b/README.md index 9213aa050..2fe6d216d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Check out our [Addons](https://github.com/Slimefun/Slimefun4/wiki/Addons), you m * **[Bug Tracker](https://github.com/Slimefun/Slimefun4/issues)** * **[Wiki](https://github.com/Slimefun/Slimefun4/wiki)** * **[FAQ](https://github.com/Slimefun/Slimefun4/wiki/FAQ)** -* **[How to contribute](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md)** +* **[How to contribute](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md)** ## Download Slimefun 4 (See also: [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun)) @@ -105,7 +105,7 @@ Slimefun 4 is an Open-Source project and licensed under Over 150+ people have already contributed to this amazing project. You guys are awesome.
Please consider helping us maintain this project too, your engagement keeps the project alive <3. -You can find more info on how to contribute to this project in our [CONTRIBUTING.md](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md). +You can find more info on how to contribute to this project in our [CONTRIBUTING.md](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md). ## Disclaimers Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project. From db52f1dfee050ba7e577677f32e2478bc25cdfef Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 27 Sep 2020 22:34:17 +0200 Subject: [PATCH 101/163] [CI skip] Updated sonarcloud links --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b95b1ae2e..2afb9dd41 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,9 +58,9 @@ You can find a tutorial on how to contribute to our wiki right here:
https://github.com/Slimefun/Slimefun4/wiki/Expanding-the-Wiki ## :star: 6. Pull Requests: Code Quality -Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) to monitor Code Quality. +Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun4) to monitor Code Quality. -We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) is a great place to start. +We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun4) is a great place to start. But please keep in mind that some design patterns may not be changed too abruptly if an addon depends on them. To prevent any accidents from happening, please contact us on our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) before-hand and state your intended changes. From b36bc379ed544e087b79dc2df7a438b24bb9cd1c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 28 Sep 2020 15:46:46 +0200 Subject: [PATCH 102/163] [CI skip] Created CODEOWNERS file --- .github/CODEOWNERS | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..7c74ab125 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,6 @@ +# Modifications to the source code should be handled by the review team +*.java @Slimefun/code-reviewers + +# Modifications to sensitive files should be reviewed by maintainers +/.github/ @Slimefun/slimefun4-maintainers +pom.xml @Slimefun/slimefun4-maintainers From 2e2083e8476016d0a52d3e0da96bca7d660fd782 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 28 Sep 2020 15:52:32 +0200 Subject: [PATCH 103/163] [CI skip] Added CONTRIBUTING.md to CODEOWNERS --- .github/CODEOWNERS | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7c74ab125..9a7a08c38 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,7 @@ # Modifications to the source code should be handled by the review team -*.java @Slimefun/code-reviewers +*.java @Slimefun/code-reviewers # Modifications to sensitive files should be reviewed by maintainers -/.github/ @Slimefun/slimefun4-maintainers -pom.xml @Slimefun/slimefun4-maintainers +/.github/ @Slimefun/slimefun4-maintainers +pom.xml @Slimefun/slimefun4-maintainers +CONTRIBUTING.md @Slimefun/slimefun4-maintainers From 35b25636d44b98d3b40741968b0c2fabdc3582e8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 28 Sep 2020 15:53:09 +0200 Subject: [PATCH 104/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5deb13e0..b9585acee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ * Fixed Climbing Pick having no animation in creative mode * Fixed #2322 * Fixed some cargo incompatibilities with overflowing inventories +* Fixed #2353 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 839d408105d1a576f641cf5874bb31330702b78e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 28 Sep 2020 21:59:18 +0200 Subject: [PATCH 105/163] [CI skip] Updated discord invite urls --- .github/CODE_OF_CONDUCT.md | 4 ++-- .github/ISSUE_TEMPLATE/config.yml | 2 +- CONTRIBUTING.md | 6 +++--- README.md | 2 +- .../slimefun4/implementation/setup/PostSetup.java | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 1bfbe1872..0a2e28521 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -19,7 +19,7 @@ We generally expect users to engage in the Issues section by reporting bugs or c Pull Requests are very much welcome and encouraged! They keep the project alive, so if you see an Issue and know how to fix it, feel free to create a Pull Request! Issues that are considered "good first issues", indicated by the [good first issue](https://github.com/Slimefun/Slimefun4/labels/good%20first%20issue) label, are generally expected to be beginner-friendly. -And even if you shouldn't know where to start or how to proceed, our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and its community will be there for you! +And even if you shouldn't know where to start or how to proceed, our [Discord Server](https://discord.gg/slimefun) and its community will be there for you! When commenting, please keep in mind that this software is offered for **free**. Don't expect to receive lightning-fast replies 24 hours a day. Everyone here works on this project in their free time and usually has work, school, university or family to take care of, so we appreciate patience and understanding. @@ -59,7 +59,7 @@ https://github.com/orgs/Slimefun/people ## :wrench: Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders (labelled on Discord as "Admins" or "Moderators") responsible for enforcement on our [Discord Server](https://github.com/Slimefun/Slimefun4#discord). +reported to the community leaders (labelled on Discord as "Admins" or "Moderators") responsible for enforcement on our [Discord Server](discord.gg/slimefun). If you want your issue to be handled discreetly, message `TheBusyBiscuit#2610` or `Walshy#9709` privately on Discord and state your concerns. All complaints will be reviewed and investigated promptly and fairly. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ab1fd5077..b14ef722f 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -7,5 +7,5 @@ contact_links: url: https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs about: Guidelines on how to make good Bug reports - name: Discord Server (for Questions and Suggestions) - url: https://discord.gg/fsD4Bkh + url: https://discord.gg/slimefun about: Please ask and answer questions here. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2afb9dd41..e9d1e9120 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ You can also comment on the existing Issue, proposing your idea or communicating ## :wrench: 3. Pull Requests: Additions/Changes Slimefun is an Open-Source project and anyone is allowed to make changes or add content to this plugin! -Please visit our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and share your ideas first, we hate to reject changes because the community disagrees.
+Please visit our [Discord Server](https://discord.gg/slimefun) and share your ideas first, we hate to reject changes because the community disagrees.
So communicating your intended changes before-hand will ensure that you don't put too much work into something that might get rejected. We also have a suggestions section in our Discord Server too. Suggestions can be placed in the `#suggestions` channel and community members can vote on a suggestion. @@ -62,7 +62,7 @@ Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimef We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun4) is a great place to start. But please keep in mind that some design patterns may not be changed too abruptly if an addon depends on them. -To prevent any accidents from happening, please contact us on our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) before-hand and state your intended changes. +To prevent any accidents from happening, please contact us on our [Discord Server](https://discord.gg/slimefun) before-hand and state your intended changes. #### Documentation Code documentation is also a great way to improve the maintainability of the project. @@ -92,5 +92,5 @@ To compile Slimefun yourself, follow these steps: If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`. -If you have any further questions, then please join our [Discord Support Server](https://github.com/Slimefun/Slimefun4#discord) and ask your questions in the `#programming-help` channel.
+If you have any further questions, then please join our [Discord Support Server](https://discord.gg/slimefun) and ask your questions in the `#programming-help` channel.
**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. diff --git a/README.md b/README.md index 2fe6d216d..80f30248b 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Due to the sheer size of this discord server, we need to enforce some [important Not following these rules can lead to a kick or even a ban from the server.

- + Discord Invite

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 b184181f1..4d6ebd3c5 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 @@ -104,7 +104,7 @@ public final class PostSetup { sender.sendMessage(ChatColor.GREEN + " - Wiki: https://github.com/Slimefun/Slimefun4/wiki"); sender.sendMessage(ChatColor.GREEN + " - Addons: https://github.com/Slimefun/Slimefun4/wiki/Addons"); sender.sendMessage(ChatColor.GREEN + " - Bug Reports: https://github.com/Slimefun/Slimefun4/issues"); - sender.sendMessage(ChatColor.GREEN + " - Discord: https://discord.gg/fsD4Bkh"); + sender.sendMessage(ChatColor.GREEN + " - Discord: https://discord.gg/slimefun"); } else { sender.sendMessage(ChatColor.GREEN + " - UNOFFICIALLY MODIFIED BUILD - NO OFFICIAL SUPPORT GIVEN"); From 56ba9f7496da73ef87f8683a1c672d49753aec16 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Tue, 29 Sep 2020 15:07:17 +0200 Subject: [PATCH 106/163] Added event cancellation --- .../implementation/items/magical/MagicalZombiePills.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 33f193ef0..5d6c66bf3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -11,7 +11,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Lists.RecipeType; @@ -35,6 +37,8 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Tue, 29 Sep 2020 15:24:17 +0200 Subject: [PATCH 107/163] Added Javadocs --- .../implementation/items/magical/MagicalZombiePills.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 5d6c66bf3..7d0be1ab4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -65,6 +65,11 @@ public class MagicalZombiePills extends SimpleSlimefunItem Date: Tue, 29 Sep 2020 15:24:45 +0200 Subject: [PATCH 108/163] Requested changes --- .../implementation/items/magical/MagicalZombiePills.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 7d0be1ab4..703181c03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -33,7 +34,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see EntityInteractHandler * */ -public class MagicalZombiePills extends SimpleSlimefunItem { +public class MagicalZombiePills extends SimpleSlimefunItem implements NotPlaceable { public MagicalZombiePills(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { super(category, item, recipeType, recipe, recipeOutput); From 362299c650a41becc6d924ea26c41c84c74dd611 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Tue, 29 Sep 2020 15:26:20 +0200 Subject: [PATCH 109/163] Sorted imports --- .../implementation/items/magical/MagicalZombiePills.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 703181c03..775a970bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -1,6 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import org.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -13,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; From fd1a30be82fb91ea6686825d31ce9352a2ea72aa Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 29 Sep 2020 15:51:59 +0200 Subject: [PATCH 110/163] [Ci skip] Updated change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9585acee..977861d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ * Fixed #2322 * Fixed some cargo incompatibilities with overflowing inventories * Fixed #2353 +* Fixed #2359 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From e7097e2c2b6d280fa1cec33232ea3a8c10d6713f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 29 Sep 2020 20:19:38 +0200 Subject: [PATCH 111/163] [CI skip] Reduced technical debt, refactoring and improved documentation --- .../services/PerWorldSettingsService.java | 95 ++++++++----------- .../services/github/ActivityCallback.java | 22 +++++ .../github/ContributionsConnector.java | 11 ++- .../core/services/github/Contributor.java | 57 +++++++++-- .../github/GitHubActivityConnector.java | 42 ++++++++ .../core/services/github/GitHubConnector.java | 31 +++++- ...racker.java => GitHubIssuesConnector.java} | 15 +-- .../core/services/github/GitHubService.java | 62 +++++------- .../core/services/github/GitHubTask.java | 5 +- ...ackerConsumer.java => IssuesCallback.java} | 4 +- .../mrCookieSlime/Slimefun/api/Slimefun.java | 3 + .../api/inventory/DirtyChestMenu.java | 10 +- 12 files changed, 233 insertions(+), 124 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java rename src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/{GitHubIssuesTracker.java => GitHubIssuesConnector.java} (72%) rename src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/{IssuesTrackerConsumer.java => IssuesCallback.java} (72%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java index f47323184..f3c9ebf3f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java @@ -1,8 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services; import java.io.File; -import java.io.IOException; -import java.nio.file.Files; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -12,8 +10,10 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.logging.Level; +import javax.annotation.Nonnull; + +import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.World; @@ -38,7 +38,7 @@ public class PerWorldSettingsService { private final Map> disabledAddons = new HashMap<>(); private final Set disabledWorlds = new HashSet<>(); - public PerWorldSettingsService(SlimefunPlugin plugin) { + public PerWorldSettingsService(@Nonnull SlimefunPlugin plugin) { this.plugin = plugin; } @@ -48,14 +48,7 @@ public class PerWorldSettingsService { * @param worlds * An {@link Iterable} of {@link World Worlds} to load */ - public void load(Iterable worlds) { - try { - migrate(); - } - catch (IOException e) { - plugin.getLogger().log(Level.WARNING, "An error occurred while migrating old world settings", e); - } - + public void load(@Nonnull Iterable worlds) { for (World world : worlds) { load(world); } @@ -67,41 +60,11 @@ public class PerWorldSettingsService { * @param world * The {@link World} to load */ - public void load(World world) { + public void load(@Nonnull World world) { + Validate.notNull(world, "Cannot load a world that is null"); disabledItems.putIfAbsent(world.getUID(), loadWorldFromConfig(world)); } - /** - * Temporary migration method for the old system - * - * @throws IOException - * This will be thrown if we failed to delete the old {@link File} - */ - private void migrate() throws IOException { - Config oldConfig = new Config(plugin, "whitelist.yml"); - - if (oldConfig.getFile().exists()) { - for (String world : oldConfig.getKeys()) { - Config newConfig = new Config(plugin, "world-settings/" + world + ".yml"); - newConfig.setDefaultValue("enabled", oldConfig.getBoolean(world + ".enabled")); - - for (String id : oldConfig.getKeys(world + ".enabled-items")) { - SlimefunItem item = SlimefunItem.getByID(id); - - if (item != null) { - String addon = item.getAddon().getName().toLowerCase(Locale.ROOT); - newConfig.setDefaultValue(addon + ".enabled", true); - newConfig.setDefaultValue(addon + '.' + id, oldConfig.getBoolean(world + ".enabled-items." + id)); - } - } - - newConfig.save(); - } - - Files.delete(oldConfig.getFile().toPath()); - } - } - /** * This method checks whether the given {@link SlimefunItem} is enabled in the given {@link World}. * @@ -112,7 +75,10 @@ public class PerWorldSettingsService { * * @return Whether the given {@link SlimefunItem} is enabled in that {@link World} */ - public boolean isEnabled(World world, SlimefunItem item) { + public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) { + Validate.notNull(world, "The world cannot be null"); + Validate.notNull(item, "The SlimefunItem cannot be null"); + Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world)); if (disabledWorlds.contains(world.getUID())) { @@ -132,7 +98,10 @@ public class PerWorldSettingsService { * @param enabled * Whether the given {@link SlimefunItem} should be enabled in that world */ - public void setEnabled(World world, SlimefunItem item, boolean enabled) { + public void setEnabled(@Nonnull World world, @Nonnull SlimefunItem item, boolean enabled) { + Validate.notNull(world, "The world cannot be null"); + Validate.notNull(item, "The SlimefunItem cannot be null"); + Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world)); if (enabled) { @@ -151,7 +120,8 @@ public class PerWorldSettingsService { * @param enabled * Whether this {@link World} should be enabled or not */ - public void setEnabled(World world, boolean enabled) { + public void setEnabled(@Nonnull World world, boolean enabled) { + Validate.notNull(world, "null is not a valid World"); load(world); if (enabled) { @@ -170,7 +140,8 @@ public class PerWorldSettingsService { * * @return Whether this {@link World} is enabled */ - public boolean isWorldEnabled(World world) { + public boolean isWorldEnabled(@Nonnull World world) { + Validate.notNull(world, "null is not a valid World"); load(world); return !disabledWorlds.contains(world.getUID()); @@ -186,7 +157,9 @@ public class PerWorldSettingsService { * * @return Whether this addon is enabled in that {@link World} */ - public boolean isAddonEnabled(World world, SlimefunAddon addon) { + public boolean isAddonEnabled(@Nonnull World world, @Nonnull SlimefunAddon addon) { + Validate.notNull(world, "World cannot be null"); + Validate.notNull(addon, "Addon cannot be null"); return isWorldEnabled(world) && disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName()); } @@ -198,7 +171,8 @@ public class PerWorldSettingsService { * @param world * The {@link World} to save */ - public void save(World world) { + public void save(@Nonnull World world) { + Validate.notNull(world, "Cannot save a World that does not exist"); Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world)); Config config = getConfig(world); @@ -213,7 +187,10 @@ public class PerWorldSettingsService { config.save(); } - private Set loadWorldFromConfig(World world) { + @Nonnull + private Set loadWorldFromConfig(@Nonnull World world) { + Validate.notNull(world, "Cannot load a World that does not exist"); + String name = world.getName(); Optional> optional = disabledItems.get(world.getUID()); @@ -231,6 +208,7 @@ public class PerWorldSettingsService { if (config.getBoolean("enabled")) { loadItemsFromWorldConfig(name, config, items); + // We don't actually wanna write to disk during a Unit test if (SlimefunPlugin.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) { config.save(); } @@ -243,13 +221,14 @@ public class PerWorldSettingsService { } } - private void loadItemsFromWorldConfig(String worldName, Config config, Set items) { + private void loadItemsFromWorldConfig(@Nonnull String worldName, @Nonnull Config config, @Nonnull Set items) { for (SlimefunItem item : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) { if (item != null) { String addon = item.getAddon().getName().toLowerCase(Locale.ROOT); config.setDefaultValue(addon + ".enabled", true); config.setDefaultValue(addon + '.' + item.getID(), true); + // Whether the entire addon has been disabled boolean isAddonDisabled = config.getBoolean(addon + ".enabled"); if (isAddonDisabled) { @@ -264,7 +243,17 @@ public class PerWorldSettingsService { } } - private Config getConfig(World world) { + /** + * This method returns the relevant {@link Config} for the given {@link World} + * + * @param world + * Our {@link World} + * + * @return The corresponding {@link Config} + */ + @Nonnull + private Config getConfig(@Nonnull World world) { + Validate.notNull(world, "World cannot be null"); return new Config(plugin, "world-settings/" + world.getName() + ".yml"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java new file mode 100644 index 000000000..e02236e39 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java @@ -0,0 +1,22 @@ +package io.github.thebusybiscuit.slimefun4.core.services.github; + +import java.time.LocalDateTime; + +import javax.annotation.Nonnull; + +@FunctionalInterface +interface ActivityCallback { + + /** + * This method is called when the {@link GitHubActivityConnector} finished loading. + * + * @param forks + * The amount of forks + * @param stars + * The amount of stars + * @param date + * The {@link LocalDateTime} of the last activity + */ + void accept(int forks, int stars, @Nonnull LocalDateTime date); + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java index 0ee739265..1d3f43e80 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java @@ -61,14 +61,14 @@ class ContributionsConnector extends GitHubConnector { } @Override - public void onSuccess(JsonNode element) { + public void onSuccess(@Nonnull JsonNode response) { finished = true; - if (element.isArray()) { - computeContributors(element.getArray()); + if (response.isArray()) { + computeContributors(response.getArray()); } else { - Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", element); + Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } @@ -96,7 +96,8 @@ class ContributionsConnector extends GitHubConnector { String profile = object.getString("html_url"); if (!blacklist.contains(name)) { - github.addContributor(aliases.getOrDefault(name, name), profile, role, commits); + String username = aliases.getOrDefault(name, name); + github.addContributor(username, profile, role, commits); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java index d48bbf8e5..82264255c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java @@ -40,15 +40,29 @@ public class Contributor { private Optional uuid = Optional.empty(); private boolean locked = false; - public Contributor(@Nonnull String username, @Nonnull String profile) { - Validate.notNull(username, "Username must never be null!"); + /** + * This creates a new {@link Contributor} with the given ingame name and GitHub profile. + * + * @param minecraftName + * The ingame name in Minecraft for this {@link Contributor} + * @param profile + * A link to their GitHub profile + */ + public Contributor(@Nonnull String minecraftName, @Nonnull String profile) { + Validate.notNull(minecraftName, "Username must never be null!"); Validate.notNull(profile, "The profile cannot be null!"); githubUsername = profile.substring(profile.lastIndexOf('/') + 1); - minecraftUsername = username; + minecraftUsername = minecraftName; profileLink = profile; } + /** + * This creates a new {@link Contributor} with the given username. + * + * @param username + * The username of this {@link Contributor} + */ public Contributor(@Nonnull String username) { Validate.notNull(username, "Username must never be null!"); @@ -57,8 +71,18 @@ public class Contributor { profileLink = null; } - public void setContribution(@Nonnull String role, int commits) { + /** + * This sets the amount of contributions of this {@link Contributor} for the + * specified role. + * + * @param role + * The role + * @param commits + * The amount of contributions made as that role + */ + public void setContributions(@Nonnull String role, int commits) { Validate.notNull(role, "The role cannot be null!"); + Validate.isTrue(commits >= 0, "Contributions cannot be negative"); if (!locked || role.startsWith("translator,")) { contributions.put(role, commits); @@ -66,9 +90,9 @@ public class Contributor { } /** - * Returns the name of this contributor. + * Returns the name of this {@link Contributor}. * - * @return the name of this contributor + * @return the name of this {@link Contributor} */ @Nonnull public String getName() { @@ -76,10 +100,10 @@ public class Contributor { } /** - * Returns the MC name of the contributor. - * This may be the same as {@link #getName()}. + * Returns the Minecraft username of the {@link Contributor}. + * This can be the same as {@link #getName()}. * - * @return The MC username of this contributor. + * @return The Minecraft username of this {@link Contributor}. */ @Nonnull public String getMinecraftName() { @@ -109,6 +133,7 @@ public class Contributor { * * @param role * The role for which to count the contributions. + * * @return The amount of contributions this {@link Contributor} submitted as the given role */ public int getContributions(@Nonnull String role) { @@ -137,7 +162,7 @@ public class Contributor { } /** - * Returns this Creator's head texture. + * Returns this contributor's head texture. * If no texture could be found, or it hasn't been pulled yet, * then it will return a placeholder texture. * @@ -171,10 +196,22 @@ public class Contributor { return headTexture.isComputed(); } + /** + * This sets the skin texture of this {@link Contributor} or clears it. + * + * @param skin + * The base64 skin texture or null + */ public void setTexture(@Nullable String skin) { headTexture.compute(skin); } + /** + * This returns the total amount of contributions towards this project for this + * {@link Contributor}. + * + * @return The total amount of contributions + */ public int getTotalContributions() { return contributions.values().stream().mapToInt(Integer::intValue).sum(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java new file mode 100644 index 000000000..e55fc722e --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java @@ -0,0 +1,42 @@ +package io.github.thebusybiscuit.slimefun4.core.services.github; + +import java.time.LocalDateTime; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import kong.unirest.JsonNode; +import kong.unirest.json.JSONObject; + +class GitHubActivityConnector extends GitHubConnector { + + private final ActivityCallback callback; + + @ParametersAreNonnullByDefault + GitHubActivityConnector(GitHubService github, String repository, ActivityCallback callback) { + super(github, repository); + this.callback = callback; + } + + @Override + public void onSuccess(@Nonnull JsonNode response) { + JSONObject object = response.getObject(); + int forks = object.getInt("forks"); + int stars = object.getInt("stargazers_count"); + LocalDateTime lastPush = NumberUtils.parseGitHubDate(object.getString("pushed_at")); + + callback.accept(forks, stars, lastPush); + } + + @Override + public String getFileName() { + return "repo"; + } + + @Override + public String getURLSuffix() { + return ""; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java index 2b563500e..46913f44e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java @@ -10,6 +10,7 @@ import java.nio.charset.StandardCharsets; import java.util.logging.Level; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import kong.unirest.HttpResponse; @@ -19,8 +20,16 @@ import kong.unirest.UnirestException; import kong.unirest.json.JSONException; import me.mrCookieSlime.Slimefun.api.Slimefun; +/** + * The {@link GitHubConnector} is used to connect to the GitHub API service. + * It can be extended by subclasses, this just serves as an abstract super class for + * other connectors. + * + * @author TheBusyBiscuit + * @author Walshy + */ abstract class GitHubConnector { - + private static final String API_URL = "https://api.github.com/"; protected File file; @@ -33,12 +42,23 @@ abstract class GitHubConnector { this.repository = repository; } + @Nonnull public abstract String getFileName(); + @Nonnull public abstract String getURLSuffix(); - public abstract void onSuccess(JsonNode element); + /** + * This method is called when the connection finished successfully. + * + * @param response + * The response + */ + public abstract void onSuccess(@Nonnull JsonNode response); + /** + * This method is called when the connection has failed. + */ public void onFailure() { // Don't do anything by default } @@ -61,7 +81,7 @@ abstract class GitHubConnector { } else { if (github.isLoggingEnabled()) { - Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] {repository + getURLSuffix(), resp.getStatus(), resp.getBody()}); + Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { repository + getURLSuffix(), resp.getStatus(), resp.getBody() }); } // It has the cached file, let's just read that then @@ -94,12 +114,13 @@ abstract class GitHubConnector { } } + @Nullable private JsonNode readCacheFile() { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { return new JsonNode(reader.readLine()); } catch (IOException | JSONException e) { - Slimefun.getLogger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] {file.getName(), e.getClass().getSimpleName(), e.getMessage()}); + Slimefun.getLogger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { file.getName(), e.getClass().getSimpleName(), e.getMessage() }); return null; } } @@ -109,7 +130,7 @@ abstract class GitHubConnector { output.write(node.toString().getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { - Slimefun.getLogger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] {e.getClass().getSimpleName(), e.getMessage()}); + Slimefun.getLogger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] { e.getClass().getSimpleName(), e.getMessage() }); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java index 4266e3c32..e30a6a623 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java @@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; import java.util.logging.Level; +import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import kong.unirest.JsonNode; @@ -9,20 +10,20 @@ import kong.unirest.json.JSONArray; import kong.unirest.json.JSONObject; import me.mrCookieSlime.Slimefun.api.Slimefun; -class GitHubIssuesTracker extends GitHubConnector { +class GitHubIssuesConnector extends GitHubConnector { - private final IssuesTrackerConsumer callback; + private final IssuesCallback callback; @ParametersAreNonnullByDefault - GitHubIssuesTracker(GitHubService github, String repository, IssuesTrackerConsumer callback) { + GitHubIssuesConnector(GitHubService github, String repository, IssuesCallback callback) { super(github, repository); this.callback = callback; } @Override - public void onSuccess(JsonNode element) { - if (element.isArray()) { - JSONArray array = element.getArray(); + public void onSuccess(@Nonnull JsonNode response) { + if (response.isArray()) { + JSONArray array = response.getArray(); int issues = 0; int pullRequests = 0; @@ -41,7 +42,7 @@ class GitHubIssuesTracker extends GitHubConnector { callback.accept(issues, pullRequests); } else { - Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", element); + Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java index e2d85b40c..b7a2fc07d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java @@ -16,9 +16,6 @@ import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.slimefun4.core.services.localization.Translators; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import kong.unirest.JsonNode; -import kong.unirest.json.JSONObject; /** * This Service is responsible for grabbing every {@link Contributor} to this project @@ -39,11 +36,11 @@ public class GitHubService { private boolean logging = false; - private int issues = 0; - private int pullRequests = 0; - private int forks = 0; - private int stars = 0; private LocalDateTime lastUpdate = LocalDateTime.now(); + private int openIssues = 0; + private int pendingPullRequests = 0; + private int publicForks = 0; + private int stargazers = 0; /** * This creates a new {@link GitHubService} for the given repository. @@ -63,6 +60,11 @@ public class GitHubService { plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new GitHubTask(this), 80L, 60 * 60 * 20L); } + /** + * This method adds a few default {@link Contributor Contributors}. + * Think of them like honorable mentions that aren't listed through + * the usual methods. + */ private void addDefaultContributors() { addContributor("Fuffles_", "&dArtist"); addContributor("IMS_Art", "&dArtist"); @@ -73,7 +75,7 @@ public class GitHubService { private void addContributor(@Nonnull String name, @Nonnull String role) { Contributor contributor = new Contributor(name); - contributor.setContribution(role, 0); + contributor.setContributions(role, 0); contributor.setUniqueId(uuidCache.getUUID(name)); contributors.put(name, contributor); } @@ -83,7 +85,7 @@ public class GitHubService { String username = profileURL.substring(profileURL.lastIndexOf('/') + 1); Contributor contributor = contributors.computeIfAbsent(username, key -> new Contributor(minecraftName, profileURL)); - contributor.setContribution(role, commits); + contributor.setContributions(role, commits); contributor.setUniqueId(uuidCache.getUUID(minecraftName)); return contributor; } @@ -97,37 +99,22 @@ public class GitHubService { connectors.add(new ContributionsConnector(this, "code2", 2, repository, "developer")); // TheBusyBiscuit/Slimefun4-Wiki - connectors.add(new ContributionsConnector(this, "wiki", 1, "Slimefun/Slimefun-wiki", "wiki")); + connectors.add(new ContributionsConnector(this, "wiki", 1, "Slimefun/Wiki", "wiki")); // TheBusyBiscuit/Slimefun4-Resourcepack connectors.add(new ContributionsConnector(this, "resourcepack", 1, "Slimefun/Resourcepack", "resourcepack")); // Issues and Pull Requests - connectors.add(new GitHubIssuesTracker(this, repository, (openIssues, openPullRequests) -> { - this.issues = openIssues; - this.pullRequests = openPullRequests; + connectors.add(new GitHubIssuesConnector(this, repository, (issues, pullRequests) -> { + this.openIssues = issues; + this.pendingPullRequests = pullRequests; })); - connectors.add(new GitHubConnector(this, repository) { - - @Override - public void onSuccess(JsonNode element) { - JSONObject object = element.getObject(); - forks = object.getInt("forks"); - stars = object.getInt("stargazers_count"); - lastUpdate = NumberUtils.parseGitHubDate(object.getString("pushed_at")); - } - - @Override - public String getFileName() { - return "repo"; - } - - @Override - public String getURLSuffix() { - return ""; - } - }); + connectors.add(new GitHubActivityConnector(this, repository, (forks, stars, date) -> { + this.publicForks = forks; + this.stargazers = stars; + this.lastUpdate = date; + })); } @Nonnull @@ -155,7 +142,7 @@ public class GitHubService { * @return The amount of forks */ public int getForks() { - return forks; + return publicForks; } /** @@ -164,7 +151,7 @@ public class GitHubService { * @return The amount of people who starred the repository */ public int getStars() { - return stars; + return stargazers; } /** @@ -173,7 +160,7 @@ public class GitHubService { * @return The amount of open issues */ public int getOpenIssues() { - return issues; + return openIssues; } /** @@ -192,7 +179,7 @@ public class GitHubService { * @return The amount of pending pull requests */ public int getPendingPullRequests() { - return pullRequests; + return pendingPullRequests; } /** @@ -212,7 +199,6 @@ public class GitHubService { protected void saveCache() { for (Contributor contributor : contributors.values()) { Optional uuid = contributor.getUniqueId(); - uuid.ifPresent(value -> uuidCache.setValue(contributor.getName(), value)); if (contributor.hasTexture()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java index 16251ef39..16e65d8f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java @@ -8,6 +8,7 @@ import java.util.UUID; import java.util.logging.Level; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.bukkit.Bukkit; @@ -29,7 +30,6 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; class GitHubTask implements Runnable { private static final int MAX_REQUESTS_PER_MINUTE = 16; - private final GitHubService gitHubService; GitHubTask(@Nonnull GitHubService github) { @@ -39,7 +39,6 @@ class GitHubTask implements Runnable { @Override public void run() { gitHubService.getConnectors().forEach(GitHubConnector::pullFile); - grabTextures(); } @@ -112,12 +111,12 @@ class GitHubTask implements Runnable { return 0; } + @Nullable private String pullTexture(@Nonnull Contributor contributor, @Nonnull Map skins) throws TooManyRequestsException, IOException { Optional uuid = contributor.getUniqueId(); if (!uuid.isPresent()) { uuid = MinecraftAccount.getUUID(contributor.getMinecraftName()); - uuid.ifPresent(contributor::setUniqueId); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesTrackerConsumer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesTrackerConsumer.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java index b0a52edd9..7d32f72da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesTrackerConsumer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java @@ -1,10 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; @FunctionalInterface -interface IssuesTrackerConsumer { +interface IssuesCallback { /** - * This method is called when the {@link GitHubIssuesTracker} finished loading. + * This method is called when the {@link GitHubIssuesConnector} finished loading. * * @param issues * The amount of open Issues diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java index 701e7ce1e..f13ba5bb0 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java @@ -3,6 +3,8 @@ package me.mrCookieSlime.Slimefun.api; import java.util.Optional; import java.util.logging.Logger; +import javax.annotation.Nonnull; + import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -23,6 +25,7 @@ public final class Slimefun { private Slimefun() {} + @Nonnull public static Logger getLogger() { return SlimefunPlugin.instance().getLogger(); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index e53fa9406..20fda5505 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -1,7 +1,6 @@ package me.mrCookieSlime.Slimefun.api.inventory; import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -68,6 +67,15 @@ public class DirtyChestMenu extends ChestMenu { } } + /** + * This method has been deprecated. + * + * @deprecated The {@link ItemManipulationEvent} has been deprecated. + * + * @param event + * deprecated class + */ + @Deprecated public void registerEvent(ItemManipulationEvent event) { this.event = event; } From 20de967306f793e9ee79a060e72c56f4987238a1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Tue, 29 Sep 2020 20:38:41 +0200 Subject: [PATCH 112/163] Improvements to block ticking --- CHANGELOG.md | 1 + .../slimefun4/core/SlimefunRegistry.java | 12 ---- .../items/androids/ProgrammableAndroid.java | 4 ++ .../implementation/tasks/TickerTask.java | 28 ++++++-- .../Slimefun/api/BlockStorage.java | 65 ++++++++----------- 5 files changed, 53 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 977861d84..2743ad916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ #### Changes * Improved Auto-Updater (Multi-Threading and more) +* General performance improvements #### Fixes * Fixed #2300 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 60a8a13f7..1b05dbcf1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -11,7 +11,6 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -70,7 +69,6 @@ public class SlimefunRegistry { private final Set tickers = new HashSet<>(); private final Set radioactive = new HashSet<>(); - private final Set activeChunks = ConcurrentHashMap.newKeySet(); private final Set barterDrops = new HashSet<>(); private final KeyMap geoResources = new KeyMap<>(); @@ -86,8 +84,6 @@ public class SlimefunRegistry { private final Map, Set> globalItemHandlers = new HashMap<>(); private final Map blockHandlers = new HashMap<>(); - private final Map> activeTickers = new ConcurrentHashMap<>(); - private final Map automatedCraftingChamberRecipes = new HashMap<>(); public void load(Config cfg) { @@ -226,10 +222,6 @@ public class SlimefunRegistry { return tickers; } - public Set getActiveChunks() { - return activeChunks; - } - public Map getSlimefunItemIds() { return slimefunIds; } @@ -262,10 +254,6 @@ public class SlimefunRegistry { return chunks; } - public Map> getActiveTickers() { - return activeTickers; - } - public KeyMap getGEOResources() { return geoResources; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index b94d6f590..a55a9adab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -7,6 +7,8 @@ import java.util.Optional; import java.util.function.Predicate; import java.util.logging.Level; +import javax.annotation.ParametersAreNonnullByDefault; + import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -220,6 +222,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, }); } + @ParametersAreNonnullByDefault public void openScript(Player p, Block b, String sourceCode) { ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.editor")); menu.setEmptySlotsClickable(false); @@ -290,6 +293,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, menu.open(p); } + @ParametersAreNonnullByDefault private String addInstruction(String[] script, int index, Instruction instruction) { int i = 0; StringBuilder builder = new StringBuilder(Instruction.START.name() + '-'); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index 61dd2a5aa..ba3856383 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -38,6 +38,9 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; */ public class TickerTask implements Runnable { + // This Map holds all currently actively ticking locations + private final Map> activeTickers = new ConcurrentHashMap<>(); + // These are "Queues" of blocks that need to be removed or moved private final Map movingQueue = new ConcurrentHashMap<>(); private final Map deletionQueue = new ConcurrentHashMap<>(); @@ -90,8 +93,8 @@ public class TickerTask implements Runnable { } if (!halted) { - for (String chunk : BlockStorage.getTickingChunks()) { - tickChunk(tickers, chunk); + for (Map.Entry> entry : activeTickers.entrySet()) { + tickChunk(tickers, entry.getKey(), entry.getValue()); } } @@ -116,9 +119,9 @@ public class TickerTask implements Runnable { } } - private void tickChunk(@Nonnull Set tickers, @Nonnull String chunk) { + @ParametersAreNonnullByDefault + private void tickChunk(Set tickers, String chunk, Set locations) { try { - Set locations = BlockStorage.getTickingLocations(chunk); String[] components = PatternUtils.SEMICOLON.split(chunk); World world = Bukkit.getWorld(components[0]); @@ -223,13 +226,24 @@ public class TickerTask implements Runnable { deletionQueue.put(l, destroy); } + /** + * This returns the delay between ticks + * + * @return The tick delay + */ public int getTickRate() { return tickRate; } - @Override - public String toString() { - return "TickerTask {\n" + " HALTED = " + halted + "\n" + " move = " + movingQueue + "\n" + " delete = " + deletionQueue + "}"; + /** + * This method returns the {@link Map} of actively ticking locations according to + * their chunk id. + * + * @return The {@link Map} of active tickers + */ + @Nonnull + public Map> getActiveTickers() { + return activeTickers; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java index 4d7221f5d..4f0ec5e90 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -15,6 +15,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -56,11 +60,11 @@ public class BlockStorage { private static int chunkChanges = 0; private int changes = 0; - public static BlockStorage getStorage(World world) { + public static BlockStorage getStorage(@Nonnull World world) { return SlimefunPlugin.getRegistry().getWorlds().get(world.getName()); } - public static BlockStorage getForcedStorage(World world) { + public static BlockStorage getForcedStorage(@Nonnull World world) { return isWorldRegistered(world.getName()) ? SlimefunPlugin.getRegistry().getWorlds().get(world.getName()) : new BlockStorage(world); } @@ -196,13 +200,9 @@ public class BlockStorage { storage.put(l, blockInfo); if (SlimefunPlugin.getRegistry().getTickerBlocks().contains(file.getName().replace(".sfb", ""))) { - Set locations = SlimefunPlugin.getRegistry().getActiveTickers().getOrDefault(chunkString, new HashSet<>()); + Map> tickers = SlimefunPlugin.getTickerTask().getActiveTickers(); + Set locations = tickers.computeIfAbsent(chunkString, id -> new HashSet<>()); locations.add(l); - SlimefunPlugin.getRegistry().getActiveTickers().put(chunkString, locations); - - if (!SlimefunPlugin.getRegistry().getActiveChunks().contains(chunkString)) { - SlimefunPlugin.getRegistry().getActiveChunks().add(chunkString); - } } } } @@ -377,22 +377,22 @@ public class BlockStorage { /** * Retrieves the SlimefunItem's ItemStack from the specified Block. - * If the specified Block is registered in BlockStorage, its data will be erased from it, regardless of the returned - * value. + * If the specified Block is registered in BlockStorage, + * its data will be erased from it, regardless of the returned value. * * @param block * the block to retrieve the ItemStack from * * @return the SlimefunItem's ItemStack corresponding to the block if it has one, otherwise null - * - * @since 4.0 */ + @Nullable public static ItemStack retrieve(Block block) { if (!hasBlockInfo(block)) { return null; } else { - SlimefunItem item = SlimefunItem.getByID(getLocationInfo(block.getLocation(), "id")); + String id = getLocationInfo(block.getLocation(), "id"); + SlimefunItem item = SlimefunItem.getByID(id); clearBlockInfo(block); if (item == null) { @@ -404,6 +404,7 @@ public class BlockStorage { } } + @Nonnull public static Config getLocationInfo(Location l) { BlockStorage storage = getStorage(l.getWorld()); @@ -415,6 +416,7 @@ public class BlockStorage { return cfg == null ? emptyBlockData : cfg; } + @Nonnull private static Map parseJSON(String json) { Map map = new HashMap<>(); @@ -608,22 +610,20 @@ public class BlockStorage { } String chunkString = locationToChunkString(l); + Map> tickers = SlimefunPlugin.getTickerTask().getActiveTickers(); + Set locations = tickers.get(chunkString); - if (SlimefunPlugin.getRegistry().getActiveTickers().containsKey(chunkString)) { - Set locations = SlimefunPlugin.getRegistry().getActiveTickers().get(chunkString); + if (locations != null) { locations.remove(l); if (locations.isEmpty()) { - SlimefunPlugin.getRegistry().getActiveTickers().remove(chunkString); - SlimefunPlugin.getRegistry().getActiveChunks().remove(chunkString); - } - else { - SlimefunPlugin.getRegistry().getActiveTickers().put(chunkString, locations); + tickers.remove(chunkString); } } } } + @ParametersAreNonnullByDefault public static void moveBlockInfo(Location from, Location to) { SlimefunPlugin.getTickerTask().queueMove(from, to); } @@ -637,6 +637,7 @@ public class BlockStorage { * @param to * The destination {@link Location} */ + @ParametersAreNonnullByDefault public static void moveLocationInfoUnsafely(Location from, Location to) { if (!hasBlockInfo(from)) { return; @@ -657,17 +658,14 @@ public class BlockStorage { storage.storage.remove(from); String chunkString = locationToChunkString(from); + Map> tickers = SlimefunPlugin.getTickerTask().getActiveTickers(); + Set locations = tickers.get(chunkString); - if (SlimefunPlugin.getRegistry().getActiveTickers().containsKey(chunkString)) { - Set locations = SlimefunPlugin.getRegistry().getActiveTickers().get(chunkString); + if (locations != null) { locations.remove(from); if (locations.isEmpty()) { - SlimefunPlugin.getRegistry().getActiveTickers().remove(chunkString); - SlimefunPlugin.getRegistry().getActiveChunks().remove(chunkString); - } - else { - SlimefunPlugin.getRegistry().getActiveTickers().put(chunkString, locations); + tickers.remove(chunkString); } } } @@ -689,10 +687,9 @@ public class BlockStorage { String chunkString = locationToChunkString(l); if (value != null) { - Set locations = SlimefunPlugin.getRegistry().getActiveTickers().computeIfAbsent(chunkString, c -> new HashSet<>()); + Map> tickers = SlimefunPlugin.getTickerTask().getActiveTickers(); + Set locations = tickers.computeIfAbsent(chunkString, id -> new HashSet<>()); locations.add(l); - - SlimefunPlugin.getRegistry().getActiveChunks().add(chunkString); } } } @@ -754,14 +751,6 @@ public class BlockStorage { return SlimefunPlugin.getRegistry().getWorlds().containsKey(name); } - public static Set getTickingChunks() { - return SlimefunPlugin.getRegistry().getActiveChunks(); - } - - public static Set getTickingLocations(String chunk) { - return SlimefunPlugin.getRegistry().getActiveTickers().getOrDefault(chunk, new HashSet<>()); - } - public BlockMenu loadInventory(Location l, BlockMenuPreset preset) { if (preset == null) { return null; From fda74388a68917a84b0a98b5dcb03ac29b4eac21 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 30 Sep 2020 11:59:55 +0200 Subject: [PATCH 113/163] [CI skip] Internal changes to custom model data --- .../core/services/CustomTextureService.java | 2 ++ .../items/androids/AndroidFuelSource.java | 9 +++++--- .../items/androids/ProgrammableAndroid.java | 23 +++++++++---------- .../slimefun4/utils/ChestMenuUtils.java | 13 +++++++++++ .../abstractItems/AContainer.java | 4 ++-- .../abstractItems/AGenerator.java | 4 ++-- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java index c84cd3830..d5ce5225b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java @@ -51,6 +51,8 @@ public class CustomTextureService { config.setDefaultValue("SLIMEFUN_GUIDE", 0); config.setDefaultValue("_UI_BACKGROUND", 0); + config.setDefaultValue("_UI_INPUT_SLOT", 0); + config.setDefaultValue("_UI_OUTPUT_SLOT", 0); config.setDefaultValue("_UI_BACK", 0); config.setDefaultValue("_UI_MENU", 0); config.setDefaultValue("_UI_SEARCH", 0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java index 47bbb6724..a8a90354f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java @@ -1,9 +1,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import javax.annotation.Nonnull; + import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; /** * This enum covers all different fuel sources a {@link ProgrammableAndroid} can have. @@ -30,7 +32,7 @@ public enum AndroidFuelSource { private final String[] lore; - AndroidFuelSource(String... lore) { + AndroidFuelSource(@Nonnull String... lore) { this.lore = lore; } @@ -39,8 +41,9 @@ public enum AndroidFuelSource { * * @return An {@link ItemStack} to display */ + @Nonnull public ItemStack getItem() { - return new CustomItem(SlimefunItems.COAL_GENERATOR, "&8\u21E9 &cFuel Input &8\u21E9", lore); + return new CustomItem(HeadTexture.GENERATOR.getAsItemStack(), "&8\u21E9 &cFuel Input &8\u21E9", lore); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index a55a9adab..52fb2feb4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.function.Predicate; import java.util.logging.Level; +import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; @@ -314,7 +315,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, return builder.toString(); } - private String duplicateInstruction(String[] script, int index) { + private String duplicateInstruction(@Nonnull String[] script, int index) { int i = 0; StringBuilder builder = new StringBuilder(Instruction.START + "-"); @@ -440,13 +441,9 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, menu.open(p); } + @ParametersAreNonnullByDefault private void uploadScript(Player p, Block b, int page) { String code = getScript(b.getLocation()); - - if (code == null) { - return; - } - int nextId = 1; for (Script script : Script.getUploadedScripts(getAndroidType())) { @@ -545,12 +542,13 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, menu.open(p); } - protected String getScript(Location l) { + @Nonnull + protected String getScript(@Nonnull Location l) { String script = BlockStorage.getLocationInfo(l, "script"); return script != null ? script : DEFAULT_SCRIPT; } - protected void setScript(Location l, String script) { + protected void setScript(@Nonnull Location l, @Nonnull String script) { BlockStorage.addBlockInfo(l, "script", script); } @@ -787,10 +785,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, return false; } + @ParametersAreNonnullByDefault private void consumeFuel(Block b, BlockMenu menu) { ItemStack item = menu.getItemInSlot(43); - if (item != null) { + if (item != null && item.getType() != Material.AIR) { for (MachineFuel fuel : fuelTypes) { if (fuel.test(item)) { menu.consumeItem(43); @@ -807,12 +806,12 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, } } - private void constructMenu(BlockMenuPreset preset) { + private void constructMenu(@Nonnull BlockMenuPreset preset) { for (int i : BORDER) { - preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } for (int i : OUTPUT_BORDER) { - preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } for (int i : getOutputSlots()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java index 82ff6cfee..f37c7db44 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java @@ -26,6 +26,9 @@ public final class ChestMenuUtils { private ChestMenuUtils() {} private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", Material.GRAY_STAINED_GLASS_PANE, " "); + private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " "); + private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " "); + private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS)); private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more"); private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch"); @@ -43,6 +46,16 @@ public final class ChestMenuUtils { return UI_BACKGROUND; } + @Nonnull + public static ItemStack getInputSlotTexture() { + return INPUT_SLOT; + } + + @Nonnull + public static ItemStack getOutputSlotTexture() { + return OUTPUT_SLOT; + } + @Nonnull public static MenuClickHandler getEmptyClickHandler() { return CLICK_HANDLER; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index ee2617d7f..d663fa2f3 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -77,11 +77,11 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, } for (int i : BORDER_IN) { - preset.addItem(i, new CustomItem(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } for (int i : BORDER_OUT) { - preset.addItem(i, new CustomItem(Material.ORANGE_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } preset.addItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index 5164679ea..1bb305799 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -88,11 +88,11 @@ public abstract class AGenerator extends AbstractEnergyProvider { } for (int i : border_in) { - preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } for (int i : border_out) { - preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } for (int i : getOutputSlots()) { From e85283776481ad47a24f4fc7cb6d43720ffca838 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:57:54 +0200 Subject: [PATCH 114/163] Added EntityInteractHandler cancellation --- .../implementation/items/tools/GoldPan.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java index 2e7c09c60..0c7101673 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java @@ -15,6 +15,7 @@ import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -47,6 +48,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip drops.addAll(getGoldPanDrops()); addItemSetting(drops.toArray(new GoldPanDrop[0])); + addItemHandler(onEntityInteract()); } protected Material getInput() { @@ -115,6 +117,16 @@ public class GoldPan extends SimpleSlimefunItem implements Recip }; } + /** + * This method cancels {@link EntityInteractHandler} to prevent interacting {@link GoldPan} + * with entities. + * + * @return the {@link EntityInteractHandler} of this {@link SlimefunItem} + */ + public EntityInteractHandler onEntityInteract() { + return (e, item, offHand) -> e.setCancelled(true); + } + @Override public List getDisplayRecipes() { List recipes = new LinkedList<>(); From 5f7efbd5a6d802a897a3667177d05be3645a365b Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 30 Sep 2020 20:14:26 +0200 Subject: [PATCH 115/163] Made Necrotic Skull unplaceable --- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 0bb375f9c..59db5d5d8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -1120,7 +1120,7 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.COBALT_INGOT, SlimefunItems.COBALT_INGOT, SlimefunItems.COBALT_INGOT, null, SlimefunItems.NICKEL_INGOT, null, null, SlimefunItems.NICKEL_INGOT, null}) .register(plugin); - new SlimefunItem(categories.magicalResources, SlimefunItems.NECROTIC_SKULL, RecipeType.MAGIC_WORKBENCH, + new UnplaceableBlock(categories.magicalResources, SlimefunItems.NECROTIC_SKULL, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}) .register(plugin); From 9dcd4193f256d9fa3d286fe46bc92ae32569dbdb Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 30 Sep 2020 20:29:14 +0200 Subject: [PATCH 116/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2743ad916..168e0ca91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ * Fixed some cargo incompatibilities with overflowing inventories * Fixed #2353 * Fixed #2359 +* Fixed #2356 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 1175bbca407085a539c8f40aaf30f42e911b83d1 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 30 Sep 2020 21:35:06 +0200 Subject: [PATCH 117/163] Added seasonal categories to the Cheat Sheet --- .../slimefun4/implementation/guide/ChestSlimefunGuide.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 33f3b0d16..83d0c40c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -29,6 +29,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory; import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory; +import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; @@ -100,7 +101,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { - if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) { + if (((!isSurvivalMode() && category instanceof SeasonalCategory) || !category.isHidden(p)) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) { categories.add(category); } } From a1c973a8177a55e8326c96969a464ba5d4a8ca7b Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 30 Sep 2020 22:13:41 +0200 Subject: [PATCH 118/163] Requested changes --- .../slimefun4/implementation/guide/ChestSlimefunGuide.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 83d0c40c3..c15da1dee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -101,8 +101,10 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { - if (((!isSurvivalMode() && category instanceof SeasonalCategory) || !category.isHidden(p)) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) { - categories.add(category); + if ((!isSurvivalMode() && category instanceof SeasonalCategory) || !category.isHidden(p)) { + if (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout())) { + categories.add(category); + } } } From 618698fa07fa16da16129e57516f39d1d5360bdf Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 1 Oct 2020 09:28:26 +0100 Subject: [PATCH 119/163] Update GrapplingHookListener --- .../listeners/GrapplingHookListener.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index f7463a370..9e9d3fde0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -136,6 +136,16 @@ public class GrapplingHookListener implements Listener { } } + // Fixing Issue #2351 + @EventHandler + public void onLeash(PlayerLeashEntityEvent e) { + if (!isEnabled()) { + return; + } + + e.setCancelled(true); + } + private void handleGrapplingHook(@Nullable Arrow arrow) { if (arrow != null && arrow.isValid() && arrow.getShooter() instanceof Player) { Player p = (Player) arrow.getShooter(); From 60c71fe56057c788fd7f145af776f2909e76b8f4 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 1 Oct 2020 09:40:19 +0100 Subject: [PATCH 120/163] Fixed Import --- .../implementation/listeners/GrapplingHookListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index 9e9d3fde0..1df1af889 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -24,6 +24,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerLeashEntityEvent; import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; From 2263c26d2c77218708d0573372439f7ae379f92b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 1 Oct 2020 11:00:51 +0200 Subject: [PATCH 121/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 168e0ca91..a1380defe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ * Fixed #2353 * Fixed #2359 * Fixed #2356 +* Fixed #2358 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From b6391160a768ce0ec30cc1d3dc57b6ad09157b13 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 1 Oct 2020 11:21:03 +0100 Subject: [PATCH 122/163] Fixed Import --- .../implementation/listeners/GrapplingHookListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index 1df1af889..93548c473 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -24,7 +24,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerLeashEntityEvent; +import org.bukkit.event.entity.PlayerLeashEntityEvent; import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; From 85ebe5322b7b04e6462df92fa57c2a809e722561 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 1 Oct 2020 11:50:55 +0100 Subject: [PATCH 123/163] Item verification --- .../listeners/GrapplingHookListener.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index 93548c473..7543fda3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -10,6 +10,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Bat; @@ -25,6 +26,7 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.entity.PlayerLeashEntityEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -144,7 +146,14 @@ public class GrapplingHookListener implements Listener { return; } - e.setCancelled(true); + Player p = (Player)e.getPlayer(); + + ItemStack item = p.getInventory().getItemInMainHand(); + SlimefunItem slimeItem = SlimefunItem.getByItem(item); + + if (slimeItem instanceof GrapplingHook) { + e.setCancelled(true); + } } private void handleGrapplingHook(@Nullable Arrow arrow) { From c86e59b6260a8500cfb332cbaca9d58e6f29c02e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 1 Oct 2020 11:55:30 +0100 Subject: [PATCH 124/163] Removed redundance --- .../implementation/listeners/GrapplingHookListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index 7543fda3c..98b3d4668 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -146,7 +146,7 @@ public class GrapplingHookListener implements Listener { return; } - Player p = (Player)e.getPlayer(); + Player p = e.getPlayer(); ItemStack item = p.getInventory().getItemInMainHand(); SlimefunItem slimeItem = SlimefunItem.getByItem(item); From affab6ab80a18a96379c60ea3ebbbc660c338111 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 17:52:26 +0200 Subject: [PATCH 125/163] Revert changes --- .../slimefun4/implementation/guide/ChestSlimefunGuide.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index c15da1dee..33f3b0d16 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -29,7 +29,6 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory; import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory; -import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; @@ -101,10 +100,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { - if ((!isSurvivalMode() && category instanceof SeasonalCategory) || !category.isHidden(p)) { - if (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout())) { - categories.add(category); - } + if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) { + categories.add(category); } } From 3948031decbcbeb3ca1cdd7806daec0d435a4fbe Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 18:06:07 +0200 Subject: [PATCH 126/163] Requested changes --- .../guide/CheatSheetSlimefunGuide.java | 19 +++++++++++++++++++ .../guide/ChestSlimefunGuide.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java index 35f31305c..77ceac5a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -1,14 +1,20 @@ package io.github.thebusybiscuit.slimefun4.implementation.guide; +import java.util.LinkedList; +import java.util.List; + import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; +import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** @@ -33,6 +39,19 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide { return false; } + @Override + protected List getVisibleCategories(Player p, PlayerProfile profile) { + List categories = new LinkedList<>(); + + for (Category category : SlimefunPlugin.getRegistry().getCategories()) { + if (!(category instanceof FlexCategory)) { + categories.add(category); + } + } + + return categories; + } + @Override public SlimefunGuideLayout getLayout() { return SlimefunGuideLayout.CHEAT_SHEET; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 33f3b0d16..c13cf9705 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -96,7 +96,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { return true; } - private List getVisibleCategories(Player p, PlayerProfile profile) { + protected List getVisibleCategories(Player p, PlayerProfile profile) { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { From cbc48584bcc14c6d8cd4d348c5e3f0461a0a0990 Mon Sep 17 00:00:00 2001 From: Roland Metivier Date: Thu, 1 Oct 2020 11:28:29 -0500 Subject: [PATCH 127/163] Attempt to fix bug #2360 --- .../listeners/BlockPhysicsListener.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index a1874ad55..31ff50fcb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -32,6 +32,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; * @author VoidAngel * @author Poslovitch * @author TheBusyBiscuit + * @author AccelShark * */ public class BlockPhysicsListener implements Listener { @@ -54,17 +55,23 @@ public class BlockPhysicsListener implements Listener { @EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { - for (Block b : e.getBlocks()) { - if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { - e.setCancelled(true); - return; + if(BlockStorage.check(e.getBlock()) != null) { + e.setCancelled(true); + } else { + for (Block b : e.getBlocks()) { + if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { + e.setCancelled(true); + return; + } } } } @EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { - if (e.isSticky()) { + if(BlockStorage.check(e.getBlock()) != null) { + e.setCancelled(true); + } else if (e.isSticky()) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); From 30603d9bf5bd3cd13d7377123b4814e6ead44e81 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:12:09 +0200 Subject: [PATCH 128/163] Added an EventHandler for Cartography Table --- .../listeners/VanillaMachinesListener.java | 13 +++++++ src/main/resources/languages/messages_en.yml | 3 ++ .../TestVanillaMachinesListener.java | 34 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index e9013fa04..6ed9bc06c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -97,6 +97,19 @@ public class VanillaMachinesListener implements Listener { } } + @EventHandler(ignoreCancelled = true) + public void onCartographyTable(InventoryClickEvent e) { + if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { + ItemStack item1 = e.getInventory().getContents()[0]; + ItemStack item2 = e.getInventory().getContents()[1]; + + if (checkForUnallowedItems(item1, item2)) { + e.setResult(Result.DENY); + SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "cartography_table.not-working", true); + } + } + } + @EventHandler(ignoreCancelled = true) public void onPreBrew(InventoryClickEvent e) { Inventory clickedInventory = e.getClickedInventory(); diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index c292b1c82..8b7e2855d 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -264,6 +264,9 @@ anvil: brewing_stand: not-working: '&4You cannot use Slimefun Items in a brewing stand!' +cartography_table: + not-working: '&4You cannot use Slimefun Items in a cartography table!' + villagers: no-trading: '&4You cannot trade Slimefun Items with Villagers!' diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java index a36b616f1..b87f39a25 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java @@ -76,6 +76,16 @@ public class TestVanillaMachinesListener { return event; } + private InventoryClickEvent mockCartographyTableEvent(ItemStack item) { + Player player = server.addPlayer(); + Inventory inv = TestUtilities.mockInventory(InventoryType.CARTOGRAPHY, new ItemStack(Material.FILLED_MAP), item, new ItemStack(Material.FILLED_MAP)); + InventoryView view = player.openInventory(inv); + InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE); + + listener.onCartographyTable(event); + return event; + } + private InventoryClickEvent mockBrewingEvent(ItemStack item) { Player player = server.addPlayer(); Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING); @@ -242,6 +252,30 @@ public class TestVanillaMachinesListener { Assertions.assertEquals(Result.DEFAULT, event.getResult()); } + @Test + public void testCartographyTableWithoutSlimefunItems() { + InventoryClickEvent event = mockCartographyTableEvent(new ItemStack(Material.PAPER)); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + + @Test + public void testCartographyTableWithSlimefunItem() { + SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_PAPER", new CustomItem(Material.PAPER, "&6Mock")); + item.register(plugin); + + InventoryClickEvent event = mockCartographyTableEvent(item.getItem()); + Assertions.assertEquals(Result.DENY, event.getResult()); + } + + @Test + public void testCartographyTableWithVanillaItem() { + VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.PAPER, true); + item.register(plugin); + + InventoryClickEvent event = mockCartographyTableEvent(item.getItem()); + Assertions.assertEquals(Result.DEFAULT, event.getResult()); + } + @Test public void testBrewingWithoutSlimefunItems() { InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER)); From a074e7cc1767483c0c66c5f7b89b5782a3a74966 Mon Sep 17 00:00:00 2001 From: Roland Metivier Date: Thu, 1 Oct 2020 12:32:17 -0500 Subject: [PATCH 129/163] Fix formatting --- .../implementation/listeners/BlockPhysicsListener.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index 31ff50fcb..ebd0110ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -55,9 +55,10 @@ public class BlockPhysicsListener implements Listener { @EventHandler public void onPistonExtend(BlockPistonExtendEvent e) { - if(BlockStorage.check(e.getBlock()) != null) { + if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); - } else { + } + else { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); @@ -69,9 +70,10 @@ public class BlockPhysicsListener implements Listener { @EventHandler public void onPistonRetract(BlockPistonRetractEvent e) { - if(BlockStorage.check(e.getBlock()) != null) { + if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); - } else if (e.isSticky()) { + } + else if (e.isSticky()) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); From b327c55b5fec399260d69c955177eca2fb844ddc Mon Sep 17 00:00:00 2001 From: Roland Metivier Date: Thu, 1 Oct 2020 12:49:05 -0500 Subject: [PATCH 130/163] Remove redundant return statements --- .../implementation/listeners/BlockPhysicsListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index ebd0110ff..aece46b06 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -62,7 +62,6 @@ public class BlockPhysicsListener implements Listener { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); - return; } } } @@ -77,7 +76,6 @@ public class BlockPhysicsListener implements Listener { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); - return; } } } From bfc221a7a549d17b7cc22e39a9e09e565562fb11 Mon Sep 17 00:00:00 2001 From: Roland Metivier Date: Thu, 1 Oct 2020 12:52:16 -0500 Subject: [PATCH 131/163] Replace w/break instead --- .../implementation/listeners/BlockPhysicsListener.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index aece46b06..29f421ed6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -62,6 +62,7 @@ public class BlockPhysicsListener implements Listener { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); + break; } } } @@ -76,6 +77,7 @@ public class BlockPhysicsListener implements Listener { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); + break; } } } From 2e4f5d565f3a5c955b67e23fa6253cc572c53c82 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 1 Oct 2020 20:28:28 +0200 Subject: [PATCH 132/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1380defe..94df69fbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ * Fixed #2359 * Fixed #2356 * Fixed #2358 +* Fixed #2360 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 501394bd0848b53108732b5adff9f021c12bd52c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 1 Oct 2020 20:45:25 +0200 Subject: [PATCH 133/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94df69fbc..e73704f9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ * Fixed #2356 * Fixed #2358 * Fixed #2360 +* Fixed #2351 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From 2cf0ca818841c46edb2792d069dfcfd43af0ad8b Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:49:54 +0200 Subject: [PATCH 134/163] Added javadocs and nullability annotations --- .../implementation/guide/ChestSlimefunGuide.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index c13cf9705..91d3e7fd3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.guide; +import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; @@ -96,7 +98,16 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { return true; } - protected List getVisibleCategories(Player p, PlayerProfile profile) { + /** + * Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display. + * + * @param p + * The {@link Player} who opened his {@link SlimefunGuide} + * @param profile + * The {@link PlayerProfile} of the {@link Player} + * @return a {@link List} of visible {@link Category} instances + */ + protected List getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { From 48b78a8af4f61c353659e4d03fdd238e945dc88d Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:58:09 +0200 Subject: [PATCH 135/163] Requested changes --- .../guide/CheatSheetSlimefunGuide.java | 13 +++++++++++++ .../implementation/guide/ChestSlimefunGuide.java | 1 + 2 files changed, 14 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java index 77ceac5a9..e4bb89a4e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -1,8 +1,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.guide; +import javax.annotation.Nonnull; + import java.util.LinkedList; import java.util.List; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; @@ -39,6 +42,16 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide { return false; } + /** + * Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display. + * + * @param p + * The {@link Player} who opened his {@link SlimefunGuide} + * @param profile + * The {@link PlayerProfile} of the {@link Player} + * @return a {@link List} of visible {@link Category} instances + */ + @Nonnull @Override protected List getVisibleCategories(Player p, PlayerProfile profile) { List categories = new LinkedList<>(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 91d3e7fd3..4aacf3a40 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -107,6 +107,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { * The {@link PlayerProfile} of the {@link Player} * @return a {@link List} of visible {@link Category} instances */ + @Nonnull protected List getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) { List categories = new LinkedList<>(); From af3156a43b5e3d23006ea7138dc95e7090ed0318 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 21:01:37 +0200 Subject: [PATCH 136/163] Requested changes --- .../slimefun4/implementation/guide/CheatSheetSlimefunGuide.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java index e4bb89a4e..d02c04c7e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -53,7 +53,7 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide { */ @Nonnull @Override - protected List getVisibleCategories(Player p, PlayerProfile profile) { + protected List getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) { List categories = new LinkedList<>(); for (Category category : SlimefunPlugin.getRegistry().getCategories()) { From 815b5ce5c2c5cefd1e110f1206bae48d63e6c933 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 1 Oct 2020 21:04:12 +0200 Subject: [PATCH 137/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e73704f9d..09f5630a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ #### Changes * Improved Auto-Updater (Multi-Threading and more) * General performance improvements +* /sf cheat now shows seasonal categories all year through #### Fixes * Fixed #2300 From 76bc9b119222b9682d5525ec3336c2c0d0116c41 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 21:25:56 +0200 Subject: [PATCH 138/163] Fixed capitalization --- src/main/resources/languages/messages_en.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index 8b7e2855d..6f2f19b8d 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -259,23 +259,23 @@ machines: finished: '&eYour Industrial Miner has finished! It obtained a total of %ores% ore(s)!' anvil: - not-working: '&4You cannot use Slimefun Items in an anvil!' + not-working: '&4You cannot use Slimefun items in an anvil!' brewing_stand: - not-working: '&4You cannot use Slimefun Items in a brewing stand!' + not-working: '&4You cannot use Slimefun items in a brewing stand!' cartography_table: - not-working: '&4You cannot use Slimefun Items in a cartography table!' + not-working: '&4You cannot use Slimefun items in a cartography table!' villagers: - no-trading: '&4You cannot trade Slimefun Items with Villagers!' + no-trading: '&4You cannot trade Slimefun items with Villagers!' backpack: already-open: '&cSorry, this Backpack is open somewhere else!' no-stack: '&cYou cannot stack Backpacks' workbench: - not-enhanced: '&4You cannot use Slimefun Items in a normal workbench' + not-enhanced: '&4You cannot use Slimefun items in a normal workbench' gps: deathpoint: '&4Deathpoint &7%date%' From 93fc7ff3abef8c83a7a1627481ad2402a12e6927 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Thu, 1 Oct 2020 22:13:47 +0200 Subject: [PATCH 139/163] Formatting --- .../implementation/listeners/VanillaMachinesListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index 6ed9bc06c..daf3b4c72 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -99,7 +99,8 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onCartographyTable(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { + if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY + && e.getWhoClicked() instanceof Player) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; From 642abb78c8a9189224baae0dd76cf7725586d07e Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 14:33:36 +0200 Subject: [PATCH 140/163] Add remaining carat golds to ore crusher --- .../items/multiblocks/OreCrusher.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index a1fd26c24..814ea561a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -53,6 +53,36 @@ public class OreCrusher extends MultiBlockMachine { recipes.add(SlimefunItems.GOLD_4K); recipes.add(SlimefunItems.GOLD_DUST); + recipes.add(SlimefunItems.GOLD_6K); + recipes.add(SlimefunItems.GOLD_DUST); + + recipes.add(SlimefunItems.GOLD_8K); + recipes.add(SlimefunItems.GOLD_DUST); + + recipes.add(SlimefunItems.GOLD_10K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + + recipes.add(SlimefunItems.GOLD_12K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + + recipes.add(SlimefunItems.GOLD_14K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + + recipes.add(SlimefunItems.GOLD_16K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + + recipes.add(SlimefunItems.GOLD_18K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + + recipes.add(SlimefunItems.GOLD_20K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + + recipes.add(SlimefunItems.GOLD_22K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + + recipes.add(SlimefunItems.GOLD_24K); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + recipes.add(new ItemStack(Material.GRAVEL)); recipes.add(new ItemStack(Material.SAND)); From 59c1683295dee603e0cb6158cc9d2cf44ae929ff Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Fri, 2 Oct 2020 14:38:57 +0200 Subject: [PATCH 141/163] Added version check --- .../implementation/listeners/VanillaMachinesListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index daf3b4c72..aae551c5a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -99,8 +99,8 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onCartographyTable(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY - && e.getWhoClicked() instanceof Player) { + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && e.getRawSlot() == 2 + && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; From a00e640a6c012a6805f3d33c94657583dbf62930 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 19:53:01 +0200 Subject: [PATCH 142/163] Add Talisman of the Hastier --- .../slimefun4/implementation/SlimefunItems.java | 1 + .../slimefun4/implementation/setup/SlimefunItemSetup.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 78fbd9b46..2aec48a66 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,6 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); + public static final SlimefunItemStack TALISMAN_HASTIER = new SlimefunItemStack("HASTIER_TALISMAN", Material.EMERALD, "&aTalisman of the Hastier", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% Chance for a decent", "&fHaste buff when you mine a block"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 59db5d5d8..7f06055ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -872,6 +872,11 @@ public final class SlimefunItemSetup { "knight", 30, new PotionEffect(PotionEffectType.REGENERATION, 100, 3)) .register(plugin); + new Talisman(SlimefunItems.TALISMAN_HASTIER, + new ItemStack[] { SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER, SlimefunItems.EARTH_RUNE, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}, + false, false, "hastier", new PotionEffect(PotionEffectType.FAST_DIGGING, 180, 3)) + .register(plugin); + new SlimefunItem(categories.resources, SlimefunItems.GILDED_IRON, RecipeType.SMELTERY, new ItemStack[] {SlimefunItems.GOLD_24K, SlimefunItems.IRON_DUST, null, null, null, null, null, null, null}) .register(plugin); From add31a38e0a30cff481d55897c5b482e42869beb Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 21:34:52 +0200 Subject: [PATCH 143/163] Set up research for TALISMAN_HASTIER --- .../slimefun4/implementation/setup/ResearchSetup.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index 59590e914..2550a3491 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -275,6 +275,7 @@ public final class ResearchSetup { register("villager_rune", 264, "Reset Villager Trades", 26, SlimefunItems.VILLAGER_RUNE, SlimefunItems.STRANGE_NETHER_GOO); register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); + register("hastier_talisman", 267, "Talisman of the Hastier", 20, SlimefunItems.TALISMAN_HASTIER); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { From 90d0019cb6d21dd79930e6c448f3cd5edabcab66 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 21:53:27 +0200 Subject: [PATCH 144/163] Add chance and proper duration --- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 7f06055ab..f9ae12d89 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -874,7 +874,7 @@ public final class SlimefunItemSetup { new Talisman(SlimefunItems.TALISMAN_HASTIER, new ItemStack[] { SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER, SlimefunItems.EARTH_RUNE, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}, - false, false, "hastier", new PotionEffect(PotionEffectType.FAST_DIGGING, 180, 3)) + false, false, "hastier", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 3)) .register(plugin); new SlimefunItem(categories.resources, SlimefunItems.GILDED_IRON, RecipeType.SMELTERY, From 4692bce3433eece6fb3426e121fe9ed2f9631080 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 21:53:53 +0200 Subject: [PATCH 145/163] Add entry to researches_en --- src/main/resources/languages/researches_en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 034d9c312..3b549accd 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -61,6 +61,7 @@ slimefun: water_talisman: Talisman of the Water Breather angel_talisman: Talisman of the Angel fire_talisman: Talisman of the Firefighter + hastier_talisman: Talisman of the Hastier lava_crystal: Firey Situation magician_talisman: Talisman of the Magician traveller_talisman: Talisman of the Traveller From 357f32579298e1e7d19c7b62a8fbc42c873e31d9 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 22:04:21 +0200 Subject: [PATCH 146/163] Add message entry for hastier talisman --- src/main/resources/languages/messages_en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index c292b1c82..65acb24ac 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -151,6 +151,7 @@ messages: knight: '&a&oYour Talisman gave you 5 Seconds of Regeneration' whirlwind: '&a&oYour Talisman reflected the Projectile' wizard: '&a&oYour Talisman has given you a better Fortune Level but maybe also lowered some other Enchantment Levels' + hastier: '&a&oYour Talisman gave you haste' soulbound-rune: fail: '&cYou can only bind one item to your soul at a time.' From 7301ca834f4bd5be1911ab96f1ee8d8ccbad5f69 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Fri, 2 Oct 2020 22:04:53 +0200 Subject: [PATCH 147/163] Add event listener to BreakBlockEvent for Hastier talisman --- .../implementation/listeners/TalismanListener.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index f1c119cd9..cd8819cdf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -24,6 +24,7 @@ import org.bukkit.entity.Trident; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDropItemEvent; import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -284,6 +285,11 @@ public class TalismanListener implements Listener { } } + @EventHandler + public void onBlockBreak(BlockBreakEvent e) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_HASTIER); + } + private int getAmountWithFortune(@Nonnull Material type, int fortuneLevel) { if (fortuneLevel > 0) { Random random = ThreadLocalRandom.current(); From ce5b7974204bdf30853d3047993bf86cf16088db Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 2 Oct 2020 22:32:44 +0000 Subject: [PATCH 148/163] Update dependency com.github.seeseemelk:MockBukkit-v1.16 to v0.6.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7ae608427..2442ec7d3 100644 --- a/pom.xml +++ b/pom.xml @@ -309,7 +309,7 @@ com.github.seeseemelk MockBukkit-v1.16 - 0.5.2 + 0.6.0 test From 7a366aa5ced75d5fd68dc67c8d6a84beba95a9b4 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 15:15:01 +0200 Subject: [PATCH 149/163] Change haste amplifier to 2 --- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index f9ae12d89..ff67fba94 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -874,7 +874,7 @@ public final class SlimefunItemSetup { new Talisman(SlimefunItems.TALISMAN_HASTIER, new ItemStack[] { SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER, SlimefunItems.EARTH_RUNE, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}, - false, false, "hastier", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 3)) + false, false, "hastier", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 2)) .register(plugin); new SlimefunItem(categories.resources, SlimefunItems.GILDED_IRON, RecipeType.SMELTERY, From 178fc6eb227509a9ab45cba8db054aa7ee7c953c Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 16:52:49 +0200 Subject: [PATCH 150/163] Rename Hastier to Caveman --- .../slimefun4/implementation/SlimefunItems.java | 2 +- .../slimefun4/implementation/listeners/TalismanListener.java | 2 +- .../slimefun4/implementation/setup/ResearchSetup.java | 2 +- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 4 ++-- src/main/resources/languages/messages_en.yml | 2 +- src/main/resources/languages/researches_en.yml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 2aec48a66..d435384cb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,7 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); - public static final SlimefunItemStack TALISMAN_HASTIER = new SlimefunItemStack("HASTIER_TALISMAN", Material.EMERALD, "&aTalisman of the Hastier", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% Chance for a decent", "&fHaste buff when you mine a block"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% Chance for a decent", "&fHaste buff when you mine a block"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index cd8819cdf..857852c85 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -287,7 +287,7 @@ public class TalismanListener implements Listener { @EventHandler public void onBlockBreak(BlockBreakEvent e) { - Talisman.checkFor(e, SlimefunItems.TALISMAN_HASTIER); + Talisman.checkFor(e, SlimefunItems.TALISMAN_CAVEMAN); } private int getAmountWithFortune(@Nonnull Material type, int fortuneLevel) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index 2550a3491..ae98e4d27 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -275,7 +275,7 @@ public final class ResearchSetup { register("villager_rune", 264, "Reset Villager Trades", 26, SlimefunItems.VILLAGER_RUNE, SlimefunItems.STRANGE_NETHER_GOO); register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR); - register("hastier_talisman", 267, "Talisman of the Hastier", 20, SlimefunItems.TALISMAN_HASTIER); + register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index ff67fba94..e72fca80a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -872,9 +872,9 @@ public final class SlimefunItemSetup { "knight", 30, new PotionEffect(PotionEffectType.REGENERATION, 100, 3)) .register(plugin); - new Talisman(SlimefunItems.TALISMAN_HASTIER, + new Talisman(SlimefunItems.TALISMAN_CAVEMAN, new ItemStack[] { SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER, SlimefunItems.EARTH_RUNE, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}, - false, false, "hastier", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 2)) + false, false, "caveman", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 2)) .register(plugin); new SlimefunItem(categories.resources, SlimefunItems.GILDED_IRON, RecipeType.SMELTERY, diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index 65acb24ac..e158be958 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -151,7 +151,7 @@ messages: knight: '&a&oYour Talisman gave you 5 Seconds of Regeneration' whirlwind: '&a&oYour Talisman reflected the Projectile' wizard: '&a&oYour Talisman has given you a better Fortune Level but maybe also lowered some other Enchantment Levels' - hastier: '&a&oYour Talisman gave you haste' + caveman: '&a&oYour Talisman gave you haste' soulbound-rune: fail: '&cYou can only bind one item to your soul at a time.' diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 3b549accd..7f7826637 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -61,7 +61,7 @@ slimefun: water_talisman: Talisman of the Water Breather angel_talisman: Talisman of the Angel fire_talisman: Talisman of the Firefighter - hastier_talisman: Talisman of the Hastier + caveman_talisman: Talisman of the Caveman lava_crystal: Firey Situation magician_talisman: Talisman of the Magician traveller_talisman: Talisman of the Traveller From b9750917a697260631f461f7c6392432885a7cb1 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 17:02:36 +0200 Subject: [PATCH 151/163] Rebalance yield results --- .../items/multiblocks/OreCrusher.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index 814ea561a..d0f93c00c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -54,34 +54,34 @@ public class OreCrusher extends MultiBlockMachine { recipes.add(SlimefunItems.GOLD_DUST); recipes.add(SlimefunItems.GOLD_6K); - recipes.add(SlimefunItems.GOLD_DUST); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); recipes.add(SlimefunItems.GOLD_8K); - recipes.add(SlimefunItems.GOLD_DUST); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); recipes.add(SlimefunItems.GOLD_10K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); recipes.add(SlimefunItems.GOLD_12K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); recipes.add(SlimefunItems.GOLD_14K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 4)); recipes.add(SlimefunItems.GOLD_16K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 2)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 4)); recipes.add(SlimefunItems.GOLD_18K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 5)); recipes.add(SlimefunItems.GOLD_20K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 5)); recipes.add(SlimefunItems.GOLD_22K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 6)); recipes.add(SlimefunItems.GOLD_24K); - recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 3)); + recipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, 6)); recipes.add(new ItemStack(Material.GRAVEL)); recipes.add(new ItemStack(Material.SAND)); From ee9b0e90ad31cca2502ce431a9d624b5e0c01a49 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 19:05:07 +0200 Subject: [PATCH 152/163] Chance.ToLowerCase() --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index d435384cb..48bedc424 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,7 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); - public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% Chance for a decent", "&fHaste buff when you mine a block"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% chance for a decent", "&fHaste buff when you mine a block"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); From 57a2704ac5ee6d80911b573ab158500554e809b2 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 19:25:41 +0200 Subject: [PATCH 153/163] [CI skip] Updated github docs links --- .github/ISSUE_TEMPLATE/hacktoberfest-issue.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md index 75f1e0827..9a30df81c 100644 --- a/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md +++ b/.github/ISSUE_TEMPLATE/hacktoberfest-issue.md @@ -45,8 +45,8 @@ If you need help on how to get started, maybe try looking into the following res * [Hacktoberfest FAQ](https://hacktoberfest.digitalocean.com/faq) * GitHub/Open-Source * [How to contribute to Open-Source](https://opensource.guide/how-to-contribute/) - * [Working with forks](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/working-with-forks) - * [Creating a Pull Request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) + * [Working with forks](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/working-with-forks) + * [Creating a Pull Request](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) * Slimefun * [Contributing to Slimefun](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md) * [Code of Conduct](https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md) From aba43c536557792022745d006cf08776bf0ebb0b Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 20:06:18 +0200 Subject: [PATCH 154/163] Buff chance to 50% --- .../slimefun4/implementation/setup/SlimefunItemSetup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index e72fca80a..2ce4ff063 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -874,7 +874,7 @@ public final class SlimefunItemSetup { new Talisman(SlimefunItems.TALISMAN_CAVEMAN, new ItemStack[] { SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER, SlimefunItems.EARTH_RUNE, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}, - false, false, "caveman", 40, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 2)) + false, false, "caveman", 50, new PotionEffect(PotionEffectType.FAST_DIGGING, 800, 2)) .register(plugin); new SlimefunItem(categories.resources, SlimefunItems.GILDED_IRON, RecipeType.SMELTERY, From d70f4df8456227660960e2df2abc04f407d9b6c4 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 20:06:46 +0200 Subject: [PATCH 155/163] Update lore of talisman --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 48bedc424..cac5bb00a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,7 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); - public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% chance for a decent", "&fHaste buff when you mine a block"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% chance for a decent", "&fHaste buff when you mine any ore"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); From 2c47a786b82ee057a93f0d68eb057341cee428e8 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 20:27:20 +0200 Subject: [PATCH 156/163] Narrow talisman down to only ores --- .../slimefun4/implementation/listeners/TalismanListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index 857852c85..abcfcca3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -287,7 +287,9 @@ public class TalismanListener implements Listener { @EventHandler public void onBlockBreak(BlockBreakEvent e) { - Talisman.checkFor(e, SlimefunItems.TALISMAN_CAVEMAN); + if (e.getBlock().getType().name().endsWith("_ORE")) { + Talisman.checkFor(e, SlimefunItems.TALISMAN_CAVEMAN); + } } private int getAmountWithFortune(@Nonnull Material type, int fortuneLevel) { From 06bf6229fa574eeead10942d192a811fb344ce2b Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 20:43:31 +0200 Subject: [PATCH 157/163] Update lore with correct chance --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index cac5bb00a..ea8ec9045 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,7 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); - public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 40% chance for a decent", "&fHaste buff when you mine any ore"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 50% chance for a decent", "&fHaste buff when you mine any ore"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); From 4c0bd29cfaf11ee57ba5e18e5b9b10a275879080 Mon Sep 17 00:00:00 2001 From: Senne Van Rompaey Date: Sat, 3 Oct 2020 20:56:28 +0200 Subject: [PATCH 158/163] Add empty line in lore Co-authored-by: poma123 <25465545+poma123@users.noreply.github.com> --- .../thebusybiscuit/slimefun4/implementation/SlimefunItems.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index ea8ec9045..254a3f511 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -546,7 +546,7 @@ public final class SlimefunItems { public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&aTalisman of the Knight", "", "&fWhile you have this Talisman", "&fin your Inventory it gives", "&fyou a 30% Chance for 5 Seconds of Regeneration", "&fwhenever You get hit", "&fbut will then be consumed"); public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&aTalisman of the Whirlwind", "", "&fHaving this Talisman", "&fin your Inventory will reflect", "&f60% of any projectiles fired at you.", "&e&oOnly a thrown Trident can pierce", "&e&othrough this layer of protection"); public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&aTalisman of the Wizard", "", "&fWhile you have this Talisman", "&fin your Inventory it allows you to", "&fobtain Fortune Level 4/5 however", "&fit also has a chance to lower the", "&fLevel of some Enchantments on your Item"); - public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 50% chance for a decent", "&fHaste buff when you mine any ore"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&aTalisman of the Caveman", "", "&fWhile you have this Talisman", "&fin your inventory it gives", "&fyou a 50% chance for a decent", "&fHaste buff when you mine any ore"); /* Staves */ public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6Elemental Staff"); From cb97a89f9837307371d5e899a9cc5ecb06237399 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 3 Oct 2020 21:12:01 +0200 Subject: [PATCH 159/163] Added a separate version check --- .../listeners/VanillaMachinesListener.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index aae551c5a..40926561d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -99,8 +99,13 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onCartographyTable(InventoryClickEvent e) { - if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && e.getRawSlot() == 2 - && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { + // The Cartography Table was only ever added in MC 1.14 + MinecraftVersion minecraftVersion = SlimefunPlugin.getMinecraftVersion(); + if (!minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { + return; + } + + if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; From ada6ce775c109ffcb52b4b7ac8c5484ee4d2994a Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 21:13:46 +0200 Subject: [PATCH 160/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f5630a9..ea497d1c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * Added Energized Energy Capacitor * Added various new fuel types to the Coal Generator * Added a config option for Grappling Hooks to not be consumed on use +* Added Talisman of the Caveman #### Changes * Improved Auto-Updater (Multi-Threading and more) From b1a07c033755fcd661fb73e2df31834e7d8c1814 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Sat, 3 Oct 2020 21:18:36 +0200 Subject: [PATCH 161/163] Minor improvements --- .../implementation/listeners/VanillaMachinesListener.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index 40926561d..b517efb0b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -41,8 +41,7 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onGrindstone(InventoryClickEvent e) { // The Grindstone was only ever added in MC 1.14 - MinecraftVersion minecraftVersion = SlimefunPlugin.getMinecraftVersion(); - if (!minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { + if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } @@ -100,8 +99,7 @@ public class VanillaMachinesListener implements Listener { @EventHandler(ignoreCancelled = true) public void onCartographyTable(InventoryClickEvent e) { // The Cartography Table was only ever added in MC 1.14 - MinecraftVersion minecraftVersion = SlimefunPlugin.getMinecraftVersion(); - if (!minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { + if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } From 49b0ec6a9ec95e381e4047e4a8b541e7a5a042b0 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 21:29:13 +0200 Subject: [PATCH 162/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea497d1c3..6eebdfaad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ * Fixed #2358 * Fixed #2360 * Fixed #2351 +* Fixed #2357 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 From a2cb2eb32419fb9f63d7a39d8240936aadfc217e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 3 Oct 2020 22:03:30 +0200 Subject: [PATCH 163/163] [CI skip] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6eebdfaad..b4653ef0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ * Added various new fuel types to the Coal Generator * Added a config option for Grappling Hooks to not be consumed on use * Added Talisman of the Caveman +* You can now convert any gold ingot into gold dust with slightly less returns #### Changes * Improved Auto-Updater (Multi-Threading and more)